Go Down

Topic: How to log into SD card without waiting for aknowledge? (Read 835 times) previous topic - next topic

steven2010

Dear all,

I use SDFat library and calatex sd card module for Arduino Due.
the command for logging data into the card is dataFile.print().

Since SD card works with SPI protocol, I'm wonderig why arduino waits to receive aknowledgment ?
The current experience of mine is that it takes 1-3 ms to log data but sometimes it takes 0.2 seconds!!
This I don't understand. If it is SPI-based, why it should wait for SD card to acknowledge

PaulS

Quote
The current experience of mine is that it takes 1-3 ms to log data but sometimes it takes 0.2 seconds!!
When you call File::print(), the print() method checks to see if there is room in the buffer for the data to be printed. If there is, the data is added to the buffer, and print() returns, nearly immediately.

If there is NOT room, then the contents of the buffer need to be copied to the hardware. THAT takes a lot longer.

Quote
This I don't understand. If it is SPI-based, why it should wait for SD card to acknowledge
Why do you assume that such a thing IS happening?
The art of getting good answers lies in asking good questions.

steven2010

Thanks for the explanation. so how can we reduce that latency of copying?
In other words, isn't there any method so that one could log data at the rate of, lets say, 100Hz reliably ?

my data format includes different variable types, i.e. int16_t, int32_t.

PaulS

Quote
so how can we reduce that latency of copying?
Use a faster Arduino.
The art of getting good answers lies in asking good questions.


Go Up