There is an error in the code that is masked by your HIGH & LOW commands later on.
TRISB = %11110000 sets port bits 7-4 as INPUTS and port bits 3-0 as OUTPUTS. This is opposite to what you are trying to do.
The HIGH xxxx and LOW xxxx over ride the TRIS statement and force the selected pin to an output. If you later need more code space and use Portb.7 = 1 instead of HIGH PortB.7 to save a few bytes it will all crash.
In the current implementation you do not need the TRISB statement so either fix it or scrap it.
You can reduce code size by using the TRISB statement followed by
PortB.n = 1 or PortB.n = 0
HTH
BrianT
Bookmarks