AnsweredAssumed Answered

STM8L051F3 RTC Issue

Question asked by harvey.brian on Aug 2, 2017
Latest reply on Aug 3, 2017 by harvey.brian

I'm struggling to initialize the RTC on an STM8L051F3 microcontroller. I've used the exact code below on an STM8L151K6 microcontroller with no issues. The code hangs waiting for the LSI clock to be ready. Interrupts are disabled before calling the initialize function. Any ideas on what could be wrong? 

 

void RTC_Initialize(void)
{
// configures the RTC (Low Speed Internal RC is 38 kHz)
CLK_RTCClockConfig(CLK_RTCCLKSource_LSI, CLK_RTCCLKDiv_1);

// wait for LSI clock to be ready
while(CLK_GetFlagStatus(CLK_FLAG_LSIRDY) == RESET);     <------CODE HANGS HERE

CLK_PeripheralClockConfig(CLK_Peripheral_RTC, ENABLE);

RTC_WakeUpClockConfig(RTC_WakeUpClock_RTCCLK_Div16);

RTC_ITConfig(RTC_IT_WUT, ENABLE);

Outcomes