At 01:26 PM 1/24/03 +0000, you wrote: >You could get bitten by the RMW issue without the extra resistor. The >forward voltage accross the LED would bring the port voltage below a logic >'1' threshold. RA4 has a Schmitt trigger input with a minimum input high >voltage of 0.8Vdd (for a 16F877 anyway). 0.8*5=4volts. With a green LED >(Vf = 2volts), the level on the pin with the LED on would be Vdd-2.0 volts = >3 volts for a 5 volt supply. Bingo! Precisely. As to the value of the resistor- we'd like it to have minimal effect on the brightness of the LED (in this case, the current difference is around 10%, which is hardly noticeable). OTOH, we'd like not to have to worry about leakage currents, but more importantly we need the voltage on RA4 to be reliably pulled above the worst-case ST input voltage that Michael mentions above between writing any "1" to the port and a possible RMW operation on a different pin of the same port. At 20MHz, we have 200ns between instructions. If we assume stray, output and LED capacitance of 50pF, the time constant is 260nsec with 4700+470 ohms, so it's perhaps not low enough for pathological examples like: ... bsf PORTA,4 ; turn LED 1 off bcf PORTA,3 ; turn LED 2 on (oops LED 1 stays ON) ... (you'd have to look at the Q states to see exactly how much time there is here, but it's less than 200nsec). A NOP between would make it (sorta) right. Needless to say, this is the kind of thing I'd not like to see in production, esp. without specific testing, I worry about the resistor being left out or bad solder joint/faulty part, and the unit passing tests only to act strange during some phases of the moon etc. Better to avoid RMW operations entirely on port A, except possibly for RA4, and save the cost and worry of the resistor. I've actually seen a circuit where they hung a 100K pullup to Vdd on RA4 as a "fix", which just gives me the willies. Best regards, Spehro Pefhany --"it's the network..." "The Journey is the reward" speff@interlog.com Info for manufacturers: http://www.trexon.com Embedded software/hardware/analog Info for designers: http://www.speff.com -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.