-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rtc mix mode with subseconds param. expressed in milliseconds #93
Conversation
Testing examples/advancedRTCAlarm or examples/RTC_Seconds with arduino RTC sketch when the on the nucleo_wl55jc or disco_l4s5i_iot1a |
23d55e4
to
0cad1db
Compare
The change to include the RTC MIX mode when manipulating the subsecond register
Setting an ALARM A in calendar and an alarm B in subsecond :
|
62a49d8
to
d98d2a1
Compare
07b3fd4
to
0e17344
Compare
8ba7f1f
to
e66f1d3
Compare
Testing on stm32g474 nucleo : RTC has BCD mode only or stm32wl55 nucleo RTC in BCD or MIX mode:
Testing on stm32wl55 nucleo RTC in BIN mode:
|
c14822f
to
0d67dc0
Compare
Configure the alarm depending on the MIX mode In case the RTC is running in MIX mode (binary and calendar), the subsecond register is a 32-bit value (and not msec) The Subsecond parameter is expressed in millisecond in RTC_SetTime/GetTime RTC_StartAlarm/GetAlarm Signed-off-by: Francois Ramu <[email protected]>
Signed-off-by: Frederic Pillon <[email protected]>
Signed-off-by: Frederic Pillon <[email protected]>
define the Getime and startAlarm function when the RTC is configured in BCD (MODE_BINARY_NONE) or BIN (MODE_BINARY_ONLY). In MODE_BINARY_ONLY, Time and Date are not used, only subsecond Signed-off-by: Francois Ramu <[email protected]>
Add new API to set alarm Time with subseconds which is a nb of milliseconds. Similar to setAlarmSubSeconds. Signed-off-by: Francois Ramu <[email protected]>
This examples is configuring the RTC in MIX (binary + calendar) or BCD and sets Alarm A & B (if exists) few ms after the current time. Signed-off-by: Francois Ramu <[email protected]>
This examples is configuring the RTC in BIN mode (binary only) and sets Alarm A & B (if exists) a few ms after the current time. Signed-off-by: Francois Ramu <[email protected]>
Signed-off-by: Frederic Pillon <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Tested with stm32duino/STM32LoRaWAN#25
stm32duino RTC add a parameter to set binary or bcd or Mix mode
The MIX mode of the RTC combines the binary and the BCD calendar modes
"The SSR binary down-counter is extended to 32-bit length and is free running. The time and
date calendar BCD registers are also available."
This is available of several stm32 devices like the stm32WL, stm32L4plus, stm32U5
The STM32RTC APi has subsecond parameter which is a value in milliseconds.
Because of the BINARY MIX mode, the parameter subsecond could be confusing as the subsecond register of the RTC is:
a nb of millisec [0-999] in BCD mode
a nb of ticks in BIN or MIX mode -> one tick is one counter unit at the fqce = RTC clock source freq / fqce_apre
For example, in MIX mode, when RTC is clocked by the LSE (32768Hz) the tick is downcounting at 256Hz
(1 tick is ~ 3.9ms )
The RTC subsecond register is converted in ms by (0xFFFFFFFF - SubSecReg) * 1000/256
And N miliseconds is converted in ticks (count unit) by 0xFFFFFFFF - (SubSecReg * 256) /1000
With this PR, the STM32RTC API is always giving the subsecond parameter in a nb of milliseconds.
Especially with functions: