Read-Modify-Write, just like the chip does it when setting a single bit.
This reads the Port, saves the bits you don't want to change, then adds the new bits and writes it back to the Port.Code:PORTB = (PORTB & %11110000) | MyNibble
If there's any possibilty of bits above 3 being set in the MyNibble variable, you should use this instead ...<br>Code:PORTB = (PORTB & %11110000) | (MyNibble & %00001111)
Bookmarks