an5406-how-to-build-a-lora-application-with-stm32cubewl-stmicroelectronics
an5406-how-to-build-a-lora-application-with-stm32cubewl-stmicroelectronics
Application note
Introduction
This application note guides the user through all the steps required to build specific LoRa® applications based on STM32WL5x/
Ex Series microcontrollers.
LoRa® is a type of wireless telecommunication network designed to allow long-range communications at a very‑low bitrate and
to enable long-life battery-operated sensors. LoRaWAN® defines the communication and security protocol that ensures the
interoperability with the LoRa® network.
The firmware in the STM32CubeWL MCU Package is compliant with the LoRa Alliance® specification protocol named
LoRaWAN® and has the following main features:
• Application integration ready
• Easy add-on of the low-power LoRa® solution
• Extremely low CPU load
• No latency requirements
• Small STM32 memory footprint
• Low-power timing services
The firmware of the STM32CubeWL MCU Package is based on the STM32Cube HAL drivers.
This document provides customer application examples on the NUCLEO-WL55JC development board with STM32WL55JC
(order codes NUCLEO‑WL55JC1 for high‑frequency band and NUCLEO-WL55JC2 for low‑frequency band) and B‑WL5M‑SUB1
connectivity expansion board with STM32WL5M.
To fully benefit from the information in this application note and to create an application, the user must be familiar with the
STM32 Series microcontrollers, the LoRa® technology, and understand system services such as low-power management and
task sequencing.
1 General information
The STM32CubeWL runs on STM32WL5x/Ex Series microcontrollers based on the Arm® Cortex®-M processor.
Note: Arm is a registered trademark of Arm Limited (or its subsidiaries) in the US and/or elsewhere.
Acronym Definition
Reference documents
LoRa standard
Refer to documents [1], [2], [3], and [4] for more details on LoRa and LoRaWAN recommendations.
LoRaWAN_AT_Slave Yes
LoRaWAN
LoRaWAN_End_Node Yes
SubGHz_Phy_AT_Slave Yes
SubGhz_Phy_PingPong Yes
SubGhz_Phy
SubGhz_Phy_LrFhss Yes No
SubGhz_Phy_Per Yes
1. High‑frequency band
2. Low‑frequency band
2 STM32CubeWL overview
The firmware of the STM32CubeWL MCU Package includes the following resources (see Figure 1):
• Board support package:
– STM32WL_Nucleo drivers
– B-WL5M-SUBG1 drivers
• STM32WLxx_HAL_Driver
• Middleware:
– LoRaWAN containing:
◦ LoRaWAN layer
◦ LoRa utilities
◦ LoRa software crypto engine
◦ LoRa state machine
– SubGHz_Phy layer middleware containing the radio and radio_driver interfaces
• LoRaWAN applications:
– LoRaWAN_AT_Slave (SingleCore and DualCore)
– LoRaWAN_End_Node (SingleCore, DualCore, SingleCore with FreeRTOS and DualCore with
FreeRTOS)
• SubGHz_Phy application:
– SubGHz_Phy_PingPong (SingleCore and DualCore)
– SubGHz_Phy_Per (SingleCore)
– SubGHz_Phy_AT_Slave (SingleCore)
– SubGHz_Phy_LrFhss (SingleCore)
In addition, this application provides an efficient system integration with the following:
• a sequencer to execute the tasks in background and to enter low-power mode when there is no activity
• a timer server to provide virtual timers running on RTC (in Stop and Standby modes) to the application
For more details, see Section 9.
BSP drivers
for STM32WL LoRaWAN_
Expansion Board AT_Slave
application
BSP drivers
for STM32WL
Nucleo board
LoRaWAN_
STM32WL
End_Node
HAL drivers
application
Middleware
LoRa crypto
engine
Middleware
LoRa State
machine
Middleware
LoRa MAC
layer
Middleware
LoRa utilities
Middleware
SubGHz_Phy
DT64327V1
This section focuses on the SubGHz HAL (other HAL functions such as timers or GPIO are not detailed).
The SubGHz HAL is directly on top of the sub-GHz radio peripheral (see Figure 3).
The SubGHz HAL driver is based on a simple one-shot command-oriented architecture (no complete processes).
Therefore, no LL driver is defined.
This SubGHz HAL driver is composed the following main parts:
• Handle, initialization and configuration data structures
• Initialization APIs
• Configuration and control APIs
• MSP and event callbacks
• Bus I/O operation based on the SUBGHZ_SPI (Intrinsic services)
As the HAL APIs are mainly based on the bus services to send commands in one-shot operations, no functional
state machine is used except the RESET/READY HAL states.
This BSP driver provides a set of functions to manage radio RF services, such as RF switch settings and control,
TCXO settings, and DC/DC settings.
Note: The radio middleware (SubGHz_Phy) interfaces the radio BSP via radio_board_if.c/h interface file. When
a custom user board is used, it is recommended to perform one of the following:
• First option
– Copy the BSP/STM32WLxx_Nucleo/ directory.
– Rename and update the user BSP APIs with:
◦ user RF switch configuration and control (such as pin control or number of port)
◦ user TCXO configuration
◦ user DC/DC configuration
– replace in the IDE project the STM32WLxx_Nucleo BSP files by the user BSP files.
• Second option
– Disable USE_BSP_DRIVER in Core/Inc/platform.h and implement the BSP functions directly
into radio_board_if.c.
4.2 RF switch
The STM32WL Nucleo board embeds an RF 3-port switch (SP3T) to address, with the same board, the following
modes:
• high-power transmission
• low-power transmission
• reception
Function Description
int32_t BSP_RADIO_ConfigRFSwitch(BSP_RADIO_Switch_TypeDef
Configures the RF switch.
Config)
int32_t BSP_RADIO_DeInit (void) De-initializes the RF switch.
The RF states versus the switch configuration are given in the table below.
Function Description
The user must start the TCXO by setting the command RADIO_SET_TCXOMODE with a timeout depending of the
application.
The timeout value can be updated in radio_conf.h. Default template value is the following:
#define RF_WAKEUP_TIME 1U
4.4 TCXO
Various oscillator types can be mounted on the user application. On the STM32WL55 Nucleo boards, a
temperature compensated crystal oscillator (TCXO) is used to achieve a better frequency accuracy.
Function Description
The TCXO mode is defined by the STM32WL Nucleo BSP by selecting USE_BSP_DRIVER
in Core/Inc/platform.h.
If the user wants to update this value (no NUCLEO board compliant), or if the BSP is not present, the TXCO
mode can be updated in radio_board_if.h. Default template value is the following:
#define IS_TCXO_SUPPORTED 1U
Function Description
The DC/DC mode is defined by the STM32WL Nucleo BSP by selecting USE_BSP_DRIVER
in Core/Inc/platform.h.
If the user wants to update this value (no NUCLEO board compliant), or if the BSP is not present, the DC/DC
mode can be updated in radio_board_if.h. Default template value is defined below:
#define IS_DCDC_SUPPORTED 1U
Data transaction:
SKC, MOSI, MISO
Control switchs
1 and 2
System clock
TCXO control
voltage
Control
switch 3
The BSP driver provides a set of functions to manage radio RF switch settings. It also gives additional
components available on B‑WL5M‑SUBG1 such as external flash memory, LEDs, and sensors (environmental,
motion, etc.).
5.1 RF switch
The B-WL5M-SUBG1 board embeds a RF switch integrated in the STM32WL5MOC. There is only a read API to
return the board configuration.
Function Description
The firmware of the STM32CubeWL MCU Package includes STM32WL resources such as:
• STM32WLxx_Nucleo drivers
• B-WL5M-SUBG1 drivers
• STM32WLxx HAL drivers
• LoRaWAN middleware
• SubGHz physical layer middleware
• LoRaWAN application example
• Utilities
The LoRaWAN stack middleware for STM32 Series microcontrollers is split into several modules:
Several LoRaWAN features are implemented in compliance with the LoRa Allicance protocol specifications:
• From the Link Layer specification:
– On-board LoRaWAN Class A, Class B and Class C protocol stack
– End-device activation either through OTAA or through activation-by-personalization (ABP)
– Adaptive data-rate support
• From the Regional Parameters specification:
– EU 868 MHz ISM band ETSI compliant
– EU 433 MHz ISM band ETSI compliant
– US 915 MHz ISM band FCC compliant
– KR 920 MHz ISM band defined by Korean government
– RU 864 MHz ISM band defined by Russian regulation
– CN 779 MHz and CN470Mhz ISM band defined by Chinese government
– AS 923 MHz ISM band defined by Asian governments
– AU 915 MHz ISM band defined by Australian government
– IN 865 MHz ISM band defined by Indian government
Additionally, the LoRaWAN stack integrates:
• Certification solution in accordance with the specifications described as below
• NVM Context Management to prevent power off loss of context
• Low-power integration by standby/sleep radio states
Warning: As the LoRaWAN integrates several stack version, the application and network keys are not
used as expected by the Link Layer v1.0.x definition, but aligned with the Link Layer v1.1.x
definition. So, AppS and NwkS keys are derived from the network root key and the
application root key is only used to manage the additional packages.
The LoRaWAN certification implementation depends on the LoRaWAN specification version used:
LoRaWAN specification
LoRaWAN certification specification
version
LoRa Alliance End Device Certification Requirements for AS923MHz ISM Band Devices
v1.1.0
LoRa Alliance End Device Certification Requirements for EU863-870 MHz ISM Band
Devices v1.6.0
LoRaWAN Link Layer 1.0.3 LoRa Alliance End Device Certification Requirements for India 865-867 MHz ISM Band
Specification v1.1.0
LoRa Alliance End Device Certification Requirements for South Korea 920-923MHz ISM
Band Devices v1.2.0
LoRa Alliance End Device Certification Requirements for US and Canada 902-928 MHz
ISM Band v1.5.0
LoRaWAN Link Layer 1.0.4 LoRaWAN 1.0.4 End Device Certification Requirements for All Regions v1.6.0
Specification (TS001-1.0.4) LoRaWAN Certification Protocol 1.0.0 Specification (TS009-1.0.0)
6.4 Architecture
Timer server
radio.h
SubGHz_Phy middleware Sequencer
radio.c
Debug trace
Low-power
radio_driver.c mode
The HAL uses STM32Cube APIs to drive the MCU hardware required by the application. Only specific hardware
is included in the LoRa middleware as it is mandatory to run a LoRa application.
The RTC provides a centralized time unit that continues to run even in low-power mode (Stop 2 mode). The RTC
alarm is used to wake up the system at specific timings managed by the timer server.
The SubGHz_Phy middleware uses the HAL SubGHz to control the radio (see the above figure). For more
details, see Section 8.
The MAC controls the SubGHz_Phy using the 802.15.4 model. The MAC interfaces with the SubGHz_Phy driver
and uses the timer server to add or remove timed tasks.
Since the state machine that controls the LoRa Class A is sensitive, an intermediate level of software is inserted (
LmHandler.c) between the MAC and the application (refer to LoRaMAC driver in the above figure). With a
limited set of APIs, the user is free to implement the Class A state machine at application level. For more details,
see Section 7.
The application, built around an infinite loop, manages the low-power mode, runs the interrupt handlers (alarm or
GPIO) and calls the LoRa Class A if any task must be done.
CPU Sub-GHz
radio
LoRaApp LmHandler LoRaMAC Radio Timer peripheral
LoRaMacMcps
LmHandlerSend RadioSend
Request
status status status
Tx
RadioIsr
OnMacProcessNotify OnRadioTxDone
_LmHandler
Packages LoRaMacProcess setRxwindow1
Process
OnTxdata McpsConfirm
TimerIsr
RadioRx
Rx
RadioIsr
OnMacProcessNotify OnRadioRxDone
_LmHandler
Packages LoRaMacProcess
Process
OnRxdata McpsIndication
Once the radio has completed the application data transmission, an asynchronous RadioIRQ wakes up the
system. The RadioIsr here calls txDone in the handler mode.
All RadioIsr and MAC timer call a LoRaMacProcessNotify callback to request the application layer to update
the LoRaMAC state and to do further processing when needed.
For instance, at the end of the reception, rxDone is called in the ISR (handler), but all the Rx packet processing
including decryption must not be processed in the ISR. This case is an example of call sequence. If no data is
received into the Rx1 window, then another Rx2 window is launched..
Sub-GHz radio
The sub-GHz radio peripheral is accessed through the stm32wlxx_hal_subghz HAL.
The sub-GHz radio issues an interrupt through SUBGHZ_Radio_IRQHandler NVIC, to notify a TxDone or
RxDone event. More events are listed in the product reference manual.
RTC
The RTC (real-time clock) calendar is used as 32-bit counter running in all power modes from the 32 kHz external
oscillator. By default, the RTC is programed to provide 1024 ticks (subseconds) per second. The RTC is
programed once at hardware initialization (when the MCU starts for the first time). The RTC output is limited to a
32-bit timer that corresponds to about a 48-day period.
Caution: When changing the tick duration, the user must keep it below 1 ms.
Function Description
LoRaMacStatus_t LoRaMacInitialization
(LoRaMacPrimitives_t *primitives, Initializes the LoRaMAC layer module
LoRaMacCallback_t *callback, (see Section 7.3)
LoRaMacRegion_t region)
Function Description
LoRaMacStatus_t LoRaMacMcpsRequest
(McpsReq_t* mcpsRequest, bool Requests to send Tx data.
allowDelayedTx)
• MLME services
The LoRaMAC layer uses the MLME services to manage the LoRaWAN network.
Function Description
• MIB services
The MIB stores important runtime information (such as MIB_NETWORK_ACTIVATION or MIB_NET_ID)
and holds the configuration of the LoRaMAC layer (for example the MIB_ADR, MIB_APP_KEY).
Function Description
LoRaMacStatus_t LoRaMacMibSetRequestConfirm
Sets attributes of the LoRaMAC layer.
(MibRequestConfirm_t *mibSet)
LoRaMacStatus_t LoRaMacMibGetRequestConfirm
Gets attributes of the LoRaMAC layer.
(MibRequestConfirm_t *mibGet )
Function Description
void (*MacMcpsConfirm )
Response to a McpsRequest
(McpsConfirm_t *McpsConfirm)
Void (*MacMcpsIndication)
(McpsIndication_t* McpsIndication, Notifies the application that a received packet is available.
LoRaMacRxStatus_t* RxStatus)
void (*MacMlmeConfirm)
Manages the LoRaWAN network.
(MlmeConfirm_t *MlmeConfirm)
void (*MacMlmeIndication)
(MlmeIndication_t* MlmeIndication, Notify the MAC layer that a MAC response is available.
LoRaMacRxStatus_t* RxStatus)
Function Description
void OnTxDelayedTimerEvent
Executed on duty cycle delayed Tx timer event.
(void* context)
Executed on AckTimeout timer event by Acknowledge
void OnAckTimeoutTimerEvent timeout timer.
(void* context) Used for packet retransmissions (only for LoRaWAN version
v1.0.3).
Function Description
The next sections detail the LoRaWAN_End_Node and LoRaWAN_AT_Slave APIs used to access the LoRaMAC
services. The corresponding interface files are located in
Middlewares\Third_Party\LoRaWAN\LmHandler\LmHandler.c
The user must implement the application with these APIs.
Function Description
LmHandlerErrorStatus_t LmHandlerInit
( LmHandlerCallbacks_t *handlerCallbacks, Initialization of the LoRa finite state machine
uint32_t fwVersion)
Deinit LoRa state machine, stop all timers, reset MAC
LmHandlerErrorStatus_t LmHandlerDeInit(void) parameters, shutdown the radio and remove all
existing callbacks references
LmHandlerErrorStatus_t LmHandlerConfigure
Configuration of all applicative parameters
(LmHandlerParams_t *handlerParams)
bool LmHandlerIsBusy( void ) Indicates if the LoRaMacHandler is busy.
LmHandlerErrorStatus LmHandlerRequestClass
Requests the MAC layer to change LoRaWAN class.
(DeviceClass_t newClass)
LmHandlerErrorStatus_t LmHandlerSend
Sends an uplink frame. This frame can be either an
(LmHandlerAppData_t *appData, unconfirmed empty frame or an unconfirmed/
LmHandlerMsgTypes_t isTxConfirmed, bool confirmed payload frame.
allowDelayedTx)
TimerTime_t LmHandlerGetDutyCycleWaitTime
Gets current duty-cycle wait time
(void)
LmHandlerErrorStatus_t LmHandlerGetVersion
(LmHandlerVersionType_t lmhType, uint32_t Returns current LoRaWAN specifications version
*featureVersion)
LmHandlerErrorStatus_t LmHandlerNvmDataStore Starts the NVM Data store process (more details in
(void) Section 15).
Function Description
void GetDevAddr (uint32_t *devAddr) Gets the board 32-bit unique ID (LSB).
Function Description
void OnNvmDataChange
Notifies the upper layer that the NVM context has changed.
(LmHandlerNvmContextStates_t state)
void OnNetworkParametersChange Notifies the upper layer that network parameters have been
(CommissioningParams_t *params) set.
void OnJoinRequest
Notifies the upper layer that a network has been joined.
(LmHandlerJoinParams_t *params)
void OnTxData (LmHandlerTxParams_t
Notifies the upper layer that a frame has been transmitted.
*params)
void OnRxData (LmHandlerAppData_t
*appData, Notifies the upper layer that an applicative frame has been
received.
LmHandlerRxParams_t *params)
void OnClassChange (DeviceClass_t
Confirms the LoRaWAN device class change.
deviceClass)
void OnBeaconStatusChange
Notifies the upper layer that the beacon status has changed.
(LmHandlerBeaconParams_t *params)
void OnBeaconStatusChange
Notifies the upper layer that the beacon status has changed.
( LmHandlerBeaconParams_t *params )
Notifies the upper layer that the system time has been
void OnSysTimeUpdate (void)
updated.
Is called to change applicative Tx frame period.
void OnTxPeriodicityChanged(uint32_t
periodicity) Compliance test protocol callbacks used when TS001-1.0.4 +
TS009 1.0.0 are defined.
Function Description
LmHandlerErrorStatus_t
LmHandlerGetCurrentClass( DeviceClass_t Gets the current LoRaWAN class.
*deviceClass)
LmHandlerErrorStatus_t
Gets the LoRaWAN device EUI.
LmHandlerGetDevEUI( uint8_t *devEUI)
LmHandlerErrorStatus_t
Sets the LoRaWAN device EUI (if OTAA).
LmHandlerSetDevEUI( uint8_t *devEUI)
LmHandlerErrorStatus_t
Gets the LoRaWAN App EUI.
LmHandlerGetAppEUI( uint8_t *appEUI)
LmHandlerErrorStatus_t
Sets the LoRaWAN App EUI.
LmHandlerSetAppEUI( uint8_t *appEUI)
LmHandlerErrorStatus_t
LmHandlerGetNetworkID( uint32_t Gets the LoRaWAN Network ID.
*networkId)
LmHandlerErrorStatus_t
LmHandlerSetNetworkID uint32_t Sets the LoRaWAN Network ID.
networkId)
LmHandlerErrorStatus_t
Gets the LoRaWAN device address.
LmHandlerGetDevAddr( uint32_t *devAddr)
LmHandlerErrorStatus_t
Sets the LoRaWAN device address (if ABP).
LmHandlerSetDevAddr( uint32_t devAddr)
LmHandlerErrorStatus_t
LmHandlerGetKey( KeyIdentifier_t keyID, Gets the LoRaWAN Key.
uint8_t *key )
LmHandlerErrorStatus_t
LmHandlerSetKey( KeyIdentifier_t keyID, Sets the LoRaWAN Key.
uint8_t *key )
LmHandlerErrorStatus_t
LmHandlerGetActiveRegion( LoRaMacRegion_ Gets the active region.
t *region)
LmHandlerErrorStatus_t
LmHandlerSetActiveRegion( LoRaMacRegion_ Sets the active region.
t region)
LmHandlerErrorStatus_t
Gets the adaptive data rate state.
LmHandlerGetAdrEnable( bool *adrEnable)
LmHandlerErrorStatus_t
Sets the adaptive data rate state.
LmHandlerSetAdrEnable( bool adrEnable)
LmHandlerErrorStatus_t
LmHandlerGetTxDatarate( int8_t Gets the current Tx data rate.
*txDatarate)
LmHandlerErrorStatus_t
LmHandlerSetTxDatarate( int8_t Sets the Tx data rate (if adaptive DR disabled).
txDatarate)
LmHandlerErrorStatus_t
Gets the current Tx duty cycle state.
LmHandlerGetDutyCycleEnable
Function Description
( bool *dutyCycleEnable)
LmHandlerErrorStatus_t
LmHandlerSetDutyCycleEnable Sets the Tx duty cycle state.
( bool dutyCycleEnable)
LmHandlerErrorStatus_t
LmHandlerGetRX2Params Gets the current Rx2 data rate and frequency conf.
( RxChannelParams_t *rxParams)
LmHandlerErrorStatus_t
LmHandlerSetRX2Params Sets the Rx2 data rate and frequency conf.
( RxChannelParams_t *rxParams)
LmHandlerErrorStatus_t
Gets the current Tx power value.
LmHandlerGetTxPower( int8_t *txPower)
LmHandlerErrorStatus_t
Sets the Tx power value.
LmHandlerSetTxPower( int8_t txPower)
LmHandlerErrorStatus_t
Gets the current Rx1 delay (after Tx window).
LmHandlerGetRx1Delay( uint32_t *rxDelay)
LmHandlerErrorStatus_t
Sets the Rx1 delay (after Tx window).
LmHandlerSetRx1Delay( uint32_t rxDelay)
LmHandlerErrorStatus_t
Gets the current Rx2 delay (after Tx window).
LmHandlerGetRx2Delay( uint32_t *rxDelay)
LmHandlerErrorStatus_t
Sets the Rx2 delay (after Tx window).
LmHandlerSetRx2Delay( uint32_t rxDelay)
LmHandlerErrorStatus_t
LmHandlerGetJoinRx1Delay( uint32_t Gets the current Join Rx1 delay (after Tx window).
*rxDelay)
LmHandlerErrorStatus_t
LmHandlerSetJoinRx1Delay( uint32_t Sets the Join Rx1 delay (after Tx window).
rxDelay)
LmHandlerErrorStatus_t
LmHandlerGetJoinRx2Delay( uint32_t Get the current Join Rx2 delay (after Tx window)
*rxDelay)
LmHandlerErrorStatus_t
LmHandlerSetJoinRx2Delay( uint32_t Sets the Join Rx2 delay (after Tx window).
rxDelay)
LmHandlerErrorStatus_t
LmHandlerGetPingPeriodicity Gets the current Rx Ping Slot periodicity (If
LORAMAC_CLASSB_ENABLED).
( uint8_t pingPeriodicity)
LmHandlerErrorStatus_t
LmHandlerSetPingPeriodicity Sets the Rx Ping Slot periodicity (If
LORAMAC_CLASSB_ENABLED).
( uint8_t pingPeriodicity)
LmHandlerErrorStatus_t
LmHandlerGetBeaconState Gets the beacon state (If LORAMAC_CLASSB_ENABLED).
( BeaconState_t *beaconState)
LmHandlerErrorStatus_t
Requests network server time update.
LmHandlerDeviceTimeReq(void)
LmHandlerErrorStatus_t
Requests Link connectivity check.
LmHandlerLinkCheckReq(void)
Function Description
LmHandlerErrorStatus_t
LmHandlerPingSlotReq(uint8_t Informs the server on the ping-slot periodicity to use.
periodicity)
Callback Description
void SetModem ( RadioModems_t modem ) Configures the radio with the given modem.
Callback Description
void Rx ( uint32_t timeout ) Sets the radio in reception mode for the given time.
Sets the radio in reception mode with max LNA gain for the
void RxBoosted ( uint32_t timeout )
given time.
void SetRxDutyCycle ( uint32_t rxTime,
Sets the Rx duty-cycle management parameters.
uint32_t sleepTime )
void TxPrbs ( void ) Sets the transmitter in continuous PRBS mode.
void TxCw ( int8_t power ) Sets the transmitter in continuous unmodulated carrier mode.
int32_t RadioSetRxGenericConfig
( GenericModems_t modem,
Sets the reception parameters with more configuration fields.
RxConfigGeneric_t* config, uint32_t
rxContinuous, uint32_t symbTimeout )
int32_t RadioSetTxGenericConfig
( GenericModems_t modem, Sets the transmission parameters with more configuration
TxConfigGeneric_t* config, int8_t power, fields.
uint32_t timeout )
int32_t TransmitLongPacket ( uint16_t
payload_size, uint32_t timeout,void
(*TxLongPacketGetNextChunkCb) Starts sending long Packet, packet may be short.
( uint8_t** buffer, uint8_t
buffer_size ) )
Callback Description
10
11
- RFU - -
12
13
Asserted at each hop, in Long Range FHSS, after
14 LrFhssHop LR-FHSS Tx
the PA has ramped-up again
15 - RFU - -
9 Utilities description
9.1 Sequencer
The sequencer provides a robust and easy framework to execute tasks in the background and enters low-power
mode when there is no more activity. The sequencer implements a mechanism to prevent race conditions.
In addition, the sequencer provides an event feature allowing any function to wait for an event (where particular
event is set by interrupt) and MIPS and power to be easily saved in any application that implements “run to
completion” command.
The utilities_def.h file located in the project sub-folder is used to configure the task and event IDs. The
ones already listed must not be removed.
The sequencer is not an OS. Any task is run to completion and cannot switch to another task like an RTOS can
do on the RTOS tick unless a task suspends itself by calling UTIL_SEQ_WaitEvt. Moreover, one single-memory
stack is used. The sequencer is an advanced ‘while loop’ centralizing task and event bitmap flags.
The sequencer provides the following features:
• Advanced and packaged while loop system
• Support up to 32 tasks and 32 events
• Task registration and execution
• Wait for an event and set event
• Task priority setting
• Race condition safe low-power entry
To use the sequencer, the application must perform the following:
• Set the number of maximum of supported functions, by defining a value for UTIL_SEQ_CONF_TASK_NBR.
• Register a function to be supported by the sequencer with UTIL_SEQ_RegTask().
• Start the sequencer by calling UTIL_SEQ_Run() to run a background while loop.
• Call UTIL_SEQ_SetTask() when a function needs to be executed.
The sequencer utility is located in Utilities\sequencer\stm32_seq.c.
Function Description
The figure below compares the standard while-loop implementation with the sequencer while-loop
implementation.
Function Description
UTIL_TIMER_Status_t
Initializes the timer server.
UTIL_TIMER_Init(void)
UTIL_TIMER_Status_t UTIL_TIMER_Create
(UTIL_TIMER_Object_t *TimerObject,
uint32_t PeriodValue, Creates the timer object and associates a callback function
when timer elapses.
UTIL_TIMER_Mode_t Mode, void (*Callback)
(void*), void *Argument)
UTIL_TIMER_Status_t
UTIL_TIMER_SetPeriod(UTIL_TIMER_Object_t Updates the period and starts the timer with a timeout value
*TimerObject, (milliseconds).
uint32_t NewPeriodValue)
UTIL_TIMER_Status_t UTIL_TIMER_Start
Starts and adds the timer object to the list of timer events.
(UTIL_TIMER_Object_t *TimerObject)
UTIL_TIMER_Status_t UTIL_TIMER_Stop Stops and removes the timer object from the list of timer
(UTIL_TIMER_Object_t *TimerObject) events.
Function Description
void UTIL_LPM_SetStopMode( UTIL_LPM_bm_t Sets Stop mode. id defines the process mode requested:
lpm_id_bm, UTIL_LPM_State_t state ); UTIL_LPM_ENABLE or UTIL_LPM_DISABLE.(1)
void UTIL_LPM_SetOffMode( UTIL_LPM_bm_t Sets Stop mode. id defines the process mode requested:
lpm_id_bm, UTIL_LPM_State_t state ); UTIL_LPM_ENABLE or UTIL_LPM_DISABLE.
UTIL_LPM_Mode_t UTIL_LPM_GetMode( void ) Returns the currently selected low-power mode.
The default low-power mode is Off mode, which may be Standby or Shutdown mode
(defined in void PWR_EnterOffMode (void) from Table 26):
• If Stop mode is disabled by at least one firmware module and low-power is entered, Sleep mode is
selected.
• If Stop mode is not disabled by any firmware module, Off mode is disabled by at least one firmware
module, and low-power is entered. Stop mode is selected.
• If Stop mode is not disabled by any firmware module, Off mode is not disabled by any firmware module,
and low-power is entered. Off mode is selected.
Figure 6 depicts the behavior with three different firmware modules setting dependently their low-power
requirements and low-power mode, selected when the system enters a low-power mode.
Sleep
mode
Low-power mode when
system enters idle mode Stop
(For example when mode
UTIL_LPM_EnterLowPo
wer is called) Off
mode
Time
Low-level APIs must be implemented to define what the system must do to enter/exit a low-power mode. These
functions are implemented in stm32_lpm_if.c of project sub-folder.
Function Description
In Sleep mode, the core clock is stopped. Each peripheral clock can be gated or not. The power is maintained on
all peripherals.
In Stop 2 mode, most peripheral clocks are stopped. Most peripheral supplies are switched off. Some registers of
the peripherals are not retained and must be reinitialized on Stop 2 mode exit. Memory and core registers are
retained.
In Standby mode, all clocks are switched off except LSI and LSE. All peripheral supplies are switched off (except
BOR, backup registers, GPIO pull, and RTC), with no retention (except additional SRAM2 with retention), and
must be reinitialized on Standby mode exit. Core registers are not retained and must be reinitialized on Standby
mode exit.
Note: The sub-GHz radio supply is independent of the rest of the system. See the product reference manual for more
details.
Function Description
1. The system time reference is the UNIX epoch starting January 1st, 1970.
2. SysTimeMkTime and SysTimeLocalTime are also provided to convert epoch into tm structure as specified by the time
.h interface.
To convert UNIX time to local time, a time zone must be added and leap seconds must be removed. In 2018, 18
leap seconds must be removed. In Paris summertime, there is two hours difference from Greenwich time.
Assuming time is set, a local time can be printed on a terminal with the code below.
{
SysTime_t UnixEpoch = SysTimeGet();
struct tm localtime;
UnixEpoch.Seconds-=18; /*removing leap seconds*/
UnixEpoch.Seconds+=3600*2; /*adding 2 hours*/
SysTimeLocalTime(UnixEpoch.Seconds, & localtime);
PRINTF ("it's %02dh%02dm%02ds on %02d/%02d/%04d\n\r",
localtime.tm_hour, localtime.tm_min, localtime.tm_sec,
localtime.tm_mday, localtime.tm_mon+1, localtime.tm_year + 1900);
}
9.5 Trace
The trace module enables printing data on a COM port using DMA. The APIs presented in the table below are
used to manage the trace functions.
The trace utility is located in Utilities\trace\adv_trace\stm32_adv_trace.c.
Function Description
The status values of the trace functions are defined in the structure UTIL_ADV_TRACE_Status_t as follows.
typedef enum {
UTIL_ADV_TRACE_OK = 0, /*Operation terminated successfully*/
UTIL_ADV_TRACE_INVALID_PARAM = -1, /*Invalid Parameter*/
UTIL_ADV_TRACE_HW_ERROR = -2, /*Hardware Error*/
UTIL_ADV_TRACE_MEM_ERROR = -3, /*Memory Allocation Error*/
UTIL_ADV_TRACE_UNKNOWN_ERROR = -4, /*Unknown Error*/
UTIL_ADV_TRACE_GIVEUP = -5, /*!< trace give up*/
UTIL_ADV_TRACE_REGIONMASKED = -6 /*!< trace region masked*/
} UTIL_ADV_TRACE_Status_t;
• in real-time mode: when there is no space left in the circular queue, the string is not added and is not
printed out in the com port
#define APP_LOG(TS,VL,...)do{
{UTIL_ADV_TRACE_COND_FSend(VL, T_REG_OFF, TS, __VA_ARGS__);} }while(0);)
where:
– VL is the VerboseLevel of the trace.
– TS allows a timestamp to be added to the trace (TS_ON or TS_OFF).
The application verbose level is set in Core\Inc\sys_conf.h with:
#define VERBOSE_LEVEL <VLEVEL>
The utility provides hooks to be implemented to forbid the system to enter Stop or lower mode while the DMA is
active:
• void UTIL_ADV_TRACE_PreSendHook (void)
{ UTIL_LPM_SetStopMode((1 << CFG_LPM_UART_TX_Id) , UTIL_LPM_DISABLE ); }
10 LoRaWAN_End_Node application
This application measures the battery level and the temperature of the MCU. These values are sent periodically to
the LoRa network using the LoRa radio in Class A at 868 MHz.
See Table 2 for applicability.
To launch the LoRaWAN_End_Node project, go to
\Projects\<target>\Applications\LoRaWAN\LoRaWAN_End_Node and choose the favorite toolchain
folder (in the IDE environment). Select the project from the proper target board.
Focus on the configuration described below to setup the application.
Function Description
in \Projects\<target>\Applications\LoRaWAN\LoRaWAN_End_Node\LoRaWAN\App\lora_app.c
and
#define LORAWAN_DEFAULT_ACTIVATION_TYPE ACTIVATION_TYPE_OTAA
in \Projects\<target>\Applications\LoRaWAN\LoRaWAN_End_Node\LoRaWAN\App\lora_app.h
where ActivationType_t enum is defined as follows:
typedef enum eActivationType {
ACTIVATION_TYPE_NONE = 0, /* None */
ACTIVATION_TYPE_ABP = 1, /* Activation by personalization */
ACTIVATION_TYPE_OTAA = 2, /* Over the Air Activation */
\Projects\<target>\Applications\LoRaWAN\LoRaWAN_End_Node\LoRaWAN\App\se-identity.h
file contains commissioning data useful for device activation.
in
\Projects\<target>\Applications\LoRaWAN\LoRaWAN_End_Node\LoRaWAN\App\lora_app.h
in
\Projects\<target>\Applications\LoRaWAN\LoRaWAN_End_Node\LoRaWAN\App\lorawan_co
nf.h
10.2.3 Tx trigger
There are two ways to generate an uplink action, with the EventType global variable in
\Projects\<target>\Applications\LoRaWAN\LoRaWAN_End_Node\LoRaWAN\App\lora_app.c:
• by timer
• by an external event
with the code
static TxEventType_t EventType = TX_ON_TIMER;
The TX_ON_EVENT feature uses the button 1 as event in the LoRaWAN_End_Node application.
Note: LORAWAN_APP_PORT must not use port 224 that is reserved for certification.
\Projects\<target>\Applications\LoRaWAN\LoRaWAN_End_Node\LoRaWAN\App\lora_app.h, with
the code below:
#define LORAWAN_DEFAULT_CONFIRMED_MSG_STATE LORAMAC_HANDLER_UNCONFIRMED_MSG
This value defines the maximum payload size that the device can be sent. But the uplink/downlink payload size is
also dependent of the data rate used. For more details, refer to Maximum payload size table of Regional
Parameters specification.
where the expected value must be in the 0-15 range (depending on the selected region configuration. For more
details, refer to TX Data rate table of Regional Parameters specification.
10.2.9 Tx power
The default Tx Power used at Join and first uplinks (until a LinkADRReq is received) can be modified in \Projec
ts\<target>\Applications\LoRaWAN\LoRaWAN_End_Node\LoRaWAN\App\lora_app.h with the code
below:
#define LORAWAN_DEFAULT_TX_POWER TX_POWER_0
where the expected value must be in the 0-15 range (depending on the selected region configuration). For more
details, refer to TX power table of Regional Parameters specification.
When the REGION_AS923 is enabled, it is also possible to select the associated channel plan with the code
below:
#define REGION_AS923_DEFAULT_CHANNEL_PLAN CHANNEL_PLAN_GROUP_AS923_1
Possible selections:
• CHANNEL_PLAN_GROUP_AS923_1 (Default configuration. Freq offset = 0.0 MHz / Freq range =
915-928 MHz)
• CHANNEL_PLAN_GROUP_AS923_2 (Freq offset = -1.80 MHz / Freq range = 915-928 MHz)
• CHANNEL_PLAN_GROUP_AS923_3 (Freq offset = -6.60 MHz / Freq range = 915-928 MHz)
• CHANNEL_PLAN_GROUP_AS923_4 (Freq offset = -5.90 MHz / Freq range = 917-920 MHz)
• CHANNEL_PLAN_GROUP_AS923_1_JP (Freq offset = 0.0 MHz / Freq range = 920.6-923.4 MHz)
Possible values: 0x01000300 or 0x01000400. For more details, see Section 6.1.
Possibles values:
• v1.0.0 packages including:
– Application Layer Clock Synchronization v1.0.0
– Remote Multicast Setup v1.0.0
– Fragmented Data Block Transport v1.0.0
• v2.0.0 packages including:
– Application Layer Clock Synchronization v2.0.0
– Remote Multicast Setup v2.0.0
– Fragmented Data Block Transport v2.0.0
– Firmware Management Protocol v1.0.0
The debug mode enables the SWD pins, even when the MCU goes in low-power mode.
Note: In order to enable a true low-power, #define DEBUGGER_ENABLED must be reset.
Some additional defines activate monitoring (probes) of some internal RF signal for debug:
#define DEBUG_SUBGHZSPI_MONITORING_ENABLED 0
#define DEBUG_RF_NRESET_ENABLED_ENABLED 0
#define DEBUG_RF_HSE32RDY_ENABLED_ENABLED 0
#define DEBUG_RF_SMPSRDY_ENABLED 0
#define DEBUG_RF_LDORDY_ENABLED 0
#define DEBUG_RF_DTB1_ENABLED 0
#define DEBUG_RF_BUSY_ENABLED 0
where:
• Low power enabled = 0 means the MCU enters to Stop 2 mode
Stop 2 is a Stop mode with low-power regulator and VDD12I interruptible digital core domain supply OFF.
Less peripherals are activated than in low-power Stop 1 mode to reduce power consumption.
Refer to document [6] for more details.
• Low power disabled = 1 means the MCU enters only in Sleep mode.
Project
Detail Switch option Definition Location
module
REGION_EU433
REGION_US915
REGION_AS923
REGION_AU915
Supported regions Regions supported by the device
REGION_CN470
REGION_CN779
REGION_IN865
REGION_RU864
lorawan_conf.h
REGION_KR920
REGION_AS923_DEFAULT_CHANNEL
AS923 channel plan Channel plan for region AS923
_PLAN
Limits the number of usable
Limited channels HYBRID_ENABLED channels by default for AU915,
CN470 and US915 regions.
Defines the read access of the keys
Read keys KEY_EXTRACTABLE
in the memory.
lora_app.h
Duty cycle APP_TX_DUTYCYCLE Time period between two Tx sent
Project
Detail Switch option Definition Location
module
LORAWAN_DEFAULT_PING
Ping period Rx ping slot period
_SLOT_PERIODICITY
LORAWAN_DEFAULT
Network Join activation Activation procedure default choice
_ACTIVATION_TYPE
Initial region ACTIVE_REGION Region used at device startup
11 SubGhz_Phy_PingPong application
This application shows a simple Rx/Tx RF link between the two PingPong devices (one called Ping, the other
called Pong).
By default, each PingPong device starts as a master, transmits a 'Ping' message, and waits for an answer. At
startup, each PingPong device has its two LEDs blinking. When the boards are synchronized (Tx window of one
board aligned with Rx window of the other board), the Ping device (board receiving 'Ping' message) makes the
green LED blinking, and the Pong device (board receiving 'Pong' message) makes the red LED blinking. The first
PingPong device that receives a 'Ping' message becomes a slave and answers with a 'Pong' message to the
master.
See Table 2 for applicability.
To launch the SubGhz_Phy_PingPong project, the user must go to
\Projects\<target>\Applications\SubGHz_Phy\SubGHz_Phy_PingPong and follow the same
procedure as for the LoRaWAN_End_Node project to launch the preferred toolchain. Select the project from the
proper target board.
DT64333V1
or or
B-WL5M-SUBG1 B-WL5M-SUBG1
LoRa FSK
LoRa FSK
The expected value of LORA_BANDWIDTH must be in the 0-2 range, corresponding the equivalent frequency:
[0: 125 kHz, 1: 250 kHz, 2: 500 kHz].
The expected value of LORA_SPREADING_FACTOR must be in the 7-12 range. The spreading factor influences
the time it takes to transmit a frame and the transmission power.
The expected value of FSK_BANDWIDTH must be in the 4800-500000 range (in Hz).
The expected value of FSK_DATARATE equivalent to the bitrate value, is typically defined a 50 kbps.
LoRa FSK
Rx/Tx
MAX_APP_BUFFER_SIZE Max data buffer size
subghz_phy_app.c
configuration RX_TIME_MARGIN Time between the end of Rx and start of Tx
Modulation
USE_MODEM_LORA LoRa modem selected
configuration USE_MODEM_FSK FSK modem selected
Bandwidth:
• 0: 125 kHz
LORA_BANDWIDTH • 1: 250 kHz
• 2: 500 kHz
• 3: Reserved
LORA_SPREADING_FACTOR Spreading factor: SF7 to SF12
Coding rate:
LoRa specific • 1: 4/5 subghz_phy_app.h
parameters LORA_CODINGRATE • 2: 4/6
• 3: 4/7
• 4: 4/8
LORA_PREAMBLE_LENGTH Length of Tx/Rx preamble
12 SubGHz_Phy_LrFhss application
The SubGHz_Phy_LrFhss application is a fast frequency hopping spread spectrum (FHSS) modulation test based
on Tx only generation from the device to the gateway.
The transmission starts in LR-FHSS with a payload of 64 bytes. This application requires a gateway solution
integrating the LR-FHSS modulation.
See Table 2 for applicability.
To launch the SubGhz_Phy_LrFhss project, the user must go to
\Projects\<target>\Applications\SubGHz_Phy\SubGHz_Phy_LrFhss, and follow the same procedure
as for the LoRaWAN_End_Node project to launch the preferred toolchain.
Gateway supporting
Tx device LR-FHSS
ComPort -------------------------- -------------------------- ComPort
NUCLEO-WL55JC
DT71515V1
or -
B-WL5M-SUBG1
Rx/Tx
TX_TIMEOUT_VALUE Tx window timeout
subghz_phy_app.c
configuration MAX_APP_BUFFER_SIZE Max data buffer size
Common
PAYLOAD_LEN Data buffer size subghz_phy_app.h
parameters
13 SubGhz_Phy_Per application
The SubGHz_Phy_Per application is a packet-error-rate test with IBM® whitening between one Tx device and one
Rx device.
Tx device
Update #define TEST_MODE to RADIO_TX in /SubGHz_Phy/App/subghz_phy_app.c. Compile and load.
The packet content is preamble | sync | payload length | payload | crc where:
• crc is calculated using payload length and payload.
• Whitening is calculated over payload length | payload | crc.
The transmission starts by default in GFSK 50 Kbit/s with a payload of 64 bytes. These parameters can be
modified in /SubGHz_Phy/App/subghz_phy_app.h with the same defines as described in Section 11.2.
In addition, the application can be modified in runtime by the user buttons:
• The user button 1 increments packet length by 16 bytes.
• The user button 2 increments packet length by 1 byte.
• The user button 3 toggles packet payload mode from ramp (0x00, 0x01..) to prbs9.
The blue LED is on while radio in Tx.
Rx device
Update #define TEST_MODE to RADIO_RX in /SubGHz_Phy/App/subghz_phy_app.c. Compile and load.
The green LED is on when Rx is OK. The red LED is on when Rx is KO.
See Table 2 for applicability.
To launch the SubGhz_Phy_Per project, the user must go to
\Projects\<target>\Applications\SubGHz_Phy\SubGHz_Phy_Per, and follow the same procedure as
for the LoRaWAN_End_Node project to launch the preferred toolchain.
Tx device Rx device
ComPort -------------------------- -------------------------- ComPort
NUCLEO-WL55JC NUCLEO-WL55JC
DT69139V1
or or
B-WL5M-SUBG1 B-WL5M-SUBG1
Modulation
USE_MODEM_LORA LoRa modem selected
configuration USE_MODEM_FSK FSK modem selected
Bandwidth:
• 0: 125 kHz
LORA_BANDWIDTH • 1: 250 kHz
• 2: 500 kHz
• 3: Reserved
LORA_SPREADING_FACTOR Spreading factor: SF7 to SF12
Coding rate:
LoRa specific • 1: 4/5 subghz_phy_app.h
parameters LORA_CODINGRATE • 2: 4/6
• 3: 4/7
• 4: 4/8
LORA_PREAMBLE_LENGTH Length of Tx/Rx preamble
14 AT_Slave applications
The purpose of these applications is to implement a SubGHz_Phy modem controlled through the AT command
interface over UART by an external host.
The external host can be a host microcontroller embedding the application and the AT driver, or simply
a computer executing a terminal. The communication between STM32WL5x/Ex and the external host happens via
AT commands over LPUART. For these applications, the STM32WL5x/Ex devices are always in Stop 2 mode
unless it wakes up to process an AT command from the external host.
See Table 2 for applicability.
Two applications are available:
• The SubGHz_Phy_AT_Slave allows an external host (via AT commands) to run some RF test on
STM32WL5x/Ex microcontrollers.
• The LoRaWAN_AT_Slave allows an external host (via AT commands) to drive the LoRaWAN stack over
the built‑in LoRa radio.
Note: The LoRaWAN_AT_Slave can also be used to run the same RT test commands as the SubGHz_Phy_AT_Slave.
Therefore, the device must be reset before using again LoRaWAN stack AT commands.
General commands
AT Checks if the interface is available Yes
AT? Helps all supported commands. Yes
ATZ Resets. Yes
AT+VER Gets the application/middleware versions. Yes
AT+VL Gets the local time in UTC format. Yes
LoRaWAN stack context management command
Erases LoRaWAN context in flash memory and restore factory
AT+RFS Yes No
settings after a reset.
AT+CS Stores the current LoRaWAN context to flash memory sector. Yes No
LoRaWAN Keys, IDs, and EUIs management commands
AT+APPEUI Sets/gets the application EUI. Yes No
AT+NWKKEY Sets/gets the network root key. Yes No
AT+APPKEY Sets/gets the application root key. Yes No
AT+APPSKEY Sets/gets the application session key. Yes No
AT+NWKSKEY Sets/gets the network session key. Yes No
AT+DADDR Sets/gets the device address. Yes No
AT+DEUI Sets/gets the module unique ID. Yes No
AT+NWKID Sets/gets the network ID. Yes No
LoRaWAN join and send data commands
AT+JOIN Joins the network. Yes No
The Piggyback link checks the MAC command request to the next
AT+LINKC Yes No
uplink.
AT+SEND Sends packets to the network. Yes No
LoRaWAN network management commands
AT+ADR Sets/gets the adaptive data rate functionality. Yes No
AT+DR Sets/gets the data rate. Yes No
AT+BAND Sets/gets the active region. Yes No
AT+CLASS Sets/gets the LoRa class. Yes No
AT+DCS Sets/gets duty cycle settings. Yes No
AT+JN1DL Sets/gets the join delay on Rx window 1. Yes No
AT+JN2DL Sets/gets the join delay on Rx window 2. Yes No
AT+RX1DL Sets/gets the delay of the Rx window 1. Yes No
AT+RX2DL Sets/gets the delay of the Rx window 2. Yes No
AT+RX2DR Sets/gets data rate of the Rx window 2. Yes No
AT+RX2FQ Sets/gets the frequency of the Rx window 2. Yes No
AT+TXP Sets/gets the transmit power. Yes No
AT+PGSLOT Sets/gets the unicast ping slot periodicity. Yes No
Radio tests commands
AT+TTONE Sets the RF tone test. Yes
AT+TRSSI Sets/gets the config LoRa RF test. Yes
AT+TTX Sets the number of packets to be sent for PER RF Tx test. Yes
AT+TRX Sets the number of packets to be received for PER RF Rx test. Yes
Starts RF Tx hopping test from Fstart to Fstop (in Hz or MHz), Fdelta
AT+TTH Yes
in Hz.
AT+TOFF Stops RF tests. Yes
LoRaWAN certification command
AT+CERTIF Sets the module in LoRaWAN certification with join mode. Yes No
Information command
AT+BAT Gets the battery level. Yes No
The table below summarizes the main options for the AT_Slave applications configuration.
Project
Detail Switch option Definition Location
module
REGION_EU433
REGION_US915
REGION_AS923
REGION_AU915
Supported regions Regions supported by the device
REGION_CN470
REGION_CN779
REGION_IN865
REGION_RU864
lorawan_conf.h
REGION_KR920
REGION_AS923_DEFAULT_CHANNE
AS923 channel plan Channel plan for region AS923
L_PLAN
Limits the number of usable
Limited channels HYBRID_ENABLED channels by default for AU915,
CN470, and US915 regions.
Defines the read access of the keys
Read keys KEY_EXTRACTABLE
in the memory.
Project
Detail Switch option Definition Location
module
SLOT_PERIODICITY
application(1)
LoRaWAN
lora_app.h
Initial region ACTIVE_REGION Region used at device startup
DEBUGGER_ENABLED
Global application
The NVM context management is used to store the current LoRaWAN stack configuration in ROM before a
power-off or a reset of the board.
The proposed solution is to store the LoRaMacNvmData_t structure of size 1484 bytes in a pre-allocated ROM
page of 2 Kbytes.
This structure is defined as below:
Size
Field Type Description
(bytes)
Function Description
If callbacks are not defined, the feature is considered as disabled. The feature is enabled by the define described
in Section 10.2.12.
16 Dual-core management
Intercore memory
Data path
MBMUX
The mailbox is specified to allow changes of the buffer definition to some extend, without breaking the backward
compatibility.
MBMUX
IPCC_IF
CPU1 to CPU2 communication direction
In order to use the MBMUX, a feature needs to be registered (except the system feature that is registered by
default and always mapped on IPCC channel 0). The registration dynamically assigns to the feature, the
requested number of IPCC channels: typically one for each direction (CPU1 to CPU2 and CPU2 to CPU1).
In the following cases, the feature needs just a channel in one direction:
• Trace feature is only meant to send debug information from CPU2 to CPU1.
• KMS is only used by CPU1 to request functions execution to CPU2.
Note: • The RTC alarm A transfers the interrupt using one IPCC IRQ, not considered as a feature.
• The user must consider adding KMS wrapper to be able to use it as a feature.
Notif/Ack communication
channel message
Cmd/Response communication
channel message
MBMUX
IPCC
Conversely, when the CPU2 needs to call a CPU1 feature_func_X_2(), a feature_func_X_2() with the
same API must be implemented on the CPU2:
1. The CPU2 sends a notification containing feature_func_X_2() in the Mapping table.
2. The CPU1 sends an acknowledge and fills the Mapping table with the return value.
MBMUX
MAPPING_TABLE
func_X_ID
a
b
c
k
CPU1 CPU2
application feature_mbwrapper.c feature_mbwrapper.c stack
a_function()
{
... feature_func_X(a,b,c)
k = { feature_func_X_wrap()
feature_func_X(a,b,c); stores: {
func_X_ID, a, b ,c k =
in MappingTable feature_func_X(a,b,c);
} }
feature_func_X(a,b,c)
{
...
CPU1 return k;
waits }
...
process continues
return;
} /* end of a_function */
MBSYS_RefTable
MBCmdRespParam[0] MsgId
MBCmdRespParam[1] void (*MsgCm4Cb)(void ComObj);
MBCmdRespParam[2] void (*MsgCm0plusCb)(void ComObj);
MBCmdRespParam[3] BufSize
MBCmdRespParam[4] ParamCnt
MBCmdRespParam[5] *ParamBuf
MBNotifAckParam[0] ReturnVal
MBNotifAckParam[1]
MBNotifAckParam[2]
MBNotifAckParam[3]
MBNotifAckParam[4]
MBNotifAckParam[5]
MBMUXMapping
[FEAT_INFO_CNT][2];
SynchronizeCpusAtBoot
ChipRevId Legend: init at registration
Page
index
10
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
11
1
2
3
4
5
6
7
8
9
(1)
Allocation region/
RAM2_Shared
RAM2_Shared
section
CPU1
CPU2
CPU1 RAM CPU2 RAM2
Size Total
CPU region Section Module Allocated symbol
(bytes) (bytes)
readwrite
CPU1 RAM CSTACK -
HEAP
MAPPING
MBMUX_SYSTEM MBMUX_ComTable_t MBSYS_RefTable 316 316
_TABLE
uint32_t aLoraCmdRespBuff[] 60
MBMUX_LORAWAN
uint32_t aLoraNotifAckBuff[] 20
uint32_t aRadioCmdRespBuff[] 60
MBMUX_RADIO
uint32_t aRadioNotifAckBuff[] 16
uint32_t aSystemPrioACmdRespBuff[] 4
MBMUX_SYSTEM
uint32_t aSystemPrioANotifAckBuff[] 4
uint32_t aSystemPrioBCmdRespBuff[] 4
uint32_t aSystemPrioBNotifAckBuff[] 4
Size Total
CPU region Section Module Allocated symbol
(bytes) (bytes)
readwrite
CPU2 RAM2 CSTACK -
HEAP
1. This new section prevents overcharge of Flash usage to init these BSS RAM variables with STM32CubeIDE.
CPU1 CPU2
boot
Platform init
· HAL
· System clock config
· LPM iNit
· Trace/USART config
Boot
Core init
· HAL init
· RTC init
· LPM init
CPU1 CPU2
MBMUX
Sequencer_run(idle)
Request to Cortex-M0+
feature list pointer Cmd
Respond to Command()
Resp Sequencer_run(idle)
Register high-Priority
channel for RTC Cmd
SynchronizeCpusAtBoot = 0x9999
Key management services (KMS) provide cryptographic services through the standard PKCS#11 APIs
(developed by OASIS), are used to abstract the key value to the caller (using object ID and not directly the key
value).
KMS can be executed inside a protected/isolated environment in order to ensure that key value cannot be
accessed by an unauthorized code running outside the protected/isolated environment, as shown in the figure
below.
KEY1
STM32 device (VALUE1)
Data file
User application
Token = STM32
Secure key update
(import BLOB())
AES RSA/
Object
decrypt/ ECDSA Digest
management
encrypt sign/verify
NVM storage
Dynamic Static ID
Static embedded keys ID keys keys
Isolated/protected environment
For more details, refer to KMS section in the user manual Getting Started with the SBSFU of STM32CubeWL
(UM2767) .
To activate the KMS module, KMS_ENABLE must be set to 1 in C/C++ compiler project options.
KMS supports only PKCS #11 APIs listed below:
• Object management functions (creation/update/deletion)
• AES encryption/decryption functions (CBC, CCM, ECB, GCM, CMAC algorithms)
• Digesting functions
• RSA and ECDSA signing/verifying functions
• Key management functions ( key generation/derivation)
Static key
Each static key is composed of the two following elements:
• a blob header: five 4-byte fields (total = 20 bytes): version, configuration, blob_size,
blob_count, and object_id.
• a blob buffer: some required and option blob elements, from the list of elements defined as follows:
CKA_DERIVE TRUE/FALSE No 12
CKA_EXTRACTABLE TRUE/FALSE No 12
12 for static
key
CKA_LABEL "UNIQUE LABEL" Yes Unique label
16 for dynamic
key
Example:
A static key composed of a blob header and eight blob elements (CKA_CLASS, CKA_KEY_TYPE, CKA_VALUE,
CKA_LABEL, CKA_DERIVE, CKA_DECRYPT, CKA_COPYABLE, and CKA_EXTRACTABLE), uses a total size of
128 bytes (blob header = 20 bytes, and blob buffer = (12 × 7 + 24) = 108 bytes).
Dynamic key
Each dynamic key is composed of three elements, a data header, a blob header, and a blob buffer, with:
• a data header: eight 4-byte fields (total = 32 bytes): magic1, magic2, slot, instance, next,
data_type, size, and checksum.
Example:
A dynamic key composed of a data header, a blob header and five blob elements (CKA_CLASS, CKA_KEY_TYPE,
CKA_VALUE, CKA_LABEL, and CKA_EXTRACTABLE) uses a total size of 128 bytes (data header = 32 bytes,
blob header = 20 bytes, and blob buffer = (12 + 12 + 24 + 12 + 16) = 76 bytes.
Note: • The NVM dynamic memory always starts with an initial data header element.
• At each dynamic key 'deletion' (such as an obsolete key replaced by a new key value), an additional data
header is written in the memory to declare that the previous instance cannot longer be used.
Key
LoRaWAN_Zer
LoRaWAN_APP
LoRaWAN_NWK
LoRaWAN_NWK
LoRaWAN_APP
(ABP only)
(ABP only)
_S_Key
_S_Key
o_Key
Attribute
_Key
_Key
CKA_CLASS CKO_SECRET_KEY
KA_KEY_TYPE CKK_AES
CKA_VALUE "KEY_VALUE"
CKA_DERIVE FALSE TRUE TRUE TRUE TRUE
CKA_ENCRYPT TRUE FALSE FALSE TRUE TRUE
CKA_DECRYPT FALSE FALSE FALSE TRUE TRUE
CKA_COPYABLE FALSE
CKA_EXTRACTABLE FALSE TRUE/FALSE defined by #define KEY_EXTRACTABLE
CKA_ LABEL "UNIQUE LABEL"
All other keys are mutable NVM_DYNAMIC generated keys, detailed in the table below.
Key
LoRaWAN_NWK
LoRaWAN_APP
MC_ROOT_Key
MC_APP_S_Ke
MC_NWK_S_Ke
SLOT_RAND_Z
MC_KE_Key
(OTAA only)
(OTAA only)
MC_KEY_0
ERO_Key
_S_Key
_S_Key
Attribute
y_0
y_0
CKA_CLASS CKO_SECRET_KEY
KA_KEY_TYPE CKK_AES
CKA_VALUE "KEY_VALUE"
CKA_DERIVE TRUE
CKA_ENCRYPT TRUE
CKA_DECRYPT TRUE
CKA_COPYABLE TRUE
CKA_EXTRACTABLE TRUE/FALSE defined by #define KEY_EXTRACTABLE
CKA_ LABEL "UNIQUE LABEL"
0x0803 FFFF
0x0803 E7FF
USER_embedded_Keys
CPU2 0x0803 E500
0x0803 DFFF
KMS_DataStorage
0x0803 D000
0x0802 0000
0x0801 FFFF
CPU1
0x0800 0000
Smaller is the NVM size, more the NVM is written and erased, shorter becomes its life expectation.
Destroy a key does not mean that this key is erased, but that this key is tagged as destroyed and is not copied at
the next flip‑flop switch. A destroy flag also occupies some NVM bytes: after destroying eight keys, the remaining
place is less than four keys.
For a scenario where four keys are generated each join, and after having destroyed the previous join key, the life
expectation is estimated as follows:
• At the 3rd join session, four new keys are derived but no place in page 1 for the last key. All four keys
(being still active) are placed in page 2. Page 1 is erased at once as the NVM page can only be fully
erased .
• At the 5th join also, page 2 is erased and keys are stored back on page 1. After 40.000 joins, the two NVM
pages have been erased 10.000 times, that is the estimated lifetime of the Flash sector.
• If the user application is supposed to join excessively frequently (for example every 2 hours), the expected
NVM live is 80.000 hours (around nine years). If the join process is done once a day, the lifetime is much
greater than ten years.
Bigger are the amount of requested derived keys simultaneously active (not destroyed), less efficient is the flip-
flop mechanism.
To conclude, for applications that need to preserve the NVM life-time duration, it is suggested to keep the NVM
size rather bigger than the number of keys active simultaneously (not destroyed).
Note: Obsolete keys must be destroyed otherwise, if page 1 is fully filled by active keys, the flip-flop switch cannot be
done and an error is generated.
in CM0PLUS/LoRaWAN/Target/lorawan_conf.h
The following files must be filled with the information on SubGHz_Phy stack keys:
• embedded keys structures defined in CM0PLUS/Core/Inc/kms_platf_objects_config.h
• embedded object handles associated to SubGHz_Phy stack keys, use of KMS modules defined in
CM0PLUS/Core/Inc/kms_platf_objects_interface.h
The document [10] describes how to secure a dual-core LoRaWAN application using the SBSFU framework.
19 System performances
Flash memory
Project module RAM (bytes) Description
(bytes)
DT64334V1
MCU
SUBGHZ_Radio_IRQHandler
txDone rxDone
Rx window channel starts. The Rx1 window opens 1 second (±20 μs) after the txDone falling edge. The Rx2
window opens 1 second (±20 μs) after the txDone falling edge.
The JOIN_ACCEPT uses a 5 seconds (±20 μs) and 6 seconds delay after the end of the uplink modulation.
The current scheduling interrupt-level priority must be respected. In other words, all the new user-interrupts must
have an interrupt priority higher than the Radio IRQ_interrupt in order to avoid stalling the received startup time.
Revision history
Table 47. Document revision history
Updated:
• Table 1. Acronyms and terms
• Section 2 STM32CubeWL overview
• Section 6 LoRaWAN middleware description
Added:
• Section 5 LoRaWAN stack description
• Section 5.4.3 Required STM32 peripherals to drive the radio
• Section 9.1 LoRaWAN user code sections description
• Section 9.2.12 Context management
21-Feb-2022 6 • Section 13 LoRaWAN context management description
• Section 13.1 NVM context management data API definition
• Section 10.2 Device configuration
• Section 10.2.1 Modulation definition
• Section 10.2.2 Payload length
• Section 10.2.3 Region and frequency
• Section 10.2.4 Bandwith, spreading factor and data rate
• Section 10.2.5 Preamble length
Removed:
• STM32CubeWL architecture
Updated:
• Table 1. Acronyms and terms
• Section 2 STM32CubeWL overview
• Section 6 LoRaWAN middleware description
Added:
• Section 5 LoRaWAN stack description
• Section 5.4.3 Required STM32 peripherals to drive the radio
• Section 9.1 LoRaWAN user code sections description
• Section 9.2.12 Context management
17-Nov-2022 7 • Section 13 LoRaWAN context management description
• Section 13.1 NVM context management data API definition
• Section 10.2 Device configuration
• Section 10.2.1 Modulation definition
• Section 10.2.2 Payload length
• Section 10.2.3 Region and frequency
• Section 10.2.4 Bandwith, spreading factor and data rate
• Section 10.2.5 Preamble length
Removed:
• STM32CubeWL architecture
Changed the scope of this document from STM32WL Series to STM32WL5x/Ex
20-Mar-2025 8
devices.
Contents
1 General information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 STM32CubeWL overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3 SubGHz HAL driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1 SubGHz resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.2 SubGHz data transfers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
4 BSP STM32WL55 Nucleo boards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4.1 Frequency band . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4.2 RF switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4.3 RF wakeup time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.4 TCXO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.5 Power regulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.6 STM32WL Nucleo board schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
5 BSP B-WL5M-SUBG1 boards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10
5.1 RF switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.2 External components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
6 LoRaWAN stack description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
6.1 LoRaWAN specifications version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
6.2 LoRaWAN commissioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
6.3 LoRaWAN certification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
6.4 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
6.4.1 Static view. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
6.4.2 Dynamic view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
6.4.3 Required STM32 peripherals to drive the radio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
7 LoRaWAN middleware description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16
7.1 LoRaWAN middleware initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
7.2 Middleware MAC layer APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
7.3 Middleware MAC layer callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
7.4 Middleware MAC layer timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
7.5 Middleware LmHandler application function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
7.5.1 Operation model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
7.5.2 Main application functions definition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
7.6 Application callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
7.7 Extended application functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
8 SubGHz_Phy layer middleware description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
List of tables
Table 1. Acronyms and terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Table 2. LoRaWAN and SubGHz_Phy projects list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Table 3. BSP radio switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Table 4. RF states versus switch configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Table 5. BSP radio wakeup time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Table 6. BSP radio TCXO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Table 7. BSP radio SMPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Table 8. BSP radio switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Table 9. LoRaWAN stack description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Table 10. LoRaWAN certification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Table 11. LoRaWAN middleware initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Table 12. MCPS services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Table 13. MLME services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Table 14. MIB services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Table 15. LoRaMacPrimitives_t structure description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Table 16. MAC Timer events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Table 17. LmHandler main functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Table 18. LmHandlerCallbacks_t callback structure description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Table 19. Getter/setter functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Table 20. Radio_s structure callbacks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Table 21. Radio IRQ bit mapping and definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Table 22. Sequencer APIs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Table 23. While-loop standard vs. sequencer implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Table 24. Timer server APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Table 25. Low-power APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Table 26. Low-level APIs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Table 27. System time functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Table 28. Trace functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Table 29. LoRaWAN user functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Table 30. Switch options for LoRaWAN_End_Node application configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Table 31. SubGHz_Phy_PingPong modulation configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Table 32. SubGHz_Phy_PingPong bandwith, SF and DR configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Table 33. SubGHz_Phy_PingPong preamble configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Table 34. Switch options for SubGhz_Phy_PingPong application configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Table 35. Switch options for SubGhz_Phy_LrFhss application configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Table 36. Switch options for SubGhz_Phy_Per application configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Table 37. AT commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Table 38. Switch options for AT_Slave applications configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Table 39. LoRaWAN NVM context structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Table 40. LoRaWAN context management API and callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Table 41. STM32WL5x RAM mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Table 42. STM32WL5x RAM allocation and shared buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Table 43. Global KMS blob elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Table 44. LoRaWAN static keys with blob attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Table 45. LoRaWAN dynamic keys with blob attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Table 46. Memory footprint values for LoRaWAN_End_Node application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Table 47. Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
List of figures
Figure 1. Project file structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Figure 2. NUCLEO-WL55JC schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Figure 3. Static LoRa architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Figure 4. Class A Tx and Rx processing MSC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Figure 5. Operation model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Figure 6. Example of low-power mode dynamic view. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Figure 7. SubGhz_Phy_PingPong application setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Figure 8. SubGhz_Phy_LrFhss application setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Figure 9. SubGhz_Phy_Per application setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Figure 10. Mailbox overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Figure 11. MBMUX - Multiplexer between features and IPCC channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Figure 12. Mailbox messages through MBMUX and IPCC channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Figure 13. CPU1 to CPU2 feature_func_X() process. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Figure 14. MBMUX communication table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Figure 15. Startup sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Figure 16. MBMUX initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Figure 17. KMS overall architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Figure 18. ROM memory mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Figure 19. Flash memory and RAM footprint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Figure 20. Rx/Tx time diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Figure 21. NUCLEO-WL55JC1 current consumption versus time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Figure 22. NUCLEO-WL55JC1 current consumption in Stop 2 mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73