0

Is there an instruction or fuse setting accessible form the running program which can turn off a Atmel Atmega completely?

My program measures via ADC the powering battery's level and then goes back to sleep mode woken up only by external interrupts to measure again and sleep again, this in an endless cycle. Since the battery level should not pass below a certain threshold (otherwise the battery will rapidly loose its recharging capabilities) I prefer to be safe and turn the Atmega off completely instead of using endless deep-sleep modes.

lorenzli
  • 620
  • 1
  • 10
  • 31
  • I'm not aware of an instruction for the AVR to nuke itself (after all, if it turns itself off, how does it turn on again?) Now, it might be that a brown out detector could do what you're interested in, by holding the AVR in reset when the voltage is too low, see for example here: http://www.scienceprog.com/microcontroller-brown-out-detection/ – Ross Oct 15 '14 at 13:21
  • Can you be clearer about what you are trying to avoid? Are you trying to stop the battery from discharging too low over time or is it that you don't want to draw too little voltage from the battery? – djUniversal Oct 15 '14 at 18:21
  • If you just want to be safe that the battery won't discharge completely and that the controller will only run above a safe threshold voltage, you could activate internal brown-out detector at the desired level. This would (for example) cause the controller to stay reset as soon as the battery level falls below 2.7V. – Rev Oct 16 '14 at 06:51
  • Thanks for your comments and further information. @djUniversal I tried now to improve the question, I don't want to undercharge the battery which means assuring to keep the battery voltage level always above a certain threshold. – lorenzli Oct 16 '14 at 09:36
  • @Ross What do you mean by "holding the AVR in reset"? Jumping back to the reset vector? Again, I would prefer it to be totally off consuming zero power or at least sleep deeply. – lorenzli Oct 16 '14 at 09:37
  • comment above counts also for @Rev1.0 – lorenzli Oct 16 '14 at 09:38
  • @lorenzli: The brown out detector itself "only" consumes around 15uA (however, this may be relevant if you go for a very low power design). The reset occurs when the voltage falls below the threshold and the brown out detector will hold the reset within a small hysteresis (IIRC about 150mV above reset threshold). Note that, depending on the battery type, the battery voltage may rise somewhat under very-low-load conditions (as soon as the controller is in reset). So either your design already draws less current that the brown-out detector would, or it could be an option to consider using it. – Rev Oct 16 '14 at 10:23
  • 1
    In short, no, there's no HALT instruction to make the CPU stop. If deep sleep modes still draw too much power for you, then you'll need to look at a hardware-based solution like a brown out detector. – Ross Oct 16 '14 at 13:25
  • Thanks for all your comments and help. As it looks now, deep sleep modes draw less then the brown-out detector which leads to the conclusion that my Atmega just will sleep very deeply and hopefully very long ;) – lorenzli Oct 16 '14 at 14:07
  • 3
    There is still the alternative of using an external brown out detector. We are using one for a design as well, because of the high consumption of the integrated one. I believe it was in the very few uA range. If you are interested I can post a part number tomorrow. – Rev Oct 16 '14 at 17:17
  • Sorry for the late reaction @Rev1.0, I missed the notification. Unfortunately the PCB is already designed and produced (the programmer got involved too late...), as I said I will stick with the deep sleep but thanks for your proposal! – lorenzli Oct 24 '14 at 12:17

2 Answers2

1

The closest you can get is to put the AVR in Power-down Mode, which consumes 0.1uA on an ATmega328P. You select the mode by writing to the SMCR register (Sleep Mode Control Register). See Tutorial 08_sleep_mode in the Piconomix FW Library and modify it.

0

No, there is not. You will need to use a high-side switch to control power to the MCU, activating it when a button is pressed and deactivating it from a pin on the MCU. Check EE.SE for various MCU-controlled power circuits.

Community
  • 1
  • 1
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358