- Thu May 17, 2012 8:46 am
#144659
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:
Here is my handler:
I'm using CrossWorks for ARM.
Any suggestions?
Regards,
Simon H.A.
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:
Code: Select all
//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:
Code: Select all
I have tested the timer itself and it works flawlessly, but It won't work with an interrupt 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'm using CrossWorks for ARM.
Any suggestions?
Regards,
Simon H.A.