Unexpected results writing to eeprom using system variable

eddydde

Member
PICAXE 20X2

If I use a normal/standard word variable e.g. W11 and write a value e.g. 430 to the eeprom, shut my project down, boot up and then read the variable it returns 430. No problems there.

(write eewatts, word, watts)
(read eewatts, word, watts)

If I then use a system variable e.g. s_w1 write the value 430 to the eeprom, shut my project down, boot up and then read the variable it returns the value 174!

430 - 256 = 174

Would appreciate knowing why when using a system variabe it appears to only write or read byte values.

Eddydde
 

Texy

Senior Member
Have you tried one of the system variables that are NOT 'reserved for future use' ?

i.e. s_w3
Texy
 

hippy

Ex-Staff (retired)
A WRITE WORD and READ WORD command actually become two WRITE and READ commands on byte variables. The 's_w0' etc variables don't however consist of two separate byte variables and this is the root issue.

We will investigate the compiler behaviour but the workround is to move the 's_w' variables into a 'w' variable etc ...

w0 = s_w1
Write ADR, WORD w0

Read ADR, WORD w0
s_w1 = w0
 

westaust55

Moderator
This past post by hippy, (albeit for put and get as opposed to write and read) may provide a clue:

This is a limitation of the special word variables. "Put 0, Word w0" actually generates code for two byte puts -

Put 0, b0
Put 1, b1

There's no s_b0 or s_b1 components of s_w0 so the code cannot be generated. The work around is to move the 's_w' variables into a normal 'w' variable then PUT, and in reverse for GET ...

w7 = s_w1
Put 0, Word w7

Get 0, Word w7
s_w1 = w7
 

SAborn

Senior Member
I have worked with Eddydde in the backround to this problem prior to his post here, the chip used is a 20x2.
Originally the system variable S_W0 was used with the same result then changed to system variable S_W1 ( a not reserved variable) and still the problem existed, through frustration it was suggested to swap the system variable to a standard working variable(w11), which solved the problem.
Either of us did not understand why, and hence the question asked here.

I gather form Hippys comment it might well be a compiler error and not a simple over look of the system variable use.
 

hippy

Ex-Staff (retired)
I gather form Hippys comment it might well be a compiler error and not a simple over look of the system variable use.
The compilers should either generate code to correctly implement the command or report that what is asked for cannot be done. We will investigate the s_w variable issue and please accept our apologies for that one slipping through the net.
 

inglewoodpete

Senior Member
Looks like hippy got in by the proverbial microsecond with the same basis as I had identified
Don't dispair WA55 - you were probably first;). Don't forget, there's an extra half second of latency between us in the antipodes and the forum server in the UK!!
 

SAborn

Senior Member
Hippy,

S#!% happens and no system is perfect, so the simple fact a error has slipped throught is a minor point, its just a matter of knowing what was thought to be correct syntax was correct, other than a compiler error problem.
In reality if these faults are never reported then how are you guys to ever know to source a problem fix.

It has resulted in many hours and trials to solve the problem, but thats programming for you.

Thanks for the response.
 
Top