SPI DMA stall time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-09-10 08:17 AM
I'm trying to use SPI with DMA and have had an issue in that data packets are sent too close to one another, based on the SPI stall time needing to be 2us between packets. Is there anyway I can set this through the SPI or DMA? I don't really want to have to idle the processor whilst waiting for this stall time to pass...
#stm32 #dma #spi- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-09-10 08:46 AM
You can trigger the DMA not from SPI itself, but from a timer.
JW- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-09-10 09:41 AM
I'm not sure that would work for me, unless I only use DMA to transfer 1 packet at a time. What I was looking at is passing the DMA a buffer of say 10 values I want to send via SPI and set it off, but somehow manage to have a stall time between each packet instead of the DMA rattling through them as fast as it can. Using DMA to send one packet at a time almost seems redundant?
Maybe I've missed something in your suggestion?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-09-10 01:29 PM
> I'm not sure that would work for me, unless I only use DMA to transfer 1 packet at a time.
Why not? The timer would be set to generate a DMA-connected event (e.g. update) at a pace equal to required distance between starts of successive word (byte, ''packet''). That event would trigger the DMA to transfer a word (byte) from memory to SPI_DR. Why wouldn't this scheme be good enough? You may be not aware of the fact that the DMA channel (stream) can transfer data between any two addresses, not being constrained to the peripheral which triggered the transfer (there are limitations, though, e.g. 'F2/'F4 DMA1 is constrained at the peripheral port to the same APB bus where the trigger source sits - this is why it's important to tell which mcu family are you talking about). JW- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-09-11 12:40 AM
Ah, I think I get what you're saying now. So I could set up the DMA to just transfer one byte, get it to increment the memory address and then re-enable it off a timer without having to re-initialise everything, causing it to just send the next byte? I'll have a play, thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-09-11 02:05 AM
No.
Set up the timer so that it triggers a DMA, then set the DMA's destination (peripheral) address to SPI_DR, source (memory) address to your buffer, and its NDTR to the size of buffer, and enable the timer. JW- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-09-11 02:13 AM
When you say trigger, you just mean enable the DMA? Or is there something I'm missing that lets you trigger the DMA to only transfer one item from its buffer at a time?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-09-11 02:31 AM
> When you say trigger, you just mean enable the DMA?
By ''trigger'' I mean the signal (wire) which comes a peripheral to the DMA, ''telling'' the DMA that it should start a transfer. Look at Fig.32 in RM0090rev10, it's what comes from the left side in the picture, REQ_STRx_CHy (''request'' is the traditional term for this signal; I should stop using ''trigger''). Look at Fig.33 in RM0090, it's the wires which go out of the peripherals on the right side, go through bottom and come into the DMA controller in the left side. > Or is there something I'm missing that lets you trigger the DMA to only transfer one item from its buffer at a time? For timers, there is an acknowledge going from the DMA back to the timer (this is not drawn on the figures), so that when the DMA performs the transfer, it pulses the acknowledge to clear the request, thus timer-initiated transfers are usually single ones (there is an exception but you don't need to be bothered by that at this moment). JW