Manage embedded software libraries with STM32CubeMX

Starting with STM32CubeMX version 4.27.0 ST added an option to manage embedded software libraries directly into CubeMX and have fully integrated graphical tool to configure project into very details before building application in final toolchain (Keil, IAR, TrueSTUDIO, …).

Embedded software libraries are libraries (also) provided by STMicroelectronics. You will notice them with X-CUBE-library_name name format, like X-CUBE-MEMS1 which is complete solution for ST MEMS sensors.

Steps to follow

To enable embedded libraries to be added to CubeMX, please follow steps, explained below:

  1. Install STM32CubeMX 4.27.0 or newer and open it
  2. Go to Help -> Manage embedded software libraries or press Alt+U
    1. Embedded software manager windows will open
  3. Find tab STMicroelectronics and you will see list of currently available integrated libraries for CubeMX
  4. Find X-CUBE-MEMS1 and install it (by time of writing this post, latest version was 5.1.0)
    1. CubeMX will automatically download sources from st.com and install it to STM32Cube Repository folder
    2. You can find all installed sources in (default folder for Windows, replace username): C:\Users\{USERNAME}\STM32Cube\Repository\Packs\STMicroelectronics\X-CUBE-MEMS1\5.1.0.
    3. Check for Documentation folder and open instructions PDF file which will guide you in details how to use this specific software in CubeMX.

Now that we have our important software installed, we can try to start a new project

  1. Start a new project and select part or board, for example STM32L476RG and start the project

    STM32CubeMX embedded software libraries

    STM32CubeMX embedded software libraries

  2. In an empty project with pinout visible, click on Project and select Select additional software packages or press CTRL + E.

    STM32CubeMX additional software packages

    STM32CubeMX additional software packages

  3. You have different installed software packages listed. Here we will focus on X-MEMS where you can select your Application or you go with accelerometer/gyro/humity/temperature or pressure sensors, supported by X-CUBE-MEMS1.
  4. By selecting your sensors, they are automatically added to the project. You may choose I2C or SPI interface for each of them and once you are ok, confirm and close the window.
  5. Now that sensors are added, we have to link physical SPI/I2C interface with sensor middleware itself.
    1. In the pinout tab, select SPI or I2C and enable it in standard way. For SPI, select Full-Duplex master
    2. Move to Configuration tab where you should see new tab for additional software. By clicking on it, you will have an option to align sensor middleware with physical hardware available in MCU.
      1. For example, use SPI2 for SPI interface in MEMS sensor
  6. Export project by clicking Project -> Generate code and your middlewares will be part of project.

tilz0R

Owner of this site. Application engineer, currently employed by STMicroelectronics. Exploring latest technologies and owner of different libraries posted on Github.

You may also like...