View Single Post
  #45   Spotlight this post!  
Unread 21-02-2003, 20:09
dave_l dave_l is offline
Registered User
#1038
 
Join Date: Feb 2003
Location: Lakota East HS
Posts: 10
dave_l is an unknown quantity at this point
Quote:
Ok.. correct me if I'm wrong (which of course I probably am, so have at it.. ), but isn't it true that the program can only access the EEPROM in the current program slot?
You are correct. But if you declare the same variables in the same order in each program, then their values are available when you swap slots. So what I read in from eeprom in one slot gets processed by the program in the other slot. Simplified structure:

slot 0
declare variables
do init stuff
loop waiting for start
if auton=1 or learn=1 then
run auto 'variable with auton prog no.
else
run 1
endif

slot 1
declare (same) variables
begin: if auton=0 and learn=0 then serin ...
process input
serout ...
if auton=1 or learn=1 then run auto
goto begin

slot 3 thru 7 (auton progs)
declare (same) variable
serin ...
if learn=0 or auton=1 then
read ...
else
write ...
endif
run 1

(and I've still got 8 bytes of ram available)