cancel
Showing results for 
Search instead for 
Did you mean: 

About PWR activation when setting clock

treeset
Associate II

 

void SystemClock_Config(void)
{  
	LL_FLASH_SetLatency(LL_FLASH_LATENCY_4);
	while(LL_FLASH_GetLatency() != LL_FLASH_LATENCY_4);

#if 1
	LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);
#endif

	LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1); //Low power mode
	while(LL_PWR_IsActiveFlag_VOS() != 0);

#ifdef _CLOCK_HSE_VER
	/* HSE configuration and activation */  
	LL_RCC_HSE_Enable();  
	while(LL_RCC_HSE_IsReady() != 1);   
#endif	
#ifdef _CLOCK_MSI_VER
	/* MSI configuration and activation */  
	LL_RCC_MSI_Enable(); 
   	while(LL_RCC_MSI_IsReady() != 1);  
#endif

	/*LSI configuration and activation*/
	LL_RCC_LSI_Enable();
	while(LL_RCC_LSI_IsReady() != 1);

	/* Main PLL configuration and activation */  
#ifdef _CLOCK_HSE_VER
	LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLM_DIV_1, 10, LL_RCC_PLLR_DIV_2);  
#endif
#ifdef _CLOCK_MSI_VER
	LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_MSI, LL_RCC_PLLM_DIV_1, 40, LL_RCC_PLLR_DIV_2);  
#endif

	LL_RCC_PLL_EnableDomain_SYS(); 
	LL_RCC_PLL_Enable();  
	while(LL_RCC_PLL_IsReady() != 1);   
  
	/* Sysclk activation on the main PLL */  
	LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL);  

	while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL);  
  
	/* Set APB1 & APB2 prescaler*/ 
	LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1);  
	LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_2);  
	LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1);  
	/* Set systick to 1ms in using frequency set to 80MHz */  
	/* This frequency can be calculated through LL RCC macro */  
	/* ex: __LL_RCC_CALC_PLLCLK_FREQ(__LL_RCC_CALC_MSI_FREQ(LL_RCC_MSIRANGESEL_RUN, LL_RCC_MSIRANGE_6),LL_RCC_PLLM_DIV_1, 40, LL_RCC_PLLR_DIV_2)*/

	/* Update CMSIS variable (which can be updated also through SystemCoreClockUpdate function) */  
	LL_SetSystemCoreClock(80000000);
}

 

 

The above code is the clock setting code. But what I'm curious about is whether there is a difference between calling the PWR activation code and not calling it. First of all, we confirmed that it works even when there is no PWR activation code, but there are cases where a reset phenomenon occurs. If you know the answer, please let me know. The MCU is using STM32L452REY6TR.

 

0 REPLIES 0