Erasing my external EEPROM

Hello People,
I played along somewhat with my External 256Kb EEPROM and because it seems old data prevents me to check if newer data is logged, or that I am seeing old data, I decided to erase the thing.

Please correct me if I'm wrong, but erasing an EEPROM means I have to fill every byte with 0xFF (11111111)?

I wrote a sketch (which by itself is something to be proud of :slight_smile: ) which sends 0xFF to the External EEPROM's address, to an ever-increasing position, starting from 0 to 32000.
So, that would, due to a 5ms delay, cost me a bit of time, but eventually getting the EEPROM erased.

Am I correct?

I would say it doesn't really matter what you will it with, but yeah programmatically that is the way. Of the top of my head i think there is a way using UV-light as well if i remember correctly.

Of the top of my head i think there is a way using UV-light as well if i remember correctly.

Not on an EEPROM.

What is the part number of the EEPROM?

missdrew:
What is the part number of the EEPROM?

24LC256

It seems I did something to it because when I read the EEPROM, all characters are 每.

See the library here

FTMZ:
I wrote a sketch (which by itself is something to be proud of :slight_smile: ) which sends 0xFF to the External EEPROM's address, to an ever-increasing position, starting from 0 to 32000.

Don't you want to erase the whole device?

Why not read each location first, and only erase the ones that are not 0xff already?
EEPROM Memory IC 256Kb (32K x 8 )
32K = 32 x 1024 = 32768 bytes

(For hard drives, manufacturers would say 32K, but would only provide 32000.
Like they claim 1 Terabyte - which does not mean 1 million megabytes in engineering, but simply 1 million million bytes, so the 1024 gets lost.
In engineering, gigabyte is megabyte x 1024, and terabyte is 1024 x gigabyte.
A real megabyte is 1024 x 1024 = 1048576 bytes
A real gigabyte is 1024 x that = 1073741824 bytes
And a real terabyte is 1024 x that = 10995116277776

But a terabyte harddrive is only 10000000000000, so 995,116,277,776, so nearly 100 GB short of a real terabyte.)

To be honest, I was afraid the device would repeat the action if I was to hit that 32768...

As long as I got the majority done, I could determine if the EEPROM was empty.

Is it correct If I got all 每's

每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每每

Why not print the numeric value, and be certain?

TheMemberFormerlyKnownAsAWOL:
Why not print the numeric value, and be certain?

I tried to load a piece of text, which seem to work, according to the behaviour of TeraTerm.
But It seems I could not receive that data back by TeraTerm.
With all the settings right, I managed to receive data, (again, according to TeraTerm), but that data was not readable (returning only "每" characters, when "reading" the received log.)

FTMZ:
I tried to load a piece of text, which seem to work, according to the behaviour of TeraTerm.
But It seems I could not receive that data back by TeraTerm.
With all the settings right, I managed to receive data, (again, according to TeraTerm), but that data was not readable (returning only "每" characters, when "reading" the received log.)

Well, I know what TeraTerm is, and I know that if you send it the ASCII representation of a number, in binary, octal, decimal or hex, it'll print that number.

The rest of those words, I didn't get.

Time to show your code, and your wiring I think.

OK... I have a 24LC256 wired up by i2c which works. I have loaded quite a few sketch examples successfully, though they only contained byte-sized variables.
And the thing is I need to write and read Floats, which contains 4 bytes.

So one tipped me for this site:
https://learn.sparkfun.com/tutorials/reading-and-writing-serial-eeproms?_ga=2.209849238.2085324980.1612820786-1668522854.1596373743

I guessed this would work out fine, but I could not get it to work.

But... Guys...
I started this topic because I could not get my memory erased.
Slowly it shifts to contents of where I already have one active topic running.
To keep things correct, I'd better direct you guys to that topic.
https://forum.arduino.cc/index.php?topic=726842.new#new

See reply #11

Read reply 12...
The sketches were in the links.

Maybe you misread reply #11.

"Time to show your code, and your wiring I think. "

(My emphasis)

that is the same code.
I copy-paste it. Because it should work.

But I mentioned it would be better to continue in another topic.
Or do you specificly want to look at that code, which I appriciate.

//Include the Wire I2C Library
#include <Wire.h>


