Closed FRASTM closed 8 months ago
Adding another commit with a new sketch to send the current calendar on LoRa
Calculate the ck_apre from the RTC clock source and the Async prescaler (prediv_A )
ck_apre = RTC_clock / (prediv_A +1)
given by the ref Manual.
This is 256 when LSE clock and prediv_A = 0x7F (default)
When the RTC is using subsecond as a nb of milliseconds (cf PR https://github.com/stm32duino/STM32RTC/pull/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 https://github.com/stm32duino/STM32RTC/pull/95
Fixes #9