Help with LPC2148 PWM?

Started by "J.C. Wren" March 3, 2008
I'm trying to get PWM working, and obviously missing something.

I want to use PWM5 as the output, and have it run continuously at a
50% duty cycle. The rate is unimportant at the moment, I can fix that
later. Here's the initialization code:

SCB_PCONP |= SCB_PCONP_PCPWM0 /* 0x20, enable PWM block */;
PCB_PINSEL1 |= PCB_PINSEL1_P021_PWM5 /* 0x400, P0.21 is PWM5 */;

PWM_PR = 0 /* Prescaler to 0 */;
PWM_PCR |= PWM_PCR_ENA5 /* 0x2000, PWM output 5 enabled */;
PWM_MCR |= (PWM_MCR_MR5R | PWM_MCR_MR0R) /* 0x10002, reset on match
0, set on match 5 */;
PWM_MR0 = 500;
PWM_MR5 = 250 /* 500 over 250 should be 50% */;
PWM_LER |= (PWM_LER_M5L | PWM_LER_M0L) /* 0x21, Latch values */;
PWM_TCR = PWM_TCR_CR /* 0x02, Counter reset */;
PWM_TCR = (PWM_TCR_CE | PWM_TCR_PWME) /* 0x09, Counter enable and
PWM enable */;

The basic initialization ordering is taken from some Keil LPC2119
example code. But I get nada. The pin doesn't budge. I see the
timer counting, but no pin activity.

I'm sure it's probably something simple, and I'm missing it from
staring at it too long. Any ideas?


An Engineer's Guide to the LPC2100 Series

Alle 05:47, luned3 marzo 2008, J.C. Wren ha scritto:

> I'm trying to get PWM working, and obviously missing something.

First: thank you for your GREAT sample code.

I'm using PWM on an LPC2106, I don't know if there are some diffs with

I got an example code here:

Hope it helps!