O.k. let's make it simple
when you define a byte(8 bits) in binary like this
a=%00000011
it set the bit 0 and 1 to 1. It's the same as a=3 in decimal
bitwise operation
working with bits in a byte or ar word sized variable...
a=%00000011
PORTA=%11111100
so if you do a bitwise OR ( or |) operation with PORTA and a
PORTA | a
the result will be %11111111
in your case you don't want to affect the other pins. If you want to set A.0 and A.1 of PORTA
PORTA=PORTA | %00000011
OR
PORTA=PORTA | 3
case you want to clear A.0 and A.1 you must use btwise AND
PORTA=PORTA & &11111100 'in binary
OR
PORTA=PORTA & $FC 'in Hexadecimeal
OR
PORTA=PORTA & 252 ' in decimal
Do you know how logical operation works? If not, the fast way to learn is to run 'calc' in windows. Select the scientic view and Voila... you'll be able to test your bitwise operations. OR see this link
Yeah Ralph... i know
(inside joke here)
you'll find all those bitwise operator at the begining of your PBP manual.
You can also use symbol for that... i prefer use VAR... i'm coming old and i have my old method.
Code:
TRISA=0 'set PORTA as output to all pins
FLTS VAR PORTA.0
RLTS VAR PORTA.1
FLTS=1 ' set PORTA.0 to 1
RLTS=1 ' set PORTA.1 to 1
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks