On Mon, 29 Dec 1997 23:10:59 +0100 Sami Khawam writes: >Hello, >How can I detect, in an open-drain line, >a High signal from a device while the PIC >is outputing a Low signal? This is not a conventional application. Usually every device except one outputs a high signal, which is essentially an open circuit. The device which is currently allowed to send may output a low signal, which all devices on the line interpret as a low. The bus acts as a wired AND gate: the line reads high only if *all* connected devices are outputting high. So the PIC is to detect a Low signal from a device while the PIC is sending a High signal. If you really need to know if all *other* devices are outputting high except one, a possible method is to sense current flow from the bus to the OC pin with an external discrete transistor: +5V----| | Rp Rp *-------PIC Sense In | |/c Bus---*---| NPN | |\e |-R1--*------PIC OC In/Out R1 provides a path to guarantee that OC In reads low when the bus is low. It should be about the same resistance as Rp. If some other device is outputting a low (holding the bus at ground potential) the transistor will never turn on. Sense In will read high. If no other device is outputting a low except the PIC, the transistor turns on, and Sense In will read low. Sense In will read high when the PIC is outputting high in either case. While the PIC is outputting high, the OC In/Out pin can be read to determine the level on the bus. This is a special technique. Nearly all OC busses run with a protocol that avoids the need to do this. This circuit degrades the 'low' voltage the PIC can send to the bus by the Vbe of the transistor, which may cause problems. >Can a pin be read when the TRIS is set to >output? Yes. The value read is always determined by the voltage present at the pin, regardless of whether the pin is set as input or output.