cancel
Showing results for 
Search instead for 
Did you mean: 

How can I use the same timer to send multiple DMA requests and output a PWM waveform?

Tommino
Senior

Hello everyone,

I am using the Nucleo l476rg and trying to use the same general purpose timer (TimX X=2 to 5) to develope both the following functions:

1)send several DMA request (let's say 1000) to transfer data from memory to SPI Data register with a rate set by the selected timer (timer update or compare)

2) The timer shall output a PWM waveform that toggles at a specific (let's say the 250th or 500th) DMA request and has a period equal to all the time needed for the DMA transfers at 1)

I am looking for a smart way to perform the above mentioned operation in HW with the same timer in order to avoid timing inaccuracies.

I have seen that the general purpose timers have 4 different CC registers. I could set the the PWM toggling with one CCR register. But how can I manage the DMA requests rate with the same timer?

Do you have any suggestion? Also on different uC that could have timers with this kind of functionalities.

Thanks in advance

3 REPLIES 3
TDK
Guru

You can't have requests happening at different frequencies on the same timer. You could use the DMA's HT and TC interrupts in such a way to trigger every 250 samples, but it will not be exact.

You could use another chained timer to get the exact waveform you want.

If you feel a post has answered your question, please click "Accept as Solution".

>>Also on different uC that could have timers with this kind of functionalities.

Simple CPLD?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Tommino
Senior

I will try to use two timers with a master timer that clocks a slave timer. In this way I should achieve my goals.

I found this very useful STM32 cross-series timer overview - Application note

But can you help me in understanding the functionality highlighted in yellow?

0693W00000KbxG7QAJ.png