Hello, At 05:17 PM 5/10/98 +0100, you wrote: >Hi all, > This is feebly easy question, but I have realized that I have got so >far, yet do not understand the basics! Perhaps somebody could check out >these assumptions and questions for me... i've been thinking about it so >much for the past few days I'm not sure why anything works!! > >This is to do with the electrical properties of the i/o pins (told ya it was >basic).. > >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? >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? > Basically, you are correct. The pins actually get "connected" through a MOSFET which is biased fully on, so they basically act as if they are connected via a small resistor (I'm not sure of the value, somewhere in the neighborhood of 30 ohms). I think that the MOSFET also limits the maximum current that the pin can source or sink(even in addition to this virtual resistance). You should not depend upon this limit, anything connected to the pin should have an external current limiting resistor if it might otherwise draw more than 20mA (or whatever the limit is for the pin). >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? > Yes, it is in a high impedance state. It is connected to the gates of a couple of mosfets. So, then, there certainly is a difference between this and the pin being in output "low" state, or "high" state, for that matter. Actually, the output driver consists of a pair of mosfets (one P channel to the ground rail, the other N channel to the supply rail, hence the term CMOS, the C stands for Complementary), and when the pin is in high-impedance state, neither of these fets is turned on. The gates of the fets which read the pin are always connected, so that the pin reads as its actual output state. So, a pin in input mode "looks" electrically like a capacitor of about 10pF or so. This is why if you leave a CMOS input floating, touching it with your finger will often change its state, or any *small* stray charge will change it, because it is a very small capacitance with very little parallel resistance. >Also, what does Input/Ouput Clamp Current mean in the specs? > I think that this is referring to the maximum current that the input protection diodes can handle. That's one thing I forgot to mention above. With the exception of the "open drain" output (pin RA4 on most PICs), every input pin has a diode to the supply rail, and a diode to the ground rail. The purpose of these is to protect the sensitive mosfet gates from voltage above the supply or below ground. This helps prevent static electricity from punching holes in the extreamly thin oxide layer which separates the fet gates from the fet's silicon channel. These diodes are also often used when the pic needs to detect, say, a 10v signal. If a large resistor is used between the input pin and the high voltage signal, it is permissible to allow these diodes to conduct and drop the voltage down from the high voltage to just the supply voltage. >Sorry 'bout this >Catchy.... > No problem at all! Piclisters, please correct what I have wrong. Sean +--------------------------------+ | Sean Breheny | | Amateur Radio Callsign: KA3YXM | | Electrical Engineering Student | +--------------------------------+ Save lives, please look at http://www.all.org Personal page: http://www.people.cornell.edu/pages/shb7 mailto:shb7@cornell.edu Phone(USA): (607) 253-0315