scratchpad use with slots

geoff07

Senior Member
I'm trying to load a lot of data into the scratchpad. Currently I do that from a separate eeprom, but would like to avoid the complication of the eeprom. As there is much unused space in slots in the 28X2 I am using, I'm wondering if I can load the scratchpad from one slot using PUT, and access it from another. This way I don't need to accommodate the PUT statements in the main program slot, which otherwise busts the memory limit. I can't find an explanation in the manual regarding the scratchpad, so am wondering if someone that uses slots can advise:

Is there a single shared scratchpad or does each slot have its own?
 

edmunds

Senior Member
I'm trying to load a lot of data into the scratchpad. Currently I do that from a separate eeprom, but would like to avoid the complication of the eeprom. As there is much unused space in slots in the 28X2 I am using, I'm wondering if I can load the scratchpad from one slot using PUT, and access it from another. This way I don't need to accommodate the PUT statements in the main program slot, which otherwise busts the memory limit. I can't find an explanation in the manual regarding the scratchpad, so am wondering if someone that uses slots can advise:

Is there a single shared scratchpad or does each slot have its own?
Page 202 in the manual#2. Point #3 in the bottom of the page. "Outputs and variables/scratchpad are not reset". Seems to suggest the scratchpad is shared between the slots.

Edmunds
 

tarzan

Senior Member
If you load the scratchpad from slot0 and run your main program from slot1 then on reset your data will reload to the scratchpad again.
 

geoff07

Senior Member
Page 202 in the manual#2. Point #3 in the bottom of the page. "Outputs and variables/scratchpad are not reset"
Interestingly, the online version doesn't mention the scratchpad, nor does the current download version, 7.9.1, where there is no point 3! Some clarification needed perhaps?
 

geoff07

Senior Member
Hmm. The bit I read says this:
Variables and pin conditions are not reset, so can be shared between the programs. However all other system functions, such as the gosub/return stack, are reset when the second program starts.
I would not have called a 1kB memory block a variable, hence my question. It isn't all that helpful to have it restated slightly differently on another page. When I look something up in a reference book I don't expect to have to search in case there is more than one version of the answer! RevEd documentation is in general pretty good for all levels of user, but there are some areas where it could be tightened up, especially the online version which would only ever be used for quick reference.
 

tarzan

Senior Member
http://www.picaxe.com/BASIC-Commands/Advanced-PICAXE-Configuration/run/

When in program 1 you can also use 'run 0' to restart the first program. If you wish to also reset the variables you must use a 'reset' command instead to restart program 0. This is equivalent to 'run 0' + variable reset.
Note that 'run 0' is not the same as the 'reset' command, as the reset command will also reset all variables and convert all pins back to inputs.
http://www.picaxe.com/BASIC-Commands/Program-Flow-Control/reset/

The program is reset to the first line and all variables, stacks etc are reset.
 

hippy

Technical Support
Staff member
And the easiest way to get a definitive answer is to try it ...

Code:
#Picaxe 28X2
#Terminal 9600
#Slot 0
Get 0, b0
SerTxd( "In Slot 0 : Scratchpad(0)=", #b0, CR, LF )
Pause 1000
b0 = b0 + 1
Put 0, b0
Run 1
Code:
#Picaxe 28X2
#Terminal 9600
#Slot 1
Get 0, b0
SerTxd( "In Slot 1 : Scratchpad(0)=", #b0, CR, LF )
Pause 1000
b0 = b0 + 1
Put 0, b0
Run 0
The scratchpad is not cleared when RUN passes control to another slot ...

Code:
In Slot 0 : Scratchpad(0)=0
In Slot 1 : Scratchpad(0)=1
In Slot 0 : Scratchpad(0)=2
In Slot 1 : Scratchpad(0)=3
etc
 

srnet

Senior Member
And the easiest way to get a definitive answer is to try it ...
Yes, that is one way.

Programs I have written make extensive use of the scratchpad, GPS background receive and a compiled transmit payload in one slot, then passed across to another slot for actual transmission, it works and very reliably too.

The run command in the manual does need to have an ammount of detail to it, so you need to read it all even if the detail does go over one 'page'.
 
Last edited:
Top