Datasheet
Chapter 5: Debugging and Datalogging ยท Page 235
Figure 5-4
Memory Map
The highest
EEPROM
address not
occupied by
PBASIC
program code is
$257.
An extra variable is necessary to keep track of which EEPROM byte gets the next record.
This
logIndex variable is used with the WRITE command for saving the records to
EEPROM and with
READ command to retrieve them.
#IF DATALOG_MODE > 0 #THEN
logIndex VAR Word ' Stores EEPROM index
#ENDIF
DATA directives should always be used to set aside EEPROM space that you will be
reading from and writing to. The
DATA directive has to be slightly different depending
on whether the
DATALOG_MODE is 1 or 2. If it's 1, new values will be recorded, and it
helps to make sure there aren't any values from a previous round still being stored.
Especially if you stop the round early, it will be easier to discern after which record you
stopped the match, because the rest will be 0. That's the purpose of the first
LogData
directive. It sets all the EEPROM bytes from $10 to MaxBytes ($150) to 0.
#IF DATALOG_MODE = 1 #THEN
LogData DATA @$10, 0 (MaxBytes) ' EEPROM data recording space
#ENDIF
#IF DATALOG_MODE = 2 #THEN
LogData DATA @$10, (MaxBytes) ' EEPROM playback space
#ENDIF
The LogData DATA directive that is declared when DATALOG_MODE = 2 does not have a
0 before (
MaxBytes). With this change, instead of writing zeros to all those EEPROM
addresses, the program just reserves the space as undefined data. This is important