The X-CUBE-CLKTRIM Expansion Package illustrates the trimming of an HSE crystal oscillator to reach the high-accuracy frequency required by RF applications.
The STM32WB Series microcontrollers support low-power RF standards such as Bluetooth® Low Energy (±50 ppm minimum HSE clock accuracy) and IEEE 802.15.4 (±40 ppm minimum HSE clock accuracy).
The STM32WL Series microcontrollers support sub-GHz RF standards such as LoRaWAN® and other low-power wide area networks (LPWAN). For these standards, the highest the HSE clock accuracy, the best the RF performance.
The frequencies of STM32 Wireless MCUs HSE oscillators can be tuned by means of values saved in dedicated registers. This features saves the extra cost of additional external capacitors and enables the compensation for frequency variations due to production, crystal, and PCB design.
The X-CUBE-CLKTRIM Expansion Package and associated application note (AN5042, AN5515) propose three different trimming procedures (manual, automatic, and with STM32CubeMonitor-RF (STM32CubeMonRF)) for the once-for-all storage of the right trimming parameters in OTP bytes. Each proposes two configurations: the trimming procedure itself and an implementation example of oscillator clock initialization in applications (loading of the trimming parameters in the according registers).
The HSE trimming manual procedure requires the user to use buttons to trim the RF clock frequency, which is output on a pin and can be monitored with a precision frequency meter. The HSE trimming automatic procedure consists in providing a precision clock reference to the STM32 so that it can trim its RF clock frequency (HSE) automatically. The HSE trimming procedure with STM32CubeMonitor-RF is similar to the manual one but uses STM32CubeMonitor-RF scripts instead of buttons.
For HSE trimming, it is not mandatory to trim each board in a production chain. A procedure is given for this purpose in the Precise HSE frequency trimming using STM32 wireless MCUs application note (AN5042).
X-CUBE-CLKTRIM firmware is built on the HAL drivers and runs on the Nucleo boards of the STM32 Wireless MCUs.