STM32CubeMX

Table Of Contents

- STM32CubeMX documentation
- CubeMX User Manual
  - 1 STM32Cube overview
  - 2 Getting started with STM32CubeMX
  - 3 Installing and running STM32CubeMX
  - 4 STM32CubeMX user interface
  - 5 STM32CubeMX tools
  - 6 STM32CubeMX C Code generation overview
  - 7 Code generation for dual-core MCUs (STM32H7 dual-core product lines only)
  - 8 Code generation with TrustZone enabled (STM32L5 series only)
  - 9 Device tree generation (STM32MPUs only)
  - 10 Support of additional software components using CMSIS-Pack standard
  - 11 Tutorial 1: From pinout to project C code generation using an MCU of the STM32F4 series
  - 12 Tutorial 2 - Example of FatFs on an SD card using STM32429I-EVAL evaluation board
  - 13 Tutorial 3 - Using the Power Consumption Calculator to optimize the embedded application consumption and more
  - 14 Tutorial 4 - Example of UART communications with an STM32L053xx Nucleo board
  - 15 Tutorial 5: Exporting current project configuration to a compatible MCU
  - 16 Tutorial 6 - Adding embedded software packs to user projects
  - 17 Tutorial 7 - Using the X-Cube-BLE1 software pack
  - 18 Creating LPBAM projects
  - Appendix A STM32CubeMX pin assignment rules
  - Appendix B STM32CubeMX C code generation design choices and limitations
  - Appendix C STM32 microcontrollers power consumption parameters
  - Appendix D STM32Cube embedded software packages
  - Revision history
- Release Notes
  - Release details
  - Release fixes
  - Known limitations
    - Miscellaneous
    - 2.1. When selecting microcontrollers in the STM32C0 series
    - 2.2. When selecting microcontrollers in the STM32G0 series
    - 2.3. When selecting microcontrollers in the STM32G4 series
    - 2.4. When selecting microcontrollers in the STM32H5 series
    - 2.5. When selecting microcontrollers in the STM32H7 series
    - 2.6. When selecting dual-core microcontrollers in the STM32H7 series
    - 2.7. When selecting microcontrollers in the STM32L5 series
    - 3.4. How to improve the wake-up from Stop sequences without relying on the global SystemClock_Config()
    - 3.3. List pinout-compatible microcontrollers
    - 3.2. DDR binaries for the STM32MP1 boards
    - 3.1. Command line authentication required
    - 2.21. Symbolic links on Ubuntu
    - 2.20. User manual
    - 2.19. DDR test suite
    - 2.18. STM32CubeIDE toolchain
    - 2.13. When selecting microcontrollers in the STM32WL series
    - 2.11. When selecting microcontrollers in the STM32WB series
    - 2.17. When using additional software packs
    - 2.16. When using the Example Selector
    - 2.15. When using the Memory Management Tool
    - 2.14. When selecting microprocessors in the STM32MP1 series
    - 2.11.1. When selecting microcontrollers in the STM32WB0 product lines
    - 2.12. When selecting microcontrollers in the STM32WBA series
    - 2.13.1. When selecting microcontrollers in the STM32WL33 product lines
    - 2.10. When selecting microcontrollers in the STM32U5 series
    - 2.9. When selecting microcontrollers in the STM32U3 series
    - 2.8. When selecting microcontrollers in the STM32N6 series
- Running STM32CubeMX in command-line mode
- FAQ
- Community

### On this page

- Figure 685. Generated project with third party pack components
  - 17 Tutorial 7 – Using the X-Cube-BLE1 software pack
- Figure 687. Embedded software packages

# 17 Tutorial 7 - Using the X-Cube-BLE1 software pack

STM32CubeF4 MCU package if it is not present in STM32Cube repository.

9. Click Open project. The Oryx software components are displayed in the generated project (see Figure 685).

## Figure 685. Generated project with third party pack components

### 17 Tutorial 7 – Using the X-Cube-BLE1 software pack

> This tutorial demonstrates how to achieve a functional project using the X-Cube-BLE1 software pack.

> Below the prerequisites to run this tutorial:

- Hardware: NUCLEO-L053R8, X-NUCLEO-IDB05A1 and mini-USB cable (see Figure 686)

- Tools: STM32CubeMX, IDE (Atollic® or any other toolchain supported by STM32CubeMX)

- Embedded software package: STM32CubeL0 (version 1.10.0 or higher), X-Cube-BLE1

> 1.1.0 (see Figure 687).

- Mobile application (see Figure 688): STMicroelectronics BlueNRG application for iOS® or Android™

## Figure 687. Embedded software packages

1. Check STM32CubeMX Internet connection:

   1. Select the Help > Updater Settings menu to open the updater window.

   2. Verify in the Connection tab that the Internet connection is configured and up.

