cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G473 spi slave mode with DMA, HAL_SPI_TransmitReceive_DMA() transmit data move a byte

Zwu.1
Associate

STM32G473 spi Full-Duplex slave mode with DMA, There is no problem in receive, but, the data transmited is move a byte. The following is a detailed description of the experiment.

This is my cubeide configuration:

0693W00000Y7moEQAR.jpg0693W00000Y7moJQAR.jpgthen, in the code, STM32 with slave mode, and initialize spi with function HAL_SPI_TransmitReceive_DMA(&hspi1, pTxData, pRxData,Size), pRxData from the mast device, pTxData[104] = {0x55, 0xaa, 0x02, 0x03, 0x04, 0x05, 0x06,..., 0x65, 0x66, 0xc3} .when up-baord(compute with spi Full-Duplex master mode) transmit a series bytes to STM32, pRxData[104] = {0xaa, 0x55, ......}.

however, the up-board get data is {0xaa, 0x02, 0x03, 0x04, 0x05, ......, 0x66, 0xc3, 0x55}, is not equal to pTxData, all data move a byte left.

following is the wave captured with logic analyzer:

start

0693W00000Y7n4MQAR.jpgend

0693W00000Y7n5ZQAR.jpg​Can someone help me?

2 REPLIES 2
S.Ma
Principal

Do you exti on nss signal?

When do you init dma?

If one byte is lost, use breakpoint to analyse. Also make sure of dma data is 8 bit to spi 8 bit modd in order to start easy debug.

Zwu.1
Associate

First of all, thank you for answering my question. My nss isgnal is Hardware NSS input signal (the first picture). I use the hal library function HAL_SPI_TransmitReceive_DMA(), where init DMA. first init DMA was automatic generated with cubeide.