STMicroelectronics STM32WB, STM32WL Application note

AN5042 Application note

Precise HSE frequency and startup time tuning for STM32 wireless MCUs

Introduction

This application note describes how to tune the HSE for RF applications using STM32WB and STM32WL Series microcontrollers (hereinafter referred to as STM32 wireless MCUs). These products offer a cost-effective and efficient solution by using their internal load capacitances to control the oscillator accuracy, hence saving the cost of external capacitances and lowering the crystal constraints.

STM32 wireless MCUs use an external oscillator high-speed clock source as the base for RF clock generation. HSE accuracy is essential for RF system performance and the external oscillator is therefore fine-tuned to achieve the highest clock accuracy.

The first part of this application note introduces the crystal oscillator solutions. The second part introduces and then compares three HSE frequency tuning methods, namely a manual one, an automatic one and another one based on STM32CubeMonitor-RF (for the STM32WB Series only). The application of these methods to STM32WB and STM32WL Nucleo boards is described in the following sections and provided as firmware and script examples in X-CUBE-CLKTRIM, an STM32Cube Expansion Package.

A specific section of this document is dedicated to a description of how to configure HSE to make its startup phase reliable and optimized for STM32WB Series microcontrollers.

This application note must be read in conjunction with the reference manuals and datasheets available at www.st.com.

January 2021

AN5042 Rev 10

1/47

www.st.com

Contents

AN5042

 

 

Contents

1

HSE oscillator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. 6

 

1.1

Crystal oscillator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7

 

1.2

STM32 wireless MCUs architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

8

 

1.3

HSE configuration parameters - STM32WB Series . . . . . . . . . . . . . . . . . .

9

 

1.4

HSE configuration parameters - STM32WL Series . . . . . . . . . . . . . . . . .

10

 

1.5

Board implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

10

 

1.6

Crystal references . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

11

 

1.7

Tuning in production . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

12

2

Trimming methods comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

13

3

Manual frequency trimming procedure example for

 

 

the STM32WB Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

15

 

3.1

Procedure description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

15

 

3.2

Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

15

3.2.1 Hardware setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 3.2.2 Software implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3.2.3 Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

4

Manual frequency trimming procedure example for

 

 

the STM32WL Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

21

 

4.1

Procedure description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

21

 

4.2

Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

21

4.2.1 Hardware setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 4.2.2 Software implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 4.2.3 Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

5

Automatic frequency trimming procedure example

 

 

for the STM32WB Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

27

 

5.1

Procedure description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

27

 

5.2

Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

28

5.2.1 Hardware setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 5.2.2 Software implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 5.2.3 Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

2/47

AN5042 Rev 10

AN5042 Contents

6

Automatic frequency trimming procedure example

 

 

for the STM32WL Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

33

 

6.1

Procedure description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

33

 

6.2

Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

34

6.2.1 Hardware setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 6.2.2 Software implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 6.2.3 Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

7

STM32CubeMonitor-RF frequency trimming

 

 

procedure example for the STM32WB Series . . . . . . . . . . . . . . . . . . . .

37

 

7.1

Procedure description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

37

 

7.2

Procedure steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

37

 

7.3

Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

38

7.3.1 Hardware setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 7.3.2 Software and scripts setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 7.3.3 Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 7.3.4 C code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

8

HSE startup optimization for the STM32WB Series . . . . . . . . . . . . . . .

42

9

Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

44

10

Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

45

AN5042 Rev 10

3/47

List of tables

AN5042

 

 

List of tables

Table 1. Carrier accuracy requirement for RF protocols. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Table 2. Oscillator pin numbers for the STM32WB Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Table 3. Crystal specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Table 4. Trimming methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Table 5. Comparison of trimming methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Table 6. Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

4/47

AN5042 Rev 10

AN5042

List of figures

 

 

List of figures

Figure 1. Crystal oscillator principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Figure 2. Crystal oscillator system overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Figure 3. UFQFPN48 (USB dongle board) footprint detail. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Figure 4. Manual calibration overview - STM32WB Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Figure 5. OB configuration to boot from SRAM with BOOT0 value driven by PH3 pin . . . . . . . . . . . 17 Figure 6. OB configuration to boot from SRAM with BOOT0 value

driven by option bit nBOOT0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Figure 7. Configuration store in OTP bytes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Figure 8. Manual calibration overview - STM32WL Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 Figure 9. OB configuration to boot from SRAM with BOOT0 value driven by PH3 pin . . . . . . . . . . . 23 Figure 10. OB configuration to boot from SRAM with BOOT0 value

driven by option bit nBOOT0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Figure 11. Automatic calibration overview - STM32WB Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 Figure 12. Procedure implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Figure 13. Automatic calibration overview - STM32WL Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Figure 14. STM32CubeMonitor-RFcalibration overview - STM32WB Series . . . . . . . . . . . . . . . . . . . 38

AN5042 Rev 10

5/47

HSE oscillator

AN5042

 

 

1 HSE oscillator

RF systems require high frequency accuracy to achieve the best performance. Any clock deviation can cause system malfunctions and/or degrade performance.

Table 1 shows the accuracy requirements for two RF protocols supported by STM32WB Series microcontrollers. For other protocols and standards refer to the corresponding specifications.

Table 1. Carrier accuracy requirement for RF protocols

 

RF standard

 

Carrier accuracy

 

 

 

 

 

Bluetooth® Low Energy

 

± 50 ppm

 

IEEE 802.15.4 / Thread

 

± 40 ppm

 

 

 

 

In STM32 wireless MCUs, based on Arm®(a) Cortex® cores, the RF clock is provided by a

 

high frequency VCO, which takes as reference a signal created by an embedded oscillator

 

using an external crystal.

 

 

This crystal is the HSE (high-speed external) clock source of the RF synthesizer and of the

 

microcontroller. Its nominal frequency can vary, depending on factors such as process

 

variations, used crystal and PCB design. Since the inaccuracy of the HSE is directly

 

transferred to the RF clock, it must be fine-tuned by adjusting load capacitance at crystal

 

terminals.

 

 

STM32 wireless MCUs offer an efficient architecture with internal load capacitances that

 

allows the users to fine tune the crystal frequency without extra cost for additional external

 

capacitances.

 

 

The reliability of the startup phase of an HSE oscillator depends on its actual

 

implementation (e.g. upon associated crystal, external components, environment). For the

 

STM32WB Series a method is proposed to adjust its internal operation to optimize and

 

consolidate this phase. A longer startup improves reliability but increases power

 

consumption.

 

Note:

AN2867 (Oscillator design guide for ST microcontrollers), which generally describes HSE

 

for STM32 product, does not apply to STM32 wireless MCUs due to the RF constraints. This

 

application note is the correct reference for these products.

 

a. Arm is a registered trademark of Arm Limited (or its subsidiaries) in the US and/or elsewhere.

6/47

AN5042 Rev 10

AN5042

HSE oscillator

 

 

1.1Crystal oscillator

Figure 1 shows the crystal oscillator system principle. An oscillator consists of an inverting amplifier, a feedback resistor (Rf), a crystal (XTAL) and two load capacitors (CL1 and CL2). Cs is the stray capacitance, resulting from the sum of the MCU pin capacitances (OSC_IN and OSC_OUT) and the PCB capacitance: it is a parasitic capacitance.

Figure 1. Crystal oscillator principle

 

Rf

 

Inv

 

XTAL

CL1

CL2

 

CS

MSv47132V1

CL load capacitance

The load capacitance is the terminal capacitance of the circuit connected to the crystal oscillator. This value is determined by the external capacitors CL1 and CL2 and the stray capacitance of the printed circuit board and connections (Cs). The CL value is specified by the crystal manufacturer. For the frequency to be accurate, the oscillator circuit has to show the same load capacitance to the crystal as the one the crystal was adjusted for.

Frequency stability mainly requires that the load capacitance be constant. The external trimming capacitors CL1 and CL2 are used to tune the desired value of CL to reach the value specified by the crystal manufacturer.

The following equation gives the expression of CL

Equation 1: Load capacitance

CL1 CL2

CL = ----------------------------- + Cs

CL1 + CL2

AN5042 Rev 10

7/47

HSE oscillator

AN5042

 

 

1.2STM32 wireless MCUs architecture

These MCUs embed an efficient and cost-effective crystal oscillator system with internal capacitances for trimming. The advantages of the internal mechanism for load capacitance tuning are twofold:

it reduces the accuracy constraints on the external crystal

it reduces the global BOM (and the footprint) of the PCB.

Figure 2 shows the crystal oscillator system embedded in the STM32 wireless MCUs. The crystal is the only external component, no extra load capacitances are needed.

Figure 2. Crystal oscillator system overview

 

Capacitance

 

 

Bank IN

 

 

OSC_IN

HSE_CLK

 

Amplifier

