Help on PWM basic code
i'm testing PWM single edge of my LPC2148, after reading the user
manual i came up with this code. It should work at 1KHz with duty 50%
(XTAL=10MHz,MSEL=6, PSEL=1) but it doesn't. i've watched the behavior
through PWM module of KEIL uVision simulator and it seems to work,
but in real, nothing appears in the osciloscope.
can someone tell me what I'm missing?
//#1: Define the pins as PWM outputs:
PINSEL0 = 0x8000;// Enable PWM2
PINSEL1 = 0x300;// Enable PWM5
//#2: Inititialize the PWM registers:
PWMPR = 0; // PWM prescal register - divide peripheral
PWMMCR = 0x2; // PWM match control - reset PMWTC at Match
PWMMR0 = 60000; // PWM match register 0 - determines PWM
PWMPCR = 0x2400; // PWM control - PWM2/PWM5 single edge |
PWMTCR = 0x9; // PWM timer control: counters enabled, PWM
//#3 Write to the PWM buffers and then latch into PWM registers
each time you want to update the PWM output.
PWMMR2 = 30000; //set the match register for the PWM
PWMMR5 = 30000; //set the match register for the PWM
PWMLER = 0x24; // Latch PWM registers
PS: sorry about my bad english.