At the bottom find the majority of my (and Jan-Erik's) previous
postings on this matter, for context.
As promised, I did a few experiments with a half-built
micropower board. All that's on it right now is a PIC18F2320,
a micropower LDO regulator (TPS77001), necessary bypass
capactiors for other ICs yet to be populated, and a few other
passives which are not connected to anything yet.
In its "natural" state, i.e., as it is intended to operate, it pulls
(per my meter; I don't know how good the accuracy really is)
25 uA. This is with PORTB all made into outputs and held
low. With PORTB all as outputs and held high, the current
draw is 825 uA. The only connection to any of these pins is
between RC7 and RB1, but RC7 is configured as an input,
so there SHOULD be no conflict.
With PORTB as inputs, and the internal pullups enabled,
the current draw is, you guessed it, 825 uA. That value
doesn't change with respect to whether LATB is all high
or all low.
The datasheet tells me that at 5V, I should expect Ipu to
be not more than 400 uA. Strange that it should be 800.
Perhaps it's due to the RC.7->RB.1 connection, but I
don't see why, since the datasheet also tells me that
input leakage current is < 1uA.
> > > > Not as I understood it. As I understand it, the act of
> > > > flipping the
> > > > NOT_RBPU bit is to activate a circuit which connects a
> > > > weak resistor
> > > > between each pin of PORTB and the positive supply rail. At
> > > > that point, the current the device is drawing goes up by ~200 uA.
> > >
> > > And where should the current go if the pin is unconnected (or held
> > > high) ?
> >
> > The same place current goes if you tie any other pin high through
> > an external pullup- through the logic.
>
> Yes, **IF** that pin is an OUTPUT so it can source
> or sink any current !
>
> But, for the weak pull-up to be enabled *at all*,
> the PIC pin must be an input, so there is noware for
> the current to go, is there ?
>
> > There just isn't any current through the external pin.
>
> And noware else either, AFAIK.
>
> Jan-Erik.
> With PORTB as inputs, and the internal pullups enabled,
> the current draw is, you guessed it, 825 uA.
What about if the wpu's are disabled ?
> The datasheet tells me that at 5V, I should expect Ipu to
> be not more than 400 uA.
I read that value (Ipu) to be *per* pin. If a pin with
spu enabled is tied to Vss (gnd), you will have aprox 400uA
(= Ipu) floating through the wpu, out from the pin to gnd.
And with WPU enabled and half the bits high and half low?
How about running a ripple counter on the bits so that
they cycle through all high to all low over 10 seconds (so
your meter can measure the changing current)?
If I understand correctly, with WPU enabled, and the port
bits high you're getting 825uA instead of the expected
25uA?
> Mike Hord wrote :
>
>
>>With PORTB as inputs, and the internal pullups enabled,
>>the current draw is, you guessed it, 825 uA.
>
>
> What about if the wpu's are disabled ?
>
>
>>The datasheet tells me that at 5V, I should expect Ipu to
>>be not more than 400 uA.
>
>
> I read that value (Ipu) to be *per* pin. If a pin with
> spu enabled is tied to Vss (gnd), you will have aprox 400uA
> (= Ipu) floating through the wpu, out from the pin to gnd.
>
> Jan-Erik.
>
>
>
> > With PORTB as inputs, and the internal pullups enabled,
> > the current draw is, you guessed it, 825 uA.
>
> What about if the wpu's are disabled ?
I didn't check; in my experience, leaving an input floating is
an invitation to ridiculously random current draws. As
*originally* programmed (i.e., with some of the PORTB pins
set as inputs, but with the ICs and pullups that are normally
supposed to keep them from floating not installed) current
draw was ~1.5mA. And that's with only 3 pins as inputs
and floating!
> > The datasheet tells me that at 5V, I should expect Ipu to
> > be not more than 400 uA.
>
> I read that value (Ipu) to be *per* pin. If a pin with
> spu enabled is tied to Vss (gnd), you will have aprox 400uA
> (= Ipu) floating through the wpu, out from the pin to gnd.
Interesting interpretation. The pullup's value would then be
~12.5k. It's a very logical interpretation as well.
It doesn't really explain why these *unconnected* pins seem
to be adding ~800 uA to the sleeping current of this board.
I must be doing something wrong...<fiddling with code>.
I think I figured it out. I think having the pins high was
causing the PIC to enter an interrupt handler and get
stuck rather than going to sleep. Once I disabled GIE,
the current with WPU's on dropped to 30uA. The added
few uA is because I've been adding stuff to the board
since I ran the initial tests.
Color me chastened. I was interpreting the Ipu spec
along the same vein as current draws provided for
peripherals (i.e., ADC, BOD, Timer1, etc.). I also
see now that the spec is stated with Vdd = 5V and
Vpin = Vss. Sigh. What an ass I feel like.
Many thanks to you all (especially Bill and Jan-Erik)
for tolerating my...ignorance...politely, and pushing
me in the right direction.