cancel
Showing results for 
Search instead for 
Did you mean: 

Continuous DMA from memory to SPI

SoCalJim
Associate

We need to continuously DMA a single 16-bit word to the SPI transmitter. (Neither the memory address nor the peripheral address would increment.) Can this be done without intervention? I.e. do we have to use a DMA Complete interrupt to set a flag and call HAL_SPI_Transmit_DMA whenever the flag gets set, or can we configure HAL_SPI_Transmit_DMA to set and forget it?

9 REPLIES 9
TDK
Guru

Should be doable. Set up a circular transfer where neither address increments. Length of the transfer is not relevant-any nonzero value will do. Disable interrupts after it starts if you don't want to service them.

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

I set up no-address-increment, Half Word (16-bit), circular DMA, from memory to SPI, transmitting 0xE002 = binary 1110000000000010 to visualize the bit spacing:

You can see there’s no space between the words.

That's what a continuous SPI stream looks like. Do you want something else?

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

Maybe I don't understand the SPI protocol well. How would the slave know where a frame/word ends and the next one begins?

Typically that's done with a separate chip select (CS) line. You can use NSS Pulse mode to have the CS line go high between words, if that's what you need.

TDK_0-1736312442117.png

 

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

Here's my Data in yellow, NSS in blue.

 

Read out and check/post content of SPI and relevant GPIO registers.

JW

Hi SoCal,

Having a look at your file 2.png, NSS is definitely not right. Whats the scale of the NSS trace? It looks like a signal with a bit of ground bounce (very low voltage) - every time your data changes, you get a bounce on NSS. Its certainly not indicating end of word.

Whats the voltage of the ringing on NSS?

Regards,

Toneski

Seems okay to me, except there's a lot of cross-talk/bounce. You're only showing about 8 bits worth of data, so could just be missing where the pulse is. Did you enable NSS Pulse mode? Can you show your code? 

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