Cortex-M0 initialization | Minimum requirements

Hi there,

I am on the learning curve of embedded software development with the Cortex-M0. I have a question that has no practical application but for learning purpose. I am interested in the minimal SW requirements to initialize the Cortex-M0 core.

For this question, I define the minimum requirements as those that get the core to a state where the clock tree is running at target frequencies and the core is ready to start configuring the rest of the microcontroller.

Is the following sufficient to get to this stage?

1. Vector table
2. Reset handler

With these two, the stack pointers MSP, PSP, and the clock tree can be initialized.

Is there a case, at this stage, when the NMI or Hard fault handlers or other system handlers may be needed?


Any recommendations for reading on this topic?

Thank you.

  • From the CPU point of view, only the stack pointer and reset handler NEED to be set, as these are architecturally defined as being the first two entries of the vector table, and hence the address of the first instruction executed.

    Depending on the device you are using to run the code, there are likely system specific requirements.

    Fault handlers only NEED to be defined if the system will generate such events (though at least a dummy 'branch to self' handler is generally recommended to be implemented).

    Are you familiar with CMSIS-Packs, which provide default init code for very many Arm based devices, including an arbitrary Cortex-M0.
    Both Keil and IAR toolchains support these 'out-of-the-box'.

    https://www.keil.arm.com/devices/arm-armcm0/boards/

  • Hi Ronan,

    Thank your answer. It helps a lot.

    I started with CMSIS and it explains a lot. I came to my question from CMSIS (I have a drawback - I like details). I want to develop a view of what happens at the HW side.

    That might seem like a raw analogy, but to make this view, I see a CPU as a "plant/factory" and its startup procedure:

    1. Power supply -> Stable.
    2. PoR -> Done
    3. "Startup" oscillator -> Drives initialization
    4. Initialization -> Configures "main" clock oscillator and tree
    5. And so on with the focus on the HW block and how it can be done with Assembly.