PIC programming which bits are which in TRIS register

93 Views Asked by At

I am trying to understand PIC18 code in a format like TRISB &= 0b11100000. What is the order the individual RB pins appear in? i.e. is this register setting RB0-RB2 as input, or RB5-RB7 as input?

2

There are 2 best solutions below

2
Ali Safari On BEST ANSWER

in the code TRISB &= 0b11100000, the binary value sets the direction of the lowest pins, RB0-RB2, as outputs, and the highest, RB5-RB7, as inputs.

0
Rameau On

After using TRISB &= 0b11100000, RB5-RB7 will keep their state and RB0-RB4 will be cleared - set to outputs.

Usually clearing bits is done with TRISB &= ~(0b00011111) for 'clarity'