We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi,
i want to understand how the startup of a cortex M3 works. When i debug the startup i saw that from adress 0x0 a big area with DCW comes, like here:
Later followed from that:
but if i debug i saw that this section was first excuted:
Can anybody explain me how the startup exactly works and what is the meaning of the DCW part?
So which assembler directive calls the SystemInit?
Best regards
Volker
Hi Vokuit,
The start up mechanism of a Cortex-M3 is very simple. It loads the initial value of the stack pointer (MSP) from the first word of the vector table and sets the initial value of the program counter (PC) from the second word. The only slight trick to remember is that function addresses must always have the LSB set to 1 (to indicate that the target instruction is in Thumb), so the first two words you are seeing are:
0x20000268 - the initial value of the stack pointer
0x00000505 - sets the initial PC to 0x00000504
If you then look down at what is at t hat address, you will find the instructions:
LDR R0, =SystemInit ; sets R0 to the value SystemInit
BLX R0 ; calls the function at the address in R0
It is this pair of instructions which calls the SystemInit function. When that function returns, you can see a similar pair of instructions which calls __main. This is the main entry point of the library and eventually the application will be called at main().
I hope that gives you a start in working out what's going on!
I would encourage you to have a look at the Cortex-M3 Devices Generic User Guide which you can find on infocenter.arm.com (along with a lot of other very useful documentation). Specifically, section 2.3.4 (Vector Table) shows the contents of the first two words which I mentioned above.
Hope this helps.
Chris
Thanks for this information,
yesterday i search 3-4 hours for details about that.
For a newbie in the arm world it is not so easy to find the searched information. For some topics there is to much information in the www but for some i can't find something useful.