I made a code to call Timer2 interrupt function like this :
timerx->TIMx_PSC =42000; // prescaler
timerx->TIMx_ARR =2000; // counting number
timerx->TIMx_CR1 |=0x90; // auto reload, count down
timerx->TIMx_DIER |=0x01; // enable update interrupt
interruptsx->ISER[0]|= 1<<(TIMER2_INTERRUPT); // enable timer_interrupt
TIMER2_INTERRUPT=28
timerx->TIMx_CR1 |=0x01; // enable counter
timerx->TIMx_EGR =0x01; // update generation
and
void TIM2_IRQHandler(){
if(timer2->TIMx_SR & 0x1){
gpio_toggle_off(gpio_A,GPIO_Pin_1);
number_display(gpio_D,number0);
}
timer2->TIMx_SR=0x0;
}
The problem is : it doesn't jump to TIM2_IRQHandler(). How can I solve this problem?
Best Answer
The following works (i.e. triggers interrupts) on my STM32F4Discovery board under the Coocox environment using GCC:
I'm pretty sure that the reason is that I don't actually start the timer (set bit 0 of TIM2->CR1) until after everything else is configured.