cancel
Showing results for 
Search instead for 
Did you mean: 

RTC Not Working Correctly with FreeRTOS

LeonSu
Associate II

Hello everyone!

We are trying to enable the RTC with FreeRTOS on the STM32U575AII6. The settings are as follows:

1.RCC

LeonSu_1-1754446923860.png

2.RTC

LeonSu_2-1754447015510.png

3.Clock

LeonSu_3-1754447140369.png

4.freeRTOS

LeonSu_4-1754447353395.png

Code

void Debug_Printf(char *format, ...)
{
	char buf[128];

	va_list args;
	va_start(args, format);
	uint16_t len = vsnprintf((char *)buf, sizeof(buf), (char *)format, args);
	va_end(args);
	HAL_UART_Transmit(&huart1 ,(uint8_t *)buf,len,150);
}

void RTCTask(void *argument)
{
  /* USER CODE BEGIN RTC_TASK */
	RTC_DateTypeDef Date;
	RTC_TimeTypeDef Time;
  /* Infinite loop */
  for(;;)
  {
	HAL_RTC_GetTime(&hrtc, &Time, RTC_FORMAT_BIN);
	HAL_RTC_GetDate(&hrtc, &Date, RTC_FORMAT_BIN);
	Debug_Printf("%02d:%02d:%02d\n",Time.Hours, Time.Minutes, Time.Seconds);
	osDelay(1000);
  }
  /* USER CODE END RTC_TASK */
}

 and the result output

"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:01\n"
"10:10:02\n"
"10:10:02\n"
"10:10:02\n"
"10:10:02\n"
"10:10:02\n"

The seconds displayed above are wrong.

Any suggestions would be greatly appreciated. Thanks in advance!

 

 

 

 

 

 

 

1 REPLY 1
TDK
Super User

Is the rate of printing (once per second) correct?

If you clock it with LSI, does it work as expected? If so, LSE isn't working right.

If you feel a post has answered your question, please click "Accept as Solution".