Hi,
I noticed an issue that the weekday is reported differently for the same date written to the RTC on various platforms.
Specifically, I compared a STM32F1 (RTCv1) and STM32F4 (RTCv2) and the latter reports one day off, e.g. stating that a date is a Friday although it ought to be Thursday.
Is it just me (so I have to check my configs once again), or can others reproduce this behavior?
In case I missed something in my code, the thread can be closed
Otherwise it should be moved to bug reports, though.
Best regards,
Thomas
RTC inconsistent weekday Topic is solved
- Giovanni
- Site Admin
- Posts: 14455
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: RTC inconsistent weekday
It could be a bug, RTCv1 hasn't been used much, just F1 used it.
Giovanni
Giovanni
-
- Posts: 135
- Joined: Wed Feb 04, 2015 5:03 pm
- Location: CITEC, Bielefeld University, germany
- Has thanked: 15 times
- Been thanked: 24 times
- Contact:
Re: RTC inconsistent weekday
Hi,
I did some more investigation and it seems, that it's just the other way around.
I am using the C tm structure only and the interface functions rtcConvertStructTmToDateTime(), rtcSetTime(), rtcGetTime(), and rtcConvertDateTimeToStructTm(). So everything that interacts with the hardware and does the calculation is on the ChibiOS-Level. When interpreting the well-defined struct tm data, the weekday is actually correct only for the F1 platform. I've tested an F4 and L4 and both have the offset of one weekday in "the future".
For me this seems as if RTCv2 has some issues, not v1. Or you optimized for the buggy v1 at the HAL level level and thereby broke the correct v2
Best regards,
Thomas
PS: For the C tm structure the weekday is defined to be a value in [0..6] as the number of days after Sunday (thus Monday = 1). The RTCDateTime struct defines the weekday just as a value in [1..7] with no further information. I could imagine that the error has something to do with that imprecise specification.
I did some more investigation and it seems, that it's just the other way around.
I am using the C tm structure only and the interface functions rtcConvertStructTmToDateTime(), rtcSetTime(), rtcGetTime(), and rtcConvertDateTimeToStructTm(). So everything that interacts with the hardware and does the calculation is on the ChibiOS-Level. When interpreting the well-defined struct tm data, the weekday is actually correct only for the F1 platform. I've tested an F4 and L4 and both have the offset of one weekday in "the future".
For me this seems as if RTCv2 has some issues, not v1. Or you optimized for the buggy v1 at the HAL level level and thereby broke the correct v2
Best regards,
Thomas
PS: For the C tm structure the weekday is defined to be a value in [0..6] as the number of days after Sunday (thus Monday = 1). The RTCDateTime struct defines the weekday just as a value in [1..7] with no further information. I could imagine that the error has something to do with that imprecise specification.
- Giovanni
- Site Admin
- Posts: 14455
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: RTC inconsistent weekday
It agree, it is the RTCv2 implementation to be wrong, I also found this in the code (forgot about it...).
So yes, it should be 1..7.
I fixed this in trunk only, it is possible that fixing this in stable branch would break things for people that just adapted to the bug.
Giovanni
Code: Select all
#define RTC_DAY_CATURDAY 0U
#define RTC_DAY_MONDAY 1U
#define RTC_DAY_TUESDAY 2U
#define RTC_DAY_WEDNESDAY 3U
#define RTC_DAY_THURSDAY 4U
#define RTC_DAY_FRIDAY 5U
#define RTC_DAY_SATURDAY 6U
#define RTC_DAY_SUNDAY 7U
So yes, it should be 1..7.
I fixed this in trunk only, it is possible that fixing this in stable branch would break things for people that just adapted to the bug.
Giovanni
Who is online
Users browsing this forum: No registered users and 22 guests