Hello,
I am trying to use both timer1 and the microcontroller's external memory on this board. The code I'm currently testing with is below. The problem is that when the external memory is enabled in the makefile, it seems to either disable or interfere with timer1.
With extmem disabled, the PWM output (connected to a motor in this case) works correctly and turns on and off as set by timer1. However enabling extmem in the makefile causes the motor to remain on constantly, seemingly ignoring timer1.
Does the extmem disable or interfere with timer1? Is there another problem or some settings missing?
#include <lpc24xx.h> int main(void) { unsigned int motor_status = 0; T1TCR = 0x02; //Timer Reset T1IR |= 1; //Clear Interrupt Register T1MR0 = 1200000; //Match Value 1 sec T1MCR |= 3; //Reset Counter and Set Interrupt on Match T1TCR = 0x01; //Start timer PINSEL2 |= (3<<6); //Set (P1.3) PWM Pin Configuration PWM0PCR |= (1<<10); //PWM Set To PWM0[2] PWM0MR0 = 120000; //PWM Frequency PWM0MCR |= (1<<1); //Reset Count On Match PWM0MR2 = 120000; //PWM Pulse Width PWM0TCR = 0x00000009; //PWM Start while(1) { if ((T1IR & 1) == 1) { if(motor == 0) { PWM0MR2 = 120000; //Set new speed PWM0LER = (1<<2); //Change to new speed motor = 1; //Motor On } else { PWM0MR2 = 0; //Set new speed PWM0LER = (1<<2); //Change to new speed motor = 0; //Motor Off } T1IR |= 1; //Clear timer0 interrupt flag } } }
Thanks, Joe