Shop OBEX P1 Docs P2 Docs Learn Events
Backspace routine for EEPROM writing — Parallax Forums

Backspace routine for EEPROM writing

NewzedNewzed Posts: 2,503
edited 2007-04-01 13:02 in Propeller 1

On my Prop piggyback, I was logging temperature data to the 24LC512 EEPROM. This function was duplicated by one of the Stamps in my network, so after I learned how to write to the EEPROM I changed the program to write strings of any length to the EEPROM. I found that I would invariably make a typo when entering data to be stored, so I created my own little "backspace" routine.

In the Slave I wrote:

PUB recdataB············ ·'receives data for storage
· repeat
··· addrb := readword($EB28)
··· u := serialIn(si,stampBaud,sim#NInv,8)
··· if u == 45··············· ·‘ 45 = the minus sign key
····· ·writeword($EB28, addrb-1)··· ·‘backs up EEPROM one byte
······ recdataB
···
writebyte(addrb, u)
··· waitcnt(wait/50 + cnt)
··· addrb := addrb + 1
··· writeword($EB28, addrb)··· 'stores new addrb in upper EEPROM
··· if u == 13
·· sendstr(string(" Data stored",13,13,10))

In the Master I wrote:

PUB senddataB········ ·‘sends string data to Slave for storage
·· repeat
····· u := key.getkey
····· print(u)
····· if u == 45
········ print($108) ‘backspaces 1 byte to erase 45 – minus sign
········ print($108) ‘backspaces 1 space to clear typo
········ serialOut(so,u,stampBaud,sim#NInv,8)
············· ‘sends backspace···· command to Slave
········ senddataB
·····
serialOut(so,u,stampBaud,sim#NInv,8)
····· waitcnt(wait/5 + cnt)
····· if u == 13
····· print_string(string(13,"End of Write"))
····· waitcnt(wait + cnt)

Works great – I have backspaced as many as 4 bytes and the data logs perfectly in the Slave. When I type the backspace key in the Master, all the " – " signs appear, but as soon as I type the next letter they all disappear and the Master displays clean text.

Sid

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Yesterday is history, tomorrow is a mystery, and today is a gift.

That is why they call it the present.

Don't have VGA?
Newzed@aol.com
·
Sign In or Register to comment.