UM1718 STM32Cube MX Manual
STM32CubeMX-Manual
User Manual:
Open the PDF directly: View PDF .
Page Count: 345
Download | ![]() |
Open PDF In Browser | View PDF |
UM1718 User manual STM32CubeMX for STM32 configuration and initialization C code generation Introduction STM32CubeMX is a graphical tool for STM32 microcontrollers. It is part of the STM32Cube™ initiative (see Section 2) and is available either as a standalone application or as an Eclipse plug-in for integration in Integrated Development Environments (IDEs). STM32CubeMX has the following key features: Easy microcontroller selection covering the whole STM32 portfolio Board selection from a list of STMicroelectronics boards Easy microcontroller configuration (pins, clock tree, peripherals, middleware) and generation of the corresponding initialization C code Easy switching to another microcontroller by importing a previously-saved configuration to a new MCU project Easy exporting of current configuration to a compatible MCU Generation of configuration reports Generation of embedded C projects for a selection of integrated development environment tool chains. STM32CubeMX projects include the generated initialization C code, MISRA 2004 compliant STM32 HAL drivers, the middleware stacks required for the user configuration, and all the relevant files for opening and building the project in the selected IDE. Power consumption calculation for a user-defined application sequence Self-updates allowing the user to keep STM32CubeMX up-to-date Download and update of STM32Cube embedded software required for user application development (see Appendix E: STM32Cube embedded software packages for details on the STM32Cube embedded software offer) Although STM32CubeMX offers a user interface and generates C code compliant with STM32 MCU design and firmware solutions, users need to refer to the product technical documentation for details on actual implementations of microcontroller peripherals and firmware. The following documents are available from www.st.com: STM32 microcontroller reference manuals and datasheets STM32Cube HAL/LL driver user manuals for STM32F0 (UM1785), STM32F1 (UM1850), STM32F2 (UM1940), STM32F3 (UM1786), STM32F4 (UM1725), STM32F7 (UM1905), STM32L0 (UM1749), STM32L1 (UM1816), STM32L4/L4+ (UM1884) and STM32H7 (UM2217). September 2018 UM1718 Rev 26 1/345 www.st.com 1 Contents UM1718 Contents 1 General information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 2 STM32Cube overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 3 Getting started with STM32CubeMX . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 4 3.1 Principles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 3.2 Key features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 3.3 Rules and limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Installing and running STM32CubeMX . . . . . . . . . . . . . . . . . . . . . . . . . 23 4.1 4.2 4.3 4.4 4.5 2/345 System requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 4.1.1 Supported operating systems and architectures . . . . . . . . . . . . . . . . . . 23 4.1.2 Memory prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 4.1.3 Software requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Installing/uninstalling STM32CubeMX standalone version . . . . . . . . . . . 23 4.2.1 Installing STM32CubeMX standalone version . . . . . . . . . . . . . . . . . . . . 23 4.2.2 Installing STM32CubeMX from command line . . . . . . . . . . . . . . . . . . . 25 4.2.3 Uninstalling STM32CubeMX standalone version . . . . . . . . . . . . . . . . . . 27 Installing STM32CubeMX plug-in version . . . . . . . . . . . . . . . . . . . . . . . . 28 4.3.1 Downloading STM32CubeMX plug-in installation package . . . . . . . . . . 28 4.3.2 Installing STM32CubeMX as an Eclipse IDE plug-in . . . . . . . . . . . . . . . 28 4.3.3 Uninstalling STM32CubeMX as Eclipse IDE plug-in . . . . . . . . . . . . . . . 29 Launching STM32CubeMX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 4.4.1 Running STM32CubeMX as standalone application . . . . . . . . . . . . . . . 31 4.4.2 Running STM32CubeMX in command-line mode . . . . . . . . . . . . . . . . . 31 4.4.3 Running STM32CubeMX plug-in from Eclipse IDE . . . . . . . . . . . . . . . . 34 Getting updates using STM32CubeMX . . . . . . . . . . . . . . . . . . . . . . . . . . 35 4.5.1 Updater configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 4.5.2 Installing STM32 MCU packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 4.5.3 Installing STM32 MCU package patches . . . . . . . . . . . . . . . . . . . . . . . . 40 4.5.4 Installing embedded software packs . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 4.5.5 Removing already installed embedded software packages . . . . . . . . . . 46 4.5.6 Checking for updates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 UM1718 Rev 26 UM1718 5 Contents STM32CubeMX user interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 5.1 Welcome page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 5.2 New project window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 5.3 Main window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 5.4 Toolbar and menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 5.5 5.4.1 File menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 5.4.2 Project menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 5.4.3 Pinout menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 5.4.4 Window menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 5.4.5 Help menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 5.4.6 Social links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 Output windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 5.5.1 MCUs selection panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 5.5.2 Output panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 5.6 Import Project window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 5.7 Set unused / Reset used GPIOs windows . . . . . . . . . . . . . . . . . . . . . . . . 72 5.8 Project Settings window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 5.8.1 Project tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 5.8.2 Code Generator tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 5.8.3 Advanced Settings tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 5.9 Update Manager windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 5.10 Additional software component selection window . . . . . . . . . . . . . . . . . . 87 5.10.1 Introduction on software components . . . . . . . . . . . . . . . . . . . . . . . . . . 87 5.10.2 Filter panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 5.10.3 Software component table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 5.10.4 Software component conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 5.10.5 Updating the tree view for additional software components . . . . . . . . . 93 5.11 About window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 5.12 Pinout view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 5.12.1 Peripheral and Middleware tree panel . . . . . . . . . . . . . . . . . . . . . . . . . . 96 5.12.2 Chip view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 5.12.3 Chip view advanced actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 5.12.4 Keep Current Signals Placement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 5.12.5 Pinning and labeling signals on pins . . . . . . . . . . . . . . . . . . . . . . . . . . 106 5.12.6 Setting HAL timebase source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 UM1718 Rev 26 3/345 8 Contents UM1718 5.13 5.14 5.15 6 Configuration view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113 5.13.1 Peripherals and Middleware Configuration window . . . . . . . . . . . . . . . 115 5.13.2 User Constants configuration window . . . . . . . . . . . . . . . . . . . . . . . . . 118 5.13.3 GPIO Configuration window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 5.13.4 DMA Configuration window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 5.13.5 NVIC Configuration window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 5.13.6 FreeRTOS middleware configuration view . . . . . . . . . . . . . . . . . . . . . 137 5.13.7 Graphics frameworks and simulator . . . . . . . . . . . . . . . . . . . . . . . . . . 143 Clock tree configuration view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 5.14.1 Clock tree configuration functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 5.14.2 Recommendations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 5.14.3 STM32F43x/42x power-over drive feature . . . . . . . . . . . . . . . . . . . . . 153 5.14.4 Clock tree glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 Power Consumption Calculator view . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 5.15.1 Building a power consumption sequence . . . . . . . . . . . . . . . . . . . . . . 156 5.15.2 Configuring a step in the power sequence . . . . . . . . . . . . . . . . . . . . . 163 5.15.3 Managing user-defined power sequence and reviewing results . . . . . 167 5.15.4 Power sequence step parameters glossary . . . . . . . . . . . . . . . . . . . . . 170 5.15.5 Battery glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 5.15.6 SMPS feature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 STM32CubeMX C Code generation overview . . . . . . . . . . . . . . . . . . . 178 6.1 STM32Cube code generation using only HAL drivers (default mode) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 6.2 STM32Cube code generation using Low Layer drivers . . . . . . . . . . . . . 180 6.3 Custom code generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 6.4 6.3.1 STM32CubeMX data model for FreeMarker user templates . . . . . . . . 186 6.3.2 Saving and selecting user templates . . . . . . . . . . . . . . . . . . . . . . . . . . 186 6.3.3 Custom code generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 Additional settings for C project generation . . . . . . . . . . . . . . . . . . . . . . 190 7 Support of additional software components using CMSIS-Pack standard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 8 Tutorial 1: From pinout to project C code generation using an STM32F4 MCU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 8.1 4/345 Creating a new STM32CubeMX Project . . . . . . . . . . . . . . . . . . . . . . . . 198 UM1718 Rev 26 UM1718 Contents 8.2 Configuring the MCU pinout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 8.3 Saving the project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 8.4 Generating the report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 8.5 Configuring the MCU clock tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 8.6 Configuring the MCU initialization parameters . . . . . . . . . . . . . . . . . . . . 206 8.7 8.6.1 Initial conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 8.6.2 Configuring the peripherals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 8.6.3 Configuring the GPIOs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 8.6.4 Configuring the DMAs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 8.6.5 Configuring the middleware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 Generating a complete C project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 8.7.1 Setting project options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 8.7.2 Downloading firmware package and generating the C code . . . . . . . . 217 8.8 Building and updating the C code project . . . . . . . . . . . . . . . . . . . . . . . . 222 8.9 Switching to another MCU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 9 Tutorial 2 - Example of FatFs on an SD card using STM32429I-EVAL evaluation board . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 10 Tutorial 3 - Using the Power Consumption Calculator to optimize the embedded application consumption and more . . . . 237 11 10.1 Tutorial overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 10.2 Application example description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 10.3 Using the Power Consumption Calculator . . . . . . . . . . . . . . . . . . . . . . . 238 10.3.1 Creating a power sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 10.3.2 Optimizing application power consumption . . . . . . . . . . . . . . . . . . . . . 241 Tutorial 4 - Example of UART communications with a STM32L053xx Nucleo board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 11.1 Tutorial overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 11.2 Creating a new STM32CubeMX project and selecting the Nucleo board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 11.3 Selecting the features from the Pinout view . . . . . . . . . . . . . . . . . . . . . . 251 11.4 Configuring the MCU clock tree from the Clock Configuration view . . . . 254 11.5 Configuring the peripheral parameters from the Configuration view . . . 255 11.6 Configuring the project settings and generating the project . . . . . . . . . . 258 UM1718 Rev 26 5/345 8 Contents UM1718 11.7 Updating the project with the user application code . . . . . . . . . . . . . . . . 259 11.8 Compiling and running the project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260 11.9 Configuring Tera Term software as serial communication client on the PC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260 12 Tutorial 5: Exporting current project configuration to a compatible MCU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 13 Tutorial 6 – Adding embedded software packs to user projects . . . 266 14 Tutorial 7 – Using the BlueNRG-MS software pack . . . . . . . . . . . . . . 270 15 Tutorial 8 – Using STemWin Graphics framework . . . . . . . . . . . . . . . 283 15.1 Step 1: Selecting an MCU for Graphics . . . . . . . . . . . . . . . . . . . . . . . . . 283 15.2 Step 2: Enabling STemWin from the pinout view . . . . . . . . . . . . . . . . . . 283 15.3 Step 3: Configuring STemWin parameters from the configuration window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 15.4 Step 4: Using STemWin GUIBuilder tool from the configuration window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 15.5 Step 5: Generating the embedded C project and updates . . . . . . . . . . . 287 16 Tutorial 9: Using STM32CubeMX Graphics simulator . . . . . . . . . . . . 289 17 FAQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 6/345 17.1 On the Pinout configuration panel, why does STM32CubeMX move some functions when I add a new peripheral mode? . . . . . . . . . . 292 17.2 How can I manually force a function remapping? . . . . . . . . . . . . . . . . . 292 17.3 Why are some pins highlighted in yellow or in light green in the Chip view? Why cannot I change the function of some pins (when I click some pins, nothing happens)? . . . . . . . . . . . . . . . . . . 292 17.4 Why do I get the error “Java 7 update 45” when installing “Java 7 update 45” or a more recent version of the JRE? . . . . . . . . . . . 292 17.5 Why does the RTC multiplexer remain inactive on the Clock tree view? 293 17.6 How can I select LSE and HSE as clock source and change the frequency? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294 17.7 Why STM32CubeMX does not allow me to configure PC13, PC14, PC15 and PI8 as outputs when one of them is already configured as an output? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294 UM1718 Rev 26 UM1718 Contents 17.8 Ethernet Configuration: why cannot I specify DP83848 or LAN8742A in some cases? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 Appendix A STM32CubeMX pin assignment rules . . . . . . . . . . . . . . . . . . . . . . 296 A.1 Block consistency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 A.2 Block inter-dependency. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300 A.3 One block = one peripheral mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303 A.4 Block remapping (STM32F10x only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303 A.5 Function remapping. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304 A.6 Block shifting (only for STM32F10x and when “Keep Current Signals placement” is unchecked) . . . . . . . . . . . . . . . . . . 305 A.7 Setting and clearing a peripheral mode. . . . . . . . . . . . . . . . . . . . . . . . . . 306 A.8 Mapping a function individually . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306 A.9 GPIO signals mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306 Appendix B STM32CubeMX C code generation design choices and limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307 B.1 STM32CubeMX generated C code and user sections . . . . . . . . . . . . . . 307 B.2 STM32CubeMX design choices for peripheral initialization . . . . . . . . . . 307 B.3 STM32CubeMX design choices and limitations for middleware initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308 B.3.1 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308 B.3.2 USB Host . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 B.3.3 USB Device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 B.3.4 FatFs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 B.3.5 FreeRTOS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310 B.3.6 LwIP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311 B.3.7 Libjpeg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313 B.3.8 Mbed TLS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314 B.3.9 TouchSensing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317 B.3.10 PDM2PCM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 B.3.11 Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 Appendix C STM32 microcontrollers naming conventions . . . . . . . . . . . . . . . 322 Appendix D STM32 microcontrollers power consumption parameters . . . . . 324 D.1 Power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324 UM1718 Rev 26 7/345 8 Contents UM1718 D.2 Appendix E 18 8/345 D.1.1 STM32L1 Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324 D.1.2 STM32F4 Series. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325 D.1.3 STM32L0 Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326 Power consumption ranges. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 D.2.1 STM32L1 Series features three VCORE ranges . . . . . . . . . . . . . . . . . 327 D.2.2 STM32F4 Series features several VCORE scales . . . . . . . . . . . . . . . . 328 D.2.3 STM32L0 Series features three VCORE ranges . . . . . . . . . . . . . . . . . 328 STM32Cube embedded software packages . . . . . . . . . . . . . . . . . 329 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330 UM1718 Rev 26 UM1718 List of tables List of tables Table 1. Table 2. Table 3. Table 4. Table 5. Table 6. Table 7. Table 8. Table 9. Table 10. Table 11. Table 12. Table 13. Table 14. Table 15. Table 16. Table 17. Table 18. Table 19. Table 20. Table 21. Table 22. Table 23. Command line summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Welcome page shortcuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 File menu functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Project menu. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 Pinout menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Window menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Help menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Software components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 Software component conditions icons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 Peripheral and Middleware tree panel - icons and color scheme . . . . . . . . . . . . . . . . . . . . 97 STM32CubeMX Chip view - Icons and color scheme. . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 Peripheral and middleware configuration buttons. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 Peripheral and Middleware Configuration window buttons and tooltips . . . . . . . . . . . . . . 116 Clock tree view widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 Voltage scaling versus power over-drive and HCLK frequency . . . . . . . . . . . . . . . . . . . . 154 Relations between power over-drive and HCLK frequency . . . . . . . . . . . . . . . . . . . . . . . 154 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 LL versus HAL code generation: drivers included in STM32CubeMX projects . . . . . . . . 181 LL versus HAL code generation: STM32CubeMX generated header files . . . . . . . . . . . . 181 LL versus HAL: STM32CubeMX generated source files . . . . . . . . . . . . . . . . . . . . . . . . . 182 LL versus HAL: STM32CubeMX generated functions and function calls . . . . . . . . . . . . . 182 Connection with hardware resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277 Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330 UM1718 Rev 26 9/345 9 List of figures UM1718 List of figures Figure 1. Figure 2. Figure 3. Figure 4. Figure 5. Figure 6. Figure 7. Figure 8. Figure 9. Figure 10. Figure 11. Figure 12. Figure 13. Figure 14. Figure 15. Figure 16. Figure 17. Figure 18. Figure 19. Figure 20. Figure 21. Figure 22. Figure 23. Figure 24. Figure 25. Figure 26. Figure 27. Figure 28. Figure 29. Figure 30. Figure 31. Figure 32. Figure 33. Figure 34. Figure 35. Figure 36. Figure 37. Figure 38. Figure 39. Figure 40. Figure 41. Figure 42. Figure 43. Figure 44. Figure 45. Figure 46. 10/345 Overview of STM32CubeMX C code generation flow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Example of STM32CubeMX installation in interactive mode . . . . . . . . . . . . . . . . . . . . . . . 25 STM32Cube Installation Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Auto-install command line. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Adding STM32CubeMX plug-in archive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 Installing STM32CubeMX plug-in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Closing STM32CubeMX perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Uninstalling STM32CubeMX plug-in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Opening Eclipse plug-in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 STM32CubeMX perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Displaying Windows default proxy settings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Updater Settings window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Connection Parameters tab - Manual Configuration of Proxy Server . . . . . . . . . . . . . . . . . 38 Embedded Software Packages Manager window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Managing embedded software packages - Help menu . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Managing embedded software packages - Adding new url . . . . . . . . . . . . . . . . . . . . . . . . 42 Checking the validity of vendor pack .pdsc file url . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 User-defined list of software packs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 Selecting an embedded software pack release . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 License agreement acceptance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Embedded software pack release - Successful installation . . . . . . . . . . . . . . . . . . . . . . . . 45 Removing libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Removing library confirmation message. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Library deletion progress window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 Help menu: checking for updates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 STM32CubeMX Welcome page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 New Project window - MCU selector. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Enabling graphics choice in MCU selector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 Marking an MCU as a favorite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 New Project window - MCU list with close MCUs function . . . . . . . . . . . . . . . . . . . . . . . . . 54 New Project window - MCU list showing close MCUs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 New Project window - board selector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 STM32CubeMX Main window upon MCU selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 STM32CubeMX Main window upon board selection (Peripheral default option unchecked) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 STM32CubeMX Main window upon board selection (Peripheral default option checked) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 Pinout menus (Pinout tab selected) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 Pinout menus (Pinout tab not selected) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Link to social platforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 MCU selection menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Output panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 Automatic project import . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 Manual project import . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 Import Project menu - Try import with errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 Import Project menu - Successful import after adjustments . . . . . . . . . . . . . . . . . . . . . . . . 71 Set unused pins window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 Reset used pins window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 UM1718 Rev 26 UM1718 Figure 47. Figure 48. Figure 49. Figure 50. Figure 51. Figure 52. Figure 53. Figure 54. Figure 55. Figure 56. Figure 57. Figure 58. Figure 59. Figure 60. Figure 61. Figure 62. Figure 63. Figure 64. Figure 65. Figure 66. Figure 67. Figure 68. Figure 69. Figure 70. Figure 71. Figure 72. Figure 73. Figure 74. Figure 75. Figure 76. Figure 77. Figure 78. Figure 79. Figure 80. Figure 81. Figure 82. Figure 83. Figure 84. Figure 85. Figure 86. Figure 87. Figure 88. Figure 89. Figure 90. Figure 91. Figure 92. Figure 93. Figure 94. Figure 95. List of figures Set unused GPIO pins with Keep Current Signals Placement checked . . . . . . . . . . . . . . . 73 Set unused GPIO pins with Keep Current Signals Placement unchecked . . . . . . . . . . . . . 74 Project Settings window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 Project folder. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 Selecting basic application structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Selecting advanced application structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Selecting a different firmware location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 Firmware location selection error message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 Recommended new firmware repository structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 Project Settings Code Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 Template Settings window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 Generated project template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 Advanced Settings window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 Generated init functions without C language “static” keyword . . . . . . . . . . . . . . . . . . . . . . 86 Additional software components - collapsed view showing packs and bundles . . . . . . . . . 88 Additional software components - expanded view showing component details . . . . . . . . . 89 Dependency solving: solution found . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 Dependency solving: no solution found . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 Software components conditions - Solution proposals and guidance . . . . . . . . . . . . . . . . 92 Software components conditions resolved . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 Selection of additional software components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 Additional software components - Updated tree view. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 About window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 STM32CubeMX Pinout view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Contextual Help Window (default) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 Contextual Help detailed information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 Chip view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 Red highlights and tooltip example - no mode configuration available . . . . . . . . . . . . . . . 103 Orange highlight and tooltip example - some configurations unavailable. . . . . . . . . . . . . 103 Tooltip example - all configurations unavailable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Modifying pin assignments from the Chip view. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 Example of remapping in case of block of pins consistency. . . . . . . . . . . . . . . . . . . . . . . 105 Pins/Signals Options window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 Selecting a HAL timebase source (STM32F407 example) . . . . . . . . . . . . . . . . . . . . . . . . 108 TIM2 selected as HAL timebase source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 NVIC settings when using SysTick as HAL timebase, no FreeRTOS . . . . . . . . . . . . . . . 109 NVIC settings when using FreeRTOS and SysTick as HAL timebase . . . . . . . . . . . . . . 110 NVIC settings when using FreeRTOS and TIM2 as HAL timebase . . . . . . . . . . . . . . . . . 112 STM32CubeMX Configuration view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 Configuration window tabs for GPIO, DMA and NVIC settings (STM32F4 Series) . . . . . 114 Peripheral Configuration window (STM32F4 Series) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 User Constants window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 Extract of the generated main.h file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 Using constants for peripheral parameter settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 Specifying user constant value and name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 Deleting user constant not allowed when the constant is already used for another constant definition. . . . . . . . . . . . . . . . . . . . . . . . . . 121 Deleting an user constant used for parameter configuration - Confirmation request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 Deleting a user constant used for peripheral configuration - Consequence on peripheral configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 Searching for a name in a user constant list. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 UM1718 Rev 26 11/345 16 List of figures Figure 96. Figure 97. Figure 98. Figure 99. Figure 100. Figure 101. Figure 102. Figure 103. Figure 104. Figure 105. Figure 106. Figure 107. Figure 108. Figure 109. Figure 110. Figure 111. Figure 112. Figure 113. Figure 114. Figure 115. Figure 116. Figure 117. Figure 118. Figure 119. Figure 120. Figure 121. Figure 122. Figure 123. Figure 124. Figure 125. Figure 126. Figure 127. Figure 128. Figure 129. Figure 130. Figure 131. Figure 132. Figure 133. Figure 134. Figure 135. Figure 136. Figure 137. Figure 138. Figure 139. Figure 140. Figure 141. Figure 142. Figure 143. 12/345 UM1718 Searching for a value in a user constant list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 GPIO Configuration window - GPIO selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 GPIO Configuration window - Displaying GPIO settings . . . . . . . . . . . . . . . . . . . . . . . . . 125 GPIO configuration grouped by peripheral . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 Multiple Pins Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 Adding a new DMA request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 DMA configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 DMA MemToMem configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 NVIC Configuration tab - FreeRTOS disabled . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 NVIC Configuration tab - FreeRTOS enabled . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 I2C NVIC Configuration window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 NVIC Code generation – All interrupts enabled . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 NVIC Code generation – Interrupt initialization sequence configuration. . . . . . . . . . . . . . 135 NVIC Code generation – IRQ Handler generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 FreeRTOS configuration view. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 FreeRTOS: configuring tasks and queues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 FreeRTOS: creating a new task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 FreeRTOS - Configuring timers, mutexes and semaphores. . . . . . . . . . . . . . . . . . . . . . . 141 FreeRTOS Heap usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 Enabling STemWin Frameworks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 Configuration view for Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 Graphics configuration window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 Saving changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 STM32F429xx Clock Tree configuration view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 Clock Tree configuration view with errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 Clock tree configuration: enabling RTC, RCC Clock source and outputs from Pinout view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 Clock tree configuration: RCC Peripheral Advanced parameters. . . . . . . . . . . . . . . . . . . 153 Power Consumption Calculator default view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 Battery selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 Building a power consumption sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 Step management functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 Power consumption sequence: new step default view . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 Edit Step window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 Enabling the transition checker option on an already configured sequence - All transitions valid. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 Enabling the transition checker option on an already configured sequence - At least one transition invalid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 Transition checker option - Show log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 Interpolated Power consumption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 ADC selected in Pinout view. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 Power Consumption Calculator Step configuration window: ADC enabled using import pinout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 Power Consumption Calculator view after sequence building . . . . . . . . . . . . . . . . . . . . . 167 Sequence table management functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 Power Consumption: Peripherals Consumption Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 Description of the Results area. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 Peripheral power consumption tooltip. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 Selecting SMPS for the current project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 SMPS database - adding new SMPS models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 SMPS database - Selecting a different SMPS model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 Current project configuration updated with new SMPS model . . . . . . . . . . . . . . . . . . . . . 175 UM1718 Rev 26 UM1718 Figure 144. Figure 145. Figure 146. Figure 147. Figure 148. Figure 149. Figure 150. Figure 151. Figure 152. Figure 153. Figure 154. Figure 155. Figure 156. Figure 157. Figure 158. Figure 159. Figure 160. Figure 161. Figure 162. Figure 163. Figure 164. Figure 165. Figure 166. Figure 167. Figure 168. Figure 169. Figure 170. Figure 171. Figure 172. Figure 173. Figure 174. Figure 175. Figure 176. Figure 177. Figure 178. Figure 179. Figure 180. Figure 181. Figure 182. Figure 183. Figure 184. Figure 185. Figure 186. Figure 187. Figure 188. Figure 189. Figure 190. Figure 191. Figure 192. Figure 193. Figure 194. List of figures SMPS database management window with new model selected. . . . . . . . . . . . . . . . . . . 175 SMPS transition checker and state diagram helper window. . . . . . . . . . . . . . . . . . . . . . . 176 Configuring the SMPS mode for each step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 Labels for pins generating define statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 User constant generating define statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 Duplicate labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 HAL-based peripheral initialization: usart.c code snippet . . . . . . . . . . . . . . . . . . . . . . . . . 184 LL-based peripheral initialization: usart.c code snippet . . . . . . . . . . . . . . . . . . . . . . . . . . 185 HAL versus LL : main.c code snippet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 extra_templates folder – default content. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 extra_templates folder with user templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 Project root folder with corresponding custom generated files . . . . . . . . . . . . . . . . . . . . . 188 User custom folder for templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 Custom folder with corresponding custom generated files . . . . . . . . . . . . . . . . . . . . . . . . 189 Update of the project .ewp file (EWARM IDE) for preprocessor define statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 Update of stm32f4xx_hal_conf.h file to enable selected modules . . . . . . . . . . . . . . . . . . 192 New groups and new files added to groups in EWARM IDE . . . . . . . . . . . . . . . . . . . . . . 192 Preprocessor define statements in EWARM IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 Selecting a CMSIS-Pack software component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 Enabling a CMSIS-Pack software components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 Enabling and configuring a CMSIS-Pack software component . . . . . . . . . . . . . . . . . . . . 196 Project generated with CMSIS-Pack software component . . . . . . . . . . . . . . . . . . . . . . . . 197 MCU selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 Pinout view with MCUs selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 Pinout view without MCUs selection window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 GPIO pin configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 Timer configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 Simple pinout configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 Save Project As window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 Generate Project Report - New project creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 Generate Project Report - Project successfully created . . . . . . . . . . . . . . . . . . . . . . . . . . 203 Clock tree view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 HSI clock enabled . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 HSE clock source disabled . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 HSE clock source enabled . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 External PLL clock source enabled . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 Configuration view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 Case of Peripheral and Middleware without configuration parameters. . . . . . . . . . . . . . . 207 Timer 3 configuration window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 Timer 3 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 Enabling Timer 3 interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 GPIO configuration color scheme and tooltip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 GPIO mode configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 DMA Parameters configuration window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 FatFs disabled . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 USB Host configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 FatFs over USB mode enabled . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 Configuration view with FatFs and USB enabled . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 FatFs peripheral instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 FatFs define statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 Project Settings and toolchain selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 UM1718 Rev 26 13/345 16 List of figures Figure 195. Figure 196. Figure 197. Figure 198. Figure 199. Figure 200. Figure 201. Figure 202. Figure 203. Figure 204. Figure 205. Figure 206. Figure 207. Figure 208. Figure 209. Figure 210. Figure 211. Figure 212. Figure 213. Figure 214. Figure 215. Figure 216. Figure 217. Figure 218. Figure 219. Figure 220. Figure 221. Figure 222. Figure 223. Figure 224. Figure 225. Figure 226. Figure 227. Figure 228. Figure 229. Figure 230. Figure 231. Figure 232. Figure 233. Figure 234. Figure 235. Figure 236. Figure 237. Figure 238. Figure 239. Figure 240. Figure 241. Figure 242. Figure 243. Figure 244. Figure 245. Figure 246. 14/345 UM1718 Project Settings menu - Code Generator tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 Missing firmware package warning message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 Error during download . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 Updater settings for download . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 Updater settings with connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 Downloading the firmware package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 Unzipping the firmware package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 C code generation completion message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 C code generation output folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 C code generation output: Projects folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222 C code generation for EWARM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 STM32CubeMX generated project open in IAR™ IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 IAR™ options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 SWD connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 Project building log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 User Section 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 User Section 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 Import Project menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 Project Import status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 Board peripheral initialization dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 Board selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 SDIO peripheral configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 FatFs mode configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 RCC peripheral configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 Clock tree view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 Project Settings menu - Code Generator tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232 C code generation completion message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232 IDE workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 Power Consumption Calculation example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 VDD and battery selection menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 Sequence table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 sequence results before optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 Step 1 optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 Step 5 optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 Step 6 optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244 Step 7 optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 Step 8 optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 Step 10 optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247 Power sequence results after optimizations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248 Selecting NUCLEO_L053R8 board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 Selecting debug pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 Selecting TIM2 clock source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 Selecting asynchronous mode for USART2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253 Checking pin assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253 Configuring the MCU clock tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 Configuring USART2 parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 Configuring TIM2 parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256 Enabling TIM2 interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 Project Settings menu. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 Generating the code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 Checking the communication port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260 Setting Tera Term port parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 UM1718 Rev 26 UM1718 List of figures Figure 247. Setting Tera Term port parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 Figure 248. Existing or new project pinout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 Figure 249. List of pinout compatible MCUs - Partial match with hardware compatibility. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 Figure 250. List of Pinout compatible MCUs - Exact and partial match . . . . . . . . . . . . . . . . . . . . . . . . 263 Figure 251. Selecting a compatible MCU and importing the configuration . . . . . . . . . . . . . . . . . . . . . 264 Figure 252. Configuration imported to the selected compatible MCU . . . . . . . . . . . . . . . . . . . . . . . . . 265 Figure 253. Additional software components enabled for the current project . . . . . . . . . . . . . . . . . . . 266 Figure 254. Saving software component selection as user preferences . . . . . . . . . . . . . . . . . . . . . . . 267 Figure 255. Pack software components - no configurable parameters . . . . . . . . . . . . . . . . . . . . . . . . 267 Figure 256. Pack tutorial - project settings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268 Figure 257. Generated project with Third party pack components . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 Figure 258. Hardware prerequisites. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270 Figure 259. Embedded software packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 Figure 260. Mobile application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 Figure 261. Installing Embedded software packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272 Figure 262. Starting a new project - selecting the NUCLEO-L053R8 board . . . . . . . . . . . . . . . . . . . . 273 Figure 263. Starting a new project - initializing all peripherals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 Figure 264. Selecting BlueNRG-MS components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 Figure 265. Configuring peripherals and GPIOs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 Figure 266. Configuring NVIC interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 Figure 267. Enabling BlueNRG-MS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277 Figure 268. Configuring BlueNRG-MS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 Figure 269. Configuring the SensorDemo project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279 Figure 270. Open SensorDemo project in the IDE toolchain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279 Figure 271. Launching the SensorDemo project in Atollic TrueStudio . . . . . . . . . . . . . . . . . . . . . . . . 279 Figure 272. Viewing the SensorDemo project in AtollicTrueStudio . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 Figure 273. Configuring the SensorDemo project in Atollic TrueStudio. . . . . . . . . . . . . . . . . . . . . . . . 281 Figure 274. Testing the SensorDemo application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282 Figure 275. Tutorial - Selecting an MCU for Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283 Figure 276. Graphics frameworks tooltip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284 Figure 277. Enabling STemWin framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284 Figure 278. STemWin Graphics framework configuration window . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 Figure 279. STemWin GUIBuilder configuration panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 Figure 280. STemWin GUIBuilder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287 Figure 281. StemWin generated project and files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 Figure 282. GFXSIMULATOR in Configuration view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 Figure 283. Graphics simulator user interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290 Figure 284. Graphics simulator - Current Configuration fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 Figure 285. Java™ Control Panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 Figure 286. Pinout view - Enabling the RTC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 Figure 287. Pinout view - Enabling LSE and HSE clocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294 Figure 288. Pinout view - Setting LSE/HSE clock frequency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294 Figure 289. Block mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 Figure 290. Block remapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298 Figure 291. Block remapping - Example 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299 Figure 292. Block remapping - Example 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300 Figure 293. Block inter-dependency - SPI signals assigned to PB3/4/5 . . . . . . . . . . . . . . . . . . . . . . . 301 Figure 294. Block inter-dependency - SPI1_MISO function assigned to PA6 . . . . . . . . . . . . . . . . . . . 302 Figure 295. One block = one peripheral mode - I2C1_SMBA function assigned to PB5. . . . . . . . . . . 303 Figure 296. Block remapping - Example 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304 Figure 297. Function remapping example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304 UM1718 Rev 26 15/345 16 List of figures Figure 298. Figure 299. Figure 300. Figure 301. Figure 302. Figure 303. Figure 304. Figure 305. Figure 306. Figure 307. Figure 308. Figure 309. Figure 310. Figure 311. Figure 312. 16/345 UM1718 Block shifting not applied . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305 Block shifting applied . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306 FreeRTOS HOOK functions to be completed by user . . . . . . . . . . . . . . . . . . . . . . . . . . . 310 LwIP 1.4.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311 LwIP 1.5 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312 Libjpeg configuration window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314 Mbed TLS without LwIP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 Mbed TLS with LwIP and FreeRTOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316 Mbed TLS configuration window. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317 Enabling the TouchSensing peripheral . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318 Touch-sensing sensor selection panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319 TouchSensing configuration panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 Graphics application architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 STM32 microcontroller part numbering scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323 STM32Cube Embedded Software package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 UM1718 Rev 26 UM1718 1 General information General information STM32CubeMX supports 32-bit Arm®(a) Cortex®-based microcontrollers. 2 STM32Cube overview STM32Cube™ is an STMicroelectronics original initiative to make developers’ lives easier by reducing development effort, time and cost. STM32Cube™covers the whole STM32 portfolio. STM32Cube™ includes: STM32CubeMX, a graphical software configuration tool that allows the generation of C initialization code using graphical wizards. A comprehensive embedded software platform, delivered per Series (such as STM32CubeF2 for STM32F2 Series and STM32CubeF4 for STM32F4 Series) – The STM32Cube™ HAL, STM32 abstraction layer embedded software ensuring maximized portability across the STM32 portfolio – Low-layer APIs (LL) offering a fast light-weight expert-oriented layer which is closer to the hardware than the HAL. LL APIs are available only for a set of peripherals. – A consistent set of middleware components such as RTOS, USB, TCP/IP, Graphics – All embedded software utilities, delivered with a full set of examples. a. Arm is a registered trademark of Arm Limited (or its subsidiaries) in the US and/or elsewhere. UM1718 Rev 26 17/345 344 Getting started with STM32CubeMX UM1718 3 Getting started with STM32CubeMX 3.1 Principles Customers need to quickly identify the MCU that best meets their requirements (core architecture, features, memory size, performance…). While board designers main concerns are to optimize the microcontroller pin configuration for their board layout and to fulfill the application requirements (choice of peripherals operating modes), embedded system developers are more interested in developing new applications for a specific target device, and migrating existing designs to different microcontrollers. The time taken to migrate to new platforms and update the C code to new firmware drivers adds unnecessary delays to the project. STM32CubeMX was developed within STM32Cube initiative which purpose is to meet customer key requirements to maximize software reuse and minimize the time to create the target system: Software reuse and application design portability are achieved through STM32Cube firmware solution proposing a common Hardware Abstraction Layer API across STM32 portfolio. Optimized migration time is achieved thanks to STM32CubeMX built-in knowledge of STM32 microcontrollers, peripherals and middleware (LwIP and USB communication protocol stacks, FatFs file system for small embedded systems, FreeRTOS). STM32CubeMX graphical interface performs the following functions: Fast and easy configuration of the MCU pins, clock tree and operating modes for the selected peripherals and middleware Generation of pin configuration report for board designers Generation of a complete project with all the necessary libraries and initialization C code to set up the device in the user defined operating mode. The project can be directly open in the selected application development environment (for a selection of supported IDEs) to proceed with application development (see Figure 1). During the configuration process, STM32CubeMX detects conflicts and invalid settings and highlights them through meaningful icons and useful tool tips. 18/345 UM1718 Rev 26 UM1718 Getting started with STM32CubeMX Figure 1. Overview of STM32CubeMX C code generation flow UM1718 Rev 26 19/345 344 Getting started with STM32CubeMX 3.2 UM1718 Key features STM32CubeMX comes with the following features: Project management STM32CubeMX allows creating, saving and loading previously saved projects: – When STM32CubeMX is launched, the user can choose to create a new project or to load a previously saved project. – Saving the project saves user settings and configuration performed within the project in an .ioc file that will be used the next time the project will be loaded in STM32CubeMX. STM32CubeMX also allows importing previously saved projects in new projects. STM32CubeMX projects come in two flavors: – MCU configuration only: .ioc file are saved anywhere, next to other .ioc files. – MCU configuration with C code generation: in this case .ioc files are saved in a dedicated project folder along with the generated source C code. There can be only one .ioc file per project. Easy MCU and STMicroelectronics board selection When starting a new project, a dedicated window opens to select either a microcontroller or an STMicroelectronics board from STM32 portfolio. Different filtering options are available to ease the MCU and board selection. Easy pinout configuration – From the Pinout view, the user can select the peripherals from a list and configure the peripheral modes required for the application. STM32CubeMX assigns and configures the pins accordingly. – For more advanced users, it is also possible to directly map a peripheral function to a physical pin using the Chip view. The signals can be locked on pins to prevent STM32CubeMX conflict solver from moving the signal to another pin. – Pinout configuration can be exported as a .csv file. Complete project generation The project generation includes pinout, firmware and middleware initialization C code for a set of IDEs. It is based on STM32Cube embedded software libraries. The following actions can be performed: 20/345 – Starting from the previously defined pinout, the user can proceed with the configuration of middleware, clock tree, services (RNG, CRC, etc...) and peripheral parameters. STM32CubeMX generates the corresponding initialization C code. The result is a project directory including generated main.c file and C header files for configuration and initialization, plus a copy of the necessary HAL and middleware libraries as well as specific files for the selected IDE. – The user can modify the generated source files by adding user-defined C code in user dedicated sections. STM32CubeMX ensures that the user C code is preserved upon next C code generation (the user C code is commented if it is no longer relevant for the current configuration). – STM32CubeMX can generate user files by using user-defined freemarker .ftl template files. – From the Project settings menu, the user can select the development toolchain (IDE) for which the C code has to be generated. STM32CubeMX ensures that the IDE relevant project files are added to the project folder so that the project can be UM1718 Rev 26 UM1718 Getting started with STM32CubeMX directly imported as a new project within third party IDE (IAR™ EWARM, Keil™ MDK-ARM, Atollic® TrueSTUDIO® and AC6 System Workbench for STM32). Power consumption calculation Starting with the selection of a microcontroller part number and a battery type, the user can define a sequence of steps representing the application life cycle and parameters (choice of frequencies, enabled peripherals, step duration). STM32CubeMX Power Consumption Calculator returns the corresponding power consumption and battery life estimates. Clock tree configuration STM32CubeMX offers a graphic representation of the clock tree as it can be found in the device reference manual. The user can change the default settings (clock sources, prescaler and frequency values). The clock tree is then updated accordingly. Invalid settings and limitations are highlighted and documented with tool tips. Clock tree configuration conflicts can be solved by using the solver feature. When no exact match is found for a given user configuration, STM32CubeMX proposes the closest solution. Automatic updates of STM32CubeMX and STM32Cube MCU packages STM32CubeMX comes with an updater mechanism that can be configured for automatic or on-demand check for updates. It supports STM32CubeMX self-updates as well as STM32Cube firmware library package updates. The updater mechanism also allows deleting previously installed packages. Report generation .pdf and .csv reports can be generated to document user configuration work. Please update section 3.2 with the following new features: Graphics simulator For graphics-capable microcontrollers, STM32CubeMX allows simulating a graphics configuration and adjusting graphics parameters to optimize the performance. Once the results are satisfactory, the current project configuration can be adjusted accordingly. Support of embedded software packages in CMSIS-Pack format STM32CubeMX allows getting and downloading updates of embedded software packages delivered in CMSIS-Pack format. Selected software components belonging to these new releases can then be added to the current project. Contextual help Contextual help windows can be displayed by hovering the mouse over Cores, Series, Peripherals And Middleware. They provide a short description and links to the relevant documentation corresponding to the selected item. 3.3 Rules and limitations C code generation covers only peripheral and middleware initialization. It is based on STM32Cube HAL firmware libraries. STM32CubeMX C code generation covers only initialization code for peripherals and middleware components that use the drivers included in STM32Cube embedded UM1718 Rev 26 21/345 344 Getting started with STM32CubeMX UM1718 software packages. The code generation of some peripherals and middleware components is not yet supported. 22/345 Refer to Appendix A for a description of pin assignment rules. Refer to Appendix B for a description of STM32CubeMX C code generation design choices and limitations. UM1718 Rev 26 UM1718 Installing and running STM32CubeMX 4 Installing and running STM32CubeMX 4.1 System requirements 4.1.1 Supported operating systems and architectures Windows® 7: 32-bit (x86), 64-bit (x64) Windows® 8: 32-bit (x86), 64-bit (x64) Windows® 10: 32-bit (x86), 64-bit (x64) Linux®: 32-bit (x86) and 64-bit (x64) (tested on RedHat, Ubuntu and Fedora) Since STM32CubeMX is a 32-bit application, some versions of Linux 64-bit distributions require to install 32-bit compliant packages such as ia32-libs. 4.1.2 Memory prerequisites 4.1.3 macOS: 64-bit (x64) (tested on OS X El Capitan and Sierra) Recommended minimum RAM: 2 Gbytes. Software requirements The following software must be installed: For Windows and Linux, install Java™ Run Time Environment for 1.7.0_45 or later If Java™ is not installed on your computer or if you have an old version, STM32CubeMX installer will open the Java™ download web page and stop. For macOS, install Java™ Development Kit 1.7.0_45 or later For Eclipse plug-in installation, install one of the following IDEs: – Eclipse Mars (4.5) – Eclipse Neon (4.6) – Eclipse Oxygen (4.7) 4.2 Installing/uninstalling STM32CubeMX standalone version 4.2.1 Installing STM32CubeMX standalone version To install STM32CubeMX, follow the steps below: 1. Download STM32CubeMX installation package from www.st.com/stm32cubemx. 2. Extract (unzip) stm32cubemx.zip whole package into the same directory. 3. Check your access rights and launch the installation wizard: On windows: a) Make sure you have administrators rights. b) Double-click the SetupSTM32CubeMX-VERSION.exe file to launch the installation wizard. On Linux: a) Make sure you have access rights to the target installation directory. You can run the installation as root (or sudo) to install STM32CubeMX in shared directories. UM1718 Rev 26 23/345 344 Installing and running STM32CubeMX b) UM1718 Double-click (or launch from the console window) on the SetupSTM32CubeMXVERSION.linux file. On macOS: Note: a) Make sure you have administrators rights. b) Double- click SetupSTM32CubeMX-VERSION application file to launch the installation wizard. In case of error, launch the exe file with the following command: sudo java -jar SetupSTM32CubeMX-4.14.0.exe. 4. Upon successful installation of STM32CubeMX on Windows, STM32CubeMX icon is displayed on your desktop and STM32CubeMX application is available from the Program menu. STM32CubeMX .ioc files are displayed with a cube icon. Double-click them to open up them using STM32CubeMX. 5. Delete the content of the zip from your disk. If the proper version of the Java™ Runtime Environment (version 1.7_45 or newer) is not installed, the wizard will propose to download it and stop. Restart STM32CubeMX installation once Java™ installation is complete. Refer to Section 17: FAQ for issues when installing the JRE. When working on Windows, only the latest installation of STM32CubeMX will be enabled in the Program menu. Previous versions can be kept on your PC (not recommended) when different installation folders have been specified. Otherwise, the new installation overwrites the previous ones. 24/345 UM1718 Rev 26 UM1718 4.2.2 Installing and running STM32CubeMX Installing STM32CubeMX from command line There are two ways to launch an installation from a console window: either in console interactive mode or via a script. Interactive mode To perform interactive installation, type the following command: java –jar SetupSTM32CubeMX-4.14.0.exe –console At each installation step, an answer is requested (see Figure 2). Figure 2. Example of STM32CubeMX installation in interactive mode UM1718 Rev 26 25/345 344 Installing and running STM32CubeMX UM1718 Auto-install mode At end of an installation, performed either using STM32CubeMX graphical wizard or console mode, it is possible to generate an auto-installation script containing user installation preferences (see Figure 3): Figure 3. STM32Cube Installation Wizard You can then launch the installation by typing the following command: java –jar SetupSTM32CubeMX-4.14.0.exe auto-install.xml 26/345 UM1718 Rev 26 UM1718 Installing and running STM32CubeMX Figure 4. Auto-install command line 4.2.3 Uninstalling STM32CubeMX standalone version Uninstalling STM32CubeMX on macOS To uninstall STM32CubeMX on macOS, use the following command line: java -jar/Uninstaller/uninstaller.jar. Uninstalling STM32CubeMX on Linux There are three means to uninstall STM32CubeMX on Linux: By using the following command line java -jar /Uninstaller/uninstaller.jar. Through a Windows Explorer window: a) Use a file explorer. b) Go to the Uninstaller directory of STM32CubeMX installation. c) Double-click the start uninstall desktop shortcut. Uninstalling STM32CubeMX on Windows There are three means to uninstall STM32CubeMX on Windows: By using the following command line java -jar /Uninstaller/uninstaller.jar. Through a Windows Explorer window: a) Use a file explorer. b) Go to the Uninstaller directory of STM32CubeMX installation. c) Double-click the start uninstall desktop shortcut. Through the Windows Control Panel: a) Select Programs and Features from the Windows Control Panel to display the list of programs installed on your computer. b) Right-click STM32CubeMX and select uninstall. UM1718 Rev 26 27/345 344 Installing and running STM32CubeMX 4.3 UM1718 Installing STM32CubeMX plug-in version STM32CubeMX plug-in can be installed within Eclipse IDE development toolchain. Installation related procedures are described in this section. 4.3.1 Downloading STM32CubeMX plug-in installation package To download STM32CubeMX plug-in, follow the sequence below: 4.3.2 1. Go to http://www.st.com/stm32cubemx. 2. Download STM32CubeMX- Eclipse-plug-in .zip file to your local disk. Installing STM32CubeMX as an Eclipse IDE plug-in To install STM32CubeMX as an Eclipse IDE plug-in, follow the sequence below: 1. Launch the Eclipse environment. 2. Select Help > Install New Software from the main menu bar. The Available Software window appears. 3. Click Add. The Add Repository window opens. 4. Click Archive. The Repository archive browser opens. 5. Select the STM32CubeMX- Eclipse-plug-in .zip file that you downloaded and click Open (see Figure 5). 6. Click OK in the Add Repository dialog box, 7. Check STM32CubeMX_Eclipse_plug-in and click Next (see Figure 6). 8. Click Next in the Install Details dialog box. 9. Click ”I accept the terms of the license agreement” in the Review Licenses dialog box and then click Finish. 10. Click OK in the Security Warning menu. 11. Click OK when requested to restart Eclipse IDE (see Section 4.4.2: Running STM32CubeMX in command-line mode). Figure 5. Adding STM32CubeMX plug-in archive 28/345 UM1718 Rev 26 UM1718 Installing and running STM32CubeMX Figure 6. Installing STM32CubeMX plug-in 4.3.3 Uninstalling STM32CubeMX as Eclipse IDE plug-in To uninstall STM32CubeMX plug-in in Eclipse IDE, follow the sequence below: 1. In Eclipse, right-click STM32CubeMX perspective Icon (see Figure 7) and select Close. 2. From Eclipse Help menu, select Install New Software. 3. Click Installed Software tab, then select STM32CubeMX and click Uninstall. 4. Click Finish in Uninstall Details menu (see Figure 8). Figure 7. Closing STM32CubeMX perspective UM1718 Rev 26 29/345 344 Installing and running STM32CubeMX UM1718 Figure 8. Uninstalling STM32CubeMX plug-in 30/345 UM1718 Rev 26 UM1718 Installing and running STM32CubeMX 4.4 Launching STM32CubeMX 4.4.1 Running STM32CubeMX as standalone application To run STM32CubeMX as a standalone application on Windows: select STM32CubeMX from Program Files > ST Microelectronics > STM32CubeMX. or double-click STM32CubeMX icon on your desktop. To run STM32CubeMX as a standalone application on Linux, launch the STM32CubeMX executable from STM32CubeMX installation directory. To run STM32CubeMX as a standalone application on macOS, launch the STM32CubeMX application from the launchpad. Note: There is no STM32CubeMX desktop icon on macOS. 4.4.2 Running STM32CubeMX in command-line mode To facilitate its integration with other tools, STM32CubeMX provides a command-line mode. Using a set of commands, you can: Load an MCU Load an existing configuration Save a current configuration Set project parameters and generate corresponding code Generate user code from templates. Three command-line modes are available: To run STM32CubeMX in interactive command-line mode, use the following command line: – On Windows: java -jar STM32CubeMX.exe –i – On Linux and macOS: java -jar STM32CubeMX –i The “MX>” prompt is then displayed to indicate that the application is ready to accept commands. To run STM32CubeMX in command-line mode getting commands from a script, use the following command line: – On Windows: java -jar STM32CubeMX.exe –s