Hello everyone!
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?
#include <LPC214x.h> int main(void){ //#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 clock PWMMCR = 0x2; // PWM match control - reset PMWTC at Match 0 PWMMR0 = 60000; // PWM match register 0 - determines PWM frequency PWMPCR = 0x2400; // PWM control - PWM2/PWM5 single edge | PWM2/PWM5 enabled PWMTCR = 0x9; // PWM timer control: counters enabled, PWM enabled
//#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 output. PWMMR5 = 30000; //set the match register for the PWM output. PWMLER = 0x24; // Latch PWM registers
while(1){ } }
PS: sorry about my bad english.