STM32 ST based on RTC

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
vrollei
Posts: 163
Joined: Sun Nov 13, 2016 8:44 am
Been thanked: 26 times

STM32 ST based on RTC

Postby vrollei » Mon Jul 03, 2017 3:09 pm

Hi,

What do you think about ST based on RTC? I have implemented first version for STM32L4.

Reason: ST based on RTC provides precise time measurement in Low Power STOP mode (ST is active in STOP mode). There is a problem with precise time measurement with ST based on TIMx in Low Power Sleep mode due to latency in code execution after changing sys clock to lowest frequency and instability of MSI frequency.

Chibios HAL changes:
st_lld.h/st_lld.c: RTC support added, including RTC alarm interrupt handler
ext_lld.c: RTC alarm line masking added
ext_lld_isr.h/ext_lld_isr.c: RTC alarm line mask macro added, disabling RTC alarm interrupt handler
hal_lld.c: RTC initialisation if ST use RTC and HAL_USE_RTC disabled

Restrictions:
HAL_USE_RTC should be FALSE
RTC clock source should be LSE
CH_CFG_ST_FREQUENCY should be equal to (32768 / (STM32_RTC_PRESS_VALUE * STM32_RTC_PRESA_VALUE)
There is uint16_t century counter, so device can work without calendar errors more than 100 years on 2048Hz ST frequency
There is no debug support for RTC

Date Algorithms for RTC based on: http://howardhinnant.github.io/date_algorithms.html

I will share sources here a little bit later.
Vitaly

vrollei
Posts: 163
Joined: Sun Nov 13, 2016 8:44 am
Been thanked: 26 times

Re: STM32 ST based on RTC

Postby vrollei » Tue Aug 01, 2017 4:00 pm

STM32L1 and L0 implementation is attached. ChibiOS 17.6.0.
Attachments
rtc_st.tar.gz
(14.58 KiB) Downloaded 224 times
Vitaly

vrollei
Posts: 163
Joined: Sun Nov 13, 2016 8:44 am
Been thanked: 26 times

Re: STM32 ST based on RTC

Postby vrollei » Fri Sep 15, 2017 2:38 pm

Hi,

any feedback?
Vitaly


Return to “ChibiOS/HAL”

Who is online

Users browsing this forum: No registered users and 8 guests