Skip to content
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

stm32LoraWan with RTC in mix mode #22

Closed
wants to merge 7 commits into from
Closed

Conversation

FRASTM
Copy link
Contributor

@FRASTM FRASTM commented Jun 28, 2023

Configure the RTC in mix mode and use the ALARM B of the stm32WL55 device
for the LoraWan purpose.

This requires the stm32duino/STM32RTC#93

The MIX mode of the RTC allows the Lorawan to use the subsecond and alarm (B) in binary mode
and the RTC to be also used in BCD calendar mode.

FRASTM added 4 commits June 14, 2023 15:45
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.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
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)

Signed-off-by: Francois Ramu <francois.ramu@st.com>
The RTC.begin does not propose the RTCmode parameter.
This is configured with the setRTCMode method before .begin
The RTC irq (for Alarm B) is handled directly by the STM32RTC library

Signed-off-by: Francois Ramu <francois.ramu@st.com>
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

Signed-off-by: Francois Ramu <francois.ramu@st.com>
@FRASTM
Copy link
Contributor Author

FRASTM commented Jun 28, 2023

Problem found with STM32duinoLoRaWAN/examples/Basic cannot connect. The RTC is running but the Lorawan started timers expires with an ALARM B interrupt

11:12:42.246 -> Start
11:12:42.547 -> Setting TX Config: modem=MODEM_LORA, power=13, fdev=0, bandwidth=0, datarate=8, coderate=1 preambleLen=8, fixLen=0, crcOn=1, freqHopOn=0, hopPeriod=0, iqInverted=0, timeout=4000
11:12:42.568 -> TX on freq 868300000 Hz at DR 4
11:12:42.568 -> TX: 00 01 01 01 01 01 01 01 01 b4 da 00 05 15 e1 80 00 4a 52 31 88 d9 b9
11:12:42.696 -> MAC txDone
11:13:02.664 -> RX_1 on freq 868300000 Hz at DR 4
11:13:02.695 -> IRQ_RX_TX_TIMEOUT
11:13:02.695 -> MAC rxTimeOut
11:13:06.803 -> RX_2 on freq 869525000 Hz at DR 0
11:13:06.995 -> IRQ_RX_TX_TIMEOUT
11:13:06.995 -> MAC rxTimeOut
11:13:07.027 -> MlmeConfirm: req=MLME_JOIN, status=LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT, airtime=114, margin=0, gateways=0
11:13:07.027 -> Setting TX Config: modem=MODEM_LORA, power=13, fdev=0, bandwidth=0, datarate=8, coderate=1 preambleLen=8, fixLen=0, crcOn=1, freqHopOn=0, hopPeriod=0, iqInverted=0, timeout=4000
11:13:07.059 -> TX on freq 868100000 Hz at DR 4
11:13:07.059 -> TX: 00 01 01 01 01 01 01 01 01 b4 da 00 05 15 e1 80 00 6e c9 6f cc f4 ec
11:13:07.188 -> MAC txDone
11:13:27.142 -> RX_1 on freq 868100000 Hz at DR 4
11:13:27.173 -> IRQ_RX_TX_TIMEOUT
11:13:27.173 -> MAC rxTimeOut
11:13:31.315 -> RX_2 on freq 869525000 Hz at DR 0
11:13:31.509 -> IRQ_RX_TX_TIMEOUT
11:13:31.509 -> MAC rxTimeOut
11:13:31.509 -> MlmeConfirm: req=MLME_JOIN, status=LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT, airtime=114, margin=0, gateways=0
11:13:31.551 -> Setting TX Config: modem=MODEM_LORA, power=13, fdev=0, bandwidth=0, datarate=8, coderate=1 preambleLen=8, fixLen=0, crcOn=1, freqHopOn=0, hopPeriod=0, iqInverted=0, timeout=4000
11:13:31.551 -> TX on freq 868100000 Hz at DR 4
11:13:31.551 -> TX: 00 01 01 01 01 01 01 01 01 b4 da 00 05 15 e1 80 00 aa b5 27 2f 2a 90
11:13:31.670 -> MAC txDone
11:13:51.635 -> RX_1 on freq 868100000 Hz at DR 4
11:13:51.667 -> IRQ_RX_TX_TIMEOUT
11:13:51.667 -> MAC rxTimeOut
11:13:55.778 -> RX_2 on freq 869525000 Hz at DR 0
11:13:56.003 -> IRQ_RX_TX_TIMEOUT
11:13:56.003 -> MAC rxTimeOut
11:13:56.003 -> MlmeConfirm: req=MLME_JOIN, status=LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT, airtime=114, margin=0, gateways=0
11:13:56.003 -> Join failed

