on 2024-01-03 09:24 AM
Examples provided by ST may not fit your specific STM32WL or other STM32 family chips in a given package. As a result, you may be in a situation where you cannot use the full potential of the STM32CubeMX software with your chip.
There are three solution options for this case. In this article, case number 3 is described below with a step-by-step guide.
This guide provides a step-by-step instruction for the third case. Generally, the STM32CubeMX import function can be used on any STM32 example but the viability may vary. The model situation for this guide is that the STM32WLE5CC (single-core, QFN package) was chosen as an MCU for a project. The example project selected is the LoRaWAN® end node.
However, the ST32CubeWL only contains projects for STM32WL55-Nucleo with an STM32WL55JC (dual-core, BGA package). The standalone STM32CubeMX is used to show the import functionality. Once the import is complete, you can continue in STM32CubeIDE as in this guide or any other supported IDE (Keil®, IAR).
To link the .h files, open the project properties, C/C++ General, Paths and Symbols. Add ../Drivers/BSP/STM32WLxx_Nucleo
Copy the definitions main.h from the example STM32Cube_FW_WL_V1.3.0\Projects\NUCLEO-WL55JC\Applications\LoRaWAN\LoRaWAN_End_Node. Keep in mind that any modification outside of the user code section can be overwritten by the next STM32CubeMX code generation. Therefore, a #if 0 trick can be used.
The example project is now imported onto an empty QFN package project. At this point, it is possible to run the example with a WL55-Nucleo. However, to run the project on your own PCB, the pinout must be adjusted. The following guidelines should help you bring up the full project on your device:
#define RF_SW_CTRLX_[PIN|PORT|CLK] - redefine the RF switches to match the layout. According to the truth table in the Nucleo schematic, it should be enough to operate CTRL2. If the RF switch is not tied to VDD and is controlled by a pin, it should also be reflected by the CTRL pins. You can also rewrite and simplify the stm32wlxx_nucleo_radio.c functions that operate the switch, if that would be a better solution for you.
Check for any pin collisions with your design. If available on your PCB, you can also have the buttons/LEDs active as on the Nucleo. Also, UART2 is used for communication through the End_Node on PA2, PA3. Check that this is available on your PCB or reconfigure to work with the UART available.
DCDC_ENABLE - based on whether you want to use SMPS or LDO.
XTAL_DEFAULT_CAP_VALUE - if Crystal is used instead of TCXO, this should be the tuning for the internal capacitor bank. For the initial testing, it should be enough to go with the default, but it should be tuned to provide the correct frequence. One can use PA8 with MCO "master clock output" to measure the frequency and tune it using the capacitor bank. For this reason, there should be no external capacitors around the HSE. If TCXO is used, this part is not used.
IS_DCDC_SUPPORTED - board support for SMPS/LDO.
IS_TCXO_SUPPORTED - 1 if TCXO mounted, 0 for Crystal.
APP_LOG_ENABLED - leave enabled for traces on UART.
DEBUGGER_ENABLED - if you are porting the firmware to your PCB, set to 1 so that the debugger can connect in low power modes. At this stage, it is useful to enable the debugger and run a debug session to go step by step with the porting. As an example, you could see through the debugger that you are stuck in clock initialization. In this case, you should focus on the HSE/LSE configuration. For current consumption measurements, it should be disabled.
LOW_POWER_DISABLE - this uses sleep instead of stop modes in case there are issues with low power modes.
Congratulations! You have successfully imported an example project onto an empty QFN package project and adjusted the pinout to run the project on your own PCB. Furthermore, how to adjust the pinout to run the project on your own device. We hope that this guide has been helpful in showing you how to import an example project using STM32CubeMX.
If you have any further questions or need additional assistance, refer to the STMicroelectronics website, create a post in the ST Community, or contact our technical support team. Happy coding!