Question
Duration of timer's IRQHandler with PWM
Posted on October 26, 2015 at 16:29
I'm using STM32F303 Discovery board.
I try to evaluate how much code can be performed intimer'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 somehowachievepossibility to use full time of PWM duty cycle fortimer's IRQHandler?
Thank you!