Arrays and hSerPtr

QuIcK

Senior Member
Hey guys.
Been a while.

I was wandering if there is any way I can store an array in the scratch pad and use background serial receive.

basically, I'm making a HUI Timecode readout (midi), and using background serial to receive the midi messages.
The way HUI sends the timecode is actually as a string of 10 characters. Theres a command for complete update (all 10) and a command for updating a single character...
so i need a way for storing the character array to be displayed, whilst letting HSerIn have the run of the scratchpad. is this possible?

If there is no other way than a select case and b0-b9, then thats what i will have to use.
 

QuIcK

Senior Member
oh, so
b0 = 12
bptr = 0
'@bptr is 12
@bptr = 14
'b0 is now 14
That right?

and then there is a further however many bytes above the general variables (b0....) that arent used by the system?
 

nick12ab

Senior Member
From PICAXE Manual 2 under scratchpad: (reworded)

For "indirect access" to the scratchpad, use the ptr pointer and @ptr variable which contains the value of whatever location is pointed to by ptr.

For convenience, @ptrinc and @ptrdec are also provided which first does the same thing as @ptr but then either increments or decrements ptr.

EDIT: It is not @bptr, this is for the general purpose variables (b0, b1...).
 

QuIcK

Senior Member
Im using a 20x2, so there is 128 bytes, of which 55 are used for Variables (bXX), giving me plenty to play with there!
 

nick12ab

Senior Member
Im using a 20x2, so there is 128 bytes, of which 55 are used for Variables (bXX), giving me plenty to play with there!
I think there's some confusion between general purpose variables and the scratchpad. The manual implies 256 bytes of general purpose variables which are addressed with bptr and @bptr and there are 128 bytes of scratchpad which are addressed with ptr and @ptr. Scratchpad <> General Purpose Variables.
 

QuIcK

Senior Member
Yeh, i get that.
the scratchpad is going to be used for background serial. I cannot reliably store an array there without the possibility of it getting wiped by a bunch of incomming serial (midi) messages
what i was looking for is a 2nd register i can use to store a 10-wide array of characters, that isnt in danger of getting wiped.

General Variables (b0, b1... b54) take up the first 55 bytes of this ram, the rest is available to the user. its all addressed using bptr or peek/poke.
Lifted from Manual said:
The peek and poke commands are used to read and write to all 256 bytes of theuser RAM. However the lower 56 bytes (addresses 0 to 55) also correspond to the
variables b0 to b55. Therefore these lower bytes can be accessed in three ways,
via the bxx variable name or via the peek/poke command or via the @bptr
variable. The higher variables can be accessed via the peek/poke commands or
@bptr variable.
Ive tested bptr, general variables and the scratchpad. it works. does exactly what i want it to do!
 

Svejk

Senior Member
@QuIcK: Pretty much that is. The best way to see what it does is to use the simulator. It can be a powerfull tool if used properly or a real bugger if not.
 
Top