piclist 2001\01\19\054842a >
Thread: Reading Outputs as Inputs
www.piclist.com/techref/microchip/ios.htm?key=input
flavicon
face BY : Simon Nield email (remove spam text)



following on from bob's suggestion of detecting the open circuit state too, how about:

; if pin n port x is pulled high  => result = 0xfe, pin is driven high
; if pin n port x is pulled low   => result = 0x00, pin is driven low
; if pin n port x is open circuit => result = 0xff, pin is driven high
; i.e. bit0 set => open circuit, bits7..1 = pin state
bsf    PORTx, n
clrf   result     ; h:00 o:00 l:00
btfsc  PORTx, n
decf   result, f  ; h:ff o:ff l:00

bcf    PORTx, n
decf   result, f  ; h:fe o:fe l:ff
btfss  PORTx, n
incfsz result, f  ; h:fe o:ff l:00
bsf    PORTx, n   ; set pin high to match state


regards,
Simon

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


<802569D9.003B7376.00@buffer1.HQ.quantel>

See also: www.piclist.com/techref/microchip/ios.htm?key=input
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) Reading Outputs as Inputs

month overview.

new search...