Which value can I expect from PORTBbits.RB7, on this port there is a green led with a resistor connected (see picture). I'm using pic F184550 with mplab ide v8.63 and a C compiler C18 from mplab microchip. Or do I need to write to putty to see this value. thanks
1 Answers
The short answer would be depending on the voltage that is measured on the PORTB7 pin, the answer will be a 0, 1, or both.
The reason for that is because of the way a digital GPIO pin works. To determine whether a given voltage across that pin results in a 0 or a 1, a threshold is set by the chip manufacturer. For the PIC18:
0.8 * Vdd == Digital '1'
0.2 * Vdd == Digital '0'
Where Vdd is the supply voltage
So if Vdd == 3.3V, the voltage across PORTB7 needs to be 2.64V or above to be read as a digital '1'. A voltage of 0 - 0.66V will be read as a digital '0'.
What if the voltage is somewhere in between those two thresholds? Who knows? All you know is that you have two choices: 0 or 1.
Now if you're looking to read the actual voltage level off of PORTB7 then unfortunatley you're out of luck. You'll need to connect that voltage level to an ADC to be able to get that information.