What you're probably seeing is the read-modify-write anomally.
When the PIC first initializes, all pins are set to inputs by default.
Then using the PBP HIGH & LOW commands in consecutive order
like this;
HIGH PORTB.5
HIGH PORTB.4
HIGH PORTB.1
HIGH PORTB.2
This generates code that first writes a 1 to the port latch, then
flips the TRIS bit for the pin to 0 to making the pin an output.
However, the remaining pins are still configured as inputs until you
land on the next HIGH statement for the next pin.
This meets the conditions for the read read-modify-write bug with
pins configured as inputs & outputs on the same port when using
read-modify-write instructions like BCF & BSF on a port.
The simple fix is to setup all output port latches & TRIS registers in
the initialization/startup section of your code.
Bookmarks