cancel
Showing results for 
Search instead for 
Did you mean: 

Interrupt Priority Sm3210e-Eval Stm32F107ZG

samed
Associate II
Posted on November 19, 2013 at 17:28

I have a problem with my Interrupt priority....

My TIM3 is called every 5ms and have high priority

and my TIM2 every 1ms have low priority

and everytime my TIM2 is called. I want Interrupt TIM2 when TIM3 is active

where is the problem ?

void Config_Timer_TIM2(TIM_TimeBaseInitTypeDef *TIM_TimeBaseStructure, NVIC_InitTypeDef *NVIC_InitStructure)

{

  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);

    

    

 /* Enable the Timer2 Interrupt */

    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);

    

  NVIC_InitStructure->NVIC_IRQChannel = TIM2_IRQn;                          //  configure the Timer2 interrupts

  NVIC_InitStructure->NVIC_IRQChannelPreemptionPriority = 0x0F;   //  sets the priority group of the TIMER2 interrupts

  NVIC_InitStructure->NVIC_IRQChannelSubPriority = 0;                    //  set the subpriority inside the group

  NVIC_InitStructure->NVIC_IRQChannelCmd = ENABLE;                            //  TIMER2 interrupts are globally enabled

  NVIC_Init(NVIC_InitStructure);        

    

    /* Configure Timer which is every 1    ms active*/

  TIM_DeInit(TIM2);

  TIM_TimeBaseStructInit(TIM_TimeBaseStructure);

 

  /* Time base configuration */

  TIM_TimeBaseStructure->TIM_Prescaler = 360 - 1; // 72 MHz / 360 = 200 khz

  TIM_TimeBaseStructure->TIM_Period = 200 - 1;    // (1/200khz) * 200 = 1 ms;

  TIM_TimeBaseStructure->TIM_ClockDivision = TIM_CKD_DIV1;

  TIM_TimeBaseStructure->TIM_CounterMode = TIM_CounterMode_Up;

  TIM_TimeBaseInit(TIM2, TIM_TimeBaseStructure);

    

    //TIM_PrescalerConfig(TIM2, 360-1 , TIM_PSCReloadMode_Immediate);

    

  /* Enable TIM2 Update Interrupt */

  TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);

 

  /* Enable TIM2 */

  TIM_Cmd(TIM2,ENABLE);            

}

void Config_Timer_TIM3(TIM_TimeBaseInitTypeDef *TIM_TimeBaseStructure, NVIC_InitTypeDef *NVIC_InitStructure)

{

  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);

 /* Enable the Timer3 Interrupt */

  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);

    

  NVIC_InitStructure->NVIC_IRQChannel = TIM3_IRQn;                          //  configure the Timer2 interrupts

  NVIC_InitStructure->NVIC_IRQChannelPreemptionPriority = 0 ;   //  sets the priority group of the TIMER2 interrupts

  NVIC_InitStructure->NVIC_IRQChannelSubPriority = 0;                    //  set the subpriority inside the group

  NVIC_InitStructure->NVIC_IRQChannelCmd = ENABLE;                    //  TIMER3 interrupts are globally enabled

  NVIC_Init(NVIC_InitStructure);        

    

    /* Configure Timer which is every 5 ms active*/

  TIM_DeInit(TIM3);

  TIM_TimeBaseStructInit(TIM_TimeBaseStructure);

 

  /* Time base configuration */

  TIM_TimeBaseStructure->TIM_Prescaler = 1800 - 1; // 72 MHz / 1800 = 40 khz

  TIM_TimeBaseStructure->TIM_Period = 200 - 1;    // (1/400khz) * 200 = 5 ms;

  TIM_TimeBaseStructure->TIM_ClockDivision = TIM_CKD_DIV1;

  TIM_TimeBaseStructure->TIM_CounterMode = TIM_CounterMode_Up;

  TIM_TimeBaseInit(TIM3, TIM_TimeBaseStructure);

    

  /* Enable TIM2 Update Interrupt */

  TIM_ITConfig(TIM3, TIM_IT_Update, ENABLE);

 

void TIM2_IRQHandler(void)

{

         Display_Adc_Value(Line7,Black,Line3,Green,ADC1);

          Display_Adc_Value(Line8,Black,Line5,Blue,ADC2);

                

             TIM_ClearITPendingBit(TIM2, TIM_IT_Update);              //Update Interrupt

}

void TIM3_IRQHandler(void)

{

    

      UARTSend(''CV'', 1);

//        if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET)

//        {

//            

//        }

        TIM_ClearITPendingBit(TIM3, TIM_IT_Update);   //Update Interrupt

}
1 REPLY 1
emalund
Associate III
Posted on November 19, 2013 at 20:33

remove the output calls from your ISRs (it is, generally a bad idea to call non-related output from ISRs) and just set/clesr a flag, then use the debug to see what happens.

Erik