An5408 Migrating From stm32l0 stm32l1 and stm32l4 Series Associated With sx12xx Transceivers To stm32wl Series Microcontrollers Stmicroelectronics
An5408 Migrating From stm32l0 stm32l1 and stm32l4 Series Associated With sx12xx Transceivers To stm32wl Series Microcontrollers Stmicroelectronics
Application note
Introduction
Migrating an application to a different microcontroller is often needed when product requirements grow, putting extra demands
on memory size, or increasing the number of I/Os. On the other hand, cost reduction objectives may force the user to switch to
smaller components and to shrink the PCB area.
This application note details the steps needed to migrate:
• from an existing application based on a microcontroller of the STM32L0, STM32L1 or STM32L4 Series, associated with
one SX12xx Semtech LoRa® transceiver
• to an application based on a microcontroller of the STM32WL Series
This document lists the main features that are necessary to build a LoRaWAN® application on STM32L0, STM32L1 or
STM32L4 Series and the equivalent features of STM32WL Series devices. For more details, see the reference manuals and
datasheets of the products.
A good knowledge of SX12xx Semtech transceivers is also needed.
Table 1. Applicable products
Reference Products
1 System overview
Several hardware models target sub-GHz RF communications. This document focus on the ones supported by
LoRaWAN STM32Cube firmwares for STM32L1/2/4 and STM32WL Arm® Cortex®-M based microcontrollers.
Note: Arm is a registered trademark of Arm Limited (or its subsidiaries) in the US and/or elsewhere.
SX1276MB1MAS X(1) X X X
SX1276MB1LAS X X X X
SX1272MB2DAS X X X X
SX1261DVK1BAS X X X X
SX1262DVK1CAS X X X X
SX1262DVK1DAS X X X X
1. X = supported.
The two Semtech radio generations featuring LoRa modulation are described in the next sections.
Board Characteristics
SX1276MB1MAS 868 MHz (HF) at 14 dBm and 433 MHz (LF) at 14 dBm
SX1276MB1LAS 915 MHz (HF) at 20 dBm and 433 MHz (LF) at 14 dBm
SX1272MB2DAS 915 MHz and 868 MHz at 14 dBm
SX1261DVK1BAS E406V03A SX1261, 14 dBm, 868 MHz, XTAL
SX1262DVK1CAS E428V03A SX1262, 22 dBm, 915 MHz, XTAL
SX1262DVK1DAS E449V01A SX1262, 22 dBm, 860-930 MHz, TCXO
The figure below shows the main interconnections between the MCU and the SX127xx.
nreset nreset
PA_BOOST
SPI SPI
VR_PA
RF switch
USART Ant
STM32Lx DIO0 SX127x
I2C DIO1 RFO_HF
DIO2
GPIO DIO3
RFI_HF
DBG
SW-CTL
nreset VR_PA
nreset
SPI SPI
RFO
RF switch
USART Ant
STM32Lx DIO0 SX126x
I2C
GPIO Busy
RFI
DBG
SW-CTL
On the CMWX1ZZABZ module, the following RF pins are connected to the RF switch pads:
• RF RX
• RFO_HF (RF low power) for the 14 dBm regions
• PABOOST (RF high power) for the 20 dBm regions
32 kHz 32 MHz
CMWX1ZZABZ module
nreset nreset
PA_BOOST
SPI SPI
VR_PA
RF switch
USART Ant
STM32L0 DIO0 SX1276
I2C DIO1 RFO_HF
DIO2
GPIO DIO3
RFI_HF
DBG
SW-CTL
SUBGHZ
Sub-GHz LDO/SMPS
APBS
SPI
radio HSE32
32 MHz
32 kHz
TAMP system peripheral
Flash interface
256-Kbyte
JTAG/SWD
memory
arbiter +
Flash
Backup IWDG
LSI
32 kHz
domain
HSI 1 %
16 MHz
PLL
MSI 5 %
NVIC 4-48MHz
AHB shared
PWR COMP/VREF
DMA1 (7 channels) EXTI WWDG
CTI
NVIC
SUBGHZ
Cortex-M0+ LDO/SMPS
Sub-GHz
SPI
≤ 48 MHz
radio HSE32
32 MHz
MPU Sub-GHz radio
SRAM2 system peripheral
backup memory
RTC LSE
32 kHz
Flash interface arbiter
TAMP
Flash memory
ART Accelerator
JTAG/SWD
Backup IWDG
LSI
256-Kbyte
32 kHz
domain
+
SRAM1
HSI 1 %
RCC 16 MHz
PLL
MSI 5 %
NVIC PWR 0.1-48MHz
Cortex-M4
AHB3
Power supply
(DSP) EXTI POR/PDR/BOR/PVD/PVM
≤ 48 MHz
HSEM SYSCFG/
MPU
AHB1 and AHB2
COMP/VREF
IPCC
DMA1 (7 channels) WWDG
RNG
DMA2 (7 channels) SPI1
AES
DMAMUX SPI2S2
PKA
GPIO ports A,B,C,H I2C1
TZSC
CRC I2C2
TZIC
DAC (12 bits) I2C3
Temperature sensor
LPUART1 TIM1
ADC (12 bits ULP,
2 Msps, 12 channels)
LPTIM1 TIM2
APB1 and APB 2
LPTIM2 USART1 TIM16
Warning:
The maximum supply voltage on RFO_LP is 1.35 V maximum. This pin must not be connected to
VR_PA in case RFO_HP is used. Otherwise this pin is damaged.
VLXSMPS VLXSMPS
LDO/SMPS LDO/SMPS
VFBSMPS (1.55V) VFBSMPS (1.55V)
VDDPA VDDPA
15 dBm
REG VR_PA (up to 1.35V) REG VR_PA (up to 1.35V)
PA PA
RFO_LP RFO_LP
LP PA LP PA
VDD VDD
VLXSMPS VLXSMPS
LDO/SMPS LDO/SMPS
VFBSMPS (1.55V) VFBSMPS (1.55V)
VDD VDD
VDDPA VDDPA
22 dBm
REG VR_PA (up to 3.1V) REG VR_PA (up to 3.1V)
PA PA
RFO_HP RFO_HP
HP PA HP PA
When an application requires both high-power and low-power RF outputs, DC switches are required as shown
below. The DC switch allows a dynamic selection of the optimum transmitter output (refer to the schematic of
STM32WL Nucleo-73 board, NUCLEO-WL55JC, as an application example). DC switches can be replaced by
solder bridges, if a static configuration is acceptable.
VDD
VLXSMPS
LDO/SMP
VFBSMPS (1.55V)
LP
VDDPA
VDD
LP
(up to 3.1V)
RFO_LP
LP PA
RFO_HP
HP PA
To drive the sub-GHz radio, a new HAL (stm32wlxx_hal_subghz.c) has been introduced managing the
initialization, the radio command and the interrupt handling.
As the configuration is hardware application dependent, the use of TCXO, RF switch types or SMPS depends on
the application. The middleware needs to be aware of these specificities to ensure proper settings are applied.
LoRa application
(AT_Slave, End_Node or PingPong)
LoRaWAN middleware
LmHandler.h
Timer server
radio.h
SubGHz_Phy middleware Sequencer
radio.c
Debug trace
Low-power
radio_driver.c mode
The LoRaWAN stack directory structure, for I-CUBE-LRWAN and STM32CubeWL, are compared in the figure
below.
No external radios!
The main features of the STM32WL devices versus STM32L0/1/4 ones are detailed in the table below.
STM32WLE5JCxx
Feature STM32L073xx STM32L152xx STM32L476xx
STM32WL55JCxx
Cortex-M4
Core Cortex-M0+ Cortex-M3 Cortex-M4-F
Cortex-M0(1)
FPU No No Yes No
Max Flash memory
192 512 1024 256
(Kbytes)
SRAM (Kbytes) 20 80 128 64
EEPROM (Kbytes) 6 16 No No
OTP No No Yes Yes
Max CPU frequency
32 32 80 48
(MHz)
Operating voltage 1.65 to 3.6 V 1.65 to 3.6 V 1.71 to 3.6 V 1.8 to 3.6 V
CAN1, DFU (USB
device FS), I2C1/
SPI1, USART1/ SPI1, USART1/ SPI1/SPI2,USART1/
Bootloader I2C2/I2C3,SPI1/SPI2,
USART2, USB USART2, USB USART2
USART1/USART2/
USART3/
Advanced timers 0 0 2 1
General- purpose timers
4 7 7 3
(16 and 32 bits)
Basic timers 2 2 2 0
Low-power timers 1 no 2 3
Hardware calendar
RTC Hardware calendar Hardware calendar Hardware calendar
and/or counter
QUADSPI No No Yes No
I2C 3 2 3 3
USART 4 5 5 2
LPUART 1 No 1 1
USB USB device FS USB device FS OTB/FS No
CAN No No Yes No
SWPMI No No Yes No
SAI No No Yes No
SDMMC No No Yes No
DMA 2 (7)
1 (7) 1 (12) 2 (7)
(number of channels) DMA2D + DMAMUX
GPIO (max) 84 115 114 43
ADC 1 1 3 1
STM32WLE5JCxx
Feature STM32L073xx STM32L152xx STM32L476xx
STM32WL55JCxx
DAC 2 2 2 1
No
AES No Yes Yes
(one in STM32L08x)
PKA No No No Yes
RNG No No Yes Yes
UID No No No Yes
LoRa modulation,
Sub-GHz radio No No No (G)FSK, (G)MSK and
BPSK
3 Peripheral migration
Only the main STM32 peripherals required to build low-power RF application are detailed below.
STM32L0 STM32L1
Feature STM32L4 Series STM32WL Series
Series Series
MSI No No It can be used as USB device clock (no need for The MSI is used as
external high-speed crystal oscillator). system clock source
after startup from
Multi speed RC factory and user trimmed
reset, configured at
(100 kHz, 200 kHz, 400 kHz, 800 kHz, 1 MHz,
4 MHz.
2 MHz, 4 MHz (default value), 8 MHz, 16 MHz,
24 MHz, 32 MHz and 48 MHz)
LSI 37 kHz RC 32 kHz RC
HSE32, 32 MHz
HSE 1 - 32 MHz 4 to 48 MHz oscillator clock, with
trimming capacitors
LSE 32.768 kHz 32.768 kHz
One PLL with three outputs One PLL with three
PLL Main PLL
2 + PLL for SAI, USB,ADC outputs
In addition to the differences described in the table above, the following additional adaptation steps may be
needed for the migration:
• performance versus VCORE ranges
• peripheral access configuration
• peripheral clock configuration
3.2 Power
• VDD = 1.65 to 3.6 V: external power supply for I/Os and the internal
regulator, provided externally through VDD pins
• VSSA, VDDA = 1.65 to 3.6 V: external analog power supplies for
ADC, reset blocks, RC and PLL (minimum voltage to be applied to
STM32L0 VDDA pin is 1.8 V when ADC is used). VDDA and VSSA pins must Integrated ZEROPOWER power-
Series be connected to VDD and VSS pins, respectively. on reset (POR)/power-down reset
• VREF+: input reference voltage, only available as an external pin on (PDR) that can be coupled with a
a few packages, otherwise bonded to VDDA Brownout reset (BOR) circuitry
• VDD_USB: dedicated independent USB power supply for full speed Two available versions:
transceivers • BOR activated at power-on
• VDD = 1.65 to 3.6 V: external power supply for I/Os and the internal operates between 1.8 and
regulator, provided externally through VDD pins 3.6 V.
• VSSA, VDDA = 1.65 to 3.6 V: external analog power supplies for • BOR operates between 1.65
and 3.6 V.
STM32L1 ADC, reset blocks, RC and PLL (minimum voltage to be applied to
Series VDDA pin is 1.8 V when ADC is used). VDDA and VSSA pins must
be connected to VDD and VSS pins, respectively.
• VREF+: input reference voltage, only available as an external pin on
some packages, otherwise bonded to VDDA
• VDD = 1.71 to 3.6 V: external power supply for I/Os (VDDIO1), for
the internal regulator and the system analog blocks such as reset,
power management and internal clocks. Provided externally through
VDD pins.
• VDDA = 1.62 (ADCs/COMPs) / 1.8 (DACs/OPAMPs) to 3.6 V: Brownout reset (BOR) active
external analog power supplies for ADCs, DACs, OPAMPs, COMPs in all modes except Shutdown
and VREFBUF. VDDA voltage is independent from VDD. (min BOR level is 1.71 V).
STM32L4 • VDDUSB = 3.0 to 3.6 V: external independent power supply for USB Devices feature an embedded
Series transceivers programmable voltage detector
(PVD) that monitors the VDD
• VDDIO2 = 1.08 to 3.6 V: external power supply for 14 I/Os. VDDIO2
power supply and compares it to
voltage is independent from VDD.
the VPVD threshold.
• VLCD = 2.5 to 3.6 V: the LCD controller can be powered either
externally through VLCD pin, or internally from an internal voltage
generated by the embedded step-up converter.
• VBAT = 1.55 to 3.6 V: power supply for RTC, external clock 32 kHz.
• VDD = 1.71 to 3.6 V: external power supply for I/Os, for the system
analog blocks such as reset, LDO/SMPS, internal clocks and low-
power regulator, provided externally through VDD pins
• VDDA = 1.62 (ADCs/COMPs), 1.8 (DACs/OPAMPs), 2.4 (VREFBUF)
to 3.6 V: external analog power supplies for ADCs, DACs, OPAMPs,
COMPs and VREFBUF.
• VDDSMPS = 1.7 to 3.6 V: external power supply for the SMPS step-
Brownout reset (BOR) active
down converter.
in all modes except Shutdown
• VDDRF = 1.7 to 3.6 V: external power supply for the sub-GHz radio, (min BOR level is 1.71 V).
STM32WL provided externally through the VDDRF pin. Must be connected to
Devices feature an embedded
Series the same supply as VDD pins.
programmable voltage detector
• VBAT = 1.55 to 3.6V: power supply for RTC, TAMP, external clock (PVD) that monitors the VDD
32 kHz oscillator and backup registers (through power switch) when power supply and compares it to
VDD is not present. the VPVD threshold.
• VDDRF1V5 = 1.45 to 1.62 V: external power supply for the sub‑GHz
radio, provided externally through the VDDRF1V5 pin
• VREF-, VREF+: input reference voltage for the ADC. Output of the
internal VREFBUF when enabled:
– When VDDA < 2 V, VREF+ must be equal to VDDA .
– When VDDA ≥ 2 V, VREF+ must be between 2 V and VDDA.
Low‑power mode STM32L0 Series STM32L1 Series STM32L4 Series STM32WL Series
Coarse digital calibration (kept for compatibility only). New developments must only use smooth
STM32L0 Series calibration.
Two anti-tamper detection pins and 20-byte backup registers
Coarse digital calibration (kept for compatibility only). New developments must only use smooth
STM32L1 Series calibration.
One tamper pin and 128-byte backup registers
Only smooth calibration available
STM32L4 Series
Three tamper pins (available in VBAT) and 128-byte backup registers
Binary alarm on 32 sub-second counters
STM32WL Series
Three tamper pins and 80-byte backup registers
LPUART1
Only a 32.768 kHz clock (LSE) is needed to allow LPUART1 communication up to 9600 bauds. Therefore, even
in Stop mode, the LPUART1 can wait for an incoming frame while having an extremely low-energy consumption.
Higher speed clock can be used to reach higher baud-rates.
Revision history
Versi
Date Changes
on
Contents
1 System overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2
1.1 STM32L0/L1/L4 devices + SX12xx radio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1.1 I-CUBE-LRWAN Expansion Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
List of tables
Table 1. Applicable products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Table 2. I-CUBE-LRWAN supported hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Table 3. Semtech radio shield characteristics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Table 4. Main features comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Table 5. RCC features comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Table 6. Power features comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Table 7. Low-power modes and wakeup sources comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Table 8. RTC features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Table 9. Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
List of figures
Figure 1. General principle of STM32Lx/SX127x connections. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Figure 2. General principle of STM32Lx/SX126x connections. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Figure 3. CMWX1ZZABZ module overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Figure 4. Sub-GHz radio peripheral in STM32WLEx devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Figure 5. Sub-GHz radio peripheral in STM32WL5x devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Figure 6. LDO/SMPS power supply schemes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Figure 7. Power strategy supporting low and high output power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Figure 8. Static LoRa architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Figure 9. LoRaWAN stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Figure 10. Sub-GHz radio block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18