cancel
Showing results for 
Search instead for 
Did you mean: 

Timers and SPI and DMA

mmensch
Associate II
Posted on December 15, 2014 at 16:52

Hi,

I am using STM32L152. I programmed some timers to output a repeated burst of pulses without any software interaction. Now I want SPI to transmit data from a buffer, one 16 bit word at each pulse, and repeat this with each burst, like this:

0x1234 - pause - 0x2345 - pause - 0x3456 - long pause - 0x1234 - pause - 0x2345 - and so on with the pause times given from the timers. At each transmit there should be a corresponding receive

I would like to do this with DMA also without any software interaction except an interrupt in the long pause but currently I can't see how to do it. If I program three words for the DMA it will send them all at once in one stream, if I program one word I need to disable the channel and set it again for the next byte and also change the data address to the next value to be send.

Any help is welcome

Thanks a lot

Martin

2 REPLIES 2
Posted on December 15, 2014 at 19:22

You'd have the TIM (Update or CCx) trigger the DMA, not the SPI TXE

You could have a secondary DMA loading a TIMx->ARR or TIMx->CCRx

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
mmensch
Associate II
Posted on December 17, 2014 at 11:56

Hi Clive,

thank you for the hint

> You'd have the TIM (Update or CCx) trigger the DMA, not the SPI TXE

Yes, thats it. I just had a misunderstanding of how DMA work, although I already did some DMA stuff. Well, still learning after all these years.

Martin