variable resetting when changing slot

kevrus

New Member
According to the manual...
"To run the second program (after downloading with a #slot 1 directive) use the
command ‘run 1’. This command stops the current program and starts the second
program running immediately. Variables and pin conditions are not reset, so can
be shared between the programs."

Using a 40x2, and incrementing the timer variable, jumping to slot 1 resets this. Does this mean that the above statement only applies to general variables, and that system variables are reset, or is there an fault?

I can work around this in my program, but was curious

test code

Code:
                          #picaxe 40x2
		       #slot 0
	
	sertxd ("timer = ",#timer,lf)
	pause 500	
	
	do
	 inc timer
	 sertxd ("timer = ",#timer,lf)
	 pause 500
	   if timer=>10 then
	    run 1
	   end if
	loop

Code:
                          #picaxe 40x2
		              #slot 1

	
	sertxd ("timer = ",#timer,lf)    'this should still be '10'
	pause 1000
	timer=0     'this should be needed to reset the timer, but isnt	
	run 0
 

BeanieBots

Moderator
I've been playing with slots, 'timer' and 'timer3' on a 40X2 myself recently.

I can confirm your observations.
General purpose (b's & w's) do NOT reset but timer variables DO reset.
Also, if you are using timer/3 as timers, you need to re-issue the settimer/tmr3setup commands again.
 

Technical

Technical Support
Staff member
Hardware 'silicon' features e.g. timers, pwmout etc. are not transferred from program slot to program slot. Therefore they do need reconfiguring in each slot if you want them to continue.
 

kevrus

New Member
Thanks BB & Technical.
Not sure if this has cropped up before so it could just be me being dumb...so, would it be worth editing the manual to state that only 'general variables' are carried over?
 
Top