Showing results for 
Search instead for 
Did you mean: 

DMA transfer data loss

Associate III
Posted on December 06, 2016 at 04:17

Dear Community members,

I'm developing a device which is based on a 'Master - Slave' communication architecture, but now I encountered with a data loss while the Slave is receiving. Since the case is occasional, I still have no idea after I read a few times of related documents, the application and the detail implementation procedures are listed below:


the 'Master - Slave' communication is formed by SPI with DMA, 15MHz.

The MCU is STM32F207.

the 'master - slave application' functionality:

master should continuously issue the request to the slave, slave will reply the requisite data to the master through SPI.

However, after communicate for a while, slave may not receive the last data issued by the master, confirmed that the last data has been sent by master and also could be observed on the oscilloscope. Since the Master should issue each request after receiving the 'HW ACK signal' from Slave, Slave should issue each 'HW ACK signal' after the next DMA receiving is ready, it is very hard to find the reason that Slave ignores the receiving of the last data from Master.

The case above I'm sure that Slave did not receive the last data from Master since I could not find the related data in the configured DMA memory buffer and the more certain point is that the register 'SxNDTR' remains as the configured value but 'zero', so I judge that Slave doesn't receive anything from DMA for the last data issued by Master.

Since the system is also integrated with USB MSC, if I turn off the USB MSC features, it can just work fine, I could not sort thing out, please suggest if you have any idea, any of it might be a great help for me.

the related code is attached, if there is any thing required please let me know.

Many thanks for all the suggestions,

Calvin Lin

Associate II
Posted on December 06, 2016 at 09:02


I'm not sure it's the same problem but I had some issue using SPI with DMA on the STM32F103. Single data bytes gets inserted in the stream sometimes. It's a known hardware error listed in the errata-sheet pdf of the uC. So I use SPI now without DMA.

Hope this helps.

Posted on December 06, 2016 at 22:47

is the SPI link connecting two boards or are both ends on a single PCB?  If on separate boards, running at 15MHz I can think of a million signal integrity and noise issues that could cause what you are seeing, including power supply noise that could be exacerbated by the USB port (and which goes away when the USB is not used).  If this seems likely, you might try running the link at say 1MHz to see if it is a speed related issue.  If so, you may need to put each of the SPI signals into coax or twisted pair configs to improve signal integrity.

BTW, What's MSC?

Associate III
Posted on December 08, 2016 at 07:09

Dear community members,

thank you for all your suggestion, I entirely review my code of the DMA CRC managing task, by now my issues seems solved, but not sure yet. I'm still running test for the stability now, since my application is based on a half-duplex architecture, when Slave transmits data, I had cleared CRC and had turned off the SPI_DMA_Rx_CRC feature in order to keep CRC value synchornized on both side, but while running  on this mechanism it was always unstable when turned on the USB HOST driver. After I rescheduled the entire CRC on/off mechanism to make it functions all the time, now it looks running properly.

BTW, MSC is the abbreviation of 'Mass-Storage-Class'.

thank you