Repository navigation
Use the RTC in MIX mode and convert timeout values - #25
Merged
Merged
Conversation
This was referenced Sep 1, 2023
Contributor
Author
|
Adding another commit with a new sketch to send the current calendar on LoRa |
FRASTM
force-pushed
the
millisec_rtc_mix
branch
from
September 5, 2023 10:52
654abe8 to
f83c35b
Compare
Contributor
Author
|
Calculate the ck_apre from the RTC clock source and the Async prescaler (prediv_A ) |
FRASTM
marked this pull request as ready for review
September 6, 2023 07:11
FRASTM
force-pushed
the
millisec_rtc_mix
branch
2 times, most recently
from
September 11, 2023 15:17
c44652e to
9366b63
Compare
fpistm
force-pushed
the
millisec_rtc_mix
branch
3 times, most recently
from
September 22, 2023 14:30
5a76db6 to
01be423
Compare
fpistm
self-requested a review
September 25, 2023 13:26
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]>
fpistm
force-pushed
the
millisec_rtc_mix
branch
from
September 25, 2023 14:25
edb4b24 to
2a18b4b
Compare
Signed-off-by: Frederic Pillon <[email protected]>
Signed-off-by: Frederic Pillon <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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