PWM Interrupt on match

Started by ajellisuk December 23, 2008

I have an application where I'm controlling a motor with one of the
PWM channels (PWM 5). This works fine, I can control the speed
without any problems.

I also want the PWM to generate an interrupt on match, for timeing
purposes. However I cannot get it to work properly. If I write a
vlaue to the PWM register to start the motor it runs fine but I get
no interrupts. If I wrtie a zero to the PWM channel the motor stops
and I get an interrupt. How do I get interrupts to be delivered

I have pasted the relevent code below:

void init_pwm()
PINSEL1_bit.P0_21 = 1;
PWMPCR = 0x00002020; //Enable single edge controlled PWM4
PWMMCR = 0x00008003; //Reset timer on MR0 match,generate
interrupt on MR5 match
PWMPR = 0x00000004; //prescaler value
PWMMR0 = 0x00000064; //30Khz cycle rate (crystal 12Mhz) - 48kHz
PWMMR5 = 0x00000000; //Dutycycle =0% ie off
PWMTCR = 0x00000002; //Reset timer counter and prescaler counter
on next = Pclk cycle
PWMTCR = 0x00000000; //enable PWM mode

PWMLER_bit.EM5L = 1; // Load PWM value into register

VICIntEnable_bit.INT8 = 1; // Enable interrupts from PWM

Thanks in advance


An Engineer's Guide to the LPC2100 Series