Ian Chapman wrote: > > It seemed so simple. I wanted a yellow LED in my PIC16C84 design, so I > connected it via a 3K3 resistor between RA4 and Vdd. So far so good. > > Then I noticed something odd. With the PIC spending most of its time in > sleep mode, its quiescent supply current (with the LED off) varied from > 30uA to 90uA in sympathy with the ambient light level - disconnection of > the LED removed this variation. A voltmeter (>1M impedance) showed RA4 > to sit at +3.6V relative to Vss when its open-drain output was inactive. > > It seems as if the photocurrent injected by the LED is entering RA4 and > affecting the operation of the PIC (maybe via the Schmitt input buffer). > > Several questions spring to mind: > > 1. What is causing the supply current variations? > 2. Is there any risk of misoperation of the PIC in this configuration? > 3. Would a non open-drain port pin be a better choice to drive an LED? > > Any thoughts? > > - Ian Chapman Ian, the inputs of CMOS circuits like the PIC don't like intermediate input levels, because then you partially enable both of the input amplifier transistors, making a weak rail-to-rail connection. The more you come to the center voltage (2.5V) the more current flows. The PIC datasheets show the input stage of the port pins, and - as I think - also the current consumption under various conditions. If you would use a non open collector output, this effect should not happen, because you short-circuit the LED (plus-rail * LED * port-pin at Vdd). Wolfram -- +-----------------------------------------------+ ! Wolfram Liebchen, liebchen@ipserv.ffo.fgan.de ! ! Forschungsinstitut fuer Optik ! +-----------------------------------------------+