Assigning a symbol to BPTR

russbow

Senior Member
Can I assign a symbol to a bptr location ?

As I am running out of variables I would like to change ( for instance )

Symbol MaxTemp= b24 to

MaxTemp = ???? :confused:
 

lbenson

Senior Member
Have you used the system word variables, s_w1 through s_w6 for M2 parts, s_w0 and s_w1 for X2 (and perhaps other "s_w" variables depending on what your program is doing), for instance:

symbol MaxTemp = s_w1

Note that the "s_w" variables can't be used in some commands.
 

russbow

Senior Member
Thanks, yes I'm using the first one listed. All others in my ( out of date ? ) documents say reserved for future use except for time.
I need to free up lots as I had incorporated a prog for the BMP08 module.

I think initial move would be to replace

Code:
 hi2csetup i2cmaster, %11010000, i2cslow, i2cbyte

	 hi2cin 1,(b0,b1,b2,b3,b4,b5,b6)
with a direct read into the upper bptr locations. Guess this is the way to go and I suppose PEEK will be needed. Even using PEEK, surely I need to assign the peek values to a variable anyway
 

hippy

Technical Support
Staff member
If you have used up all byte variables it may be worth taking a look to see if you can restructure things in some other way, such that variables in one part of the code can be used elsewhere.
 

russbow

Senior Member
The problem is that I have married the BMP code from here

http://www.picaxeforum.co.uk/showthread.php?26974-BMP180-Code&highlight=bmp*

to an existing logger routine. Once the BMP code is run I store the pressure and temperature resuts using the WRITE function and recall them later. So far so good, the theory being I can re-use those variables. I think one of the initial declared SYMBOL variable is used in the BMP routine and corrupts the original assignment.

I am getting a strange result in that although the entry values to call a sub routine are correct, the routine is not executed. REM out the BMP part of the program and the whole sequence works fine.
 

russbow

Senior Member
Problem solved.
I was declaring a Symbol Flag1 to b21, a variable that was clearly used in the main routine.
By WRITE 18,0 and then Read 0,flag1 when it is needed the program works fine.

Thanks for your thoughts anyway.

R.
 

hippy

Technical Support
Staff member
I think that BMP code is a fine example of why using raw PICAXE variable names isn't as easy to fathom as using SYMBOL defined variable names.

Not being familiar with that sensor, what the code is doing, means I can't give any immediate help. The starting point might be to work through it, seeing what variables and @bptr addresses are used. Perhaps then converting some of the code to use named variables, seeing what's left, and rationalising that.

There do seem to be a lot of intermediate calculations required as shown in the datasheet but only a few bytes read from the sensor and a few bytes in the results so everything else except that which needs to be kept should be reusable.

If going the whole hog, I would probably start by renaming 'w' variables as 'xw' then symbol defining 'xw' = 'w', renaming 'b' variables as 'xw.msb' or 'xw.lsb' and adding symbols for those. Give 'xw' variables more meaningful names, then sort into order as to which ones are to be kept and which are reusable. Then allocate real 'w' variables as appropriate.
 

russbow

Senior Member
Thanks Hippy. I'm not delving into that code :) , far beyond me.
Having realised it was an earlier symbol assignment that was being corrupted, a quick write / read produced a workaround and all is OK now.
:cool:
 

jims

Senior Member
I think that BMP code is a fine example of why using raw PICAXE variable names isn't as easy to fathom as using SYMBOL defined variable names.

Not being familiar with that sensor, what the code is doing, means I can't give any immediate help. The starting point might be to work through it, seeing what variables and @bptr addresses are used. Perhaps then converting some of the code to use named variables, seeing what's left, and rationalising that.

There do seem to be a lot of intermediate calculations required as shown in the datasheet but only a few bytes read from the sensor and a few bytes in the results so everything else except that which needs to be kept should be reusable.

If going the whole hog, I would probably start by renaming 'w' variables as 'xw' then symbol defining 'xw' = 'w', renaming 'b' variables as 'xw.msb' or 'xw.lsb' and adding symbols for those. Give 'xw' variables more meaningful names, then sort into order as to which ones are to be kept and which are reusable. Then allocate real 'w' variables as appropriate.
Hippy...How do I "sort: the symbols "into order"? Is there a sort command in PE6? Thank you, JimS
 

hippy

Technical Support
Staff member
I was meaning manually sorting, cut and paste or drag and drop moving of lines around.

Once variables have meaningful names ( such as 'p.msw' and 'p.lsw' for real pressure most and least significant words ), those can be moved to the top to the 'keep' section, what's left can go down in the 'temporary' section.

I don't think there's any easily automated way to rationalise things.
 
Top