EmbeddedRelated.com
Forums

PWM Explanation

Started by todd...@hotmail.com January 24, 2011
Hi Todd,
's...@ptmelec.com' is right.
The LER needs to be written after the MRx values are filled, except for the first time initialization when PWM-mode in TCR hasn't been set. Otherwise, new MRx values will not be used by PWM.
Regards,-daniel

--- On Fri, 1/28/11, Todd Gilbert wrote:

From: Todd Gilbert
Subject: RE: [lpc2000] Re: PWM Explanation
To: l...
Date: Friday, January 28, 2011, 4:40 PM

I'm using the LPC2368. The code seems to work.


To: l...
From: s...@ptmelec.com
Date: Fri, 28 Jan 2011 16:28:14 +0000
Subject: [lpc2000] Re: PWM Explanation


Which device are you using?
I'm looking at the 2478 spec and for that your values for
TCR,and LER should be
0x05, and 0x55
also, if I understand right, LER needs to be written to after writing the MRs.

--- In l..., "Todd Gilbert" wrote:
>
> Sorry - realized I forget about including PWM1MRx in the reply. Here's the complete PWM code. The question again: is there anything missing?
>
> PINSEL3 |= (0x02 << 8); /* PWM1.2 */
> PINSEL3 |= (0x02 << 14) /* PWM1.4 */
> PINSEL3 |= (0x02 << 20) /* PWM1.6 */
> PWM1PCR = 0x5454; /* all set up in 1 line of code */
> PWM1MCR = (0x01 << 1); /* set up match control to reset on MR0 */
> PWM1TCR = 0x41; /* enable TCR and PWM */
> PWM1LER = 0x01; /* enable LER and latch values into PWM */
>
> PWM1MR0 = cycle;
> PWM1MR1 = 0;
> PWM1MR2 = cycle*1/3;
> PWM1MR3 = cycle*1/3;
> PWM1MR4 = cycle*2/3;
> PWM1MR5 = cycle*2/3;
> PWM1MR6 = cycle;

An Engineer's Guide to the LPC2100 Series