stm32duino / STM32LoRaWAN

Arduino library to support LoRaWAN communication using the STM32WL series.
https://stm32duino.github.io/STM32LoRaWAN/
Other
34 stars 7 forks source link

Use the RTC in MIX mode and convert timeout values #25

Closed FRASTM closed 8 months ago

FRASTM commented 11 months ago

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

FRASTM commented 10 months ago

Adding another commit with a new sketch to send the current calendar on LoRa

FRASTM commented 10 months ago

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)

fpistm commented 8 months ago

Dependency: https://github.com/stm32duino/STM32RTC/releases/tag/1.4.0