cancel
Showing results for 
Search instead for 
Did you mean: 

the boot time of 60ms is too long for STM32L031K6 with the Nucleo EVK

Rob Wei
Associate
Posted on November 28, 2017 at 04:08

Dear there,

 I'm using the Nucleo STM32L031K6 EVK as a 12MHZ SPI slave in my application. Now I found it takes about 60ms from VDD ready to finishing excetution of below code snippet so the SPI slave misses some cmd of SPI master. How can I reduce the boot time to below 20ms(lesser is better)? Thank you very much.

   HAL_Init();

  /* Configure the system clock to 32 MHz */

  SystemClock32m_Config();

  MX_GPIO_Init();

//============================

void SystemClock32m_Config(void)

 

{

 

 

  RCC_OscInitTypeDef RCC_OscInitStruct;

 

  RCC_ClkInitTypeDef RCC_ClkInitStruct;

 

  RCC_PeriphCLKInitTypeDef PeriphClkInit;

 

 

    /**Configure the main internal regulator output voltage

 

    */

 

  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

 

 

    /**Initializes the CPU, AHB and APB busses clocks

 

    */

 

  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;

 

  RCC_OscInitStruct.HSIState = RCC_HSI_ON;

 

  RCC_OscInitStruct.HSICalibrationValue = 16;

 

  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

 

  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;

 

  RCC_OscInitStruct.PLL.PLLMUL = RCC_PLLMUL_4;

 

  RCC_OscInitStruct.PLL.PLLDIV = RCC_PLLDIV_2;

 

  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

 

  {

 

    Error_Handler(__FILE__, __LINE__);

 

  }

 

 

    /**Initializes the CPU, AHB and APB busses clocks

 

    */

 

  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK

 

                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;

 

  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;

 

  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

 

  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;

 

  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

 

 

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)

 

  {

 

    Error_Handler(__FILE__, __LINE__);

 

  }

 

 

  PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_I2C1;

 

  PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1;

 

  if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)

 

  {

 

    Error_Handler(__FILE__, __LINE__);

 

  }

 

 

    /**Configure the Systick interrupt time

 

    */

 

  HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);

 

 

    /**Configure the Systick

 

    */

 

  HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);

 

 

  /* SysTick_IRQn interrupt configuration */

 

  HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);

 

}

 

#stm32 #spi #boot-time
5 REPLIES 5
Rob Wei
Associate
Posted on November 29, 2017 at 11:07

Hi There,

 I have new finding today. Actually, on the entry of the main() it already takes about 60ms.

 So what happen before that? I went through the Reset_Handler and found it just call SystemInit before branching into main( ). And the SystemInit looks simple. So how does the 60mS come from? Any idea is appreciated.

Marcus Peter
Associate
Posted on February 09, 2018 at 11:39

Hi There,

I have the same problem with stm32L452. From reset to main it takes more than 4ms which is too long for my apllication. Have you found a solution for the long boot time ?

Posted on February 09, 2018 at 17:44

Probably by running off the MSI clock it started with rather than enable and wait for other clocks and PLLs to start?

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
henry.dick
Senior II
Posted on February 09, 2018 at 20:00

'

How can I reduce the boot time to below 20ms(lesser is better)?

 '

not sure how you measured it but it is entirely possible that the actual time is considerably shorter / longer than what you thought it was.

with that said, a few things will help you speed up the process:

1) use an external oscillator - hopefully with a quick start-up time.

2) disable PLL.

3) roll your own configuration code so you don't incur the library related bloat. 60ms for a 32-bit chip is like enternity.

4) the most effective: start your chip first before anything else.

...

T J
Lead
Posted on February 10, 2018 at 02:02

If you have a low impedance power supply,

the 3V rise time would be sharper,

then your reset would be quicker.

but you may only gain 10-20mS.