XTAL

and

 

 

Reshaping

 

 

OSC_OUT

 

 

Capacitance

 

 

Bank OUT

 

 

Crystal oscillator

 

 

STM32WB/WL

 

MS53500V1

The crystal oscillator system consists of two pads (OSC_IN and OSC_OUT) with their respective capacitance banks, and the amplifier stage.

For STM32WB Series, the capacitance value is the same for both the IN and the OUT banks. This value, alongside with the oscillator gain and sense (the parameters that make possible the optimization of the start-up phase), is driven by a register and controls the system behavior. These parameters are explained in Section 1.3.

For STM32WL Series, the capacitance values for the IN and the OUT banks are independent. These two values are driven by two sub-GHz radio registers and control the system behavior. These parameters are explained in Section 1.4.

8/47

AN5042 Rev 10

AN5042

HSE oscillator

 

 

1.3HSE configuration parameters - STM32WB Series

Three parameters can be set to control the oscillator module. They are accessible in the RCC_HSECR register described below.

RCC_HSECR

 

 

Address

0x09C

 

 

 

 

 

 

 

 

 

 

 

 

 

Reset

 

0x0000 0030

 

 

 

 

 

 

 

 

 

 

 

 

Access

 

This register is protected to avoid on-the-fly modification.

 

 

 

 

 

 

 

A key (0xCAFECAFE) must be written at the register address to unlock it

 

 

 

 

 

before any single write access, it is then locked again.

 

 

 

 

 

 

 

 

The HSE clock must be switched off during register access procedure to avoid

 

 

 

 

 

unpredictable behavior. Note that HSE must not be used as CPU clock source

 

 

 

 

 

during this step.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

In this document the default MSI clock is used as system clock source after

 

 

 

 

 

startup from Reset.

 

 

 

 

 

 

 

 

 

31

30

29

 

28

27

26

25

24

23

22

21

20

19

 

18

17

16

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Res.

Res.

Res.

 

Res.

Res.

Res.

Res.

Res.

Res.

Res.

Res.

Res.

Res.

 

Res.

Res.

Res.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

15

14

13

 

12

11

10

9

8

7

6

5

4

3

 

2

1

0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Res.

Res.

 

 

 

HSETUNE[5:0]

 

 

Res.

HSEGMC[2:0]

HSES

 

Res.

Res.

UNLOCKED

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

rw

 

rw

rw

rw

rw

rw

 

rw

rw

rw

rw

 

 

 

rw

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Load capacitance: HSETUNE[5:0]

This is the parameter responsible for the clock accuracy. It selects the capacitance value added on both input and output pads. The adjustable range is set to have a global load capacitance comprised between 12 and 16 pf. The minimum (0x00) and maximum (0x3F) values correspond, respectively, to the smallest and to the largest load capacitance.

Default value is 0x00 (minimum load capacitance).

Current control: HSEGMC[2:0]

This parameter (referred to as Gm or Gm_crit_max in the documentation of other STM32 products for which it has a fixed value) is the maximum critical crystal transconductance of the oscillator. It controls the startup performance of the system. A low value decreases the power consumption, while a high value improves the startup time.

The minimum value (0b000) corresponds to Gm = 0.18 mA/V, the maximum value (0b111) to Gm = 2.84 mA/V. Default value is 0x3 (Gm = 1.13 mA/V).

HSES sense amplifier threshold

This parameter controls an internal comparison threshold for the oscillator startup. When this bit is set (1), the startup time is reduced (from around 15 µs) but the current consumption is higher.

Default value is 0x0 (1/2 ratio).

AN5042 Rev 10

9/47

HSE oscillator

AN5042

 

 

1.4HSE configuration parameters - STM32WL Series

For the STM32WL Series two parameters can be set to control the oscillator module. They are accessible in the SUBGHZ_HSEINTRIMR and the SUBGHZ_HSEOUTTRIMR sub-GHz radio registers, which contain the capacitance value of the IN and OUT banks, respectively. The associated value is represented by their six lower bits (the remaining bits of these registers must be kept at their reset values).

For both registers:

0x00 corresponds to the minimum capacitance (~11.3 pF)

0x2F corresponds to the maximum capacitance (~33.4 pF)

the values must not exceed 0x2F and the trimming step is ~0.47 pF

the reset value is 0x12, which corresponds to ~20.3 pF.

As mentioned earlier, SUBGHZ_HSEINTRIMR and SUBGHZ_HSEOUTTRIMR are part of the sub-GHz radio and not of the system CPU. To modify their values the user code needs to communicate with the sub-GHz radio via its SPI interface. The addresses of these registers, considering this SPI interface, are 0x911 for SUBGHZ_HSEINTRIMR and 0x912 for SUBGHZ_HSEOUTTRIMR.

1.5Board implementation

Oscillator pads are available on different pins (named OSC_IN and OSC_OUT), depending upon the package. Table 2 shows the pin numbers for four different packages used in Nucleo and USB dongle boards for the STM32WB Series.

Table 2. Oscillator pin numbers for the STM32WB Series

Package

OSC_IN

OSC_OUT

 

 

 

UFQFPN48

25

24

 

 

 

VFQFPN68

35

34

 

 

 

WLCSP100

J1

J2

 

 

 

BGA129

M13

N13

 

 

 

The crystal is plugged directly onto the pads, with no extra capacitance, and as close as possible to the device to minimize parasitic capacitance.

Figure 3 shows a typical UFQFPN48 footprint for the STM32WB Series.

10/47

AN5042 Rev 10

STMicroelectronics STM32WB, STM32WL Application note

AN5042

HSE oscillator

 

 

Figure 3. UFQFPN48 (USB dongle board) footprint detail

GND

Crystal_pins

OSC_IN

OSC_OUT

MS47142V1

The PCB layout for the STM32WB and STM32WL Series reference designs are detailed, respectively, in AN5165 “Development of RF hardware using STM32WB microcontrollers” and AN5407 “Optimized RF board layout for STM32WL Series”, both available on www.st.com.

1.6Crystal references

Table 3 shows the specification of the crystals used to validate the reference designs.

Table 3. Crystal specifications

Series

NDK crystal

Parameter

Value

 

 

 

 

 

 

Load capacitance

8 pF

 

 

 

 

STM32WB

NX2016SA 32 MHz

Frequency tolerance

(25 ± 3 °C) ± 10 × 10−6

EXS00A-CS06654

 

 

 

Frequency vs. temperature

± 25 × 10−6

 

 

 

 

(with reference to +25 °C)

 

 

 

 

 

 

 

 

 

Load capacitance

10 pF

 

 

 

 

STM32WL

NX2016SA 32 MHz

Frequency tolerance

± 10 ppm at 25 °C

EXS00A-CS06465

 

 

Frequency vs. temperature

± 10 ppm (-25 to +70 °C)

 

 

 

 

 

± 30 ppm (-40 to +85 °C)

 

 

 

 

 

 

 

AN5042 Rev 10

11/47

HSE oscillator

AN5042

 

 

It is possible to use other crystals, as long as they respect the carrier accuracy requirements (see Table 1). More precisely, the sum of the maximum values for the following parameter specifications of the chosen crystal must be below the carrier accuracy requirements:

frequency tolerance

frequency versus temperature characteristics (for the temperature in which the crystal must be used)

aging (for the duration during which the crystal must be used).

Note:

Such data can be named differently or absent in the crystal documentation.

 

The previous verification is reliable if the PCB based on the chosen crystal is designed with

 

the requirements mentioned in Section 1.5 and fine-tuned with one of the HSE trimming

 

methods described in the next sections of this document.

 

Note that the accuracy of the capacitance bank used for the HSE trimming can vary from a

 

product to another. If the carrier accuracy verification is needed for the whole production

 

chain refer to Section 1.7.

1.7 Tuning in production

With mass production in perspective, it is important to know if the trimming parameters defined for a test PCB will have the same efficiency when applied to all the PCBs to be produced.

To have a faster and more efficient production chain, it is not mandatory to operate the trimming process on each PCB.

Data gathered during the production of the STM32WB Nucleo boards have shown some variations of the HSE frequency for a fixed HSETUNE value (HSETUNE accuracy). Besides, the typical HSETUNE granularity is 1 ppm (see XOTUNE granularity in STM32WB datasheets). To compensate for these variations, the following trimming method is suggested for production:

1.tune some PCBs (not more than a few dozens) to get a significant span of HSETUNE values

2.calculate the median of the found values, and use the result to trim all other PCBs

3.the interval between the median and the maximum/minimum of the found values corresponds to the HSETUNE accuracy for the tuned design.

Moreover, after having followed this process, a potential frequency deviation due to the HSETUNE accuracy (point 3) has to be taken into account and added to the carrier accuracy verification calculation presented in Section 1.6.

