-
Notifications
You must be signed in to change notification settings - Fork 9
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
Use the RTC in MIX mode and convert timeout values #25
Conversation
Adding another commit with a new sketch to send the current calendar on LoRa |
654abe8
to
f83c35b
Compare
Calculate the ck_apre from the RTC clock source and the Async prescaler (prediv_A ) |
c44652e
to
9366b63
Compare
5a76db6
to
01be423
Compare
Include the STM32RTC library to all the BSP as only few functions remain in the BSP as the RTC is instantiated by the STM32RTC library The Alarm B of the RTC is used for LoRaWan purpose. Use the LSE as clock source for the RTC instance. Set the free running mix mode. The RTC is configured with the setBinaryModesetRTCMode method before .begin to set the MIX (BCD + binary) mode. The RTC irq (for Alarm B) is handled directly by the STM32RTC library Mask is set to ALL in case of MIX mode, so that interrupt is trigged on the sub-second basis (other calendar values do not care) Let the IsEnabled.RtcFeatures be handled by the RTC library Signed-off-by: Francois Ramu <[email protected]>
Give the parameters a 32-bit value to match the SubSecond register of the RTC. Signed-off-by: Francois Ramu <[email protected]>
In Mix mode, the SSR is counting on a fqce APRE which is RTCCLK freq / 'PREDIV_A + 1). For example for Nucleo_WL55JC, this value is 256Hz when RTC is clocked by LSE. This frqe gives a tick of 3.9ms (= 1/256 * 1000) Signed-off-by: Francois Ramu <[email protected]>
Signed-off-by: Frederic Pillon <[email protected]>
The timeout is a nb of tick counter (1/256Hz) in mix mode and must be converted in ms to match the RTC_StartAlarm API (1 tick is 3.9ms) Signed-off-by: Francois Ramu <[email protected]>
Modifying the basic.ino to format the Tx packet with the current calendar Date and Time Get the RTC instance initialized in MIX mode Signed-off-by: Francois Ramu <[email protected]>
Configuration is not the same than Arduino IDE. Signed-off-by: Frederic Pillon <[email protected]>
Signed-off-by: Frederic Pillon <[email protected]>
Signed-off-by: Frederic Pillon <[email protected]>
edb4b24
to
2a18b4b
Compare
Signed-off-by: Frederic Pillon <[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
When the RTC is using subsecond as a nb of milliseconds (cf PR stm32duino/STM32RTC#95)
The LoraWan is always using timeout values as a nb of ticks
Ticks is the RTC count unit when running in BINATY or MIX mode to be 1000ms/fqce_apre = 1000 / 256 ~ 3.9ms when the RTC is clocked by the LSE (32768Hz)
fqce_apre = LSE clock/ (Async prediv + 1)
Setting the Lorawan alarm (ALARM B) to expire in a nb of ticks, requires a conversion to when the RTC_StartAlarm() has a subsecond parameter expressed in milliseconds :
Timeout in milliseconds = timeout in ticks * 1000 / 256 ( + 1 to compensate division uncertainty)
Requires RTC stm32duino/STM32RTC#95
Fixes #9