cancel
Showing results for 
Search instead for 
Did you mean: 

How to use 'HAL_SPI_TransmitReceive_DMA' & 'HAL_SPI_Transmit_DMA' for spi, but error in 'devID'

kim_dy
Associate II

i'm using 'HAL_SPI_TransmitReceive_DMA' , but error in 'devid'

'HAL_SPI_TransmitReceive_DMA'  -> The path to use this function is

kim_dy_0-1688604723751.png

kim_dy_1-1688605009400.png

kim_dy_2-1688605029020.png

kim_dy_3-1688605113687.png

 

kim_dy_4-1688605178758.png

kim_dy_5-1688605226133.png

If I use the commented 'HAL_SPI_TransmitReceive' function, the 'devID' value is 0xdeca0310 (normal value)
If you use the 'HAL_SPI_TransmitReceive_DMA' function, the 'devID' value comes out as 0x0(error).

DMA settings are as follows.

kim_dy_6-1688605424895.png

I must solve this problem/
Let me know if there is any information you need to solve the problem.

6 REPLIES 6
TDK
Guru

HAL_SPI_TransmitReceive_DMA starts a transmission which runs in the background. You need to wait for it to complete before you can pull up the CS pin and read the data.

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

I'm sorry, but what CS pin are you talking about?

kim_dy
Associate II

In addition, do I need to use HAL_DMA_Start as well?

Lachezar
Associate II

Lachezar_0-1708507458430.png

Wait DMA to finish before you set NSS(CS) pin. 

Andrew Neil
Evangelist III

Please use this button to properly post source code - not as images:

AndrewNeil_0-1708510610942.png

 

 


@kim_dy wrote:

I'm sorry, but what CS pin are you talking about?


"CS" = "Chip Select"

AndrewNeil_1-1708510800361.png