1

I was wondering if it is possible to shut an atmel microcontroller down with a software command? I want to shut my controller down either via a remote command via USART or if an internal error happens (as BOD, for example). Unfortunately the whole data sheet tells me nothing about that.

arc_lupus
  • 724
  • 1
  • 10
  • 28
  • 1
    I think you need to specify more detail on what "shut down" means. Several cases come to mind. 1) Hold the MCU in reset after the shut down command. 2) Use the shutdown command to cut the power source to the MCU and its associated peripheral circuits. 3) Equip the power entry to board with a fuse in series and then use the shutdown command to gate a large load current through the fuse causing it to blow. All three approaches would require some level of intervention to restore the MCU into operation. – Michael Karas Mar 06 '15 at 15:06
  • @MichaelKaras: I want to have the µC in a state where it is safe to disconnect the power source (manually), i.e. where I don't have to worry about interrupting it during some calculations. – arc_lupus Mar 06 '15 at 15:09
  • Just put it to some state where it doesn't perform any critical calculation (An empty while (1) with disabled interrupts will do). – Eugene Sh. Mar 06 '15 at 15:16
  • 1
    You will have to use some software technique right on the MCU to indicate that the "computations are complete". The only thing that is aware of that is the current software state itself!! You could add some external indicator that allows the software to "report out" its state!! One of the simplest ideas would be to have the software turn off an LED when the MCU software is idle (and turn it back on as computation begins again). When you see that the LED is fully off you could feel confident to be able to pull the power plug. – Michael Karas Mar 06 '15 at 15:19

3 Answers3

3

Microcontrollers are not meant to be shut down in the same sense as a PC. They can be put into a low-power sleep mode, and additional hardware can be added to disconnect power externally, but there is no equivalent to turning power off internally.

Ignacio Vazquez-Abrams
  • 48,488
  • 4
  • 73
  • 103
1

Microcontrollers, and indeed CPUs in general, don't understand the concept of "shutting down". They just run and do what they are told.

When you shut down your computer you're not shutting down the CPU, you're shutting down the operating system. The last thing that shutting down of software does is to interface with a part of the hardware on the motherboard to indicate to the power supply to switch the power off. The CPU is still running as per normal at that point since it is the CPU that has to perform the software instructions to send the signal to request the poweroff.

Microcontrollers and CPUs do have different internal power states though where they can turn different parts of themselves on and off - these are often referred to as "sleep" or "idle" modes, and different modes can cause different effects on the internals of the chip (memory loss, etc). The datasheet for your specific chip will detail these modes and what their effects are - as well as how to utilise them. No chip ever has an "off" mode though, only very low power modes.

Boards like the BeagleBone Black which you can "shut down" in software and switch themselves off have a separate power management chip which is instructed by the CPU to switch the power off to the whole board.

Majenko
  • 56,223
  • 9
  • 105
  • 189
1

There is the 'sleep' instruction. It waits for an interrupt to occur. Clearing the interrupt flag (CLI) will disable them and it will never wake up. However how are you going to tell it's done, without some kind of outside indicator (LED?) BTW, software code is usually referred to as instructions, not commands. :)

Jack
  • 21
  • 2