Sup everyone,
I'm trying to implement a datalogger on a Teensy 3.5 with as low latency and high write speeds as possible (WITHOUT writing to a .dat file) and I've been running some speed benchmark tests.
During my benchmark tests, I've been writing some dummy data to a .csv file with one field being a the output of a timer (in microseconds) that measures how long it took for the loop() function to complete it's current iteration. I have code for other features of the project, but all of them are commented out in the loop() function so that the only two features currently running constantly is the SD logging function and the timer.
After running a test, I've found that the data writes usually take about 3200us (0.0032s) but randomly get spikes of about 10000us (0.01s) and once in a while even get a spike as large as 230000us (0.23s).
The time between spikes seem to be random.
I'm doing a flush() once every 100 iterations of loop().
The complete code and the resulting .csv are attached to this post.
My question is this: What is causing these random lag spikes? Is there anything I can do to eliminate these?
Thank you,
PB
Code_and_CSV.zip (495 KB)