AnsweredAssumed Answered

Control TIMER interrupts- STM32F4 discovery board

Question asked by dang_hong.quan on Jun 24, 2014
This is my program to control TIMER2 interrupt but it doesn't jump into interrupt function. How can I fix this problems?????
 I used startup_stm32f4xx.s , set clock for timer2, enable timer2 interrupt in NVIC register.
/************************************************************/
void TIM2_IRQHandler(void){
     if(timer2->TIMx_SR & 0x1){
     gpio_toggle_off(gpio_A,GPIO_Pin_1);
     number_display(gpio_D,number0);
     }
     timer2->TIMx_SR=0x0;
}
__declspec(noreturn) void main(void) 
{
     gpio_setlock(rcc,GPIOD_CLOCK);          /*PORT-A enable*/
     gpio_setlock(rcc,GPIOA_CLOCK);          /*PORT-B enable*/
     timer_setlock(rcc,TIMER_2);               /* TIMER2 enable*/


     //timer_interrupt(timer2,interrupts);
          NVIC->ISER[0]|= 1<<(TIM2_IRQn);     // enable timer_interrupt =28
          timer2->TIMx_PSC     =41999;               // prescaler
          timer2->TIMx_DIER     |=0x01;          // enable update interrupt
          timer2->TIMx_ARR     =1999;          // counting number
          timer2->TIMx_CR1     |=0x90;                // auto reload, count down
          timer2->TIMx_CR1     |=0x01;               // enable counter
          timer2->TIMx_EGR     =0x01;          // update generation
          while(1);
}
/***************************************************************/

Outcomes