Hi,
I’m trying to work out the TIM2 interrupt handler. But it doesn’t seem to run the function at all.
Here is my initialization code for the TIM2:
//Enable TIM2.
RCC_APB1ENR |= RCC_APB1ENR_TIM2EN;
//Prescaler.
TIM2->PSC = 65535;
//Auto reload value.
TIM2->ARR = 1000;
//Enable update interrupt (timer level).
TIM2->DIER = TIM_DIER_UIE;
//Enable timer.
TIM2->CR1 = TIM_CR1_CEN;
//Enable interrupt.
NVIC_EnableIRQ(TIM2_IRQn);
Here is my handler:
//Timer 2 interrupt.
void TIM2_IRQHandler(void) {
//Is the timer set?
if(TIM2->SR & TIM_SR_UIF) {
//Draw a rectangle on screen (test purpose).
FillRect(100, 100, 20, 20, 0xFF);
//Clears flag.
TIM2_SR &= ~TIM_SR_UIF;
}
}
I have tested the timer itself and it works flawlessly, but It won’t work with an interrupt handler.
I’m using CrossWorks for ARM.
Any suggestions?
Regards,
Simon H.A.