/*This address is determined by the way your address pins are wired.
In the diagram from earlier, we connected A0 and A1 to Ground and聽
A2 to 5V. To get the address, we start with the control code from聽
the datasheet (1010) and add the logic state for each address pin
in the order A2, A1, A0 (100) which gives us 0b1010100, or in聽
Hexadecimal, 0x54*/


#define EEPROM_ADR 0x54


/*Theoretically, the 24LC256 has a 64-byte page write buffer but聽
we'll write 16 at a time to be safe*/聽


#define MAX_I2C_WRITE 16聽


byte tempStore[MAX_I2C_WRITE];


void setup()
{


//Start the I2C Library
聽 Wire.begin();
聽 Wire.setClock(400000);


//Start the serial port
聽 Serial.begin(19200);


//Here is where we'll keep track of where in the memory we're writing
聽 long currentSpot = 0;
聽 long timerReset = 0;
聽 byte counter = 0;


聽 //Here we listen for bytes on the serial port and increment
聽 //the counter as we store them in our tempStore variable
聽 while (1)
聽 {
聽 聽 while (Serial.available())
聽 聽 {
聽 聽 聽 tempStore[counter++] = Serial.read(); //Read this byte into the array


聽 聽 聽 if (counter == MAX_I2C_WRITE)
聽 聽 聽 {
聽 聽 聽 //Once we've collected a page worth, go ahead and do聽
聽 聽 聽 //a page write operation
聽 聽 聽 聽 writeEEPROMPage(currentSpot);
聽 聽 聽 聽 counter = 0; //Reset
聽 聽 聽 聽 currentSpot += MAX_I2C_WRITE;
聽 聽 聽 }


聽 聽 聽 timerReset = millis();
聽 聽 }


聽 聽 if (millis() - timerReset > 2000)
聽 聽 {
聽 聽 聽 Serial.println(currentSpot);
聽 聽 聽 timerReset = millis();
聽 聽 }
聽 }


}


void loop()
{
聽 聽 // Don't do anything here
}


/* This is the 3 step memory writing procedure that
we talked about. First we send the MSB of the address.聽
Then we send the LSB of the address. Then we send the聽
data that we want to store. */


void writeEEPROMPage(long eeAddress)
{


聽 Wire.beginTransmission(EEPROM_ADR);


聽 Wire.write((int)(eeAddress >> 8)); // MSB
聽 Wire.write((int)(eeAddress & 0xFF)); // LSB


聽 //Write bytes to EEPROM
聽 for (byte x = 0 ; x < MAX_I2C_WRITE ; x++)
聽 聽 Wire.write(tempStore[x]); //Write the data


聽 Wire.endTransmission(); //Send stop condition
}
//Include the Wire I2C Library
#include <Wire.h>


/*This address is determined by the way your address pins are wired.
In the diagram from earlier, we connected A0 and A1 to Ground and聽
A2 to 5V. To get the address, we start with the control code from聽
the datasheet (1010) and add the logic state for each address pin
in the order A2, A1, A0 (100) which gives us 0b1010100, or in聽
Hexadecimal, 0x54*/


#define EEPROM_ADR 0x54


void setup()
{


//Start the I2C Library
聽 Wire.begin();
聽 Wire.setClock(400000);聽


//Start the serial port
聽 Serial.begin(115200);


聽 //Output raw bytes to terminal
聽 //In this case we're going to read all of the bytes
聽 //which is 32000, or in hex, 0x7D00
聽 for (long x = 0 ; x < 0x7D00 ; x++) //Read all 131,071 bytes from EERPOM
聽 {
聽 聽 byte val = readEEPROM(x);
聽 聽 Serial.write(val);
聽 }
}


void loop()
{
聽 //Nothing to do, just hang out.
}


/* This is the 3 step memory reading procedure that
we talked about. First we send the MSB of the address.聽
Then we send the LSB of the address. Then we ask for the聽
number of bytes that we want to receive. Here, we're聽
going 1 byte at a time*/


byte readEEPROM(long eeaddress)
{
聽 Wire.beginTransmission(EEPROM_ADR);


聽 Wire.write((int)(eeaddress >> 8)); // MSB
聽 Wire.write((int)(eeaddress & 0xFF)); // LSB
聽 Wire.endTransmission();


聽 Wire.requestFrom(EEPROM_ADR, 1);


聽 byte rdata = 0xFF;
聽 if (Wire.available()) rdata = Wire.read();
聽 return rdata;
}

//Output raw bytes to terminal Why raw?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.