PDA

View Full Version : Saving numeric data to eeprom from array



joseph Degorio
- 10th December 2007, 04:56
Hello everyone,
Can anyone guide me how to save/write the content of variable mydata[5] which consist of '98765' to the internal eeprom...


Thanks,
joe

mister_e
- 10th December 2007, 18:02
You need to use WRITE statement.

Jerson
- 11th December 2007, 04:50
' originally posted EEdata var byte [5] ' make space for mydata in eeprom
EEdata Data 0 ' This is where the data is written to in eeprom, initial value is 0


Cntr var byte ' counter to index the array

' write the data to the eeprom
for Cntr = 0 to 4
write EEdata+Cntr, mydata[cntr]
next

' done

joseph Degorio
- 11th December 2007, 06:25
Thanks everyone for the responce, here is what I'm trying to do...kindly guide me.

Data @0, 5 ,"29690" 'initially saved to memory

-to check if the code is the same with the data stored in the eeprom, Lookdown() is used for security password.
What i'm trying todo is to change "29690" with this code..
************************************************** *******
' Saving to EEPROM
@ READKEYPAD _myvar
if scroll = 3 then
Serout PortC.1, 6, [$FE,1]
Serout PortC.1, 6, [$FE,$C0]
for countera = 0 to 4
@ READKEYPAD _Key
Serout PortC.1, 6, [$FE,($C0+5),"["]
Serout PortC.1, 6, [$FE,($C0+6+COUNTERA),"*"]
Serout PortC.1, 6, [$FE,($C0+7+COUNTERA),"]"]
code[countera]=key
Write countera+1, code[countera] ; write the digit to EEPROM
next countera
Serout PortC.1, 6, [$FE,1,"Saving..."]
pause 1000
WRITE 0,5
Endif
**************************************
'To check if the new number is saved I used this code...
@ READKEYPAD _Key
if key = 11 then
read 0,code
serout PortC.1, 6, [$FE, 1,#code]
pause 1000
for countera = 0 to 4
read countera+1,code
serout PortC.1, 6, [$FE, $82+countera,#code]
pause 1000
next countera
Endif

it shows that i succeeded overwriting the "29690" using the above code, But when I try to use it for password entry using the Lookdown(), I get Access denied.
Originally the code is from Darrel and Steve.


Thanks,
Joe

mister_e
- 11th December 2007, 16:09
Did you refresh the array which hold the code?

What happen when you remove the power and reconnect it? Is the new code works?

With the whole code, it will be easier so far..

joseph Degorio
- 14th December 2007, 06:18
Hi everyone,
I got the code working as I intended to, thanks for the guide...now I can write and read to the eeprom. I realized that there is a need for convertion to hex.

Thanks to all,
joe