Problem storing words in high scratchpad locations

dellarb

New Member
Hi All. The below applies for a 28X2 I am working with.

I've done some searching and havent turned anything up on this so just wanted to put it out there.

I am having problems storing word variables in high number scratchpad locations. Using the "put location,word w0" works fine for scratchpad locations like 200 but if i try put 800,word w0 when i retrieve it it comes back garbled.

I've tested in the simulator and live with the following code
================
w0 = 1000
w1 = 2222

put 883,word w0
put 258,word w1

w0 = 0
w1 = 0

get 883, word w0
get 258,word w1
=========

where it should return w0 as 1000 and w1 as 2222 w0 becomes 2280 while w1 is returned normally as 2222.

The wierd thing is if i remove the code do deal with scratchpad 258 w0 comes back normally. This has me extreemly confused and if anyone could help i would appreciate it.
 

hippy

Ex-Staff (retired)
This seems to be a problem related to the code generated by the compiler when using the WORD option which we will investigate. The real firmware and simulator appear to be operating correctly but are not being instructed as required as a result of what the compiler produces.

A temporary workround is to put and get word variables as their component byte variables ...

#Picaxe 28x2

w0 = 1000
w1 = 2222

put 883, b1 : put 884, b0 ' w0
put 258, b3 : put 259, b2 ' w1

w0 = 0
w1 = 0

get 883, b1 : get 884, b0 ' w0
get 258, b3 : get 259, b2 ' w1

Note that "put 883,b1,b0" and "get 883,b1,b0" etc seem to exhibit the same compiler issue so please use the above code formats.
 

Technical

Technical Support
Staff member
The compiler currently doesn't allow the address to be a constant higher than 255 when working with the WORD keyword.

This is a legacy bug as all previous chips did not have scratchpad addresses available above 255! We will fix the compiler for the next release.

There are three workarounds:

1) copy the address into a word variable and use the variable within the command rather than a constant. You can the use WORD
2) only use scratchpad addresses under 255
3) output each byte separately without the WORD keyword as hippy explains above
 

hippy

Ex-Staff (retired)
1) copy the address into a word variable and use the variable within the command rather than a constant.
This would seem to be the most appropriate workround for addresses 256 and above if there is a free word variable as it is the easiest change to implement a workround and to revert back when the next compiler is released if desired.

If w27 were not used ...

PUT 883, WORD w0

Would become ...

w27 = 883 : PUT w27, WORD w0
 

dellarb

New Member
Thanks for the responses. Didn't seem to get any email notifications of my thread. Oh well.

I had been working around by sending the bytes separatley as described by hippy. Thanks for confirming that is a 100% valid soloution for now.

Its also good to hear I'm not crazy and that it's something that will eventually be addressed in the compiler.
 
Top