[Solved] PWM TIM1 output randomly dropping out when modulating the frequency
Solution: the ARPE bit was not set in the CR1. TIM1->CR1 |= 0x0080; solved the problem.
Dear community,
I am experiencing with an issue using TIM1 as a PWM timer. It all works fine, I can set the frequency and duty cycle with TIM1->ARR and TIM1->CCR1. I am not using anything else at the moment (no ADC, no UART, etc...) and it's all intialized with Cube. I don't use any cube functions in my main.
Then I am generating a little triangle oscillator in my code with the frequency of 1hz, that oscillator modulates the value of overflow for TIM1 in order to modulate its frequency.
About every 1ms (I am timing this using the DWT->CYCCNT, not even a timer to simpify debugging), I am writing the new TIM1->ARR and TIM1->CCR1 to modulate the frequency of the PWM timer over time and then recalculate the next value.
My issue is: When modulating the frequency, I get random drop-outs on the PWM pin, from time to time the output drops to ground for a while. When the frequency is constant I get no drop outs. I tested with F103 and F411, same issue...
See output read by logic analyzer:

I am confident that my registers values for the timer are correct. I stored few periods in an array and plot them in excel:

So the issue is that I am changing the registers values over time. I am doing this with a frequency of about 1hz and the PWM frequencies are modulating from 35k to 80k. Where could it go wrong ?
Here is the code if anybody want to look at it:
https://github.com/soundforce/PWM_mod_issue
I am stuck with this problem since februari... Thanks in advance!
