AnsweredAssumed Answered

Writing to SD card via SPI interfering with USART DMA Rx?

Question asked by Sebastian K. on Jan 4, 2018
Latest reply on Jan 5, 2018 by Sebastian K.



I am having a problem with a simple data logging project on an L432KC Nucleo board.


I have a microSD breakout board from Adafruit hooked up via SPI1 and receive data on USART1 via DMA using a circular buffer for continuous reception. I am firing data at the board from another board in frames of ~100 Bytes every 20 ms at 460.8 kBaud. The intention is that the DMA keeps filling up the buffer with incoming data while I'm busy writing chunks of it to the card (which I am aware can take relatively long). Both parts work fine by themselves, I can write data to the card and the USART Half and Full Rx Completed callbacks are triggered as expected. I'm using the FATFS middleware provided by CubeMX and an adapted version of the Adafruit LCD shield library from the ST examples.


The weird thing is that it seems that whenever I write to the card (or sync it), during that time the USART does not receive any characters. I know that because the test data I am sending includes a running frame counter, and in the recorded file I see missing frames each time I write a chunk of data to the card. The DMA buffer is large enough to not overflow while I'm writing to the card.


Is that supposed to happen? I thought the SPI and USART were independent peripherals, and in the SD card / FAT code I see nothing that could lock the USART or DMA. Does anyone have any pointers as to what could be going on? I looked at the documentation, but found nothing that could explain it.


Thanks for reading.