ATMEGA328p Standalone 8MHz @ 2.5v

I originally had the same issue with 2.5V not running the sketch. I disabled brown-out detection by setting the extended fuse to 0x07 and that fixed it.

So it looks like 2.5 mA is normal for this circuit. That's still much better than 16.5 mA and is going to increase battery life in my project quite a bit.

Looks like I'm going to invest in a better meter. Merry Christmas me!

I was wondering why my chip seemed to be "out of spec" until I realized about the brown-out detection (which you have also commented on). Turning off brown-out detection, I got these figures:

Voltage  Clock  Current
         (MHz)   (mA)
  5.0     16*a   16.5
  4.0     16      9.1
  3.3     16      6.7
  3.0     16      6.0
  2.8     16      5.5
  2.5     16      4.8
  2.4     16      4.6
  2.3     16      4.3
  2.2     16      4.1
  2.1     16      3.8
  2.0     16      did not run

  5.0      8*b   12.3
  4.0      8      5.5
  3.3      8      3.7
  3.0      8      3.3
  2.8      8      3.0
  2.5      8      2.7
  2.4      8      2.5
  2.3      8      2.4
  2.2      8      2.3
  2.1      8      2.1
  2.0      8      2.0

*a Low fuse = 0xFF
*b Low fuse = 0xE2

As you can see, now we can run down to quite low voltages.

Of course, you can save a lot more current by actually sleeping, this is running normally.

I disabled brown-out detection

Generally, three things consume a lot of current:

1) watchdog; 2) BOD; 3) crystal oscillator.

If you want to lower current consumption, that's where you start.

From there, I would deal with unused pins, and any modules that you can turn off.

After that, put the mcu to sleep.

has everyone including nick been ignoring the fact that unconnected inputs can increase current big time? ive seen a 1000:1 variation in consumption when running empty endless loop like used here simply by waving my hand near the chip. internal or external pullups are essential in low current tests like this. and you must remember to disconnect programming leads too before making measurements.

Can you or anyone else post some tests? I can't until I buy a new meter.

I think the unconnected inputs would make a difference, but only once you get into low power modes (ie. sleep). My measurements previously indicated configuring the pins as outputs made a difference, but we are talking around 1 microamp, not milliamps.

A quick test shows that waving the hands over the bare leads (on my bare-bones board) seems to make some minor differences, but the readings weren't steady anyway. Quite possibly because I hadn't grounded the pins.

Another test had all pins set to input with internal pull-ups. That should have been reasonably resistant to noise. However if anything it consumed slightly more (4.82 mA compared to 4.75 mA).

I don't see any evidence of 1000 x more consumption with the pins floating. However once again this was not in sleep mode.

This test (running at 2.5V) consumed 100 nA (0.1 uA):

#include <avr/sleep.h>
void setup() 
  for (int i = 0; i <= A5; i++)
    pinMode (i, OUTPUT);
    digitalWrite (i, LOW);
  // disable ADC
  ADCSRA = 0;  
  // turn off various modules
  PRR = 0xFF; 
  set_sleep_mode (SLEEP_MODE_PWR_DOWN);  
  sleep_cpu ();          

void loop() { }

So, sleep mode is the way to go. :slight_smile:

Setting the pins output and low seemed to rule out having to worry about floating inputs.

