Home | Projects | Notes > ARM Cortex-M3/M4 Processor > Reset Sequence
When you reset the processor (e.g., press the reset button on the boad), the PC is loaded with the value 0x0000_0000. (Memory location 0x0000_0000 belongs to a Flash memory, or ROM memory, or Program memory.)
Then the processor reads the value at the memory location 0x0000_0000 into the MSP.
MSP = value at 0x0000_0000
MSP is the Main Stack Pointer register. This means that the processor, upon reset, first initializes the Stack Pointer.
Then the processor reads the value at the memory location 0x000_0004 into PC. That value is actually the address of the reset handler. (In other words, the address of the reset handler gets stored into PC.)
PC jumps to the reset handler.
A reset handler is just a C or assembly function written by you to carry out any initialization required.
From the reset handler, main() function of the application gets called.
This is how the control reaches your program's main() function after reset.

Reset handler does the early initialization after which the call to the user program (main()) is made:
Processor reset
__libc_init_array();)
main())
Remember! The main() function cannot be called without these important early initializations.
xxxxxxxxxx431/* a section of startup file (startup_stm32f407vgtx.s) */2
3Reset_Handler:4 ldr r0, =_estack5 mov sp, r0 /* set stack pointer */6/* Call the clock system initialization function.*/7 bl SystemInit8
9/* Copy the data segment initializers from flash to SRAM */10 ldr r0, =_sdata11 ldr r1, =_edata12 ldr r2, =_sidata13 movs r3, #014 b LoopCopyDataInit15
16CopyDataInit:17 ldr r4, [r2, r3]18 str r4, [r0, r3]19 adds r3, r3, #420
21LoopCopyDataInit:22 adds r4, r0, r323 cmp r4, r124 bcc CopyDataInit25
26/* Zero fill the bss segment. */27 ldr r2, =_sbss28 ldr r4, =_ebss29 movs r3, #030 b LoopFillZerobss31
32FillZerobss:33 str r3, [r2]34 adds r2, r2, #435
36LoopFillZerobss:37 cmp r2, r438 bcc FillZerobss39
40/* Call static constructors */41 bl __libc_init_array42/* Call the application's entry point.*/43 bl main
Nayak, K. (2022). Embedded Systems Programming on ARM Cortex-M3/M4 Processor [Video file]. Retrieved from https://www.udemy.com/course/embedded-system-programming-on-arm-cortex-m3m4/