The Handoff:
Entering the C World
You have power. You have a stack. Your RAM is zeroed and ready. There is only one thing left to do: Pass the baton to the user's code.
1. The Final Branch Instruction
In the assembly startup file (usually titled startup_stm32.s or similar), the very last instruction of the initialization process is a "Jump" or "Branch" instruction.
bl main // Branch with Link to 'main'
2. What if main() ends?
In a standard computer program (like a Python script), the program finishes and you go back to the terminal.
But in a Microcontroller, there is nowhere to go back to.
If main() ever finishes, the CPU would continue executing random uninitialized memory—resulting in a catastrophic crash. To prevent this, the startup assembly usually has an "Infinite Loop" trap right after the branch:
b _exit_trap ; Hang here forever if main exits
Congratulations!
You've mastered the internal journey of a Microcontroller from power-on to application entry.
Return to Syllabus Hub →