issue with debugin, write, read, debug
chz
Posts: 8
i've been trying to follow the manual for quite some time and i am still not understanding how to WRITE a variable after DEBUGIN and then READing it back with a DEBUG to follow. heres what i have followed by my input of 4304
PLEASE HELP! thanks in advance
' {$STAMP BS2} ' {$PBASIC 2.5} counter VAR Word counter = 0 'PAUSE 3000 valin VAR Word(3) valout VAR Word(3) DEBUGIN DEC4 valin WRITE 0, Word valin READ 0, valout(0), valout(1), valout(2) DEBUG DEC1 valout(0), DEC1 valout(1), DEC1 valout(2)
4304861
PLEASE HELP! thanks in advance
Comments
·· Wht aren't you reading the DATA values back in to a WORD variable?· The data is actually stored as two bytes when you use a WORD variable.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
how bout if i wanted to write say 300 at location 0, but i wanted to read exactly starting from 0, 300 back instead of 0300? i want to be able to write to memory 3 characters at a time only using 3 mem spaces, but it seems to take up 4 mem spaces.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
thanks for the help!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Post Edited (Andy Lindsay (Parallax)) : 4/28/2006 8:20:48 PM GMT
One other note.· The DATA directive was given a starting address of 10 in EEPROM.· This prevented the WRITE operations (which went up to address 5) from overwriting the "abcdef".· The DATA directive only writes values to EEPROM once, when the program is downloaded.· After that, the programmer has to make sure not to overwrite them.·
I find it helpful to add empty DATA directives to define the portions of EEPROM that WRITE commands will have access to.· For example:
RwVals DATA @2, (6)
Label· DATA @8, "abcdef"
Since RwVals now starts at address 2, all READ and WRITE commands in the FOR...NEXT loops will have to use RwVals + counter in their Address arguments (instead of just counter).· This means the FOR...NEXT loops can always start from 0.· If you need to write more values, make sure to increase the starting address of the Label DATA directive.
(Modified code attached.)