ATmega328P power consumption

Go To Last Post
25 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

 

I can see in the ATmega328P datasheet figure 33-6 that idle supply current is 0.08mA @ 1MHz and 3.3V. To get this power consumption, do I have to use an external 1MHz crystal oscillator? What about the internal RC oscillator at 8.0MHz and the fuse CKDIV8 programmed?  

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

larsi wrote:
do I have to use an external 1MHz crystal oscillator?
External "costs more" than internal in fact.
larsi wrote:
hat about the internal RC oscillator at 8.0MHz and the fuse CKDIV8 programmed?
That's exactly how the chip defaults when you first buy it. It has an 8MHz intRC but, because of CKDIV8 preloading the /8 value into the CLKPR register it actually runs at about 1MHz.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I know that.

 

My question is still how to achieve 0.08mA idle supply current.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You put it in idle sleep mode.

 

Are you saying you have tried that but you aren't achieving 80uA then?

Last Edited: Mon. Sep 11, 2017 - 10:35 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Getting that power consumption that low is an art in itself.

Some hints:

I believe there is a section in the datasheet dealling spcifically with this.

chapter 9

9. Power Management and Sleep Modes

9.10 Minimizing Power Consumption

 

As an overview: Look at the power consumption of each separate part of the processor, and disable them if you can.

Things like:

Brown out.

ADC voltage reference

WDT, running timers

Lowering the Vcc.

 

It is also a good idea to keep the processor in the deepest sleep modes as long as possible.

Often it saves power to use a fast clock frequency, do what you want to do fast, and then go back to sleep earlier.

 

Also note that there is a atmega328pb which presumably has an even lower power consumption, and an extra uart and probably more stuff.

Paul van der Hoeven.
Bunch of old projects with AVR's:
http://www.hoevendesign.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

External crystal oscillators draw more current. Use the internal rc osc with div8.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Paulvdh wrote:
I believe there is a section in the datasheet dealing specifically with this

ISTR there is also an Application Note dealing specifically with this

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK. I am testing now with internal RC (8MHz) and CKDIV8 enabled. I don't see 80uA, but much higher. I measure about 300uA. I will have to find what is not powered down and disable it then.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

larsi wrote:
I will have to find what is not powered down and disable it then.

Indeed. http://www.avrfreaks.net/comment...

theusch wrote:
IMO, from experience, the only way to do your work is to start from the "bare" AVR with the absolute minimum of external connections, and work with that until you are satisfied that it meets specs. Then add subsystems one-by-one and retest. As you have found, with the whole app the draw can be ANYwhere. There are a lot of uA in a bushel-basket.

 

http://www.avrfreaks.net/comment...

theusch wrote:
If you are satisfied that it >>is<< going to sleep--e.g., the non-sleep current is 4mA or 5mA or whatever--then you've got to look at each pin and each peripheral subsystem. I find it MUCH easier to start with a bare chip and only the essential signals hooked up, stay awake for a few seconds to measure the "active" draw", then go to sleep never to awake until the next reset. Don't even hook up/enable your RTC stuff.

 

http://www.avrfreaks.net/comment...

