stm32duino / STM32RTC

Arduino RTC library for STM32.
127 stars 48 forks source link

[Enhancement] Implement RTC Seconds Interrupt for STM32F1xx #42

Closed josh-gaby closed 2 years ago

josh-gaby commented 3 years ago

Implement the built-in Seconds interrupt functionality

Currently working for stm32f1xx only as the core code is already in place. I would like to implement this feature for all variants but the core HAL drivers for each variant would need to be updated to enable the seconds interrupt.

Requires core > 1.9.0 so that rtc.h and rtc.c are included from this library.

EDIT It looks like this interrupt is not available on other variants. For all variants that don't support the Seconds Interrupt, this could be implemented using AlarmB since its not currently accessible, might need to be able to choose between enable Seconds Interrupts or enable AlarmB to make it safe on these variants if AlarmB is going to be implemented in a future version though?

_Using RTC in F0, F2, F3, F4 and L1 App note AN3371_

josh-gaby commented 3 years ago

@fpistm What do you think about the idea of implementing a seconds interrupt using alarm B on other variants?

fpistm commented 3 years ago

Well second interrupt for all should be fine for all series but to keep genericity this should not be dependent of a dedicated alarm. And it is planned to support second alarm for all supported mode.

josh-gaby commented 3 years ago

I'm fairly certain that only the F1xx series actually has a seconds interrupt, that's why I was thinking about using the unused alarm.

I went through a number of the other series in STM32CubeMX configuration and only the F1xx series seemed to have the seconds interrupt available.

If it isn't available would it be best to only put support in for seconds interrupts on the F1xx series?

fpistm commented 3 years ago

Right, I'm thinking about the periodic auto-wakeup which can be used for this. But maybe I'm wrong.

josh-gaby commented 3 years ago

You may be onto something there, I ignored that option initially because I was thinking it only triggered an interrupt on PC13 but it seems that may be an optional feature. I'll look into using the PWUT to implement this feature for other variants.

josh-gaby commented 3 years ago

I've only got a few different STM32F1xx based boards at the moment so can't test the Periodic wakeup timer, I'm waiting for some new dev boards to arrive in the mail before I can continue with this, might be a couple of weeks

FRASTM commented 2 years ago

please have a look at https://github.com/FRASTM/STM32RTC/tree/seconds_int including a simple example to display the Seconds Callback function for the STM32F1

fpistm commented 2 years ago

This one has been superseded by #57.