Can't WRITE into internal EEPROM with 40X2 ???

franfee

New Member
Can anybody tell me why my short program don't really WRITE and READ the internal EEPROM when I try it simple. I try a lot of example found on Picaxe documentation, but none of them can make my data restored after having remove the power on the 40X2 . Whit DEBUG activated, I can see my results WRITEN in the normal RAM memory. I worked since 3 days on this bug, I realy need. Thank you
 

Attachments

cpedw

Senior Member
Your program uses SERTXD which sends output by the programming output to the PC. I think you want to use SEROUT to send data to the LCD.
 

inglewoodpete

Senior Member
Welcome to the PICAXE forum. You have come the right place for help!

Your LCD initialisation subroutine is sending its data to the PICAXE terminal in the programming editor (SerTxd command)
After reading the EEPROM, you are logging the data to the PICAXE terminal in the programming editor (SerTxd command)

You need to change all of the SerTxd lines to: serout LCD1_1602, T2400_8, (...….
 

franfee

New Member
Sorry but I tried all what you proposed to me and nothing change. Would you please give me a simple small example code that you verifiied working on the 40X2, to write and read some bytes in the EEPROM. Don't mind with the serial LCD that work very well.
 

geoff07

Senior Member
Run this twice, first with the commented lines included, and the second with them commented out. The first run will load the eeprom and then report. The second time will show you what is in the eeprom. The trick is the #no_data statement.
 

Attachments

lbenson

Senior Member
Code:
#picaxe 40x2

for b0=0 to 10
  write b0,b0
next b0
for b0=0 to 10
  read b0,b1
  sertxd(#b1)
next b0
sertxd(cr,lf)
23879
 

darb1972

Senior Member
Hello lbenson

Although this isn't my thread, thank you for the code snippet. Great example. I am always trying to fully understand code rather than just "accept" it and move on. I am wondering if I can trouble you with some questions regarding the code? Rather than parse the code, seeing it is small and I would like to add some comments/questions, I thought it would be ok to paste as normal.

Code:
#picaxe 40x2

for b0=0 to 10
  write b0,b0 'Correct me if I am wrong, but unless we are overwriting b0, I gather this is "write the RAM contents of b0 in the EEPROM location of b0" Correct??? Also, once the for/next loop is complete, where does the PICaxe track the increment so on the next loop it doesn't write the contents of b0 (RAM) into b0 (EEPROM) again??? I gather the same incrementation method applies to the read command below.
next b0
for b0=0 to 10
  read b0,b1
  sertxd(#b1)
next b0
sertxd(cr,lf)
Thankyou for your time.
 

lbenson

Senior Member
write b0,b0 ' writes the value in b0 to the location in EEPROM with the address in b0 (but note that the first b0 is the address and the second is the value to be written)

Not the "RAM contents of b0" (in normal terminology), but the value of b0 to the address in EEPROM corresponding to that value, so that when b0 is 0, zero gets written to EEPROM address 0, then 1 gets written to EEPROM address 1, 2 gets written to EEPROM address 2, etc. through value and address 10.

Then the second loop reads the values at EEPROM addresses 0-10 sequentially into b1, and prints that value with sertxd.

The second loop has no WRITE command in it, so it doesn't alter the contents of the EEPROM--it just reads the stored values and prints them.

b0 technically +is+ RAM (that is, volatile memory whose contents will be lost upon power-off), but we would generally think of it as a variable. That variable is at RAM address 0, so "BPTR=0: SERTXD(@BPTR)" would print the value of b0, just as SERTXD(b0) would.

I'm not sure that I answered all of your question--please ask again for additional clarification.

Note that geoff07's caveat holds--if you reprogram the chip and don't include the directive, "#no_data", everything that you have previously written to EEPROM will be zeroed out. If you include "#no_data", the contents of EEPROM will be preserved.
 
Last edited:

darb1972

Senior Member
Hello lbenson

Sorry for the delay in responding. I have heavy work commitments. Thank you for your extremely prompt response and detailed explanation. I now have a much better understanding of the process. The screenshots are most helpful.

Thank you again.
 
Top