This paper introduces in detail STM32 The process of single chip microcomputer starting , Power on from Reset_Handle Jump to main() Process of function . among , Will focus on explanation __main Assembly code for

<>STM32 Start process

<>1. from Reset_Handler Start

Reset_Handler The code of is as follows , reference resources 《startup_stm32f10x_hd.s》

1- calculation SystemInit Function entry address , And put the address load reach R0;
R0 = [PC + 24] = [0x08000144 + 24 +4] = [0x08000160] = 0x08000495

2 – implement r0 Function pointed to , as well as SystemInit(); meanwhile , The address of the next instruction ( as well as PC+4) Save to lr(r14) in
3 – calculation __main Entry address of , and load reach r0

4 – implement __main()

<>__main Implementation process of

* __main Function content

* SP(R13) assignment
SP = [pc +12 +4] = [0x08000130 + 12 + 4] = [0x08000140] = 0x20000408

* implement __scatterload() ( address 0x08000168), and load R14, lr = 0x08000139

<>__scatterload Function execution process

<>__scatterload_copy Execution process

<>__scatterload_zeroinit Execution process

<>__main_after_scatterload Execution process

Technology