Hello, I have to write an SD-Card, with all the values of every single Byte of every single sector a (Byte: "00000000"). The Arduino managed to write them all, except sector 0. How do I also write sector 0?
The part of code that performs the job:
byte buffer_c[512] = {0x00};
byte buffer_d[512] = {0x00};
byte buffer_e[512] = {0x00};
long i = 0;
bool uguale = false;
int car = 0;
i = 0;
long h = 0;
for (i = 0; i < sd1block; i++) {
sd1.writeBlock(i,buffer_c);
Serial.print("Write: ");
Serial.println(i);
sd1.readBlock(i, buffer_e);
uguale = true;
h=0;
for (h=0;h<512;h++) {
if(buffer_e[h] == buffer_d[h]) {
Welcome to the Forum! You will get faster and better help if you post your code as requested by the forum guidelines. Read the forum guidelines to see how to properly post code and some good information on making a good post. Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting
SD cards are not meant to be written to in sectors. They are designed to be used with files. I am sure that sector 0 is where the code stored in the SD card writes its file allocation memory map, and so this sector is protected.
The file operating system also implements sector ware control, so that no single sectors receive too many writes and burn out due to writing a sector too frequently.