STM32L151ZETx: Optimizing Initialization Time (Power-On to while(1))
Target MCU: STM32L151ZETx (LQFP144)
Main Clock Frequency: 32 MHz
When the MCU is first powered on, it takes about 41 ms to reach the while(1) loop in the main() function, based on the code shown below.
For my product requirements, I would like this startup time (from power-on to reaching while(1)) to be reduced to around 16 ms.
Is there any way to achieve this reduction? Any suggestions or optimization techniques would be greatly appreciated.
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "adc.h"
#include "dma.h"
#include "rtc.h"
#include "tim.h"
#include "usart.h"
#include "gpio.h"
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
int main(void)
{
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_ADC_Init();
MX_TIM5_Init();
MX_TIM2_Init();
MX_TIM3_Init();
MX_TIM4_Init();
MX_TIM6_Init();
MX_RTC_Init();
MX_USART1_UART_Init();
MX_USART3_UART_Init();
/* Start timers */
HAL_TIM_Base_Start_IT(&htim2); // TIMER2(100us)
HAL_TIM_Base_Start_IT(&htim5); // TIMER5(1ms)
HAL_TIM_Base_Start_IT(&htim3); // TIMER3(10ms)
HAL_TIM_Base_Start_IT(&htim4); // TIMER4(20ms)
HAL_TIM_Base_Start_IT(&htim6); // TIMER6(1440Hz)
HAL_TIM_PWM_Start(&htim5, TIM_CHANNEL_1);
/* Infinite loop */
while (1)
{
}
Edited to apply source code formatting as recommended in this guideline How to insert source code.