FRASTM added 3 commits July 3, 2023 13:17
Directly call the RTC functions from the STM32duino RTC library
Let the IsEnabled.RtcFeatures be handled by the RTC library
Give the parameters a 32-bit value to match the
SubSecond register of the RTC.
In Mix mode, the SSR is counting on a fqce APRE which is
RTCCLK freq / 'PREDIV_A + 1) = 256Hz when RTC is clocked
by LSE. This frqe gives a tick of 3.9ms (= 1/256 * 1000)
@FRASTM
Copy link
Contributor Author

FRASTM commented Jul 3, 2023

Adjusting the conversion formula to change ticks in ms and ms to ticks.
With the RTC clocked by the LSE (32768Hz) in the MIX mode, the SubSecond SSR register is counting ticks on a freq equal to RTCCLK / (PREDIV_A + 1) = 32768 / (0x7F +1) = 256Hz.
That means one tick unit = 3.9ms (cannot define timeout lower than 3.9 ms)

@FRASTM
Copy link
Contributor Author

FRASTM commented Jul 3, 2023

Running the STM32duinoLoRaWAN/examples/Basic on the nucleo_wl55jc

13:28:42.040 -> Start
13:28:42.041 -> Setting TX Config: modem=MODEM_LORA, power=13, fdev=0, bandwidth=0, datarate=8, coderate=1 preambleLen=8, fixLen=0, crcOn=1, freqHopOn=0, hopPeriod=0, iqInverted=0, timeout=4000
13:28:42.041 -> TX on freq 868100000 Hz at DR 4
13:28:42.041 -> TX: 00 01 01 01 01 01 01 01 01 89 dd 00 05 15 e1 80 00 4a a9 3b 24 c0 de
13:28:42.107 -> MAC txDone
13:28:47.118 -> RX_1 on freq 868100000 Hz at DR 4
13:28:47.150 -> IRQ_RX_TX_TIMEOUT
13:28:47.150 -> MAC rxTimeOut
13:28:48.145 -> RX_2 on freq 869525000 Hz at DR 0
13:28:49.942 -> MAC rxDone
13:28:49.974 -> RX: 2008caff22d905b7d069dd0c7dfeb2b89c05c073422dae781024e2482236a0f38c
13:28:49.974 -> MlmeConfirm: req=MLME_JOIN, status=LORAMAC_EVENT_INFO_STATUS_OK, airtime=114, margin=0, gateways=0
13:28:49.974 -> Joined
13:28:49.974 -> Setting TX Config: modem=MODEM_LORA, power=13, fdev=0, bandwidth=0, datarate=8, coderate=1 preambleLen=8, fixLen=0, crcOn=1, freqHopOn=0, hopPeriod=0, iqInverted=0, timeout=4000
13:28:50.007 -> TX on freq 868500000 Hz at DR 4
13:28:50.007 -> TX: 40 c4 8b 4a 1f 80 01 00 0a b9 51 24 49 b8 c3 b8 93
13:28:50.102 -> MAC txDone
13:28:55.114 -> RX_1 on freq 868500000 Hz at DR 2
13:28:55.179 -> IRQ_RX_TX_TIMEOUT
13:28:55.179 -> MAC rxTimeOut
13:28:56.142 -> RX_2 on freq 869525000 Hz at DR 0
13:28:56.335 -> IRQ_RX_TX_TIMEOUT
13:28:56.335 -> MAC rxTimeOut
13:28:56.335 -> McpsConfirm: req=MCPS_UNCONFIRMED, status=LORAMAC_EVENT_INFO_STATUS_OK, datarate=4, power=0, ack=0, retries=0, airtime=93, upcnt=1, channel=2
13:28:56.367 -> Sent packet
...

@FRASTM
Copy link
Contributor Author

FRASTM commented Sep 1, 2023

now replaced by the #25

@FRASTM FRASTM closed this Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant