One way to accomplish this is this way.
This will copy the upper 4 bits of the value of PORTB into a new byte variable in the lower 4 bit positions and will copy the lower 4 bits of the value of PORTB into another byte variable in the lower 4 bit positions.
Code:myPortB var byte HighNib var byte LowNib var byte myPortB = PortB HighNib = myPortB >> 4 'Right shift myPortB 4 bits, (moves bits 7:4 to bits 3:0 and then set bits 7:4 to 0) LowNib = myPortB & %00001111 'Mask off bits 7:4 to 0, Only get bits 3:0 So if PortB = %10010110 '$96 Then HighNib = %00001001 '$09 LowNib = %00000110 '$06




Bookmarks