s_w0-7 words

rq3

Senior Member
On the 20M2, which bytes are associated with words s_w0 through s_w7? I can't find this anywhere!
 

techElder

Well-known member
Those are system variables. Usually "reserved", but we have been advised that we can use them without repercussions except when there are repercussions. As far as I know, they aren't shown as memory locations anywhere, but you can view them in the memory pane in PE.

I use them extensively in macros and etc. as temporary variables.
 

hippy

Technical Support
Staff member
Page 16 of PICAXE Manual 2 "Basic Commands" -

www.picaxe.com/docs/picaxe_manual2.pdf

For the M2's -

s_w0 - task - current task (during parallel processing)
s_w7 - time - elapsed time

The rest are 'reserved for future use'.

The 's_wX' variables are not split into individual byte variables, are solely word variables.
 

rq3

Senior Member
Page 16 of PICAXE Manual 2 "Basic Commands" -

www.picaxe.com/docs/picaxe_manual2.pdf

For the M2's -

s_w0 - task - current task (during parallel processing)
s_w7 - time - elapsed time

The rest are 'reserved for future use'.

The 's_wX' variables are not split into individual byte variables, are solely word variables.
Tex, many thanks for the suggestion. I was aware of what these are, and I use them in a similar fashion, but I hadn't thought of looking at them in the code explorer!
 

rq3

Senior Member
Page 16 of PICAXE Manual 2 "Basic Commands" -

www.picaxe.com/docs/picaxe_manual2.pdf

For the M2's -

s_w0 - task - current task (during parallel processing)
s_w7 - time - elapsed time

The rest are 'reserved for future use'.

The 's_wX' variables are not split into individual byte variables, are solely word variables.
Thanks, hippy. You answered my question as to whether these are split into byte variables. It's interesting to see that, in PE6 using the code explorer under the system variable, they only show up as 8 bit bytes. I ran a quick simulation, and while the decimal value indeed increments all the way to 65535, the binary 8 bit byte goes blank at 255. The memory map shows nothing.
 
Last edited:

Technical

Technical Support
Staff member
The binary display is purely a cosmetic issue - there is only physical space to show 8x 1/0s. It is still always a word value as shown by the decimal/hex values.
 

AllyCat

Senior Member
Hi,

The 's_wX' variables are not split into individual byte variables, are solely word variables.
Yes, I also find them useful in subroutines, etc.. But beware that, at least in PE5 and/or the simulator, there are some bugs if bytes are involved. I don't recall the full details now, but for example the following behaves differently in the simulator (6.0.9.3) for w5 and s_w5. :(

Code:
[color=Blue]symbol [/color][color=Purple]value [/color][color=DarkCyan]= [/color][color=Purple]s_w5[/color]
[color=Blue]write [/color][color=Navy][b]0[/b][/color][color=Black], [/color][color=Navy][b]12[/b][/color][color=Black],[/color][color=Navy][b]34[/b][/color]
[color=Blue]read [/color][color=Navy][b]0[/b][/color][color=Black], [/color][color=Blue]word [/color][color=Purple]value[/color]
[color=Blue]sertxd([/color][color=Black]#[/color][color=Purple]value[/color][color=Blue])[/color]
Cheers, Alan.
 

techElder

Well-known member
Thanks, Alan. Now I remember that none of the "system variables" work with EEPROM reads or writes.

It always writes / reads the LSB of the word. (Even though it isn't separated into bytes.) Something like that, anyway.
 

hippy

Technical Support
Staff member
There does seem to be an issue with simulation which I will report for investigation but this worked on both a 20M2 and 28X2 I tested ...

Code:
Pause 2000

; Initialise to 0
s_w1 = 0
Write 0, Word s_w1

; Read back that zero
s_w1 = 12345
Read 0, Word s_w1
SerTxd( "Rst", TAB, #s_w1, CR, LF ) ; Shows 0

; Write a value
s_w1 = 54321
Write 0, Word s_w1
SerTxd( "Set", TAB, #s_w1, CR, LF ) ; Shows 54321

; Read what was written
s_w1 = 12345
Read 0, Word s_w1
SerTxd( "Now", TAB, #s_w1, CR, LF ) ; shows 54321
End
 
Top