Microcontroller Boot Process

The microcontroller boot process is the sequence of events that occurs when a microcontroller is turned on or reset. The boot process typically includes the following steps:

  1. Power-on reset. When power is applied to the microcontroller, the reset pin is pulled low. This causes the microcontroller to enter a reset state.
  2. Fetching the reset vector. The microcontroller’s processor fetches the address of the reset vector from a special location in memory called the reset vector address.
  3. Executing the reset vector. The processor executes the instructions at the reset vector address. These instructions typically initialize the microcontroller’s hardware and prepare it for operation.
  4. Calling the main function. The processor calls the main function of the user’s application code. This is where the user’s application code begins execution.

The exact steps involved in the microcontroller boot process may vary depending on the specific microcontroller. However, the general steps outlined above are common to all microcontrollers.

Here is a more detailed explanation of each step in the microcontroller boot process:

Power-on reset

When power is applied to the microcontroller, the reset pin is pulled low. This causes the microcontroller to enter a reset state. In this state, the microcontroller’s processor is halted and its memory is erased.

Fetching the reset vector

The microcontroller’s processor fetches the address of the reset vector from a special location in memory called the reset vector address. The reset vector address is typically 0x0000.

Executing the reset vector

The processor executes the instructions at the reset vector address. These instructions typically initialize the microcontroller’s hardware and prepare it for operation. Some of the tasks that may be performed during the reset process include:

  • Configuring the clock system
  • Initializing the memory system
  • Configuring the peripherals
  • Clearing the uninitialized data segment
  • Setting the stack pointer

Calling the main function

The processor calls the main function of the user’s application code. This is where the user’s application code begins execution. The main function is typically the first function that is called when the microcontroller is booted up.

The microcontroller boot process is a complex and important process. It is essential that the boot process is performed correctly in order for the microcontroller to operate properly.

Sample code:

// Declare the reset handler as the entry point for the application
void Reset_Handler(void);

// Define the vector table with the reset handler as the first entry
__attribute__((section(".isr_vector")))
void(*const g_pfnVectors[])(void) = { (void(*)(void))((uint32_t) &_estack),	// The initial stack pointer
	Reset_Handler,	// The reset handler
	// Other exception handlers
};

// The reset handler implementation
void Reset_Handler(void)
{
	// Initialize the system clock and peripheral clocks
	SystemInit();

	// Enable the FPU if present
	#
	ifdef __FPU_PRESENT
	SCB->CPACR |= ((3 UL << 10 *2) | (3 UL << 11 *2));#
	endif

	// Initialize global data variables
	uint32_t *pSrc = &_sidata;
	for (uint32_t *pDest = &_sdata; pDest<&_edata;)
	{
		*pDest++ = *pSrc++;
	}

	// Zero-initialize global and static variables
	for (uint32_t *pDest = &_sbss; pDest<&_ebss;)
	{
		*pDest++ = 0;
	}

	// Call the application entry point
	main();
}
  1. The MCU is powered on.
  2. The MCU checks the voltage rails to ensure that they are within the correct range.
  3. The MCU initializes the oscillator.
  4. The MCU copies the reset vector from flash memory to RAM.
  5. The MCU executes the instructions in the reset vector.
  6. The MCU initializes the peripherals.
  7. The MCU calls the main() function of the user’s application.

The MCU boot process is a critical part of ensuring that the MCU starts up correctly. If any of the steps in the boot process fail, the MCU may not start up correctly or may not function properly.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s