Getting Started with X-CUBE-BLE2

Sep 1, 2020 11:27 · 1682 words · 8 minute read pop get started need peripherals

Getting Started with X-CUBE-BLE2 In this webinar we will see an introduction to STM32Cube the list of the required hardware and software tools how to install an STM32Cube Expansion Package in STM32CubeMX how to get started with the X-CUBE-BLE2 in STM32CubeMX Introduction to STM32Cube STM32Cube is the Software Ecosystem for STM32, made and supported by STMicroelectronics, and proposed to all STM32 developers for free. It combines a set of PC software development tools and a set of embedded software bricks. STM32CubeExpansion packages provides an easy and powerful way to integrate additional components to the project, such as drivers for other ST components (sensor for instance) or middleware components. The latest STM32CubeExpansion specifications offer the ability to configure and integrate these components directly into the project from STM32CubeMX and STM32CubeIDE. The embedded software environment for STM32 offers the standard STM32Cube MCU packages (such as STM32CubeF4, STM32CubeH7 or STM32CubeL5…).

01:38 - STM32Cube Expansion packages extend it with additional software components enabling high-level application solutions. Those packages can come: - from STMicroelectronics, to support digital or high-level software component from ST portfolio (eg : NFC, MEMS, Bluetooth or even AI). - from ST Partners or third parties - from communities and education programs, or from your own, personal or professional, to share embedded software components with each other or just within restricted groups. The STM32Cube Expansion guidelines are publicly available on www.st.com/stm32cube Required hardware and software You need an ST Nucleo board or any evaluation board equipped with an STM32MCU on the ST Nucleo board you have flexible board power supply through USB or external source integrated ST-Link/V2-1 for mass storage device flash programming 2 push buttons and 2 color LEDs the Arduino connectors to easy access to add-ons the STM32 MCU the Morpho extension headers to directly access the MCU pinout In this webinar we will use a Nucleo-F401RE You need the ST X-NUCLEO-BNRG2A1 expansion board equipped with the BlueNRG-2 Bluetooth Low Energy device On this board you have also the Arduino connectors to easy access to add-ons The X-NUCLEO-BNRG2A1 embeds BlueNRG-M2SP, BLE 5.0 network processor module.

03:28 - ST’s BlueNRG Modules are designed for fast time-to-market: adding connectivity using modules does not require any prior RF expertise. Available in a tiny form factor, BlueNRG-M2SP is Bluetooth SIG End- Product certified, and has obtained pre-certification across major worldwide regions. It is suitable to operate in industrial environments up to +85 °C, and is included in ST’s 10-year longevity program. BlueNRG-M2SP is built around BlueNRG-2 processor chip, based on ultra-low power Cortex-M0 core, embedding 256 kB programmable Flash and 24 kB RAM with data retention. The X-NUCLEO-BNRG2A1 expansion board must be plugged on top of the STM32 Nucleo board An Android or iOS device running the ST BLE Sensor app freely available on the app stores Finally, you need the latest STM32CubeMX tool, available on st.com, installed on your PC.

04:34 - How to install an STM32Cube Expansion Package in STM32CubeMX Launch the STM32CubeMX on your PC Click the INSTALL/REMOVE button Go to STMicroelectronics tab Expand the pack you need to install (e.g. the X-CUBE-GNSS1) Click the Refresh button to retrieve all the available pack versions Select the version you want to install (it is suggested to install the latest one) Click the Install Now button to install the selected pack version To successfully complete the installation process, accept the license terms and click Finish The green box indicates that the pack has been successfully installed Close the window. Getting Started with X-CUBE-BLE2 in STM32CubeMX To set up a new project, the user can start either selecting an MCU or an ST board As previously said, in this webinar we will use the ST Nucleo-F401RE board To easily find it in the ST board list, use some filter Check the Nucleo-64 box in the board Type list and the STM32F4 box in the MCU Series list Once you find your board, double click on it start the project Click Yes to initialize all peripherals with their default mode From the Pinout view it is possible to Configure the MCU pins Enable the Peripherals Clicking the Software Packs menu it is also possible to include additional software components to the project Just expand the line of the STM32 Expansion Package components you want to add And start to select the components The best way to get familiar with an STM32Cube Expansion Package is generating one of the included sample applications For example, select the SensorDemoBLESensor sample application Double clicking the Application row, some useful information are displayed You can open the application readme or the Getting Started Guide containing all the information on how to set up a project using the X-CUBE-BLE2 components. You can find, for instance, the sample application descriptions and the Configuration Steps with the information on the pins, the peripherals and the middlewares to use for generating one of the sample applications or your own project using either an ST board or a custom board equipped with any STM32 MCU. After selecting the sample application all the required software components can be easily detected from the Component dependencies window.

