sensorNET - utility to initialize arduino EEPROM
On the sensorNEt project I'm saving data to EEPROM and, during development, I have the need to test programming with the EEPROM as it comes from factory, i.e. with all bytes set to 0xFF. because I write and clear the memory meny times, I needed a fast program to re-initialize the EEPROM to 0xFF. Yes it's simple but it's always a good sketch to keep on the utilities folder (besides, it displays a nice progress line on the serial monitor!!.
Here it goes:
/*this sketch initializes EEPROM with 255 for all addresses*/
/*for atMEGA 328P */
#include <EEPROM.h>
void setup(){
Serial.begin(9600);
Serial.println("Started!");
int counter = 0;
//write a new "." every counter_step
int counter_step = 32;
int current_step = 32;
for (int i = 0; i < 1024; i++){
EEPROM.write(i, 0xFF);
if (counter == current_step){
Serial.print(".");
current_step = current_step + counter_step;
}
counter++;
}
Serial.println();
Serial.println("Complete! EEPROM reinitialized!");
}
void loop(){
//nothing to do here!
}
Comments