SdFat icon indicating copy to clipboard operation
SdFat copied to clipboard

How to deploy SdSpiSTM32.cpp

Open JK-Pair opened this issue 3 years ago • 5 comments

I'm currently working on STM32 Bluepil (https://github.com/rogerclarkmelbourne/Arduino_STM32) I would like to decrease saving time (about 20ms, which is not enough), So I saw the DMA function in the SdSpiSTM32.cpp would help me solve that problem. By looking at examples/UserSPIDriver/UserSPIDriver.ino, Still have no idea about how it works.

Could anyone give me an example of using the SdSpiSTM32.cpp?

JK-Pair avatar Feb 28 '23 05:02 JK-Pair

you didn't provide enough information about your problem so I can't help.

DMA can provide better transfer rates but does not help with some SD latency problems.

greiman avatar Feb 28 '23 12:02 greiman

My problem is the SD latency, which took time around ~15ms to save the data into SD Card, which means the MCU will be interrupted for 15ms. I don't want that. I thought the DMA function could help me solve that problem, still have no idea. Do have any suggestions about my problem? (Can't use RTOS)

JK-Pair avatar Feb 28 '23 13:02 JK-Pair

See this example for a program that overcomes latency.

This example logs data at more than 25 ksps.

greiman avatar Mar 01 '23 23:03 greiman

Thank you so much for your help. I still want to try the DMA method, Could you also give me an example of using it?

JK-Pair avatar Mar 02 '23 03:03 JK-Pair

You won't get any latency help from DMA. You must look at the above examples to avoid long latency while the SD is busy.

You must pre-allocate the file, use file.isBusy() to buffer data until the SD is not busy.

to use DMA replace this and this with calls to SPI DMA functions.

Run this example on your board to see the performance.

greiman avatar Mar 02 '23 12:03 greiman