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 ?
Hello, I don't know the ARM architecture very well, but why don't you read the reference manual for your PLC? The answer must be there, and available for download from Keil's website.
Hello R A,
You said: "I don't understand how 0xFF in PWMMR0 means 16 ticks ? Also in PWMMR1 and PWMMR2?"
In ARM devices, implementation of peripherals, such as PWM, differ form vendor to vendor. So this is a NXP specific question, not an ARM question.
You can find the latest NXP documentation for the LPC2129 here:
www.standardics.nxp.com/.../
The latest user manual for this device can be found here:
www.standardics.nxp.com/.../user.manual.lpc2109.lpc2114.lpc2119.lpc2124.lpc2129.lpc2194.lpc2210.lpc2212.lpc2214.lpc2220.lpc2290.lpc2292.lpc2294.pdf
Chapter 16: LPC21xx/22xx Pulse Width Modulator (PWM) Describes how this device's PWM works.
Section 5.7 'PWM Match Control Register" Describes the what each of the bits signify.
You may also want to use Keil's peripheral PWM simulation details as a 'crib' sheet:
http://www.keil.com/dd/vtr/4364/8152.htm
Check with your Local NXP FAE for more details. Or check on the Yahoo LPC2000 user group for PWM examples:
groups.yahoo.com/.../
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?