Prevent lockup on boot in case of 32kHz oscillator failure (fix #5294)
This commit is contained in:
@@ -64,7 +64,15 @@ void rtcInit()
|
|||||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
|
||||||
PWR_BackupAccessCmd(ENABLE);
|
PWR_BackupAccessCmd(ENABLE);
|
||||||
RCC_LSEConfig(RCC_LSE_ON);
|
RCC_LSEConfig(RCC_LSE_ON);
|
||||||
while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET);
|
|
||||||
|
// Prevent lockup in case of 32kHz oscillator failure
|
||||||
|
uint32_t i = 0;
|
||||||
|
while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
|
||||||
|
{
|
||||||
|
if ( ++i > 1000000 )
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
|
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
|
||||||
RCC_RTCCLKCmd(ENABLE);
|
RCC_RTCCLKCmd(ENABLE);
|
||||||
RTC_WaitForSynchro();
|
RTC_WaitForSynchro();
|
||||||
|
|||||||
Reference in New Issue
Block a user