Skip to main content
Zwu.1
Associate
January 10, 2023
Question

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

  • January 10, 2023
  • 2 replies
  • 1558 views

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?

This topic has been closed for replies.

2 replies

S.Ma
Principal
January 10, 2023

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
Zwu.1Author
Associate
January 10, 2023

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.