Question
RTC on B-L475E-IOT01A.
At evening I set time 18-38-00, got it back, it was OK and left it to run. At morning I see the time 32-59-48.
My set-get functions
int RTC_SetTime(uint8_t hours, uint8_t minutes, uint8_t seconds)
{
if (hours < 24 && minutes < 60 && seconds < 60)
{
LL_RTC_DisableWriteProtection(RTC);
if (Enter_RTC_InitMode() != RTC_OK)
return RTC_ERROR;
LL_RTC_TIME_Config(RTC, LL_RTC_TIME_FORMAT_AM_OR_24, __LL_RTC_CONVERT_BIN2BCD(hours),
__LL_RTC_CONVERT_BIN2BCD(minutes),
__LL_RTC_CONVERT_BIN2BCD(seconds));
if (Exit_RTC_InitMode() != RTC_OK)
return RTC_ERROR;
LL_RTC_EnableWriteProtection(RTC);
}
else
return RTC_ERROR;
return RTC_OK;
}
int RTC_GetTime( uint8_t *hours, uint8_t *minutes, uint8_t *seconds)
{
*hours = __LL_RTC_CONVERT_BCD2BIN(LL_RTC_TIME_GetHour(RTC));
*minutes = __LL_RTC_CONVERT_BCD2BIN(LL_RTC_TIME_GetMinute(RTC));
*seconds = __LL_RTC_CONVERT_BCD2BIN(LL_RTC_TIME_GetSecond(RTC));
return 0;
}