STM32F4xxx RTC coming soon !

Limited support for STM32F4 Discovery, Nucleo and custom F4 boards
Post Reply
User avatar
martinayotte
Posts: 1229
Joined: Mon Apr 27, 2015 1:45 pm

STM32F4xxx RTC coming soon !

Post by martinayotte » Wed Dec 02, 2015 5:32 pm

Hi folks,

Few weeks ago, I start digging into RTC when I figured out that RTC in F1 and F4 are far from each other.
F1 is mainly a "seconds counter" while F4 is a real BCD oriented RTC with several alarms and timers.
I've start developping a new RTClock library, messing also with the BKP and RCC settings.
Suddenly, my working code stopped to work ... :(
It took me days to figure out other issue by starting from scratch the debugging of the clock init.
I figured out that even if I tried to change clock source, it didn't have any clock, until I found that Backup Domain need to be reset each time the clock source was changed.

Anyway, I'm posting here just to let you know that I will probably push the current prototype soon and send a PR to Roger.
Of course, it won't be complete, but at least the basics will be there.

User avatar
RogerClark
Posts: 7136
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: STM32F4xxx RTC coming soon !

Post by RogerClark » Wed Dec 02, 2015 9:05 pm

Martin

Thanks for the update

User avatar
martinayotte
Posts: 1229
Joined: Mon Apr 27, 2015 1:45 pm

Re: STM32F4xxx RTC coming soon !

Post by martinayotte » Thu Dec 03, 2015 1:39 am

I'm still struggling with Alarm and Periodic WakeUp interrupts, but I think I will push the basics, which are setTime() and getTime().
The interrupt handling is maybe not related to this library, but maybe to NVIC and/or EXTI. I need to dig further.

User avatar
martinayotte
Posts: 1229
Joined: Mon Apr 27, 2015 1:45 pm

Re: STM32F4xxx RTC coming soon !

Post by martinayotte » Thu Dec 03, 2015 3:50 am

I've done my initial commit of RTClock library for F4 !
It has been merged by Roger ! Thanks, Roger !
It is only provide setTime() and getTime() for now, the Alarm and Periodic interrupts are not working yet.

User avatar
martinayotte
Posts: 1229
Joined: Mon Apr 27, 2015 1:45 pm

Re: STM32F4xxx RTC coming soon !

Post by martinayotte » Fri Dec 04, 2015 12:46 am

PeriodicWakeup and AlarmA/AlarmB is now working !
I've probably found a bug in Paul Stoffregen Time library while doing some test, it seems that setTime() with time_t and the other with hr/min/sec/dy/mnth/year is producing a time_t of a week difference. I was thinking this was a bug on my side, but it doesn't seems too ...
Further steps will be to add the TimeStampAlarm, which provides the DayOfWeek trigger which the AlarmA/AlarmB doesn't provide.

EDIT : the 7 days difference issue was finally in my code, missing 7 days from leap years between 1970 and 2000 in "time_t getTime()".

User avatar
martinayotte
Posts: 1229
Joined: Mon Apr 27, 2015 1:45 pm

Re: STM32F4xxx RTC coming soon !

Post by martinayotte » Sat Dec 05, 2015 2:26 am

I've looked at TimeStampInterrupt and figured out that there is no hurry to handle it for now except if someone as emergency needs.
So, the current state of RTClock for STM32F4 should now be declared as "stable" ! :)

User avatar
ahull
Posts: 1627
Joined: Mon Apr 27, 2015 11:04 pm
Location: Sunny Scotland
Contact:

Re: STM32F4xxx RTC coming soon !

Post by ahull » Sat Dec 05, 2015 12:49 pm

Are any of your changes applicable to the other members of the STM32 family?
- Andy Hull -

User avatar
martinayotte
Posts: 1229
Joined: Mon Apr 27, 2015 1:45 pm

Re: STM32F4xxx RTC coming soon !

Post by martinayotte » Sat Dec 05, 2015 2:36 pm

Hi Andy,
Do you means other F4xx ? of course !
Others STM32 ? Not F1xxx, since the RTC is completely differents. Some STM32 have Real Time Counter, some other have Real Time Clock, meaning some are simply 32 bits counters and some other have full BCD registers with several match compares. For example, in my new lib, the setAlarmA() and setAlarmB have arguments for date match, hours match and minutes match, so the alarms can be triggered with full time/date match (even with year), but also can be a match of seconds/minutes every hours.

stevestrong
Posts: 1735
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

[libmaple] STM32F4 RTC update is here

Post by stevestrong » Mon Jul 10, 2017 5:10 pm

Hi all,

I know this is a long forgotten thread, but I would like to inform you about an update.
I have re-worked the RTC library (thanks for the good work, Martin!) so that the attached RTC lib is independent from other time libraries, and it includes most utility functions of the Time lib from Paul (https://github.com/PaulStoffregen/Time).

The supported time related functions can be identified from the RTC header file.
There is one small difference, the equivalent of function "now()" is here "getTime()" returning the current epoch time from RTC.

I post it here because there are two different PRs pending by Roger which all includes my current master image, and don't want to start another identical one. And I don't want to overload these PRs.
I wouldn't mind if someone could test this and send a PR to Roger if it works.

The zip file contains also an example how to use the RTC lib. The sketch allows the RTC time update either from user serial input, or over serial sync using a Processing sketch: https://github.com/PaulStoffregen/Time/ ... duinoClock.

Enjoy.

P.S. In the example sketch I used the ArduinoStreaming library (which is actually consisting of one header file only), which I found very useful.
Alternatively, you can place the attached header file to the RTC src folder.

EDIT
I removed the lib because it needs a small fix. I will post it again when it is fixed.

EDIT 2
I attached it again, now it should be ok.

EDIT 3
PR requested: https://github.com/rogerclarkmelbourne/ ... 2/pull/315
Attachments
RTClock.zip
(10.4 KiB) Downloaded 21 times
Streaming.h
(3.47 KiB) Downloaded 12 times

Post Reply