A similar method can be used for STM32WL Series. The number of test boards must be larger because of the two trimming parameters for these products.

12/47

AN5042 Rev 10

AN5042

Trimming methods comparison

 

 

2 Trimming methods comparison

The three trimming methods described in this document are detailed in Table 4, and compared in Table 5.

 

Table 4. Trimming methods

Method

Description

 

 

 

A precision frequency meter is used to measure the HSE frequency

Manual

output on one of the STM32 pins. Then, the user tunes the HSE

frequency with the buttons of a Nucleo board. A button is dedicated to

 

 

the saving of the tuning parameters in the STM32 non-volatile memory.

 

 

 

One STM32 timer is clocked with a precision external clock source

 

provided by the user via one of the STM32 pins. This reference clock

Automatic

allows the user to measure the internal STM32 system HSE frequency.

Then, the STM32 can compare the frequency measured with the one

 

 

expected, to test and determine the best tuning parameters. Finally, the

 

STM32 saves these parameters in its non-volatile memory.

 

 

 

A precision frequency meter is used to measure the HSE frequency

 

output on one of the STM32 pins. Then, the user tunes the HSE

STM32CubeMonitor-RF(1)

frequency with a script to run in STM32CubeMonitor-RF. The user has

to change the tuning parameter values in the script to test them. When

 

 

the correct values are found, another script saves them in the STM32

 

non-volatile memory.

 

 

1. Compatible with STM32WB Series only.

Table 5. Comparison of trimming methods

Method

Advantages

Disadvantages

 

 

 

Manual

Runs in SRAM (user program in

Needs the use of buttons and a

Flash memory is not affected).

frequency meter for each product.

 

 

 

 

 

Runs in SRAM (user program in

 

 

Flash memory is not affected).

Method based on a more complex

Automatic

The user needs to set up a

principle.

 

reference clock only once to trim as

 

many devices as wanted.

 

 

 

 

 

 

BLE stack and transparent mode

 

Convenient for users familiar with

FW must be flashed in the device.

STM32CubeMonitor-RF(1)

Requires several actions from the

STM32CubeMonitor-RF, willing to

 

achieve the maximum functionality.

user for each product (modifying

 

 

and running the script, use of a

 

 

frequency meter).

 

 

 

 

1. Compatible with STM32WB Series only.

Note:

The proposed methods require the use of a pin (MCO) to output the HSE signal for the

 

frequency measurement. If no MCO pin is available for this purpose, AN5378 (available on

 

www.st.com) describes another technique: instead of measuring the frequency on the MCO

 

pin, it proposes to do the measurement on a tone frequency emitted by the STM32WB

 

radio. However, while this tone is emitted, HSE cannot be trimmed because it is used by the

AN5042 Rev 10

13/47

Trimming methods comparison

AN5042

 

 

radio (actually this is more a verification than a real trimming method like those exposed in this document).

14/47

AN5042 Rev 10

AN5042

Manual frequency trimming procedure example for the STM32WB Series

 

 

3Manual frequency trimming procedure example for the STM32WB Series

The firmware and scripts associated to this document are available as an STM32Cube Expansion Package (X-CUBE-CLKTRIM_vx.y\Projects\P-NUCLEO-WB55.Nucleo\RCC_HSE_Calib).

3.1Procedure description

 

The procedure consists in measuring the HSE clock generated inside the device from the

 

external crystal. This clock is output on pin PA8 and is measured by a precision frequency

 

meter.

Note:

An external reference is mandatory since no such accurate one is integrated in the device.

 

A step-by-step tuning of the load capacitance is performed to reach the best accuracy of the

 

HSE clock. The load capacitance value is then stored inside a non-volatile location of the

 

device, either a dedicated area of the user Flash memory or in the One-Time-Programming

 

area.

 

Flash memory or OTP programming is done with a double-word granularity (64 bits). To

 

save OTP bytes (1 K in the STM32WB Series), the load capacitance value on six bits can

 

be appended to a 64-bit wide structure with other personalization data (such as the

 

Bluetooth® device address, the MAC short address, the product specific code, the key).

 

This procedure can be done several times, only the latest setup is active.

 

Once the procedure is completed, the active load capacitance value can be retrieved at

 

startup (in the clock configuration function) and the HSE configuration register set

 

accordingly.

3.2 Implementation

The procedure is executed in SRAM, so it can be run on an already programmed device without modifying the Flash memory content.

AN5042 Rev 10

15/47

Loading...
+ 32 hidden pages