cancel
Showing results for 
Search instead for 
Did you mean: 

Calculation of RTC in certain months(Months with 31)

baris.akpinar
Associate II

Hello everyone,
In my sample project I have created, RTC does not perceive certain months as 31 days. Although it is 31 days in July, October, December, I took the same result in my essays with a code sample with an RTC code.I don't have problems in January, March, and August.
What are your ideas?

 

July 30 -> 01 august (Problem)

Func:

HAL_RTC_SetTime(&hrtc,&updateTime,RTC_FORMAT_BIN);
HAL_RTC_SetDate(&hrtc,&updateDate,RTC_FORMAT_BIN);

Card I used: F407VG 168mhz 

1 ACCEPTED SOLUTION

Accepted Solutions

Did you fix your code?

Not sure what you're looking for here. The off-by-one error was clearly the issue.

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

View solution in original post

8 REPLIES 8
TDK
Guru

Sure you're not setting the month off by 1? What is your code to set the date to july 30th?

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

 

I set up RTC for the time I wanted and then read it.

updateTime.Seconds=SECONDS; // 45
updateTime.Minutes=MINUTES; // 59
updateTime.Hours =HOUR; //23
 
updateDate.Date = DAY; // 30
updateDate.Month = MONTH; // 06
updateDate.Year = YEAR;
 
HAL_RTC_SetTime(&hrtc,&updateTime,RTC_FORMAT_BIN);
HAL_RTC_SetDate(&hrtc,&updateDate,RTC_FORMAT_BIN);
TDK
Guru

July is 7, not 6.

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

My problem is still going on.

With MONTH = 7?

JW

Did you fix your code?

Not sure what you're looking for here. The off-by-one error was clearly the issue.

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

July = 6(Including zero)

My problem was solved, it was wrong to start the months, including zero.Thanks. I'm sorry for my bad english.