2022-06-18 03:32 AM
Hi, I use the timer3 to detect PWM Duty cycle from the input signal.
The signal is an angle sensor from a BLDC Motor. That means 0% DCy is 0 grad and 100% is 2pi grad. The sensor has 4096 bit resolution.
But I have a problem to detect an overflow interrupt, because in PWM Mode, Rising Edge and Falling Edge Interrupts are also active and seems that all three interrupts call the function HAL_TIM_PeriodElapsedCallback after an event update.
The problem in my application is, that in transition from 2pi to 0 grad, the PWM goes from 100% DCy to 0%DCy, that means for a whole period I don't have a Rising edge signal to detect the new period.
I thought that with an overflow interrupt I can reveal that the period is over and if a rising edge does not occur then I am on the transition.
Do u have any ideas?
2022-06-18 11:08 AM
I am not trying to understand fully your problem. I don't use Cube/HAL, but if HAL_TIM_PeriodElapsedCallback() is Cube's way to handle the Update event, you may want to set TIMx_CR1.URS to prevent Update events to be generated by the Slave-mode controller being set in Reset mode (as that's what "PWM Input" entails).
JW
2022-06-18 02:30 PM
Thanks, I think URS bit is the solution.
I searched in c code from CubeMX and seems that there is no option to change this bit.
Maybe I have an older version, but no URS bit can be changed with cubemx.