Weird thing is going on here.
I have LPC1788 board and I just started writing a simple application. If I initialize timer like this, code seems to be executed, but of course my timer interrupt is not called.
void initTimer (void) { LPC_TIM_TypeDef *timer = LPC_TIM1; LPC_SC->PCONP |= (0x1<<2); timer->TC = 0x00; //Clear Timer Counter timer->PR = 0x00; //No prescaler timer->MCR = 0x3; //enable interrupt timer->MR0 = 0x02710; //interrupt every 1ms //NVIC_EnableIRQ(TIMER1_IRQn); timer->TCR = 0x02; //reset timer timer->TCR = 0x01; //enable timer counter } void TIMER1_IRQHandler(void) { LPC_TIM1->IR = (1u<<0); // Reset the MR0 Interrupt; Writing a zero has no effect. decrementFlags(); }
As soon as I enable NVIC IRQ, my code crash and points to Default_Handler PROC in startup.s. Deducing R15(PC) with -8 and use U 0xXXX, I end up in SVC_Handler part. My Timer1_IRQ never got called.
There is really nothing going on in the code besides this. As I just started writing program and hit the wall...
Any idea what else could I try, to debug this ?
Thanks.
So are you getting a Hard Fault and, thence, ending up in the Default Handler?
Search here for info & references on debugging a Hard Fault...
I dont really end up in Hard Fault when I break the execution. It points to the Default Handler part of startup code. As I said, it looks like that if I havent defined the IRQ handler.
I dont really end up in Hard Fault when I break the execution. It points to the Default Handler part of startup code. As I said, it looks like that if I havent defined the IRQ handler. Then are you sure that the actual definition is provided is Startup assembly file? that might be just a misspelling problem for TIMER1_IRQHandler
I am using default startup file from Keil. But I did check that handler is there, and I did defined it in my project.
We haven't seen any new post with code that initializes the VIC before the timer may start to create interrupts.
This is the whole code.. I changed to Timer0 but it crashes as well ...
#include <LPC177x_8x.H> void TIMER0_IRQHandler(void); void SystemInit() { } int main (void) { NVIC_EnableIRQ(TIMER0_IRQn); LPC_SC->PCONP |= 1 << 1; LPC_SC->PCLKSEL |= 1 << 2; LPC_TIM0->MR0 = 1 << 23; LPC_TIM0->MCR |= 1 << 0; LPC_TIM0->MCR |= 1 << 1; LPC_TIM0->TCR |= 1 << 1; LPC_TIM0->TCR &= ~(1 << 1); LPC_TIM0->TCR |= 1 << 0; while (1) {} return 0; } void TIMER0_IRQHandler(void) { if ( (LPC_TIM0->IR & 0x01) == 0x01 ) { LPC_TIM0->IR |= 1 << 0; } }
Is this in a .CPP file?
Does the name for the IRQ match exactly with what is in the startup_arch.s file's vector table?
It points to the Default Handler part of startup
And guess what that Default Handler is for: it's where interrupts end up that didn't have a handler set up, at the time they fired.
So, in the light of this: are you still sure that your setting up of interrupt handlers was done early enough, and correctly?
View all questions in Keil forum