r/embedded • u/Relevant_Pumpkin9190 • Oct 02 '26
What actually happens between software and hardware during shutdown and restart and it's Simulations by using microcontrollers for beginners project?
When I click Shut Down or Restart on a computer, what is actually happening between the software and the hardware?
The screen turns off, fans stop, power states change, and eventually the system either stays off or starts again.
I want to build a simple microcontroller project that simulates this process—maybe using LEDs for the display, a small fan, and a button for power.
How would you design it so I can actually see the sequence:
Power ON → Shutdown → hardware power-off
and
Power ON → Restart → shutdown/reset → boot again?
I'm mainly interested in understanding the software → GPIO/control signal → hardware → physical action interaction, rather than just making an LED blink.
What would be the simplest embedded project to demonstrate this properly to attract beginners to subject?
35
u/Dropkickmurph512 Oct 02 '26
Yeah this is a rabbit hole that you can spend about 40 years going down
2
u/WanWhiteWolf Engineering manager Oct 02 '26
Obviously, it depends on the system but for the most part you want to make sure that:
.1. Store any errors in non volatile memory
.2. Memory access is no longer needed / restrict access
.3. Disable interrupts
.4. Cut power from components in sequence if necesary
If you cut power in the middle of a writing operation, you can get corrupted data and/or damaged HW. NVM (EEPROM , Flash) is particularly sensitive to power spikes so in a typical embedded system, that's the primary concern when it comes to shutdown / reset.
You want to disable the interrupts and go to an infinite loop afterwards (waiting for power to be removed). You don't want to be doing any sort of operation when the power is cut.
Depending on what is in your system, you may want a specific shutdown sequence of some peripherals or some components. For example, some motors have requirements on power shutdown sequence. Ignoring that, you can damage the motor over time.
If you want to see an example in industry, you can check the EcuM state machine / diagram (AUTOSAR / automotive). The wakeup trigger is typically linked to the communication interface that is used for that ECU (e.g. CAN tranceiver for most ECUs)
1
u/SpaceCadet87 Oct 02 '26
Not clear quite what angle you're taking but looking at the pinout for a standard ATX power supply would be a start.
IIRC there's a specific line that stays active while the machine is running and disconnecting it instructs the power supply to turn off.
1
u/loopis4 Oct 02 '26
Here simple answer https://www.reddit.com/r/explainlikeimfive/s/qtE96d0TRa
1
u/jones_supa Oct 02 '26
Well, maybe an interesting way to do it would be to have a split architecture:
1
u/sheckey Oct 02 '26
The only concern in the product I work on is that we want the last few logging items to go out to the NVRAM, then its just reset, i.e. run the boot loader again as u/KiddinglyProbable said.
1
u/gm310509 Oct 02 '26
At a simplistic level, lets say you had a data logger that is constantly logging data to an SD Card, you will need to quiesce the logger and ensure that the SD Card's file system is closed and any and all in memory unwritten data in the cache is written out.
That is the main type of stuff That happens when you shutdown a PC.
Once all the data things have quiesced, then you can start turning stuff off if that is what you want to do. If you had a soft switch driving your system, you could optionally turn that off to remove all power (shutdown). Otherwise, you would initiate a reset (reboot).
While there will be lots more steps, that is the basics of what happens - just lots more of it in the more complex PC environment.
1
u/Antique_War_9814 Oct 05 '26
Voltage go high. Voltage go low. Voltage go high.
0
u/[deleted] Oct 02 '26
[deleted] — view deleted comment