So we specify the address of our Reset Handler which is the first code it will execute. Then it copies the next entry into PC (Program counter) and the execution starts from this address. During the startup operation, the ARM Cortex-M processor copies the first entry in the vector table to the stack pointer (which is the Main Stack Pointer or MSP). ![]() The vector table and especially the first two entries in it are essential for the ARM Cortex-M startup code to start executing application program and handle stacking operations. The list continues up to FPU_IRQHandler (Flash point Unit IRQ). These interrupts are connected to various peripherals in the MCU such as Watchdog, DMA, RTC etc. Here external refers to Arm processor and not the MCU STM32. Following these processor exceptions are the external interrupts. These are the first 15 exceptions starting from Reset_Handler up to SysTick_Handler. ARM Cortex-M processor provides some default exceptions. Exception Handlers Declarationįollowing the reset handler are the starting addresses of various exception handlers such as NMI_Handler, HardFault_Handler and so on. (The assembler processes the file in two passes which helps it to resolve such forward references). This is a forward reference because the label Reset_Handler is declared somewhere down the code. Similarly the next word stored is the address of Reset_Handler. Let’s look at the Vector table contents in detail. Starting addresses of all other exceptions and interrupts including the NMI handler, Hard fault handler and so on.Starting address of the reset handler (Reset handler is the code executed on reset).The Vector table in the ARM Cortex-M startup code contains the following things. This value is also specified in linker options - either in a scatter file or by command line linker options. You can get this detail from the memory map from the STM32F4 datasheet. Since the vector table offset register VTOR defaults to 0, the processor uses this vector table at startup. This places the vector table at offset 0. The RESET area is located at start of the CODE section of the flash memory. ![]() This makes sure that the application code is not able to overwrite this area. This is true because the vector table contains only the addresses of the handlers and initial stack pointer value.Īnother attribute is READONLY. The attribute DATA indicates that this section will contain data and not instructions. The ARM Cortex-M startup code defines stack area with following code.ĪREA directive denotes the RESET section. ![]() Stack is an area used for temporary storage of variables and register contents during code execution. If you would like to go deeper in assembly programming, then the ARM assembler user guide is your best friend. This blog post contains brief explanation of the syntax and code involved. Remember that this startup code is completely in assembly language. We can divide the ARM Corte-M startup code broadly in 5 different sections. This post was originally published in ARM Community. You can download the startup code file from this Keil website. Note that the code uses ARM assembly directives. To be precise the startup code is for STM32F4 – an ARM Cortex-M4 based micro-controller. It uses ARM assembler with the Keil MDK-ARM toolsuite. This post referst to the startup code in the ST Microelectronics software pack.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |