This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

PWM LPC2129

Hi. I found initialization code on KEIL website for the PWM on LPC2129. It uses 12Mhz oscillator.

Here is part of the code:

PWMPR = 0x00000001; //Load prescaler

PWMPCR = 0x0000404; //PWM channel 2 double edge control, output enabled
PWMMCR = 0x00000003; //On match with timer reset the counter
PWMMR0 = 0x000000FF; //set cycle rate to sixteen ticks
PWMMR1 = 0x00000080; //set rising edge of PWM2 to 2 ticks
PWMMR2 = 0x00000080; //set falling edge of PWM2 to 8 ticks
PWMLER = 0x00000007; //enable shadow latch for match 0 - 2
PWMEMR = 0x00000280; //Match 1 and Match 2 outputs set high
PWMTCR = 0x00000002; //Reset counter and prescaler
PWMTCR = 0x00000009; //enable counter and PWM, release counter from reset
//------------------------end-------------------

i dont understand how 0xFF in PWMMR0 means 16 ticks ? Also in PWMMR1 and PWMMR2 ?

Parents Reply Children
  • Hi,,
    I have read the manuals, i could not get a clue. Because the concept of a single edge PWM is when MR1 = Time counter resets(from high goes low), i.e. if MR0 = 100 and MR1 =50, at time conter = 50 PWM1 rests. What do the ticks mean in the comments i dont know...

    One more thing do you know how to simulate hardware PWM in Logic analyzer?