I have a problem with Timers and the VIC on an Arm LPC2138. I have two timers that run fine, both are programmed thru the VIC and are IRQ. In the main program loop, I need to disable one of the Interrupts (Timer0) in order to reset a variable that is updated in the timer Interrupt. When I disable timer0 in the VIC, the program runs but the interrupts don't fire. ie: Case (1)
unsigned char hw_msec(void) { static unsigned char milli_count = 0; VICIntEnClr |= (1 << 4); // Disable Time 0 in Vic milli_count = uiGlobalTimerMs; if(milli_count) { uiGlobalTimerMs = 0; } VICIntEnable |= (1 << 4); // Re-Enable Timner 0 return milli_count; }
However it works when I disable all IRQs, but I would prefer not to have to do that: Case (2)
unsigned char hw_msec(void) { static unsigned char milli_count = 0; milli_count = uiGlobalTimerMs; if(milli_count) { hw_irq_disable(); uiGlobalTimerMs = 0; hw_irq_enable(); } return milli_count; }
I have stopped the program in Case (1) at Line: VICIntEnClr |= (1 << 4); and the VICIntEnable is correct (0x00000030) (Timer 1 is also enabled). After stepping over VICIntEnClr, it correctly goes to (0x00000020) and after re-enabling it returns to (0x00000030). The VICVectAddr4 & 5 are both valid and the Timers are enabled (T1TCR = 1) Any Ideas would be greatly appriciated.