2023-01-09 06:13 PM
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:
then, 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
end
Can someone help me?
2023-01-09 09:21 PM
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.
2023-01-10 02:59 AM
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.