Scratchpad and bintoascii in 20x2

Hello,
I am measureing an analogue voltage, and displaying the value in a 4 digit 7-seg LED display. My H/SW is a 20x2 vs. c.0, and PE vs. 5.3.0.
A fairly straightforward task, but on my way, I have encountered a couple of 'strangeties' :
1. bintoascii on a wordvar using bptr (scratchpad, right?) does affect b0.
In essence, this is, what I did:
..
sertxd ("b0 before bintoascii: ",#b0,13,10)
bintoascii w5,@bptrinc, @bptrinc,@bptrinc, @bptrinc,@bptr
sertxd ("b0 after bintoascii: ",#b0,13,10)
..
I do not know if more regs are affected, just realized (after an hr's struggle..) that my flags got corrupted.. (Simulation , however, preserved b0..)

2. Unlike the chip, using the scratchpad mem with the simulator does not seem to work. I ran the following in the simulator and on the chip. No data could be found in the 'Memory'-window when simulating:
....
w5=12345
bintoascii w5,@bptrinc, @bptrinc,@bptrinc, @bptrinc,@bptr
bptr=3
@bptr="%"
bptr=0
sertxd (@bptrinc, @bptrinc,@bptrinc, @bptrinc,@bptr,13,10)
....

(The sertxd here is just for checking, and not used in the actual program, which is displaying w5 in a 4 digit 7-seg LED display)

Isn't there something odd here, or have I misunderstood the use of the scratchpad or anything else?

Where are the "variables" ptr, bptr, and timer3 located?
Thanks ..
 

Technical

Technical Support
Staff member
You're not really understanding the use of the bptr and @bptr

bptr is a real variable. It can contain the number 0-127 on the 20X2.

@bptr is a virtual variable, which points to the memory address currently 'pointed to' by the value in bptr.

So if bptr is 0, @bptr will read or write the value at address 0. This is really the same as a peek or poke at address 0.

However as the lower addesses are also the variable b0, b1 etc, an @bptr write when bptr is 0 will also change b0, as address 0 and b0 are the same.

so
bptr = 0 : @bptr = 255
poke 0, 255
b0 = 255

are all exactly the same.


The same principles apply to the scratchpad, but then you use ptr and @ptr and get/put
 
Last edited:
Thanks a lot! I did know the diff btw ptr and @ptr from my C-experience, but what I did NOT know, was the diff btw ptr and bptr. Knowing that bptr points to b0--> explains everything, I wrongly believed I was using the scratchpad!
 
Top