user21128: I have a global uint32_t that keep tracks of used Bytes:
uint32_t usedBytes;
int bytesWritten;

byteWritten = myFile.print(data, FILE_WRITE);

if (byteWritten > 0) {
  usedBytes += bytesWritten;
}

What happen if usedBytes is close to the maximum (0xFFFFFFFF)? Will incrementing it make it 0, or stuck at 0xFFFFFFFF?

user4143: It will wrap around though 0.
0xFFFFFFFF + 1 = 0

You can add a higher order word to track more data:
if (byteWritten > 0) {
    uint32_t newUsed = usedBytes + byteWritten;
    if (newUsed < usedBytes) {
        fourGigsUsed ++;
    }
    usedBytes = newUsed;
}

Or you could use uint64_t to automate it - however none of the Arduino print routines cope with the uint64_t variable type.

21128: <p>I have a global uint32_t that keep tracks of used Bytes:</p>

<pre><code>uint32_t usedBytes;
int bytesWritten;

byteWritten = myFile.print(data, FILE_WRITE);

if (byteWritten &gt; 0) {
  usedBytes += bytesWritten;
}
</code></pre>

<p>What happen if usedBytes is close to the maximum (0xFFFFFFFF)? Will incrementing it make it 0, or stuck at 0xFFFFFFFF?</p>
 4143: <p>It will wrap around though 0.</p>

<pre><code>0xFFFFFFFF + 1 = 0
</code></pre>

<p>You can add a higher order word to track more data:</p>

<pre><code>if (byteWritten &gt; 0) {
    uint32_t newUsed = usedBytes + byteWritten;
    if (newUsed &lt; usedBytes) {
        fourGigsUsed ++;
    }
    usedBytes = newUsed;
}
</code></pre>

<p>Or you could use <code>uint64_t</code> to automate it - however none of the Arduino print routines cope with the <code>uint64_t</code> variable type.</p>
