user35603: I'm writing on a SD card the value of a measured voltage. I've a good sampling/writing frequency but regularly the acquisition take a lot of time (like 4000us instead of 400us). I noticed that this "pause" appears every 85 values (my values are 6 bytes long, so it appears every 510 bytes). 
So I have hypothesized that there is a buffer of 512 bytes somewhere which is full and need some times to empty.
But I don't know where is this buffer. In SDcard? in Arduino? And how can I avoid this issue?
Here, my results on 1Hz sinus with a zoom on the "break":
And here my loop to read the value and write it on sd card:

Hope you can help me guys !

user4143: The buffer is in the SD card library. It is the size of one block on the SD card. When it is full it needs flushing out to the SD card, which takes time. Once that is done the buffer is then empty again and can be filled back up by your code.
It has to be done this way because SD cards work in blocks of 512 bytes. 

user31105: Possibilities:

What you can do it measure what you need inside an interrupt routine (I hope the measurement itself does not take too long). Write it to a buffer in the interrupt routine. Your 'normal' loop can do the writing to the SD card.
A possible very extensive solution would be to send the sampled data to another Arduino which can store it on an SD without affecting the sampling (since it's done on another Arduino). 
Using DMA (Direct Memory Access), however afaik this option is not available for an Arduino.


35603: <p>I'm writing on a SD card the value of a measured voltage. I've a good sampling/writing frequency but regularly the acquisition take a lot of time (like 4000us instead of 400us). I noticed that this "pause" appears every 85 values (my values are 6 bytes long, so it appears every 510 bytes). </p>

<p>So I have hypothesized that there is a buffer of 512 bytes somewhere which is full and need some times to empty.</p>

<p>But I don't know where is this buffer. In SDcard? in Arduino? And how can I avoid this issue?</p>

<p>Here, my results on 1Hz sinus with a zoom on the "break":<a href="https://i.stack.imgur.com/Cb02t.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Cb02t.jpg" alt="enter image description here"></a></p>

<p>And here my loop to read the value and write it on sd card:</p>

<p><a href="https://i.stack.imgur.com/iWD1Z.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iWD1Z.jpg" alt="enter image description here"></a></p>

<p>Hope you can help me guys !</p>
 4143: <p>The buffer is in the SD card library. It is the size of one block on the SD card. When it is full it needs flushing out to the SD card, which takes time. Once that is done the buffer is then empty again and can be filled back up by your code.</p>

<p>It has to be done this way because SD cards work in blocks of 512 bytes. </p>
 31105: <p>Possibilities:</p>

<ul>
<li>What you can do it measure what you need inside an interrupt routine (I hope the measurement itself does not take too long). Write it to a buffer in the interrupt routine. Your 'normal' loop can do the writing to the SD card.</li>
<li>A possible very extensive solution would be to send the sampled data to another Arduino which can store it on an SD without affecting the sampling (since it's done on another Arduino). </li>
<li>Using DMA (Direct Memory Access), however afaik this option is not available for an Arduino.</li>
</ul>
