Content originally posted in LPCWare by cararra on Wed Nov 21 07:59:53 MST 2012
Hi,
I got RS232 all working with interrupt driven code.
But this timer code just does not seem to work.
The variable Timer0_M0_Counter is always 0.
If I put a break in the middle of the code it never reaches the interrupt handler.
Any ideas what I am missing / doing wrong? :confused:
// LPC1113 code
int Timer0_M0_Counter = 0;
void TIMER16_0_IRQHandler(void) // This is being overridden from its definition in cr_startup_lpc11.c
{[INDENT] if(LPC_TMR16B0->IR & (0x1<<0)) // Check for Match Register0 for interrupt on timer0
{
[/INDENT][INDENT][INDENT] LPC_TMR16B0->IR = 0x1<<0; // Clear M0 interrupt flag of timer0
[/INDENT][/INDENT][INDENT][INDENT] Timer0_M0_Counter++; // general time keeping counter that ticks every millisecond
[/INDENT][/INDENT][INDENT] }
[/INDENT]}
main()
{[INDENT] ..
[/INDENT][INDENT] LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6 | 1<<7); // Enable AHB clock to the GPIO (bit 6), and t Timer0 (bit7).
[/INDENT][INDENT] LPC_TMR16B0->MR0 = 1000; // Set up 1 mS interval
[/INDENT][INDENT] NVIC_EnableIRQ(TIMER_16_0_IRQn); // This enables the timer interrupts
[/INDENT][INDENT] LPC_TMR16B0->TCR = 1; // enable timer0
[/INDENT][INDENT] ..
[/INDENT]}