So I am using a smart phone application to set the Time
and Date
of the RTC on the micro-controller. The RTC runs on LSE.
The formatting of the string that I sent over to the micro-controller is correct. I can be certain of that when I set the relevant variables on "Watch 1". I am using Keil uVision 5.
/**
* @brief RTC Date structure definition
*/
typedef struct
{
uint8_t WeekDay; /*!< Specifies the RTC Date WeekDay.
This parameter can be a value of @ref RTC_WeekDay_Definitions */
uint8_t Month; /*!< Specifies the RTC Date Month (in BCD format).
This parameter can be a value of @ref RTC_Month_Date_Definitions */
uint8_t Date; /*!< Specifies the RTC Date.
This parameter must be a number between Min_Data = 1 and Max_Data = 31 */
uint8_t Year; /*!< Specifies the RTC Date Year.
This parameter must be a number between Min_Data = 0 and Max_Data = 99 */
}RTC_DateTypeDef;
So my command that I sent over actually sets the DD/MM/YY and of course the time as well but I have no issues with time.
After setting it and then calling HAL_RTC_GetDate
and HAL_RTC_GetTime
, everything is correct except for the Year
field.
My command that I send over will always be year 2018 however the HAL_RTC_GetTime
function will always return a higher and random value such as 24, 22, 21 and 19. Occasionally, after sending a few times of the same command but with different mins and seconds, the Year will go back to 18...
What could be the issue? Also, must I set the WeekDay
parameter since I only set the Day
, Month
and Year
.
Thank you!
*I have a function that will help me take the last two digit of the year 2018 which I send over and it will push the value of 18 to the micro-controller.