I'm using a barebones 32U4 board running at 3.3 V/8 Mhz, with an external ceramic oscillator and no LDO. I'm trying to use idle mode to reduce consumption, and the lowest I'm able to get it is around 5.9 mA. I've tried both the avr/sleep.h library and the LowPower library from RocketScream. I'm disabling USB, ADC, timers 0,1,3,4, SPI, USART1, and TWI.
The datasheet suggests (p. 396) that the power when in idle mode should be around 1.5 mA. Could anyone tell me why I'm seeing this large difference? Even the active supply current shown in the datasheet is lower than what I'm seeing with my board.
I agree that 5.9 mA is too high. It sounds like you never do put the processor in idle mode.
But to determine the problem(s) requires that you post the code (using code tags) and a complete schematic (not Fritzing) for the board, with parts and pins labeled.
Thanks! This is the schematic, but I haven't installed any of the sensors, the LDO, the tact switches, or the 3.5mm jack. I'm powering the board from an external regulated 3.3V through the ICSP header. I don't think there's anything else that consumes a significant amount of power.
The code below gives me 4.5 mA, but that's still quite a bit higher than the datasheet suggests:
Interestingly, my results are similar to those shown here for Teensy 2.0, but I don't understand why they are so much higher than shown on the datasheet.
Thanks--I have read that, but I'm fairly certain my MCUs are legit as I get them from Digikey, and the fact that my results are pretty close to the Teensy results seem to support that.
At the moment, you and forum members have nothing to go on. So, why not try some other experiments?
Instead of that single call, where you have no way of checking for success, run some code and after 10 seconds, execute one of the low power functions. Measure the change in current consumption.
Have you tried uploading a blank sketch to it and see if it is still high?
If there is nothing currently connected to it, I would check the values of all components used to make the circuit. Possibly a wrong capacitor value or resistor, transistor etc?
Thinking here as an electronics technician atm not as a coder.
Secondly how are you reading the power consumption? Some multimeters will add in an odd value to amperage.
Try using a constant 5V supply without a regulator and check it also.
I ran this test for you using an unmodified Adafruit 5V, 16 MHz ItsyBitsy, on a 6V power supply.
Running: 36.8 when the LED is not lit
idle mode: 20 mA, LED not lit
powerDown mode: 150 uA, and that includes the MIC5525 regulator quiescent current.
Obviously, the Low Power library could be improved in its handling of the various 32U4 peripherals, since most remain powered up.
/*
Low Power library powerDown test ATmega32U4
*/
#include <LowPower.h>
int led = 13;
void setup() {
pinMode(led, OUTPUT);
}
void loop() {
static int count = 0;
digitalWrite(led, HIGH); // LED on 10X
delay(700); // wait
digitalWrite(led, LOW); // LED off
delay(300); // wait
count++;
if (count == 10) { //idle or powerDown
count = 0;
// LowPower.idle(SLEEP_8S, ADC_OFF, TIMER4_OFF, TIMER3_OFF, TIMER1_OFF,
// TIMER0_OFF, SPI_OFF, USART1_OFF, TWI_OFF, USB_OFF);
LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); //this is all that this mode allows
// wake up and blink long
USBDevice.attach();
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
delay(2000);
digitalWrite(13, LOW);
}
}
Thanks for doing these tests! With my board, using similar code, I get:
Running: 10.5 mA
Idle mode: 5.0 mA
powerDown: 640 uA
Athough the powerDown current is a little higher than I expected, it tells me that stray current on my board isn't contributing in a significant way to the high idle current that I'm seeing.
Out of curiosity-- you mentioned that the Low Power library leaves most peripherals turned on. To which ones are you referring?
Using ADC Noise Reduction mode with the ADC off results in 3.0 mA consumption, so better than idle. That makes sense because an additional clock is turned off. However, ADCNR mode with the ADC turned on yields higher consumption than idle mode with the ADC on (nearly 6 mA). I suspect that's because it won't actually stay in that mode because a conversion is triggered when entering ADCNR and the ADC complete interrupt wakes it back up. Not sure about, though (?). This seems like a useful mode for shaving off a few more mA, though I'd still like to see it lower :).
If you look at the Low Power library code, the only 32U4 peripheral it claims to turn off is the ADC. You can turn the rest off by setting various bits in the PRRx registers.
I was under the impression that it turns off everything below, is that not the case? Isn't that everything in the PRR register? If not, that would certainly help explain my results.
I see, I thought you were referring to the idle mode implementation. I believe the library doesn’t shut down the other peripherals in power down mode because the MCU shuts them down automatically.
Edit: I see that I may be wrong about that. I’ve primarily looked at the idle mode because I need that or the ADCNR mode for my application.
I found the issue—the LowPower library doesn’t actually disable the USB clock before entering idle mode. If I do that with the code below before entering idle mode, the consumption drops to 2.3 mA. It’s still a bit higher than the datasheet suggests, but much closer.
USBCON |= (1 << FRZCLK); // Freeze the USB Clock
PLLCSR &= ~(1 << PLLE); // Disable the USB Clock (PPL)
USBCON &= ~(1 << USBE); // Disable the USB
Thanks. After looking at the powerDown section, I had already come to the conclusion that the LowPower library is not doing a useful job with the 32U4.
You will be much better off going through the data sheet carefully, and setting all the various register bits as needed. Unfortunately those bits are rather scattered around.