what is the range of values it can possible read off PORTB.6? I could swear it was something like [0,255] but I am not sure anymore (would it be only binary?).
Could you clear something up for me then? I thought before that if you picked up, say, PORTB in the chip, you would have some 8 pins associated with it. I thought before that each pin would be able to read 8bit values. From what you are saying, each pin is a bit and all together makes up the 8bit resolution provided by portB. Am I correct?[/quote]
Could you clear something up for me then? I thought before that if you picked up, say, PORTB in the chip, you would have some 8 pins associated with it. I thought before that each pin would be able to read 8bit values. From what you are saying, each pin is a bit and all together makes up the 8bit resolution provided by portB. Am I correct?
If you treat the port as a byte, reading it with 'movf PORTB, w' that transfers the individual 8 bits as a single byte into the w register. Likewise, 'movwf PORTB' transfers the 8 bit value in the w register to PORTB. These both obviously depend on how the port is configured, you can't output to a pin configured as an input, nor can you read a pin configured as an output (at least not to get a sensible reading!).
You can also access individual pins using 'bitwise operators', using 'bsf PORTB, 1' to set bit 1 of PORTB, or 'bcf' to clear it. To test individual bits you use 'btfsc PORTB, 1' or 'btfss PORTB, 1'.