Home > database >  What’s the difference between the startup code and reset handler
What’s the difference between the startup code and reset handler

Time:12-05

Hello stackoverflow community,

Can someone, please, help me to understand the difference between the startup code and the reset handler? When start our microcontroller which one is called? And when we reset our microcontroller which one is called?

I know that the startup code can be found inside the startup.s file bit where can we find the reset handler?

Thank you!

CodePudding user response:

Startup code and reset handler are just two names of the same thing.

Reset hander is like an interrupt, it's called by the mcu at boot. MCU loads reset handler address from the interrupt vector table. Reset handler usualy just callst the startup or consists of it.

Startup is usualy written in assember, but sometimes in C. To find the reset handler - look at the interrupt vector table, for Cortex-M core it's the second item, first is the top of stack initial value.

CodePudding user response:

Some microcontrollers allow you to differentiate between different kinds of reset (e.g. power-on reset, software reset, brown-out reset and possibly others). In such situation your reset handler could check the reset reason and only execute the startup code to initialize the hardware and start the main task when really necessary.

  • Related