Hi All,
I m using PIC16F676 .I have 6 Pins From port A and 2 Pins from PortC as my input. I want to know how to combine input from these 2 port as 1 8-bit binary input so that i can use the whole data as 1 8 bit data
A simple way to do it is to clear the value in memory and then do btfsc PORTA,x then bsf Variable,n and repeat for other 7 bits. The other way is to shift left/right then AND with a mask and finally OR them together.
A simple way to do it is to clear the value in memory and then do btfsc PORTA,x then bsf Variable,n and repeat for other 7 bits. The other way is to shift left/right then AND with a mask and finally OR them together.
Well, if you are using porta bits 0-5 and portb bits 0-1 then you would read porta and AND it with 0x3f to keep the bottom 6 bits. You would store that in the memory location. Then take portb and shift it left 6 times (rlf) so the bits are in position 6 & 7. Then AND that value with 0xc0 and OR with the memory value.