2024-09-15 11:32 AM - edited 2024-09-15 11:32 AM
I have setup Timer 8 to generate PWMs, to modulate a sinewave. I use preload, but that is only used once.
I have debugged and compared the registers, but i could not find a cause. I have also partially compared the sram bytes, but i could not find the cause there either. I checked my program too. But now after about 18 hours of searching i have to create this post.
Interestingly, it looks like the compare registers dont compare. But it looks to me, like the output is enabled (see picture). Sometimes, the complementary output stays high!
Before i post the code, i would like to know if someone knows of any hardware issues/difficulties.
A good idea how to troubleshoot this, would be welcome.
2024-09-15 03:07 PM
Read out and check/post content of TIM and relevant GPIO registers.
JW
2024-09-15 10:11 PM
2024-09-15 10:44 PM
I think what Jan also meant was:
How does your source code set things up? TIM & DMA (circular?) settings.
Please show relevant code, using the "</>" button.
In case you are using HAL: the timers are not that mystical, try using direct register access to better understand what's going on, set it up step by step.
2024-09-15 11:12 PM - edited 2024-09-16 12:57 AM
I have now gotton further. I found out, that the problem appeared, depending of how the timer settings (preload) were before. I could constantly reproduce the issue when keeping them fixed. Then i found out, that after setting the preload values, with a delay of 150-200us, it works with any timer settings that there were before.
See picture attached.
I also tried disabling updates while changing settings, and update event via UG bit after chaning the setting. None fixed the issue.
See fail.txt for registers.
I never use HAL, except in the init or for testing purposes.
2024-09-16 03:27 AM
2024-09-16 07:54 AM - edited 2024-09-16 02:05 PM
I have found another issue, that does not seem to be related, but maybe the chip is bad?
It seems, that there was some problem, that has been resolved with a power cycle. Neither this topics issue, nor the issue in the link does exist anymore. I wonder what has led to this issue.
My guess is, that is has something to do with the debug system. Somehow the setting of registers was blocked, or read wrong with the debugger.
2024-09-17 09:00 AM
Current test setup:
I reset the device every 590ms, and have a pwm input to the (hall-)input pin. The pwm input has a constant phase to the reset signal. Depending on the phase, there are freezes in the pwm signal more or less often, on one channel OR the other, or even none at all. Interestingly, the fail/freeze rate of certain channels changes, if i disconnect the reset signal line, and connecting it back (the phase does not change).
The code has the delay removed again, to investigate this issue further.
2024-09-18 12:40 PM
After a lot of time used for tests, i dont really havent worked out what the problem exactly is here. It seemed to me, that writing twice to the preload register would drop the last written value. Since i changed my code, i will not test any further here.