On Sun, 10 May 1998 17:17:13 +0100 Catch-It writes: > >first the assumption: >In output mode, setting the corresponding bit in the SFR does the >equivalent >of connecting the I/O pin to the supply voltage, correct? >In output mode, clearing the corresponding bit in the SFR does the >equivalent of connecting the I/O pin to the ground rail, correct? True, though there are current limits. I see the ideal logic output as a SPDT switch that moves the output line between Vcc and GND. In a tri-state output , the switch has a third position where the pin is connected to an open circuit (the third state of tri-state). >If this is so I could connect an LED through a diode to the i/o pin >from the >supply voltage, and the state of the diode would be the inverse of the >bit >in the SFR, right? You can connect an LED to the pin with a current limiting resistor to either Vcc or GND (with the LED polarity as appropriate). If the LED/resistor combination is connected to ground, a high on the output pin (or in the SFR) lights the LED. If the LED/resistor combination is connected to Vcc, a low on the pin makes the LED light. > >Now the question: >What is the pin doing in input mode? Is it high impedance or >something? Is >there any electrical difference between the pin being in input mode or >the >pin being in ouput mode with a '0' in the SFR? Exactly... It's "tri-stated" (or disconnected from the output driver) when a TRIS bit is set. Note that the input circuit is ALWAYS connected to the pin, even when TRIS is low. In fact, I think this is why they use the term TRIS instead of Data Direction Register. You can still read a pin when it's the processor itself that is setting the state of the pin. In fact, the slowing of the transitions of voltages on the pins due to loading can cause problems with read-modify-write instructions (such as BSF) if the lines are heavily loaded. > >Also, what does Input/Ouput Clamp Current mean in the specs? > Each pin has a clamp diode to ground and Vcc to limit voltage excursions to that which the chip will tolerate. As long as you are using resistive loads that only connect to +5V and GND, you'll not get any current through the clamp diodes. A favorite example of using the clamp diodes is to put a current limit resistor between the clamped pin and some higher AC voltage. I typically connect a 10K between the INT pin and 12VAC to detect AC line zero crossings (see the Shoebox dimmer at http://www.dovesystems.com). Microchip has an application note where they do this to detect zero cross by running a resistor directly to the 120 VAC line. Have fun with it! Harold _____________________________________________________________________ You don't need to buy Internet access to use free Internet e-mail. Get completely free e-mail from Juno at http://www.juno.com Or call Juno at (800) 654-JUNO [654-5866]