[quote author=Nick Gammon link=topic=138473.msg1042891#msg1042891 date=1356307812]My measurements previously indicated configuring the pins as outputs made a difference, but we are talking around 1 microamp, not milliamps. [/quote]

ive seen it range into amps with unconnected pins on at90s1200. the chip not only got too hot to hold but started smoking. rare but ive seen that happen more than once. probably due to lockup or oscillation rather than sitting at threshold but definitely caused by floating pins. modern avrs have improved design to help with this but still not to be ignored. of course we are entitled to our own design practices but imo good idea to be careful when doling out advice to those less experienced.

in virtually all avr docs:

atmel: One of the most important considerations is to ensure a defined level on all I/O pins. A floating pin will give a significant increase in the overall power consumption.

also here:

MarkT: Basically any "standard" CMOS input stage is an inverter and will consume non-trivial power if the input is somewhere in the middle of the range (the "forbidden region"). Here non-trivial means its an issue for battery-powered circuitry in sleep mode - something on the scale of 1mA might flow from that one input circuit when the whole chip is supposed to be shutdown (a few uA usually).

atmel recommends at least activating the built-in pull ups. considering it costs nothing i suggest its good advice.

On my power saving page: Gammon Forum : Electronics : Microprocessors : Power saving techniques for microprocessors

I have this:

  • All pins as outputs, and LOW: 0.35 uA (same as before).
  • All pins as outputs, and HIGH: 1.86 uA.
  • All pins as inputs, and LOW (in other words, internal pull-ups disabled): 0.35 uA (same as before).
  • All pins as inputs, and HIGH (in other words, internal pull-ups enabled): 1.25 uA.

All pins inputs and low is the one case where floating voltages might affect it. My test above had outputs and low, so that should not be susceptible to floating voltages.

Page 43 of the Atmega328P datasheet says:

9.10.6 Port Pins

When entering a sleep mode, all port pins should be configured to use minimum power. The most important is then to ensure that no pins drive resistive loads. In sleep modes where both the I/O clock (clkI/O) and the ADC clock (clkADC) are stopped, the input buffers of the device will be disabled. This ensures that no power is consumed by the input logic when not needed. In some cases, the input logic is needed for detecting wake-up conditions, and it will then be enabled. Refer to the section ”Digital Input Enable and Sleep Modes” on page 79 for details on which pins are enabled. If the input buffer is enabled and the input signal is left floating or have an analog signal level close to VCC/2, the input buffer will use excessive power.

This suggests that the input pins are disabled anyway (especially since I do not have any configured to wake it up).

So it would seem you don't need to obsessively put pull-down (or pull-up) resistors on all unused pins, since in the deep sleep modes the pins will be disabled. And if you had one configured as an interrupt to wake it up, presumably that would not be floating.

However I take it as a good point that in some sleep modes, floating voltages on input pins could well be a bad idea.

id have to agree that disabling input buffers is a better solution for unused pins. that way it dont matter what they might be connected to or what mode the chip is in. out of habit i use the pull ups because not all avrs have that capability and it is a little easier.

btw thanks for directing me to your field programmer project a while back. not so much for the usbasp problem but very useful being able to quickly burn lots of chips w/o having to lug around a pc.

Its probably like my meter, the regular (non shunted) terminal has a max 200ma current measue ability and it works just like that
You could alternatively put a precision 1 or .1ohm resistor in series with the supply and measure the mv across it to get the current

precision 1 or .1ohm resistor

They are tough to find.

Alternatively, you can use a small power resistor (0.1, 0.22, or 0.47ohm, or in parallel), to measure the current. You can calibrate / measure the resistor's value via a constant current source.

Hard part is having a reliable precision device to start with to calibrate thr rest, unless its a precision current source it won't be accurate, unless its a precision resistor it won't be accurate, might as well just buy a better multimeter lol

unlikely you need one part per million accuracy. 10% is probably fine. and power resistor is definitely not required. regular tiny 1ohm, 10ohm, or 100ohm of any low wattage will do here. at really low reading even 1k may work. or maybe replace the fuse in that meter. #1 cause of bad meters is using any of the the current ranges to measure across a high current supply like a battery. guaranteed to blow the fuse or smoke the leads on no-fuse setting.

even cheapo $3 harbor frieght meters are accurate within fraction of a percent. not like the ol’ day where mechanical meter could be 2% or even 3% off. still ok here though. accuracy and should not be confused with sensitivity either. however both are cheap these days.

It doesn't seem like anyone in this thread is aware of "Burden Voltage" - You cannot measure the current the chip is using without adjusting the voltage of the power supply, so it's correct at the target.

Have a look here on what i'm talking about

// Per.

Have a look here on what i'm talking about

Way exaggerated.

If you truly care about it, put a current sensing amplifier there and call it a day.


Have a look here on what i'm talking about

Way exaggerated.

I wouldn't call it exaggerated when you set your power supply at 2,5V, put your meter in series with the chip and then the chip only gets maybe 1,9V and you wonder what happened!

// Per.

I would argue that if a chip draws so much current that it causes that substantial of a voltage drop over the meter, the chip is no good; and/or the person doing the measurement is no good.

The issue he raised can be easily addressed.

dhenry: I would argue that if a chip draws so much current that it causes that substantial of a voltage drop over the meter, the chip is no good; and/or the person doing the measurement is no good.

The burden voltage of a multimeter is the same, regardless if you pull 1 mA or 200 mA trough it.... It does not change.

// Per.