cancel
Showing results for 
Search instead for 
Did you mean: 

The procss of using SPI slave with dma

Logann123321
Associate III

Hi I am fairly new to SPI slave with dma on a microcontroller, I am wondering in firmware what is the process of implementing it? I have set spi1 up as spi slave and assign dma streams to it in the cubeide, but now that it is set up, how is the data trasmitted and received? What do I need to do additionally to send and receive data automatically when the master sends a sclk signal?

Thanks!

2 REPLIES 2
CBai.428
Associate

Good question!

You first route the requests from SPI to DMA in DMAMUX,. Then you set the respective DMA Streams' registers (peripheral/memory pointer, NDTR, and the control register) and enable them in the control register. This of course assumes you've already set the DMA's clock in RCC.

Provided the SPI is set up properly, it's enabled for Tx/Rx DMA, this is it. As soon as the Tx DMA is enabled, it transfers enough frames to keep the SPI FIFO full. Then, when SCK clocks arrive, the data are transmitted and DMA fills the succeeding bytes until its NDTR gets zero, unless set to circular. Similarly, received frames fill the FIFO, and when the set threshold is reached, they get transferred by the DMA assigned to Rx into its destination as set in there.

You may want to read the DMA, DMAMUX and SPI chapters in the RM.

I don't Cube.

JW