2022-08-20 10:03 AM
Hi guys,
I am working with the LoRaWAN_End_Node example provided in STM32WL SDK. I want to set up the calendar and get the time and date. The example itself initializes the RTC in rtc.c. Then I set the time and date and I call getTime and getDate from the main.c
My problem is that the time does not update and the seconds are always 0 as shown in the image below.
However, when I create a fresh new project the calendar works fine. But when I work with the End_Node example it doesn't. I have also read AN5406 but I didn't find any related information.
Any help?
rtc.c file
/* USER CODE BEGIN 1 */
void setTime(void) {
sTime.Hours = 16;
sTime.Minutes = 0;
sTime.Seconds = 0;
sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
sTime.StoreOperation = RTC_STOREOPERATION_RESET;
if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BIN) != HAL_OK) {
Error_Handler();
}
}
void setDate(void) {
sDate.WeekDay = RTC_WEEKDAY_SATURDAY;
sDate.Month = RTC_MONTH_AUGUST;
sDate.Date = 13;
sDate.Year = 0;
if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BIN) != HAL_OK) {
Error_Handler();
}
}
void getTime(void) {
HAL_RTC_GetTime(&hrtc, &sTime, RTC_FORMAT_BIN);
}
void getDate(void) {
HAL_RTC_GetDate(&hrtc, &sDate, RTC_FORMAT_BIN);
}
/* USER CODE END 1 */
main.c
while (1) {
getTime();
getDate();
HAL_Delay(1000);
}
debugging
2022-09-29 12:51 AM
Thank you @GLee.12, I will check this out!!