PDA

View Full Version : Testing PortB pin



jrt4fun
- 22nd July 2005, 23:03
Hi there,

I'm struggling a bit with testing the status of PortB pin of a Pic16F876A.
I want to be able to read the state of one of the pins of PORTB based upon a variable.
-----------------------------------
DEFINE LOADER_USED 1
DEFINE OSC 10

Green var PORTA.0 ' Led 2
Data_1 var byte

ADCON1=$07
TRISB=%00000000

Init:
high green
pause 2000
low green

data_1 = 5

test:
if PortB.0(data_1) = 0 then
--> LCD should show "Low"
else
--> LCD should show "high
endif
pause 2000
goto test
------------------------------
When I use 'Data_1' as a variable with PortB it doesn't seem to work.
Is there a solution or workaround for this?
Data_1 can be from 0 to 7.

Thanks

Bruce
- 22nd July 2005, 23:39
TRISB = %00000000 sets portb as outputs. Try TRISB = $FF and see how it
responds.

jrt4fun
- 2nd August 2005, 07:08
Bruce,

Thanks got it sorted out.
Appologies for the late reply