I have a practice exam question that asks me to read PORTB input logic levels into a single char variable called result. (On a PIC18F252). I had some ideas for this but I haven't got answers to check so I'm not sure whats right. This is what I was thinking at first, but I don't know if calling PORTB in a bitwise OR operation would actually retrieve all the input levels:
void setup(){
TRISB = 0xFF; //Set all portB pins as inputs
}
void main(){
char result;
result |= PORTB; //OR the value of the PORTB register into the result variable
}
Would this be right? And if not can anyone help me find a better way to do it?