2015-10-26 08:29 AM
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!
2015-10-27 09:14 AM
This would be more illustrative, less clutter between the entry point and the edge
void TIM3_IRQHandler(void)
{
GPIOE->BSSR = GPIO_Pin_0;
TIM_ClearITPendingBit(TIM3, TIM_IT_Update);
for(aaa=0;aaa<
6
;aaa++)
__nop();
GPIOE->BSSR = GPIO_Pin_0 << 16;
}
You're going to have to look at the code generated by the compiler to understand where the cycles are going. The context push is 12 cycles.
You're not going to be able to interrupt at MHz rates. For that consider using hardware.
2015-10-28 08:55 AM
Thank you for all. Probably i'll have questions about hardware interfaces soon.
Now just want to ask you where i can find examples for combined mode of PWM?2015-10-28 10:31 AM
The various SPL releases have quite a lot of examples in them, I've posted a bunch of stuff to the forum.
I believe ST published an App Note on the TIM Peripheral. AN2581http://notes-application.abcelectronique.com/005/5-10377.pdf
At the end-of-the-day you really need to digest the reference manual, and ponder the mechanical implementation and interconnections. The documentation is a bit dense, and the peripheral rather awkward and limiting at times.