Hi All,
I am new here in Arduino forum, so excuse me if the question is replicated or not in the correct place.
I am trying to make an extreme low power application (IR code transmitter) therefore I assembled a bare "Arduino" on a breadboard to do measures of current consumption. I used standard arv/power.h to switch off all peripherals and avr/sleep.h to go into power down mode. External (push button) interrupt is used to wake up the processor, and "L" LED is to indicate the operation. Everything was working fine, but current consumption was measured to be ~150uA instead of the maximum few microamperes, that should be by the datasheet.
Rummaging the net I found a library "Low-Power" (rocketscream), that could do the thing, in the power down mode current consumption was less then a microampere! As the Low-Power library does not know my final target platform (ATmega88), I looked into the code and was found the difference between the power.h and Low-Power: the power.h only uses PRR (power reduction register) to switch off ADC, while Low-Power disables the ADC in ADCSRA (ADC Control and Status Register A).
The datasheet sais about PRADC bit in the PRR 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."
As it seems, powering down ADC is not working if the ADC is not disabled before shutting down. While the ADC disabling code in avr/power.h does not matter with ADCSRA register, using only the built-in function the real low power consumption cannot be reached.
As I want to write my code with minimal using of "non standard" codelets make my code more portable, I cannot decide what I should do. I think, the best way would be correcting the "official" avr/power.h, but I don't know if it is possible anyway (not my local copy of it).
What do you suggest me, what way should walk?
Thanks.