PDA

View Full Version : Problem with bit array



Dick M
- 12th May 2005, 10:45
I don't seem to be able to get the bit array to work. I'm using PicBasic Pro Compiler 2.44 and the p16F648A

I declare the var " flags var bit[8]" and it assembles ok but when I try and use it "flags[2] = 1" the bit does not get set. Am i doing something wrong or is there a problem with the bit array in this version.

Bruce
- 12th May 2005, 15:45
Flags is the name of an internal PBP variable. Try changing the name to
something else. It should work fine then.

Dick M
- 12th May 2005, 16:49
I just picked variable name flags when i wrote the post the variable name that I was using was "ChShmr1"
Neighter "flag" or "flags" are listed as Reserved Words if they are they Reserved Words then shouldn't they be added to the list.

Bruce
- 12th May 2005, 17:03
Actually there are several other variable names that should be included
in the PBP reserved words list.

For example;

R0
R1
R2
R2
FLAGS
GOP
RM1, and more

Look in the PBPPIC14.RAM or PBPPIC18.RAM files. Not sure why these
aren't in the reserved words list..!

Using R0, flags, etc with version 2.46 returns an error at compile time
with "Redefinition of VAR".

Not sure why you wouldn't get the same error with v2.44?

With v2.46 this works;


X VAR BYTE
Y VAR BYTE
BITS VAR BIT[8]

Main:
CLEAR
FOR X = 0 to 7
BITS[X] = 1
Y.0[X] = BITS[X] ' Y.bit.X = BITS.bit.X
NEXT X
GOTO Main