How can I read the first 2 bits from PORTA
(RA0
, RA1
) and then work with them ?
I have a switch connected to each one of them, and I want to output a 1
on RB1
when both RA0
, RA1
are 1
.
I have configured PORTA
as input and PORTB
as output
MOVLW 0xF
MOVWF TRISA,0 ;PORTA IN
And then in a loop, I continuously read PORTA
values and I want to check if the two lowest bits are at 1
. To do so I compare value PORTA
with 0x03
after moving PORTA
to the WREG.
MOVF PORTA, 0, 0 ;W<--PORTA
CPFSLT 0x20, 0
MOVWF PORTB,0 ;PORTB<--W
In address 0x02
I have previously stored the value 0x03
But it doesn't work, I don't know why.
thanks a lot