ATMEGA328P Power Saving

Hello,

I've been working on reducing the power consumption of my circuit design which at a high level uses an ATMEGA328P chip to control an Allegro A1330 magnetic sensor (SPI bus) and MCP4725 DAC (I2C bus). The magnetic sensor uses ~15mA and the DAC hardly uses any power.

I ran through some cases on reducing power and my results are below.

I had a couple of questions:

  1. Would doing a brown out disable further reduce my power consumption?
  2. If i reduce my clock speed to 2MHz, do I need to adjust my SPI settings (i.e. is the program smart enough to know that when my SPISETTINGS say 2MHz it doesn't scale or have anything to do with the MCU clock speed?)

//disable ADC
ADCSRA = 0;

// turn off all modules
power_all_disable();

= 25.4mA but device didn't work


//disable ADC
ADCSRA = 0;

power_adc_disable(); // ADC converter
power_timer0_disable();// Timer 0
power_timer1_disable();// Timer 1
power_timer2_disable();// Timer 2

=28.1mA


//disable ADC
ADCSRA = 0;

power_adc_disable(); // ADC converter
power_timer0_disable();// Timer 0
power_timer1_disable();// Timer 1
power_timer2_disable();// Timer 2

CLKPR = 0x80;
CLKPR = 0x01;

=23.4mA


//disable ADC
ADCSRA = 0;

power_adc_disable(); // ADC converter
power_timer0_disable();// Timer 0
power_timer1_disable();// Timer 1
power_timer2_disable();// Timer 2

CLKPR = 0x80;
CLKPR = 0x02;

=21.2mA


//disable ADC
ADCSRA = 0;

power_adc_disable(); // ADC converter
power_timer0_disable();// Timer 0
power_timer1_disable();// Timer 1
power_timer2_disable();// Timer 2

CLKPR = 0x80;
CLKPR = 0x03;

=19.5mA


The first thing is to make sure that all the unused I/O pins are at one power rail or the other, and not floating (i.e. - in INPUT mode). By default they are floating at power up, and consume significant current in that mode. So any pins not used for SPI, I2C or other functions should be set to either OUTPUT or INPUT_PULLUP. This includes the analog pins.

Remove the power-on LED indicator if there is one.

I'm not sure the BOD disable is effective except in deep sleep mode. Just don't know for sure. Is your 328P ever sleeping, or is it on all the time? Sleeping can save a lot of power.

I believe the SPI library takes into account the F_CPU value, which is the system clock based on the crystal. But I don't think F_CPU is automatically modified if you go changing the system clock prescaler, so you would have to do that adjustment yourself. But it may be possible for you to simply change the value of F_CPU to 2000000, and then SPIsettings would automatically take that into account.

Should have mentioned that I do have all of the unused pins pulled high.

Board never sleeps, issue I have is I can't source more than 21mA ever.

No leds on the board.

That's what I was thinking for the bod and since i don't sleep it won't help.

Thanks for the data on the fcpu I'll take a look at that.

I probably need to look at lowering the voltage on the mcu. My only concern is I need to output 5v out of my DAC and if the i2c logic coming out of the atmega328p is 3.3 I'm not sure if that screws it up.

I really don't know what else to suggest. it seems most of your current is drawn by the magnetic sensor. Maybe there's a more efficient version of that device. I'm not sure that reducing the voltage to 3.3V necessarily reduces current. But you haven't given any info on where your power is coming from. Don't know about the DAC.

Yeah I'm looking for a lower power consuming device. Data out there seems to show a pretty significant savings on switching to lower voltage. I would have to take into account that I'm going to have to convert 5v to 3.3v.

https://learn.sparkfun.com/tutorials/reducing-arduino-power-consumption/all

Power is coming from a car ecu that is current limited to 21mA