2023-05-30 09:55 PM
I am using STM32G031 where in my application I have to capture the frequency of Input signal from a sensor and then generate an output PWM with frequency which is twice of input frequency.
I am using TIM3 to capture the input signal from sensor and calculate the frequency and pulse width. Then I'm taking this pulse width as value for TIM1->ARR and half the value of pulse width is set as TIM1->CCR1.
The problem I am facing is that the generated PWM has glitches. The output PWM stops for 1-2ms and then starts again.
Please suggest how I can solve this issue.
2023-05-30 11:50 PM
I can think of a couple of lines of attack:
2023-05-31 03:39 AM
> How do you handle the case where the TIM1 counter is already higher than a new, lower-than-before ARR value?
ARR preload enabled by TIMx_CR1.ARPE is designed to prevent this problem.
(Btw. CCRx can/should be set to preloaded, too)
JW