2023-04-30 03:33 AM
Hi everyone, Could u help me how to update RTC time n date using serial Usart. Example code will help me to better understand , the date n time stored in this variable
sTime.Hours = 0x00;
sTime.Minutes = 0x00;
sTime.Seconds = 0x00;
sDate.WeekDay = RTC_WEEKDAY_SATURDAY;
sDate.Month = RTC_MONTH_APRIL;
sDate.Date = 0x15;
sDate.Year = 0x23;
2023-04-30 04:27 AM
Do you want to program the RTC using CubeProgrammer over UART??
2023-04-30 05:26 AM
Collect bytes from the serial port to construct a string, break down with sscanf().
2023-05-01 07:41 PM
Hi , appreciate it, like this code?
while (1)
{
// Send a message to request the new date and time
HAL_UART_Transmit(&huart1, "Please enter the new date and time (YYYY-MM-DD HH:MM:SS):\r\n", strlen("Please enter the new date and time (YYYY-MM-DD HH:MM:SS):\r\n"), HAL_MAX_DELAY);
// Receive the new date and time from the user
HAL_UART_Receive(&huart1, usart_buffer, sizeof(usart_buffer), HAL_MAX_DELAY);
// Parse the received string to extract the year, month, day, hour, minute, and second values
int year, month, day, hour, minute, second;
sscanf(usart_buffer, "%d-%d-%d %d:%d:%d", &year, &month, &day, &hour, &minute, &second);