Variable B0 using bits

100317

New Member
Hi all,

after 3 hours, searching picaxe manuals and in the Forum but i'm to stupid to find how to use bits from a variable (b0).
I found a BS2 Program on Internet and I want to modify it for a 08M.

There is a definition:

showPeak VAR Bit ' bit to indicate to show peak

and Code:

showPeak = showPeak + 1 ' alternate between 0 and 1

if showPeak then doLedsWithPeak
OUTH = leds
GOTO shiftValue

Is there a workaround?

many Thank's
Hans
 

Taniwha

Senior Member
like this?

Simply bit 0, bit1 etc.

I tried a very simple:
Main:
bit0 = b0 + 1
goto main

In the PE and watched it cycle between 0 & 1 endlessly.

Remember though that Word0 (w0) is made up of Byte0 + Byte1 (b0 + b1) which in turn is made up of Bits 0 to 15 so its important not to overwrite the bits later in the program.
 
Last edited:

hippy

Technical Support
Staff member
You have 16 bit variables on the 08M; bit0 through bit15 ( 32 bit variables on X2 and M2 ). Simply define the variable as one of those bits -

Symbol showPeak = bit0

If using 'bit0' through 'bit7' don't use 'b0' nor 'w0' at the same time
If using 'bit8' through 'bit15' don't use 'b1' nor 'w0' at the same time
If using 'bit16' through 'bit23' don't use 'b2' nor 'w1' at the same time
If using 'bit24' through 'bit31' don't use 'b3' nor 'w1' at the same time

... unless you know what you are doing and have taken multiple uses of those variables into accout .
 
Top