' READ.BS1 ' This program reads a string of data stored in EEPROM. The EEPROM data is ' downloaded to the BS1 at compile-time and remains there (even with the ' power off) until overwritten. Put ASCII characters into EEPROM, followed ' by 0, which will serve as the end-of-message marker. For programs with ' multiple strings, use the Memory Map window to find the starting character ' address. ' {$STAMP BS1} ' {$PBASIC 1.0} SYMBOL strAddr = B2 SYMBOL char = B3 Msg1: EEPROM ("BS1", 13, "EEPROM Storage!", 0) Main: strAddr = 0 ' set to start of message GOSUB String_Out END String_Out: READ strAddr, char ' read byte from EEPROM strAddr = strAddr + 1 ' point to next character IF char = 0 THEN StrOut_Exit ' if 0, exit routine DEBUG #@char ' otherwise print char GOTO String_Out ' get next character StrOut_Exit: RETURN
NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.
' READ.BS2 ' This program reads a string of data stored in EEPROM. The EEPROM data is ' downloaded to the BS2 at compile-time and remains there (even with the ' power off) until overwritten. Put ASCII characters into EEPROM, followed ' by 0, which will serve as the end-of-message marker. ' {$STAMP BS2} ' {$PBASIC 2.5} strAddr VAR Word char VAR Byte Msg1 DATA "BS2", CR, "EEPROM Storage!", 0 Main: strAddr = Msg ' set to start of message GOSUB String_Out END String_Out: DO READ strAddr, char ' read byte from EEPROM strAddr = strAddr + 1 ' point to next character IF (char = 0) THEN EXIT ' if 0, exit routine DEBUG char ' otherwise print char LOOP RETURN
BASIC Stamp Help Version 2.5.4
Copyright © Parallax Inc.
8/8/2012