PDA

View Full Version : Reading EEPROM data?



Qacer
- 9th March 2006, 19:41
Hi again all,

I have the following code:




I2CWRITE I2CDAT, I2CLCK,addr,[fmwrt1,fmwrt2,fmwrt3,fmwrt4,fmwrt5], NOGO
Pause 200
I2CREAD I2CDAT, I2CLCK,addr,[fmred1,fmred2,fmred3,fmred4], NOGO
WRITE 0,fmred1
WRITE 1,fmred2
WRITE 2,fmred3
WRITE 3,fmred4



I am trying to read the EEPROM data values, but I can't seem to get it to work. I think it maybe the fact that when I plug the chip back into the programmer, the code is executed again and (maybe?) overwriting the data in the same EEPROM address.

Any tips?

My main objective is to just read the current values from an I2C device and store those values in the EEPROM so I can view it using MPLAB.


Thanks!

Darrel Taylor
- 9th March 2006, 23:01
Maybe you could use another EEPROM location as a Flag, so that it only runs once.

READ 127,temp
IF (temp <> 1) then
I2CWRITE I2CDAT, I2CLCK,addr,[fmwrt1,fmwrt2,fmwrt3,fmwrt4,fmwrt5], NOGO
Pause 200
I2CREAD I2CDAT, I2CLCK,addr,[fmred1,fmred2,fmred3,fmred4], NOGO
WRITE 0,fmred1
WRITE 1,fmred2
WRITE 2,fmred3
WRITE 3,fmred4
temp = 1
WRITE 127, temp
ENDIF

P.S. You might need a Big pause at the beginning, to allow time to remove the power after programming.

Qacer
- 10th March 2006, 17:06
Ahh, thanks, Darrel! :-) This should work.