AnsweredAssumed Answered

timer interrupt

Question asked by kaka on Dec 2, 2015
Latest reply on Dec 4, 2015 by kaka
hi

i have configurd to get an interrupt nce the timer update . But it did not work, can anyone knows whats the problem.
I am using stm32f429 discovery board...


 void timer_init()
 {
      /**** clock for the timer *****/
      RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM2, ENABLE);
     // RCC->AHB2RSTR  |= timer2_RCC_Enable;


      /*** timebase init and nested vector init *****/
     TIM_TimeBaseInitTypeDef TIM_TimeBaseStruct;




     /**** timer has the delay of 45MHz *****/
     TIM_TimeBaseStruct.TIM_ClockDivision = 0;
     TIM_TimeBaseStruct.TIM_CounterMode = TIM_CounterMode_Up ;
     TIM_TimeBaseStruct.TIM_Period =  1000000-1; // 1Mhz to 1hz  which equals to  1s
     TIM_TimeBaseStruct.TIM_Prescaler = 45-1;  //45 Mhz to 1 Mhz which equals to 1us
     TIM_TimeBaseStruct.TIM_RepetitionCounter = 0 ;
     TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStruct);

     /**** Enable the timer ****/
          /* start timer */


     TIM_Cmd(TIM2, ENABLE);

     /**** interrupt ****/
     NVIC_InitTypeDef NVIC_IntStruct;
     NVIC_IntStruct.NVIC_IRQChannel = TIM2_IRQn;
     NVIC_IntStruct.NVIC_IRQChannelCmd = ENABLE;
     NVIC_IntStruct.NVIC_IRQChannelPreemptionPriority = 0;
     NVIC_IntStruct.NVIC_IRQChannelSubPriority = 1 ;
     NVIC_Init(&NVIC_IntStruct);

     /*** interrupt on nvic ******/
     TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);

 }

Outcomes