EEPROM help

HAZELEB

Member
Hi
Having a problem reading back from a external eeprom 24lc254, I’m using Keyin to write to an lcd and save in the eeprom and then read them back to the terminal, Which works fine if I use keyvalue to jump to the code to read it back, However I want to remove the keypad, So as the program sits and waits for a keyin I have put an if then statement in front of keyin to jump to the same bit of code, So at turn on I press a button and it lumps to the code, And this is where I have the problem it just sends out yyyyyyyyyy`s instead of the characters I have typed in any help would be appreciated thanks in advance.

Ted.
 

hippy

Ex-Staff (retired)
I think we'll need to see more of your code to tell exactly what the problem is.
 

HAZELEB

Member
Hi Hippy
This is my code thanks for your help.


EEPROM $00,("?9?5312C?A864?'?") ' Function keys
EEPROM $10,("?????Q1???ZSAW2?") ' Main keyboard keys
EEPROM $20,("?CXDE43?? VFTR5?")
EEPROM $30,("?NBHGY6???MJU78?")
EEPROM $40,("?,KIO09??./L;P-?")
EEPROM $50,("??'?[=?????]????")
EEPROM $60,(" MEMORY CLEARED ")
EEPROM $80,(" PRESS ENTER ")
EEPROM $96,(0,0)
EEPROM $b0,("PRESS NUM/LOCK")
#com 1
#picaxe 18x

INIT:

serout 6,n2400,(254,1)
pause 30
serout 6,n2400,(254,2)
pause 30
serout 6,n2400,(254,14)
pause 30
b6 = 127
MAIN:

low 2
high 3
pause 300
low 3
main1:
b6 = b6 +1
main2:

if pin0 = 1 then memory_full
keyin


if keyvalue = $76 then clmem
if keyvalue = $5A then clear
if keyvalue = $58 then memory_full

read keyvalue,b5
pause 50
if b5 = 63 then back
serout 6,n2400,(254,b6,b5)
pause 30

i2cslave %10100000,i2cfast,i2cword
pause 10
low 5
writei2c w4,(b5)


inc w4
inc b13
write $96,b8
write $97,B9

if b13 = 26 then press
if w4 > 1196 then MEMORY_FULL
if b13 = 16 or b13 = 17 or b13 = 18 or b13 = 19 or b13 = 20 or b13 = 21 or b13 = 22 or b13 = 23 or b13 = 24 or b13 = 25 or b13 = 26 then scroll
goto main1

scroll:
inc b6
serout 6,n2400,(254,24)
pause 30
goto main2
clear:
serout 6,n2400,(254,2)
pause 30
serout 6,n2400,(254,1)
pause 30
goto init

back:
dec w4
dec b13
dec b6


serout 6,n2400,(254,16)
pause 30
goto main2



press:
serout 6,n2400,(254,2)
pause 30
serout 6,n2400,(254,1)
pause 30
B13 = 0
b1 = 0
b6 = 192
for b0 = $80 to $95
read b0,b1
serout 6,n2400,(254,b6,b1)
pause 30
b6 = b6
if b6 = 207 then MAIN
inc b6
next b0

clmem:


w4 = 0
B6 = 128
for b0 = $60 to $76
read b0,b1
serout 6,n2400,(254,b6,b1)
pause 30
b6 = b6
if b6 = 142 then MAIN
inc b6
next b0




memory_full:
high 2
w4 = 0
b0 = 0
read_data:
readi2c w4,(b0)
pause 10
inc w4
readi2c w4,(B1)
pause 10
inc w4
readi2c w4,(b2)
pause 10
inc w4
readi2c w4,(b3)
pause 10
inc w4
readi2c w4,(b4)
pause 10
inc w4
sertxd (b0,b1,b2,b3,b4)
readi2c w4,(b0)
pause 10
inc w4
readi2c w4,(b1)
pause 10
inc w4
readi2c w4,(b2)
pause 10
inc w4
readi2c w4,(b3)
pause 10
inc w4
readi2c w4,(b4)
pause 10
inc w4
sertxd (b0,b1,b2,b3,b4)
readi2c w4,(b0)
pause 10
inc w4
readi2c w4,(b1)
pause 10
inc w4
readi2c w4,(b2)
pause 10
inc w4
readi2c w4,(B3)
pause 10
inc w4
readi2c w4,(B4)
pause 10
inc w4
sertxd (b0,b1,b2,b3,b4)
readi2c w4,(B0)
pause 10
inc w4
readi2c w4,(b1)
pause 10
inc w4
readi2c w4,(b2)
pause 10
inc w4
readi2c w4,(b3)
pause 10
inc w4
readi2c w4,(b4)
pause 10
inc w4
sertxd (b0,b1,b2,b3,b4)
readi2c w4,(b0)
pause 10
inc w4
readi2c W4,(b1)
pause 10
inc w4
readi2c w4,(b2)
pause 10
inc w4
readi2c w4,(b3)
pause 10
inc w4
readi2c w4,(b4)
pause 10
inc w4
readi2c w4,(b5)
pause 10
inc w4
sertxd (B0,B1,B2,b3,b4,b5,13,10)
pause 10

read $96,b10
read $97,B11
if w4 = w5 then all_done
goto read_data
all_done:
sertxd (0)
goto CLMEM























































































































 

hippy

Ex-Staff (retired)
I presume "if pin0 = 1 then memory_full" is where you decide whether to read in a new sequence via KEYIN or jump to outputting what was already stored.

If you follow the flow from power-up, by the time it gets to this IF, jumps to memory_full and starts reading from the external Eeprom, you haven't issued an I2CSLAVE command.

When you come to read from I2C Eeprom the PICAXE will not have been configured correctly and there's no guarantee what will be read.

Unless the pauses are all there for some reason you can probably remove those after READI2C. You could also simplify the reading of the I2C Eeprom and the SERTXD so this is done one at a time in a loop rather than as blocks of bytes.
 

HAZELEB

Member
Thanks Hippy the I2CSLAVE command was the problem I will also take your advice on using the loop rather than the blocks of bytes again many thanks.
Ted.

 
Top