2020-04-06 12:05 PM
I need to dynamically change waveforms on a PWM output on an STMF030 MCU.
See it as a poor man's alternative to a signal generator using a DAC.
It will be used to generate modulated audio waveforms.
I am using DMA to lookup (a sine) waveform via a circular buffer, that is updating TIM->CCR1 to control the PWM duty Cycle. The PWM frequency is in the range 40-100kHz (10-25us period), and waveforms (duty cycle) will be stored in a 16 - 128 word lookup table, providing a modulated waveform in the 1-8kHz range.
I would like to be able to update the waveform (CCR1 table) dynamically, but I am uncertain how to best do so. I would prefer the waveform change to be timed to take place at the completion of a waveform (DMA buffer transfer), to provide a controlled (smooth) transition between the two.
Here are the options, that I have considered.
I would really like some advice as to options of achieving my goal of smoothly transitioning waveforms, and any suggestions are welcome.
Thanks in advance,
Morten
Solved! Go to Solution.
2020-04-06 02:21 PM
> This would require the interrupt to be serviced in 25us,
Why wouldn't that be viable? Surely writing to a couple of registers on a multi-ten-MHz mcu should not last more than a few microsenconds (or even below a microsecond with a bit of planning) - unless you burn them up in some inflated "library".
> half-buffer updated upon DMA HTIF
Doesn't sound hopeless either, but that of course depends on the particular algorithm you want to employ. Benchmark.
JW
2020-04-06 02:21 PM
> This would require the interrupt to be serviced in 25us,
Why wouldn't that be viable? Surely writing to a couple of registers on a multi-ten-MHz mcu should not last more than a few microsenconds (or even below a microsecond with a bit of planning) - unless you burn them up in some inflated "library".
> half-buffer updated upon DMA HTIF
Doesn't sound hopeless either, but that of course depends on the particular algorithm you want to employ. Benchmark.
JW