Electrical – LSE fail to enable

clockstm32

I am using a blue pill with STM32F103C8 and I am trying to debugg my programm but every time it is stack in the activation of the LSE clock (LL_RCC_LSE_IsReady() != 1)

I have the following system clock configuration:

/* Set FLASH latency */
/* How many clock cycles should SYSCLK wait to access flash memory */
LL_FLASH_SetLatency(LL_FLASH_LATENCY_2);

/* Enable HSE oscillator */
LL_RCC_HSE_Enable();
while (LL_RCC_HSE_IsReady() != 1) {
};

/* Enable LSE oscillator */
LL_PWR_EnableBkUpAccess();
LL_RCC_ForceBackupDomainReset();
LL_RCC_ReleaseBackupDomainReset();
LL_RCC_LSE_Enable();
while (LL_RCC_LSE_IsReady() != 1) {
};

/* Main PLL configuration and activation */
LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE_DIV_1, LL_RCC_PLL_MUL_9);
LL_RCC_PLL_Enable();
while (LL_RCC_PLL_IsReady() != 1) {
};

/* Sysclk activation on the main PLL */
LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1);
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL);
while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) {
};

/* Set APB1 & APB2 prescaler*/
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 72MHz */
LL_Init1msTick(72000000);

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

Can anyone understand why?

Best Answer

I find the solution:

LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);
LL_PWR_EnableBkUpAccess();
LL_RCC_ForceBackupDomainReset();
LL_RCC_ReleaseBackupDomainReset();
LL_RCC_LSE_Enable();

I should first enable the peripheral power bus(LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR))