AnsweredAssumed Answered

Duration of timer's IRQHandler with PWM

Question asked by greber.anthony on Oct 26, 2015
Latest reply on Oct 28, 2015 by Clive One
I'm using STM32F303 Discovery board. 

I try to evaluate how much code can be performed in timer's IRQHandler without causing desynchronization with PWM of the same timer.

//interrupt code
if (TIM_GetITStatus(TIMX.name, TIM_IT_Update) != RESET)
{
    TIM_ClearITPendingBit(TIMX.name, TIM_IT_Update);
  GPIO_SetBits(GPIOE, GPIO_Pin_0);
    for(aaa=0;aaa<6;aaa++)
        __nop();
    GPIO_ResetBits(PIOE, GPIO_Pin_0);
}

//some init strings
//---
    base_timer.TIM_Prescaler = 8 
    base_timer.TIM_Period = 20;
    base_timer.TIM_ClockDivision = 0;
    base_timer.TIM_CounterMode = TIM_CounterMode_Up;
//---
  oc_init.TIM_OCMode = TIM_OCMode_PWM1;  
    oc_init.TIM_OutputState = TIM_OutputState_Enable;
    oc_init.TIM_Pulse = 10;   
    oc_init.TIM_OCPolarity = TIM_OCPolarity_High;
    oc_init.TIM_OCNPolarity = TIM_OCNPolarity_High;
    oc_init.TIM_OCIdleState = TIM_OCNIdleState_Set;
    oc_init.TIM_OCNIdleState = TIM_OCNIdleState_Set;

So due to toggling pin inside IRQHandler i saw necessity that time of code performing was less then half of PWM duty cycle. 

I also try to use CCR2 interrupt but situation is the same.

Can somebody explain the reason of such behavior? And maybe it's real somehow achieve possibility to use full time of PWM duty cycle for timer's IRQHandler?

Thank you!

Outcomes