Go Down

Topic: Writing to External Eeprom From Serial Monitor (Read 770 times) previous topic - next topic

Caleborp

Hey everyone,
I am using a arduino Mega 2560 and am attempting to write some data from the serial monitor to a 24lc256 Eeprom. I cannot tell whether I have written the data correctly, or whether my code to read the data is the problem. I have two separate sketches, one for writing data, and one for reading. When I try to write data, everything performs as expected, but when I try to read the data I get "myyyyyyyyyyyyyyyyyyyyyyyyyyyy" except the y's have two dots on top of them. I tried writing the phrase "Hi, I am an Eeprom" to the 24lc256 so something is obviously going wrong.

For some reason, this thing refuses to let me paste my code, so it is attached. First sketch is for writing, and the second for reading.
Help is greatly appreciated!

-confused hobbyist

el_supremo

In the writing routine you declare writeaddress as a global variable. Then you pass it as an argument into the write routine and inside that routine writeaddress is a different local variable. So, when the write routine increments writeaddress it is incrementing the local copy, not the global one which always stays at zero.
You have the same problem in the read routine as well. Don't pass those addresses as arguments and the code will work.

Pete


Go Up