2

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 Answers 2

1

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'

Sign up to request clarification or add additional context in comments.

Comments

0

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.

2 Comments

Actually, it doesn't touch RB5-RB7, it leaves them as they are. Because it's a &=, not a = operation.
Indeed, it doesn't change the states of ` RB5-RB7; it only clears bits RB0 to RB4 to make them outputs while leaving RB5-RB7` in their current states.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.