So I am attempting to build a keyboard FIFO buffer using a 28X1 as an i2c slave to another 28X1. I developed a sort of handshaking protocol to let them exchange data: In the scratchpad ram, 0x00 = keyboard status byte (Empty=0, ready=1), and 0x01 = current character. Here is the code:
For some reason, however, whenever I try to read the first two bytes repeatedly from another chip via i2c, location 0x0 of the slave = 128 initially, and whenever I hit a key the value gets placed into location 0x0 instead of 0x1 like it is supposed to, with none of the status updating being processed at all!
I'm just reading it with the following code:
kbtest:
hi2cin 0,(b0,b1)
sertxd(#b0,",",#b1,cr,lf)
pause 10000
goto kbtest
What is going on with this code?!?!
Code:
'0x0 = status, 1=ready, 0=empty
'0x1 = latest key value
startup:
put 0,0
hi2csetup i2cslave,%11100000
main:
kbin [400,kbtimeout],b0 'grab one character
get 0,b1
if b1=1 then main 'if status=ready, discard character
put 1,b0 'if status <> ready, store character
put 0,1 'update status=ready
pause 400
kbtimeout:
goto main
For some reason, however, whenever I try to read the first two bytes repeatedly from another chip via i2c, location 0x0 of the slave = 128 initially, and whenever I hit a key the value gets placed into location 0x0 instead of 0x1 like it is supposed to, with none of the status updating being processed at all!
I'm just reading it with the following code:
kbtest:
hi2cin 0,(b0,b1)
sertxd(#b0,",",#b1,cr,lf)
pause 10000
goto kbtest
What is going on with this code?!?!