> I am new to PICs and would appreciate some help. My question concerns the > use of resistors. What is a "pull-up" resistor for, why and when do you > need it? I see them used sometimes and not other times. Can you connect an > I/O pin directly to 5 volts and read a logic high or is a resistor of some > kind needed. Can you connect an I/O pin directly to another I/O pin or to a > pin from other TTL chips, transistor etc.? Is there some rule of thumb that > I don't know about? I know my ignorance is bare naked here, but bear with me. A digital input pin on may be thought of as having small capacitors to +5 and to ground, and (usually) large resistors in series to both. Generally the capacitor to ground is larger than the one to +5 (though both are small); depending upon the chip, the implicit resistors to +5 or ground may be very large and they may or may not be sufficiently unbalanced that the input swings consistently to +5 or ground. Whenever possible, all inputs should be at a voltage potential of less than 1v or more than 4v. While some chips (such as the 8x51) have inputs with sufficiently small resistors to +5 that the inputs will go to +5 without any assistance, the inputs to many CMOS chips have sufficiently large resistance that they may tend to float around due to nearby signals and such; it is not uncommon for the data seen on a floating input to change when someone's hand or a piece of measuring equipment is placed _near_ it. This is very much an observable phenomenon with PICS. Given that it's necessary to ensure that all inputs are pulled "somewhere", the question then arises how this may best be accomplished. There are a number of common methods, each with pros and cons: [1] Ignore the problem Generally, on a PIC, you can get away with this. If you read the inputs in question, the value read will do whatever the PIC--not you--feels like but there aren't likely to be any major problems if you do this on the bench. Since power consumption and reliability may be adversely affected by floating inputs, however, this technique really isn't recom- mended, at least not compared with #2 [2] Set unused pins to outputs This approach has the advantage that no extra hardware is required and it may usually be easily accomplished. Although the extra pins will be floating whenever the device is in reset, this will probably not be a concern in most applications. [3] Strap unused pins to "hard" +5 or ground (no resistors) This approach requires no extra hardware vs #2 though it may require extra layout work; if either +5 or ground is acceptable one or the other should usually be available near the pin. The primary disadvan- tages to this method are: (a) If the "unused" pin gets set to be an output, current consumption may go "through the roof" (30+ mA/pin) and the chip may be destroyed if this condition persists for very long; (b) If the unused pin is needed for something else, there may be no convenient way to "override" the strap; certainly no way to do so as a temporary measure. If you use this approach on a four-layer board, it may be a good idea to pop a +5 via near the pin and run a short trace to the pin itself; otherwise, removing the VDD connection will be a real pain. [4] Strap unused pins together, and pull them all up with approx. 4.7K This approach is used frequently; it requires only one extra part vs #'s 1-3, is more effective than #1-#2, and may be safer than #3. In particular, shorting one of the unused pins to ground briefly will not kill power for the whole board and there is less risk of undue power consumption if the ports get set to outputs (if two or more pins get set to conflicting outputs, power consumption will be very bad and the device could be damaged, but since the device's source and sink transistors would be in series, the power consumption would not be as bad as in #3. [5] Pull up unused pins individually with 4.7K or similar resistors This approach is the nicest approach if the need for resistors is not a problem (e.g. if you already have unused resistors in resistor-SIPs). In many cases, if a design change or a piece of test software requires a formerly-unused pin to be used as an input, the pin may safely be tied to whatever is supposed to feed it without any other design or board changes. Personally, I tend to use #1 more than I should (esp. with the RTCC pin), but usually try to use #2. The other techniques may be useful with other chips, however.