How to fix a glitch in output PWM from TIM1 of STM32G031xx?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-30 9: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.
- Labels:
-
STM32G0 Series
-
TIM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-30 11:50 PM
I can think of a couple of lines of attack:
- How strongly do you know that the glitches come in the generation of the pwm rather than the measurement of the incoming frequency?
- How do you handle the case where the TIM1 counter is already higher than a new, lower-than-before ARR value? If you do nothing, you will have to wait for CNT to roll over from 65535 back to 0 before pwm will resume.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-31 3: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