2. Install the required embedded software packages (see Figure 689):

   1. Select the Help > Manage Embedded software packages menu to open the embedded software package manager window.

   2. Click the Refresh button to refresh the list with the latest available package versions.

   3. Select the STM32Cube MCU Package tab and check that the STM32CubeL0 firmware package version 1.10.0 or higher is installed (the checkbox must be green). Otherwise select the checkbox and click Install now.

   4. Select the STMicrolectronics tab and check that the X-Cube-BLE1 software pack version 1.0.0 is installed (checkbox must be green). Otherwise, select the checkbox and click Install now.

> Figure 689. Installing Embedded software packages

3. Start a new project:

   1. Select New Project to open the new project window.

   2. Select the Board selector tab.

   3. Select Nucleo64 as board type and STM32L0 as MCU Series.

   4. Select the NUCLEO-L053R8 from the resulting board list (see Figure 690).

   5. Answer No when prompted to initialize all peripherals in their default mode (see Figure 691).

> Figure 690. Starting a new project - selecting the NUCLEO-L053R8 board

4. Add X-Cube-BLE1 components to the project:

   1. Click Additional Software from Pinout & Configuration view to open the Additional Software component Selection window.

   2. Select the relevant components (see Figure 692)

> The Application group comes with a list of applications: the C files implement the application loop, that is the Process() function. From the Application group, select the SensorDemo application.

> Select the Controller and Utils components

> Select the Basic variant for the HCI_TL component . The Basic variant provides the STMicroelectronics implementation of the HCI_TL API while the template option requires users to implement their own code.

> Select the UserBoard variant as HCI_TL_INTERFACE component. Using the UserBoard option generates the <boardname>_bus.c file, that is nucleo_l053r8_bus.c for this tutorial, while the template option generates the custom_bus.c file and requires users to provide their own implementation.

> Refer to the X-Cube-BLE1 pack documentation for more details on software components.

> 3. Click OK to apply the selection to the project and close the window. The left panel Additional Software section is updated accordingly.

> Figure 692. Selecting X-Cube-BLE1 components

5. Enable peripherals and GPIOs from the Pinout tab (see Figure 693):

   1. Configure USART2 in Asynchronous mode.

   2. Configure SPI1 in Full-duplex master mode.

   3. Left-click the following pins and configure them for the required GPIO settings:

> PA0: GPIO_EXTI0

> PA1: GPIO_Output

> PA8: GPIO_Output

4. Enable Debug Serial Wire under SYS peripheral.

> Figure 693. Configuring peripherals and GPIOs

6. Configure the peripherals from the Configuration tab:

   1. Click the NVIC button under the System section to open the NVIC configuration window. Enable EXTI line 0 and line 1 interrupts and click OK (see Figure 694).

   2. Click the SPI button under the Connectivity section to open the SPI configuration window. Check that the data size is set to 8 bits and the prescaler value to 16 so that HCLK divided by the prescaler value is less or equal to 8 MHz.

   3. Click USART2 under the Connectivity section to open the Configuration window and check the following parameter settings:

> Under Parameter Settings:

> Baud rate: 115200 bits/s

> Word length: 8 bits (including parity) Parity: none

> Stop bits: 1

> Under GPIO Settings:

> User labels: USART_TX and USART_RX

> Figure 694. Configuring NVIC interrupts

7. Enable and configure X-Cube-BLE1 pack components from the Pinout & Configuration view:

   1. Click the pack items from the left panel to show the mode and configuration tabs.

   2. Click the check boxes from the Mode panel to enable X-Cube-BLE1, the configuration panel appears showing the parameters to configure. An orange triangle indicates that some parameters are not configured. It turns into a green check mark once all parameters are correctly configured (see Figure 695).

   3. Leave the Parameter Settings Tab unchanged.

   4. Go the Platform settings tab, configure the connection with the hardware resources as indicated in Figure 695 and Table 29.

> Table 29. Connection with hardware resources

Name | IPs or components | Found solutions
--- | --- | ---
BUS IO driver | SPI in Full-duplex master mode | SPI1
EXTI Line | GPIO:EXTI | PA0
CS Line | GPIO:output | PA1
Reset Line | GPIO:output | PA8
BSP LED | GPIO:output | PA5
BSP Button | GPIO:EXTI | PC13
BSP USART | USART in Asynchronous mode | USART2

> Check that the icon turns to . Click OK to close the Configuration window .

8. Generate the SensorDemo project:

a) Click to generate the code. The Project Settings window opens if the project has not yet been saved. .. image:: ../../../assets/media/image1302.webp

> width :

>   1.16667in

> height :

>   0.20167in

b) Click to generate the code once the project settings have .. image:: ../../../assets/media/image1302.webp

> width :

>   1.16667in

> height :

>   0.20167in