2024-06-30 09:29 PM
i am using STM3210E Eval board which has STM32F103 uC i am trying to recorded some adc value over the period of long time but with the time. I am using RTC to achieve that so that even in case pf power loss the adc might not get measured but the time stays correct. As per my cell holder's size in the board i am using CR1220 button cell of 3V and have changed the jumper to give cell volatge to VBAT of uC but the values i am getting out of RTC is not correct. It does stays even if main supply is off but the value itself is not correct for example it's seconds goes upto 90 and then next min comes up but on measuring that 90 seconds is actually 60s only where few steps are missed to like after72 it's directly 80. I haven't checked for min,hr and more but even so the value is totally incorrect. i mean just look at below.
i mean how can the year go to 36 and date to 41 and hours 33!!!. i mean why is it like this what changes do i need to make to get it right
PS: i had programmed it 2 days ago to match it at that time it was showing correct at that moment but two days later it's just this
Solved! Go to Solution.
2024-07-01 10:55 PM
Actually all it needed was to set the format into binary and voila it was there then upload it and then next time reupload it but with the below removed
RTC_TimeTypeDef sTime = {0};
sTime.Hours = 17;
sTime.Minutes = 6;
sTime.Seconds = 0;
if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BIN) != HAL_OK)
{
Error_Handler();
}
comment this and you are done.
now the problem is that it sets the time perfectly but the day month stuff is stays the one you set and that does not change. i tried doing the same with date,month stuff by removing it but then i got 1/1/0 date by default. what to do
2024-06-30 09:48 PM
In BCD hours 0x23 == 35
2024-06-30 10:17 PM - edited 2024-06-30 10:25 PM
but it isn't showing in hex, it is in decimal format. if I am viewing it wrong tell me how to get the correct data
2024-07-01 10:55 PM
Actually all it needed was to set the format into binary and voila it was there then upload it and then next time reupload it but with the below removed
RTC_TimeTypeDef sTime = {0};
sTime.Hours = 17;
sTime.Minutes = 6;
sTime.Seconds = 0;
if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BIN) != HAL_OK)
{
Error_Handler();
}
comment this and you are done.
now the problem is that it sets the time perfectly but the day month stuff is stays the one you set and that does not change. i tried doing the same with date,month stuff by removing it but then i got 1/1/0 date by default. what to do
2024-07-02 03:14 AM
Don't use Cube/HAL. Use epoch time and <time.h> facilities.
JW
2024-07-02 05:33 AM
is time.h readily available to use on cube ide or di need to add something....please elaborate whatever you are explaining
2024-07-02 06:15 AM
<time.h> is a standard C header for standard C library functions related to time and date. Read some basic C literature for explanations of these functions.
Use the RTC counter as a time_t type variable, i.e. number of seconds since 1.1.1970.
JW