Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
That's because you should use AND to clear, or mask, the upper nibble - not the lower nibble. Like this:Hi I need to mask the upper nibble & must not do any harm to the lower nibble.
But this code works but corrupting lower nibble.
Code:movf Data,W andlw b'11110000' movwf PORTB,F
andlw b'00001111'
Do you wish to transfer the upper nibble of Data to the upper nibble of PORTB without disturbing the lower nibble in either?
Then first move Data to a temp variable or W and mask the lower nibble. Then mask the upper nibble of PORTB (maybe move it to a temporary variable first). Then OR them together.Exactly this is what I need to do.
Then first move Data to a temp variable or W and mask the lower nibble. Then mask the upper nibble of PORTB (maybe move it to a temporary variable first). Then OR them together.
Maybe there's a simpler way?
movf Data,W
andlw b'00001111'
???? ????
iorwf PORTB,F
Hmm... Is that right? Just quickly banged it out. Can't test it quickly.Code:movf Data,W andlw b'11110000' movwf temp1 movf PORTB,w andlw b'00001111' iorwf temp1,w movwf PORTB