07:58 - Clicking each row with the yellow icon, you can solve all the component dependencies. Unless you want to implement, from your own, a customized Host Controller Interface (HCI) Transport Layer and the relative Interface select the Basic and User Board component variants with the default implementation. When all the dependencies are solved, a green icon appears close to the each component. Click Ok to save your component selection. Now the pinout configuration can start using the information contained in the Getting Started guide.

08:32 - Open it and take note of the pins, peripherals and middlewares that must be enabled and configured From this picture, in particular, you can get the information on how to configure the pins and the SPI bus used by the STM32 MCU to communicate with the BlueNRG-2 device. Hence, on your Nucleo 64-PINs board, you’ll have to use the PA_6 and PA_7 pins for the SPI MISO and MOSI, the PA_8 for the BlueNRG-2 reset, the PB_3 for the SPI clock and the PA_0 and PA_1, respectively, for the BlueNRG-2 external interrupt and the chip select. So, after getting all the useful information, you can start the pinout configuration. Reset status of the PB_3 pin (since it has to be used for the SPI clock) Set PA_6 as SPI1_MISO and PA_7 as SPI1_MOSI. Set PA_0 as GPIO_EXTI0 and PA_1 as GPIO_Output. Finally, set PA_8 as GPIO_Output.

09:50 - Now enable the SPI1 from the Connectivity list in Full-Duplex Master mode Check that the Data Size is set to 8 Bits, the Clock Phase is 2 Edge and set the Prescaler (for Baud Rate) to a value so that the HClock/Prescaler is less or equal to 1000.0 Kbits/s (the maximum supported SPI speed). To do so, for instance, you could go to the Clock Configuration and set the HCLK to 64 MHz. Going back to the Pinout & Configuration you can set the Prescaler (for Baud Rate) to 64 in order to have the Baud Rate to 1000.0 Kbits/s. Since the USART is enabled by default for the Nucleo-F401RE, we can move to configure the BLE components clicking on Software Packs and then on STMicroelectronics.X-CUBE-BLE2 pack. Select all the BLE components and associate peripherals and pins to their proper function: - the EXTI Line to the PA_0 - the BUS IO to the SPI1 - the Chip Select (CS) to PA_1 - the pin for the chip Reset to PA_8 - the GPIO EXTI for the User Button to PC_13 - the USART2 as bus for the COM logs (the serial communication between the MCU and the user’s PC) - and finally, the GPIO for the User LED to PA_5.

11:26 - Clicking the User Constants and the Parameter Settings tabs the user can set constants or parameters such as the Debug messages or some network parameters Clicking the System View the user can access the NVIC section to enable the interrupt lines. Hence, enable the EXTI line0 for the BlueNRG-2 external interrupt and the EXTI line[15:10] for the User Button. For any further check on all other settings, the sections in System View (System Core,…, Connectivity,…) can be accessed. For example, clicking USART2 it is possible to check that its parameters are as indicated in the Getting Started guide Now click the Project Manager tab Insert your project name. Set the Project Location on your file system.

12:33 - You can also select the folder structure of the generated project: using Basic all application files are generated under Src and Inc folders, while with Advanced the generated files are grouped in different folders (App, Target, Core). Select your preferred toolchain among the list of the supported ones. In this example we use the STM32CubeIDE (without the Under Root option). Now we are ready to generate the code clicking the GENERATE CODE button. Wait few seconds… … and click Open Project to open the generated STM32CubeIDE project. The STM32CubeIDE will start opening… Once the STM32CubeIDE is open, a pop-up will show the project import status. Close the pop-up expand the project structure and browse the generated code (where you can find the application, the driver and the middleware files). Build the project to generate the binary file. The Console output in the IDE shows the logs of the build process Wait until the build process finishes… After connecting your STM32 development board to your PC, flash it with the generated binary file Right-click on the project name and select the Run As –> STM32 Cortex-M C/C++ Application Accept the default settings in the Edit Configuration clicking OK The flashing process will start (its progress is shown in the Console output) Once the flashing process has successfully terminated Launch the ST BLE Sensor app on your mobile device, connect to the BlueNRG device and you’ll see the emulated sensor data coming from your board stack. For more information, please, visit www.st.

com/stm32cubemx 15:01 - Thank You! For further information on our products, please, visit us at www.st.com .