- Start with a bare AVR chip, with the minimum circuitry--all Vcc (including AVcc and Gnd pins hooked up; /RESET pin circuitry.
-- Ensure you are measuring only the AVR current draw.
-- Have the AVR start up and run for a few seconds in Active mode, then enter your power-saving mode of choice and just stay there. Don't worry about any wakeup sources. Continue to work with this arrangement until you get satisfactory results that match the charts in the datasheet.
-- Note that there should not be any "floating inputs" in this configuration or your numbers will not be correct.

 

-- Then add connections to your application circuitry, one by one, and retest.

-- Then add your wakeup sources one by one and retest.

Starting with the full app and trying to minimize the numbers will lead you to disconnect stuff until you arrive at the bare chip anyway. I find it a LOT easier to use the build-up approach.

Let's start by asking how you are measuring current.  The AVR itself?  Or input to a regulator?

 

Are all Vcc and Gnd connected at good levels, and properly decoupled?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theusch wrote:
Let's start by asking how you are measuring current.  

+10

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theusch wrote:
Let's start by asking how you are measuring current. The AVR itself?

If indeed the AVR itself, then let's see schematic, and [very preferably complete] test program.

 

ADC and AC disabled, so internal ref is off?  PRR settings?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, proper use of the PRR is critical. Another factor is disabling the digital I/O on ADC inputs. 

 

In the Electrical Characteristics chapter, you will find a number of sections on the power consumption of various individual peripheral modules, such as the ADC. These show you what the power cost is when you leave them enabled in the PRR (Power Reduction Register).

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is what I power down before going to sleep:

// disable WDT
// Clear WDRF in MCUSR
MCUSR &= ~(1 << WDRF);
// Write logical one to WDCE and WDE
// Keep old prescaler setting to prevent unintentional time-out
WDTCSR |= (1 << WDCE) | (1 << WDE);
// Turn off WDT
WDTCSR = 0x00;

// disable UART
UCSR0B = 0x00;
	
// disable the ADC
ADCSRA = 0;
// disable the Analog to Digital Converter module
power_adc_disable();

// sleep
set_sleep_mode(SLEEP_MODE_PWR_SAVE);
sleep_enable();
sleep_bod_disable();   // disable brown-out detection while sleeping (20-25µA)	
sei();                 // ensure interrupts enabled so we can wake up again
sleep_cpu();           // go to sleep

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

larsi wrote:
This is what I power down before going to sleep:

Well, a start -- I guess...

 

awneil wrote:
theusch wrote: Let's start by asking how you are measuring current. +10
...which you haven't answered.

 

theusch wrote:
If indeed the AVR itself, then let's see schematic, and [very preferably complete] test program.

 

Could it be that you are awakening?  [that is where the complete program comes in...]  A few hundred uA is about Active draw at your numbers.

 

larsi wrote:
// disable WDT

Now we are back to toolchain/version/optimization settings.  Are you sure that sequence follows the 4-cycle limitation?  Show the generated code.

 

larsi wrote:
// disable the Analog to Digital Converter module power_adc_disable();

A mystery function?

 

I see no manipulation of PRR.  And without the complete program, we cannot see if e.g. timers are running.

 

============

When I am serious about your task, I make a test program that stays awake for some seconds, so that the Active current draw can be measured.  Then I set up and go to sleep -- WITH NO WAKEUP SOURCES ENABLED.  Thus, the AVR sleeps with the fishes forever.  Use reset or reprogram to run again.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

To start, set ACD...

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
#include <avr/sleep.h>
#include <avr/power.h>

// disable the Analog to Digital Converter module
power_adc_disable();

I measure current from the power supply. So I have some loss in my DC-DC converter as well, but I still think the ATmega draws about 300uA.

 

WDT function:

void WDT_off(void)
{	
	// disable all interrupts
	cli();
	// Clear WDRF in MCUSR 
	MCUSR &= ~(1 << WDRF);
	// Write logical one to WDCE and WDE 
	// Keep old prescaler setting to prevent unintentional time-out 
	WDTCSR |= (1 << WDCE) | (1 << WDE);
	// Turn off WDT 
	WDTCSR = 0x00;
	// enable all interrupts
	sei();
}

I will try making a program only sleeping, no interrupt waking it up.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

larsi wrote:
I measure current from the power supply. So I have some loss in my DC-DC converter as well, but I still think the ATmega draws about 300uA.

How can you "think" that without measuring?!?

larsi wrote:
WDT function:

That doesn't address the issues I raised.

 

I'd say I'm fairly experienced in this area.  IME AVR8 models will have current draw consistent with datasheet numbers.

 

But this is approaching pulling teeth; so painful to do one at a time.  There is a reason for each of the questions and comments in the responses.  Do you want me to go over them one by one?

 

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The posts mention "Idle", the code indicates "Power Save".  (which should draw about 1uA?)

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theusch wrote:
How can you "think" that without measuring?!?

I think he means, "guess".

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

I can see in the ATmega328P datasheet figure 33-6 that idle supply current is 0.08mA @ 1MHz and 3.3V. To get this power consumption, do I have to use an external 1MHz crystal oscillator? What about the internal RC oscillator at 8.0MHz and the fuse CKDIV8 programmed?  

The figure you quote does not include current drawn by an oscillator... neither the internal RC oscillator, nor an external crystal oscillator.  The measurements were made using an external clock:

 

 

Figure 33-9 shows idle current when running at 1 MHz from the internal RC with a /8 prescaler.  Note that at your specified VCC=3.3V and at 25C, the current is about 0.18 mA, not 0.08 mA.  The RC oscillator itself takes about 100 uA.

 

There are no figures which show the current consumption w.r.t. the external crystal oscillator.  The consumption of that oscillator depends upon a great many things, like the characteristics of the crystal itself (CL, ESR, operating mode, etc.), the load capacitors (which themselves have complex characteristics like ESR, leakage current...), the oscillator mode (low-power v.s. full swing), the PCB layout of those components, and near those components.  There is no 'one-size-fits-all' figure to describe the infinity of possibilities.  If you need to accurately characterise current consumption with the external crystal oscillator, you'll have to put it on the bench yourself.  However, as has been said, generally the crystal oscillator draws more current than the internal RC oscillator.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Tue. Sep 12, 2017 - 07:19 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks joeymorin!

When I make a simple program just going to sleep (SLEEP_MODE_PWR_SAVE) with no interrupts enabled, I measure 0.17mA. This is closer to what is shown in figure 33-9.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

are you still including your regulator in that?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But power save mode is not the same thing as idle mode.  In power save mode, the system clock is stopped, and so is the oscillator.  The only clocks running are the async clock for TIMER2, but only if enabled, and the watchdog timer, but only if enabled.

 

Otherwise, the current should be the same as power down mode, about 100 nA, assuming you've shut everything else off.  So you're off by a factor of more than a thousand.  See figure 33-11.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Tue. Sep 12, 2017 - 05:55 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am still including my regulator in the measurements. I am using a TLV61225 taking the voltage up from 3VDC to 3.3VDC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

I am still including my regulator in the measurements. I am using a TLV61225 taking the voltage up from 3VDC to 3.3VDC

Then that's not going to tell you much about how much current your AVR is consuming, is it?

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]