1
\$\begingroup\$

This is my first time to design STM32 circuit and I have no experience about the power down procedure.

In my opinion, it may be very rude to shut down the power supply as soon as the user presses the power down button because STM32 may need some time to store important information before shutdown.

Therefore, I guess the procedure may be like this: after the user presses the power button, the circuit should send the highest priority interrupt to STM32 who stores all necessary data immediately. After that, STM32 sends the disable signal to the regulator who provides the power to the whole system.

I'm not sure whether my guess is correct. If it doesn't like this, can someone tells me how what should the power-down procedure be in a real product or tell me where can I get the tutorial about power-down design? Thank you.

\$\endgroup\$
4
  • 4
    \$\begingroup\$ It depends entirely on your application. How often do you need to write data to nonvolatile storage (the only kind that matters during power-down)? \$\endgroup\$
    – Dave Tweed
    Oct 5, 2018 at 1:36
  • \$\begingroup\$ It's an image processing system. Every time when a user captures an image, it will take around 100ms to process and store. The user controls the capturing time. \$\endgroup\$
    – Ross
    Oct 5, 2018 at 1:57
  • 1
    \$\begingroup\$ What's the impact to the user if there's an image lost when the power shuts off? \$\endgroup\$
    – The Photon
    Oct 5, 2018 at 2:41
  • \$\begingroup\$ In a "real product" often the exact desired behavior on power up is a fresh boot to run the firmware exactly as it was loaded. This is, of course, entirely dependent on what the product is and what the desired behavior is. Your question is unanswerable without real information that you haven't provided. If you want to stick to a hypothetical, that's fine, but at least provide some framework. \$\endgroup\$ Oct 5, 2018 at 13:29

1 Answer 1

2
\$\begingroup\$

The best solution (assuming this is a soft power button monitored by the MCU) is probably to not actually turn it off, but to put the device into one of it's low power modes so that your volatile memory is maintained. There are applications that use sleep modes to get months of life out of pretty small batteries, it's just a matter of optimizing your code for power savings.

If this is a hard power button (meaning that it actually removes power from the MCU) then you could use a supercapacitor to keep the MCU running for a few seconds after power off. Read the state of the power supply before the supercap on one of the GPIOs and if it ever goes low that means power has been turned off and it's time to store everything before the supercap gets fully drained.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.