A typical 32-bit Cortex-M part has just left power-on reset. What does the core read first?
- (A)
The first instruction of main(), at address 0x00000000
- (B)
The word at 0x00000000 as the initial stack pointer, then the word at 0x00000004 as the address of the reset handler
- (C)
The word at 0x00000000 as the address of the reset handler, then the word at 0x00000004 as the initial stack pointer
- (D)
The starting values of initialised variables, which it copies from flash to RAM
Answer and solution
Answer: (B)
After reset the core reads the reset vector.
On a typical Cortex-M part, the word at 0x00000000 is the initial stack pointer.
The word at 0x00000004 is the address of the reset handler, which is startup code.
main() is called last by startup code, and the copy of initial values is done by startup code, so A and D are wrong. C swaps the two words.