0
Offline
Jr. Member
Karma: 0
Posts: 53
Arduino rocks
|
 |
« on: February 28, 2011, 07:02:49 am » |
Hi, On a custom board, consisting in an Atmega328P and some few passives, I want to check the current consumption of the board in Power Down mode. The only pull-up resistor is the 10k one for the reset circuit. Then there are a number of de-coupling capacitors, that's all. No external crystal used. The atmega is running at 8 MHz internal RC clock, 3.3VDC, BOD disabled. I've picked some ideas from this post: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1285656727/5So I've created a very simple sketch that puts the atmega in Power Down State: #include <avr/power.h> #include <avr/sleep.h>
void setup() { byte i; // Ensure no floating pins for(i=0; i<32 ; i++) { pinMode(i, OUTPUT); digitalWrite(i, LOW); }
// Power-down state set_sleep_mode(SLEEP_MODE_PWR_DOWN); sleep_enable(); // Disable functions power_all_disable(); // Enter sleep mode sleep_mode(); }
void loop() { }
The issue is that I was hopping to see some few microamps entering the board but I'm finally monitoring 105 uA after entering the Power Down state. Being the circuit so simple I wonder whether I'm entering the low-power state and disabling the functions correctly... On the other hand, I'm now checking the possible leakage through the de-coupling capacitors. Thanks in advance for your help. Daniel.
|
|
|
|
« Last Edit: February 28, 2011, 07:11:29 am by estratos »
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 1
Posts: 172
www.rocketscream.com
|
 |
« Reply #1 on: February 28, 2011, 07:57:44 am » |
Hi,
Is there any 3.3 V regulator?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 53
Arduino rocks
|
 |
« Reply #2 on: February 28, 2011, 08:01:49 am » |
Hi,
Is there any 3.3 V regulator?
No, I'm directly powering the board from an external power supply. Thanks.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Dallas
Offline
Shannon Member
Karma: 120
Posts: 10199
|
 |
« Reply #3 on: February 28, 2011, 02:17:17 pm » |
BOD disabled Disabled by fuse settings? // Ensure no floating pins for(i=0; i<32 ; i++) { pinMode(i, OUTPUT); digitalWrite(i, LOW); }
There are no definitions for pins 20 through 31 and neither pinMode nor digitalWrite check for an out-of-bounds pin number. Change the for condition to "< 20". // Disable functions power_all_disable();
I vaguely recall that this function does not catch everything. I can't remember the details so you'll have to search the forum.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 53
Arduino rocks
|
 |
« Reply #4 on: March 01, 2011, 03:13:37 am » |
Thank you very much for your response. BOD disabled Disabled by fuse settings? Yes // Ensure no floating pins for(i=0; i<32 ; i++) { pinMode(i, OUTPUT); digitalWrite(i, LOW); }
There are no definitions for pins 20 through 31 and neither pinMode nor digitalWrite check for an out-of-bounds pin number. Change the for condition to "< 20". OK thanks. I copied that piece of code from an sketch written for the Atmega644... // Disable functions power_all_disable();
I vaguely recall that this function does not catch everything. I can't remember the details so you'll have to search the forum. [/quote] Indeed, removing "power_all_disable()" from the code does not add a single uA to the consumption so I've decided to directly work with the PRR register instead: #include <avr/power.h> #include <avr/sleep.h>
void setup() { byte i; // Ensure no floating pins for(i=0; i<20 ; i++) { pinMode(i, OUTPUT); digitalWrite(i, LOW); } // Power-down board set_sleep_mode(SLEEP_MODE_PWR_DOWN); sleep_enable(); // Disable functions PRR = 0xFF; // Enter sleep mode sleep_mode(); }
void loop() { }
Unfortunately, the above changes still achieve 105 uA in the global consumption. I'm beginning to think that I have a damaged capacitor or a micro-shortcut somewhere on my board... Thanks again.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Dallas
Offline
Shannon Member
Karma: 120
Posts: 10199
|
 |
« Reply #5 on: March 01, 2011, 03:28:39 am » |
From the datasheet...
9.11.3 PRR – Power Reduction Register
Bit 0 – PRADC: Power Reduction ADC Writing a logic one to this bit shuts down the ADC. The ADC must be disabled before shut down. The analog comparator cannot use the ADC input MUX when the ADC is shut down.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 1
Posts: 172
www.rocketscream.com
|
 |
« Reply #6 on: March 01, 2011, 03:58:05 am » |
From the datasheet...
9.11.3 PRR – Power Reduction Register
Bit 0 – PRADC: Power Reduction ADC Writing a logic one to this bit shuts down the ADC. The ADC must be disabled before shut down. The analog comparator cannot use the ADC input MUX when the ADC is shut down. But, if we don't enable the ADC at the 1st place, we don't have to do the above setting right? Look at 9.10.1 of the datasheet.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Dallas
Offline
Shannon Member
Karma: 120
Posts: 10199
|
 |
« Reply #7 on: March 01, 2011, 04:17:19 am » |
The ADC is enabled by the core. I believe init in wiring.c does the deed.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 1
Posts: 172
www.rocketscream.com
|
 |
« Reply #8 on: March 01, 2011, 04:25:34 am » |
Found it, it is in the wiring file in the core folder. The ADC is enabled by default. For timers, I think for power down mode, the clock source is not available for it to work.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 53
Arduino rocks
|
 |
« Reply #9 on: March 01, 2011, 04:42:58 am » |
OK, trying to disable individual functions before stopping each function clock: #include <avr/power.h> #include <avr/sleep.h>
void setup() { byte i; // Ensure no floating pins for(i=0; i<20 ; i++) { pinMode(i, OUTPUT); digitalWrite(i, LOW); } // Power-down board set_sleep_mode(SLEEP_MODE_PWR_DOWN); sleep_enable(); // Disable functions power_adc_disable(); power_spi_disable(); power_twi_disable(); power_usart0_disable(); power_timer0_disable(); power_timer1_disable(); power_timer2_disable(); PRR = 0xFF; // Enter sleep mode sleep_mode(); }
void loop() { }
Consumption is still around 105 uA  Thanks guys!
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 53
Arduino rocks
|
 |
« Reply #10 on: March 01, 2011, 07:25:07 am » |
I've investigated the possibility of "loosing" current through the decoupling capacitors but, even in the worst cases, they might be wasting a total of a few uAmps maximum. I think I'm going to order a couple of DIP-form atmegas in order to do the tests on a breadboard. Then I'll be able to mount only the essential components and measure the current consumption. That will let me discard any programming-related problem.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Dallas
Offline
Shannon Member
Karma: 120
Posts: 10199
|
 |
« Reply #11 on: March 01, 2011, 01:16:17 pm » |
These... // Disable functions power_adc_disable(); power_spi_disable(); power_twi_disable(); power_usart0_disable(); power_timer0_disable(); power_timer1_disable(); power_timer2_disable();
...and this... PRR = 0xFF;
...are equivalent. You still have not disabled the ADC.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 53
Arduino rocks
|
 |
« Reply #12 on: March 01, 2011, 01:47:41 pm » |
You're right! Let's do then: #include <avr/power.h> #include <avr/sleep.h>
void setup() { byte i; // Ensure no floating pins for(i=0; i<20 ; i++) { pinMode(i, OUTPUT); digitalWrite(i, LOW); } // Power-down board set_sleep_mode(SLEEP_MODE_PWR_DOWN); sleep_enable(); // Disable ADC ADCSRA &= ~(1 << ADEN);
// Power down functions PRR = 0xFF; // Enter sleep mode sleep_mode(); }
void loop() { }
And the result is... less than 0.2 uAmps !!! Thanks a lot guys for your great help!!
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Boston area, metrowest
Offline
Brattain Member
Karma: 249
Posts: 16572
Available for Design & Build services
|
 |
« Reply #13 on: March 01, 2011, 02:31:28 pm » |
Can you wake up on external interrupt with these power down settings??
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Dallas
Offline
Shannon Member
Karma: 120
Posts: 10199
|
 |
« Reply #14 on: March 01, 2011, 02:44:47 pm » |
I think Atmel calls them "asynchronous interrupts". Off the top of my head (read that as probably with mistakes): pin-change interrupts, USART activity, TWI address match, watchdog interrupt, INTx level. For the 328, the table in "9.1 Sleep Modes" provides a good overview.
|
|
|
|
|
Logged
|
|
|
|
|
|