Home

UM1718 - STMicroelectronics

image

Contents

1. Warnings The step consumption is higher than the max continuous current 3 mA of the battery selection Step 4 Run RTC e Action Reduce the time spent in this mode to 0 1 ms DoclD025776 Rev 12 159 200 q Tutorial 3 Using PCC to optimize the embedded application power consumption and more Step 5 Run ADC DMA RTC e Actions Change to Low power run mode Lower the operating frequency e Results The current consumption is reduced from 6 17 mA to 271 pA see Figure 161 Figure 161 Step 5 optimization s Edit Step NoRange FLASH ART Cache 2 4 CPU Frequency Interpolation ranges Interpolation ranges User choice Hz User choice Hz Clock Configuration HSE Mic Clock Configuration Clock Source Frequency 16 0 MHz ge Clock Source Frequency 2 0 MHz Optional Settings r Optional Settings Step Duration m Step Duration 6 17 mA 1 i Step Consumption 271 HA 12 16 mA F Without Peripherals 271pA 4 01 mA A 296 25 uA D 3 72 mA Peripherals Part OWA A O pA D O pA 104 33 Ta Max C 104 97 The step consu
2. Managing the whole sequence load save and compare The current sequence can be saved or deleted In addition a previously saved sequence can be either loaded in the current view or opened for comparison see Figure 87 Figure 87 Sequence table management functions Sequence test soe okt compare To load a previously saved sequence 1 Click the load button 2 Browse to select the sequence to load To open a previously saved sequence for comparison 1 Click the Compare button 2 Browse and select the pcs sequence file to be compared with the current sequence A new window opens showing the selected sequence details DoclD025776 Rev 12 105 200 q STM32CubeMX User Interface UM1718 Figure 88 PCC Edit Step window Wo Edit Step Power Mode Power Range Memory Fetch Type Vdd Voltage Source Clocks CPU Frequency User defined Interpolation ranges 8 0 MHz 16 0 MHz User choice Hz 8000000 Clock Configuration H amp EBYP Clock Source Frequency 8 0 MHz Optional Settings Step Duration Additional Consumption Results Step Consumption Without Peripherals 1 55 mA Peripherals Part O0 pA A 0 HA D O HA Ta Max C 104 74 Managing the results charts and display options In the Display area select the type of chart to display sequence steps pie charts consumption per IPs You can also click External Display to open the cha
3. Microcontroller power consumption depends on chip size supply voltage clock frequency and operating mode Embedded applications can optimize STM32 MCU power consumption by reducing the clock frequency when fast processing is not required and choosing the optimal operating mode and voltage range to run from A description of STM32 power modes and voltage range is provided below Power modes STM32 MCUs support different power modes refer to STM32 MCU datasheets for full details STM32L1 series STM32L1 microcontrollers feature up to 6 power modes including 5 low power modes e Run mode This mode offers the highest performance using HSE HSI clock sources The CPU runs up to 32 MHz and the voltage regulator is enabled e Sleep mode This mode uses HSE or HSI as system clock sources The voltage regulator is enabled and the CPU is stopped All peripherals continue to operate and can wake up the CPU when an interrupt event occurs e Low power run mode This mode uses the multispeed internal MSI RC oscillator set to the minimum clock frequency 131 kHz and the internal regulator in low power mode The clock frequency and the number of enabled peripherals are limited e Low power sleep mode This mode is achieved by entering Sleep mode The internal voltage regulator is in low power mode The clock frequency and the number of enabled peripherals are limited A typical example would be a timer running at 32 kHz When the wakeu
4. a lox C Hardware NSS Signal a SPI2 SPI3 LQFP100 a SYS TIM1 H TIM2 STM32F 107VBTx ea dd e s 7 172 200 DoclD025776 Rev 12 UM1718 STM32CubeMX STM32CubeMX pin assignment rules Figure 174 Block remapping example 2 itlegd lt 32F107VB7 File Project Pinout Window Help mauu s F Keep Current Signals Placement 9 Q Find Pinout dock Configuration Configuration Power Consumption Calculator IO Output I2C1 SMBA T CO t O a I2C1 SDA I2C1 SCL N D un BE a a Master Clock Output H 1253 4 IWDG RCC RTC SPIL Hardware NSS Signal 6 SPI2 SPI3 SYS 6 TIM1 6 TIM2 H 6 TIM3 4 9 TIM4 9 TIMS 3j 9 TIM6 TIM7 A 2 q STM32F107VBTx LQFP100 g D D g D D D D J D D g D Y D g D m 2 z 2 O68 8 pa Block inter dependency On the Chip view the same signal can appear as an alternate function for multiple pins However it can be mapped only once As a consequence for STM32F1 MCUs two blocks of pins cannot be selected simultaneously for the same peripheral mode when a block signal from a block is selected the alternate blocks are cleared Example of block remapping of SPI in full duplex master mode with a STM32F107x MCU If SP11 full duplex master mode is selected from the tree vi
5. 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 8 200 Overview of STM32CubeMX C code generation flow llle 14 Example of STM32CubeMX installation in interactive mode LL 18 STM32Cube Installation Wizard ee eee 19 Auto install command line EES ee ee eee nee 20 Adding STM32CubeMX plug in archive lille 21 Installing STM32CubeMX plug in lllllllellee rn 22 Closing STM32CubeMX perspective aaa aaa 22 Uninstalling STM32CubeMX plug in a an anaa aaa ee es es es ee 23 Opening EcIpse DIO iss sd acum x OE TE he REED ORR S MORE HOER RA se ba x BERDE a 26 STM32CubeMX perspective nananana SE SE SE eee rrr 26 Displaying Windows default proxy settings SESSE SS ES SS SE ees 27 Updater Settings window aaaea aaa SE SE Se SS Se lr 28 Connection Parameters tab No proxy SS SS SES SS SS ee ee ee 29 Connection Parameters tab Use System proxy parameters nannaa SE SE 30 Connection Parameters tab Manual Configuration of Proxy Server 31 New library Manager window 1 6 mar 32 REMOVING MIDIANGS uu ME n OD ceases EDE dog id OO Ek bakes ER RE a n OP e 33 Removing library confirmation message ES
6. JADC 1 fs_10 OmA 1 94mA ims 16 0 MHz 16 0 MHz ADC 1 fs_10 T 0 mA 724 2 uA 1ms 16 0 MHz 16 0 MHz A1RTCU 0 mA 0 Hz lo Hz USART 1 OmA 1 94 mA 110 pA 1ms 1ms 16 0 MHz 16 0 MHz 0 mA 1 62 mA 6 3 us 16 0 MHz 16 0 MHz 0 mA 1 91mA ims 0 Hz 137 0 kHz TC USART1 RC lo mA 10 46 uA 1ms DoclD025776 Rev 12 157 200 Tutorial 3 Using PCC to optimize the embedded application power consumption and more 7 Click the Save button to save the sequence as SequenceOne The application consumption profile is the generated It shows that the overall sequence consumes an average of 2 01 mA for 9 ms and the battery lifetime is only 4 days see Figure 159 Figure 159 PCC sequence results before optimization Consumption mA GJ Results Charts ON UI E Consumption Profile by Step RUN 5 RUN 7 RUN 3 WU 4F OM STANDBY P 11 STANDBY 0 0 0 5 1 0 15 2 0 aS 3 0 35 4 0 4 5 5 0 E 6 0 6 5 7 0 Z5 8 0 8 5 9 0 Time ms Idd by Step Average Current Results Summary Sequence Time Ta Max 9ms 104 0 C Average Consumption 2 01 mA Battery Life Estimation 4 days amp 15 hours Battery compatibility not garanteed with defined step s Average DMIPS 22 0 DMIPS 8 3 2 Optimizing application power consump
7. 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 197 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 List of figures Project building OQ acid ued sane ood eek ww fe oa a aR ql ecd SRE x ae 144 User Section 2 anaana naaa ee ee eee ee eee 144 User Section 4 MO MI and ON ON EE EE ac d award ended twas 144 Import Project Men ss cium RE KOR BROER KAR Rd EE N Ee RE OE aE eee ress Re BEE 146 Project Import status EES ES ES ee ee se ee ee ee es 146 Board selection EES EE SE SE ee aras 147 SDIO IP congu atO RA OER RT EE OE OE N EE OR ek 148 FatFs mode configuratiON SS SES SS ee ee ee ee see 148 RCC peripheral configuration 0 2 EES ES SE EE eee eens 148 Clock di TREE ee ee eee 149 Project Settings menu Code Generator tab anana naaa ee 149 C code generation completion message 0 ee ee 150 IDE WORKSDGCC acon OE OE pira Choe eyes pes OE E ud nma fe E eed 150 Power Consumption Calculation example 0 0 00 cc eee 156 PCC VDD and b
8. define I2C1B7 GPIO Port GPIOB Figure 94 Duplicate labels Ly DoclD025776 Rev 12 UM1718 3 STM32CubeMX C Code generation overview In order for the generated project to compile define statements shall follow strict naming conventions They shall start with a letter or an underscore as well as the corresponding label In addition they shall not include any special character such as minus sign parenthesis or brackets Any special character within the label will be automatically replaced by an underscore in the define name If the label contains character strings between or only the first string listed is used for the define name As an example the label LD6 Blue Led corresponds the following define statements define LD6 Pin GPIO PIN 15 define LD6 GPIO Port GPIOD The define statements are used to configure the GPIOs in the generated initialization code In the following example the initialization of the pins labeled Audio RST Pin and LD4 Pin is done using the corresponding define statements Configure GPIO pins LD4 Pin Audio RST Pin GPIO InitStruct Pin LD4 Pin Audio RST Pin GPIO InitStruct Mode GPIO MODE OUTPUT PP GPIO InitStruct Pull GPIO NOPULL GPIO InitStruct Speed GPIO SPEED LOW HAL GPIO Init GPIOD amp GPIO InitStruct Finally it generates a Projects folder that contains the toolchain specific files that match the user project settings Double clicking the
9. lt 7 UM1718 Yy life augmented User manual STM32CubeMX for STM32 configuration and initialization C code generation Introduction STM32CubeMX is a graphical tool for 32 bit ARM Cortex STM32 microcontrollers It is part of STMCube initiative see Section 1 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 e Easy microcontroller selection covering whole STM32 portfolio e Board selection from a list of STMicroelectronics boards e Easy microcontroller configuration pins clock tree peripherals middleware and generation of the corresponding initialization C code e Easy switching to another microcontroller belonging to the same series by importing a previously saved configuration to a new MCU project e Generation of configuration reports e Generation of IDE ready projects for a selection of integrated development environment tool chains STM32CubeMX projects include the generated initialization C code STM32 HAL drivers the middleware stacks required for the user configuration and all the relevant files needed to open and build the project in the selected IDE e Power consumption calculation for a user defined application sequence e Self updates allowing the user to keep the STM32CubeMX up to date e Download and update of STM32Cube embedded software required for user application devel
10. rMs2rF4 STM32F429 439 STMS2F42OVITx JLOFP100 RTC SALSDIO rIMs2rF4 STM32F429 439 STMS2F42OzETx LQFPi44 RTCSALSDIO rIMs2rF4 STM32F429 439 STM3eF42UzGTx LGFPi44 RTGSALSDIO rMs2rF4 STMA2Fd29 438 STM3eF42UZITx LQFPi4d4 RTGSALSDIO rMs2rF4 STMA2F429 439 STM32F429ZEYx_ MLCSPI43 RTC SALSDIO rMs2rF4 STM32F429 439 STM32F429ZGYx WLCSP143 RTC SALSDIO rMs2r4 STM32F429 439 STMSZF42UZIYx WLCSP143 RTC SALSDIO prIMs2F4 STMA2F429 439 STM3SeF439BGTx LOFP20B RTC SALSDIO pIM32F4 STM32F429 439 STM32F439BITx LQFPeOB RTCSALSDIO pIM32F4 STM32F429 439 STM32F438IGHx UFBGAI76 RTCSALSDIO prMs2rF4 STMA2Fd29 439 STMS2F43OUHx UFBGA176 RTCSALSDIO rMs2rF4 STMA2rd29 439 STMS2F43SIGTx LQFPi b RTCSALSDIO rMs2r4 STMAard29 439 STMSZF43OITx LQFP176 RTCSALSDIO prMs2rF4 STM32F429 439 GTMeF439NGHx TFBGA216 RTC SALSDIO rMs2rF4 STM32F429 4390 STM32F439NIHx TFBGA216 RTC SALSDIO rMs2r4 STM32F429 439 GTM3eF439vGTx LQFP100 RTCSALSDIO OSTM32r4 STMA2F429 439 STMS2F43OVITIx LGFPi00 RTC SALSDIO rMs2r4 STM32F429 439 STM3S2F433zGTx
11. 1 92 mA Step Consumption 42 06 HA Without Peripherals 1 81 mA E Without Peripherals 41 8 pA Peripherals Part 105 6 pA A 0 HA D 105 6 HA Peripherals Part 0 26 uA A 0 HA D 0 26 HA Ta Max C 104 79 u Ta Max C 105 Warnings Warnings 3 162 200 DoclD025776 Rev 12 UM1718 Tutorial 3 Using PCC to optimize the embedded application power consumption and Step 8 Stop 0 USART e Actions Switch to Stop1 low power mode Use the power efficient LPUART peripheral e Results The current consumption is reduced from 110 pA to 6 65 pA see Figure 164 Figure 164 Step 8 optimization E 7 6 Edit Step Edit Step jy jy ml COMP High Speed St r NE DACA COMP_High_Speed st i F OUT1 0UT2 Buffer_0 NoRange E COMP Medium Powe NoRange F OUT1 0UT2 Buffer_O e 7 COMP Medium Powe nia C OUT1 Buffer ON Midd 7 COMP_Medium_Powe f OUT1 Buffer ON Wor COMP Medium Powe OUT2 Buffer ON Midd COMP Medium Powe i OUT2 Buffer ON Wors COMP Medium Powe GPIOA Clocks COMP Medium Powe GPIOB CPU Frequency Oz E COMP Medium Powe OH GPIOC COMP OFF VREFBUF Interpolation ranges GPIOD COMP OFF VREFBUF GPIOH User choice
12. FW F4 1 6 0 C Users frq09031 STM32Cube Repository ST M32Cube_FW_F4_V1 6 0 Please confirm firmware pack s deletion Ly DoclD025776 Rev 12 33 200 Installing and running STM32CubeMX UM1718 Figure 19 Library deletion progress window Remove selected Firmware Deleting 22962 items Deleting Firmware STM32Cube FW F4 V1 6 0 3 5 4 Checking for updates When the updater is configured for automatic checks it regularly verifies if updates are available In this case a green arrow icon appears on the tool bar When automatic checks have been disabled in the updater settings window the user can manually check if updates are available 1 Click the icon to open the Update Manager window or Select Help Check for Updates All the updates available for the user current installation are listed 2 Click the check box to select a package and then Install Now to download the update 34 200 DoclD025776 Rev 12 7 UM1718 4 4 1 STM32CubeMX User Interface STM32CubeMX User Interface STM32CubeMX user interface consists of a main window a menu bar a toolbar four views Pinout Configuration Clock Configuration Power Consumption Calculator and a set of help windows MCUs selection Update manager About All these menus are described in the following sections For C code generation although the user can switch back and forth between the different configuration views it is recommended to follow
13. GPIO selection Pin Configuration Pin 5ignal on Pin GPIO mode GPIO Pull up Pu Maximum outpu User Label IPD 10 n a Input mode Mo pull up and no n PD11 na JututPushPul Na pull up and no L Pos ja OutputPush Pul No pulap andro Select Pins from table to configure them Multiple selection is Allowed E Group By IP Click a row or select a set of rows to display the corresponding GPIO parameters see Figure 63 e GPIO mode analog input output alternate function Selecting an IP mode in the Pinout view automatically configures the pins with the relevant alternate function and GPIO mode e GPIO pull up pull down It is set to a default value and can be configured when other choices are possible e GPIO maximum output speed for communication IPs only It is set to Low by default for power consumption optimization and can be changed to a higher frequency to fit application requirements e User Label It changes the default name e g GPIO input into a user defined name The Chip view is updated accordingly The GPIO can be found under this new name via the Find menu 7 18 200 DoclD025776 Rev 12 UM1718 STM32CubeMX User Interface Figure 63 GPIO Configuration window displaying GPIO settings Pin Configuration GPIO ADC2 E Show only Modified Pins ge Pin Name Signal on Pin GPIO mode GPIO Pull up Pu Maximum outpu User Label Modified PEG I2C1_5CL Alternate Functio
14. Peripheral default option unchecked 9 STM32CubeMX Untitled File Project Pinout Window Help He OE d j V Keep Current Signals Placement j Find 9 v ShowuserLabel 7 p Pinout Clock Configuration Configuration Power Consumption Calculator onfiguration Middlewares 5 FATFS 9 FREERTOS 3 1 SDRAM UI NA LO SORAM LI 1 gt d Spe G BBREBRERERBEBBES uU 7 2C3 SCL ACP RF SU I2C3 SDA ACP RF SDA HSYNC SOC DOTCLK LCT RG8 DOTCLK STM32F429ZITx NCS MEMS SPI L3GD20 CS I2C SPI L Q EP 1 44 CSX LCD RGB CSX 81 Blue PushButtan MEMS INT1 L3GD20 INT1 MEMS_INT2 L3GD20 INT2 INASA z 1st cOV BRAG E E E E E E E E E E E E E E E E E E E E E E E E amp 0 O5c Sz DLO LO 20 5 510 BERE 7 40 200 DoclD025776 Rev 12 UM1718 STM32CubeMX User Interface Selecting a board with the peripheral default modes option checked automatically sets both the pinout and the default modes for the peripherals available on the board This means that SIM32CubeMX will generate the C initialization code for all the peripherals available on the board and not only for those relevant to the user application see Figure 25 Figure 25 STM32CubeMX Main window upon board selection Peripheral default option checked STM32CubeMX Untitled STM32F429ZITx e File Pro
15. Pin Configuration GPIO Show only Modified Pins P Signal on Pin GPIO mode GPIO Pull up Pu Maximum outpu User Label Output Push Pull Ma pull up and no Low LD4 Green Led PD14 Configuration GPIO mode Output Push Pull GPIO Pull up Pull down No pull up and no pull down Maximum output speed Low User Label LD4 Green Led Group By IP 3 Click Apply then Ok to close the window 7 130 200 DoclD025776 Rev 12 UM1718 Tutorial 1 From pinout to project C code generation using an STM32F4 MCU 6 6 4 Configuring the DMAs This is not required for the example taken for the tutorial It is recommended to use DMA transfers to offload the CPU The DMA Configuration window provides a fast and easy way to configure the DMAs see Figure 127 1 Adda new DMA request and select among a list of possible configurations 2 Select among the available streams 3 Select the Direction Memory to Peripheral or Peripheral to Memory 4 Select a Priority Note Configuring the DMA for a given IP can also be performed using the IP configuration window Figure 121 DMA Parameters configuration window is DMA Configuration Stream Direction DMA1 Stream 0 IM3_CH4 UP Peripheral Memory DMA Request Settings Mode Normal Increment Add Use Fifo Thres Half Full w Data Width Burst Size DoclD025776 Rev 12 131 200 q Tutorial 1 Fro
16. SPI2 SPI3 He sys s s TIMI STM32F107VBTx H 6 TIM2 LOFP100 H TIMS 9 TIM4 8 TIMS 8 TIM6 H 9 TIM7 J3 USART3 CK i UART4 UARTS i USART1 i USART2 Tad trad xr clLavsn HIE xa ELAYSN Setting and clearing a peripheral mode The Peripherals panel and the Chip view are linked when a peripheral mode is set or cleared the corresponding pin functions are set or cleared Mapping a function individually When STM32CubeMX needs a pin that has already been assigned manually to a function no peripheral mode set it can move this function to another pin only if Keep Current Signals Placement is unchecked and the function is not pinned no pin icon GPIO signals mapping VO signals GPIO Input GPIO Output GPIO Analog can be assigned to pins either manually through the Chip view or automatically through the Pinout menu Such pins can no longer be assigned automatically to another signal STM32CubeMX signal automatic placement does not take into account this pin anymore since it does not shift VO signals to other pins The pin can still be manually assigned to another signal or to a reset state DoclD025776 Rev 12 179 200 STM32CubeMX C code generation design choices and limitations UM1718 Appendix B STM32CubeMX C code generation design B 1 Note B 2 180 200 choices and limitations This section summarizes STM32CubeMX design choices and limitations STM32Cub
17. 4 13 2 Recommendations 0 0000 cc eens 89 4 133 STM32F43x 42x power over drive feature 91 4 13 4 Clock tree glossary ellen 93 Power Consumption Calculator PCC view 0200 00 ee 93 4 14 1 Building a power consumption sequence 94 4 14 2 Configuring a step in the power sequence 100 4 14 3 Managing user defined power sequence and reviewing results 104 4 144 Power sequence step parameters glossary 2005 108 4 14 5 Battery glossary SS SS SS eee 110 DoclD025776 Rev 12 3 200 Contents 5 4 200 UM1718 STM32CubeMX C Code generation overview 111 5 1 Standard STM32Cube code generation 0 000 eee ees 111 5 2 Custom code generation SS SS SS ee es 114 Tutorial 1 From pinout to project C code generation using an STM32F4 MCU EER EE EE EE EE es 118 6 1 Creating a new STM32CubeMX Project SESSE SS SE eae 118 6 2 Configuring the MCU pinout ESE ES ESE SE SS ees 121 6 3 Saving the project EES EES eee ees 122 6 4 Generating the report 0 EE EE SE ee ee ene 123 6 5 Configuring the MCU Clock tree EES SS ES Se ee see 123 6 6 Configuring the MCU initialization parameters 126 6 6 1 Initial conditions EES EES ee eee 126 6 6 2 Configuring the peripherals ESE EE cece ee Ee ee 127 6 6 3 Configuring the GPIOS SEE E
18. E 2 um Ru Peripheral Names n c Uu E uU e wo zm EE te 5 n4 4093 GNI C AO EO a 3 C GO OOP Z Analog Digital Overview of the Results summary area This area provides the following information see Figure 90 e Total sequence time as the sum of the sequence steps durations e Average consumption as the sum of each step consumption weighed by the step duration e The average DMIPS Dhrystone Million Instructions per Second based on Dhrystone benchmark highlighting the CPU performance for the defined sequence e Battery life estimation for the selected battery model based on the average power consumption and the battery self discharge e Tamax highest maximum ambient temperature value encountered during the sequence DoclD025776 Rev 12 107 200 q STM32CubeMX User Interface UM1718 Figure 90 Description of the Results area Results Summary Total Sequence Time 6 ms Average Consumption 4 74 mA Battery Life Estimation 25 days Average DMIP S 13 67 DMIPS 4 14 4 Power sequence step parameters glossary The parameters that characterize power sequence steps are the following refer to Appendix D STM32 microcontrollers power consumption parameters for more details e Power modes To save energy it is recommended to switch the microcontroller operating mode from running mode where a maximum power is required to a low power mode requiring limited resources e Vcore
19. Figure 106 Figure 107 Generate Project Report New project creation Generate Project Report i rr a The project name is generally used as report name but no project is currently saved If the project is not created now you will be asked for a report file name Would you like to create a project first L ve No Cancel r 2 Open the pdf report using Adobe Reader or the txt report using your favorite text editor The reports summarize all the settings and MCU configuration performed for the project Configuring the MCU Clock tree The following sequence describes how to configure the clocks required by the application based on an STM32F4 MCU STM32CubeMX automatically generates the system CPU and AHB APB bus frequencies from the clock sources and prescalers selected by the user Wrong settings are detected and highlighted in red through a dynamic validation of minimum and maximum conditions Useful tooltips provide a detailed description of the actions to undertake when the settings are unavailable or wrong User frequency selection can influence some peripheral parameters e g UART baudrate limitation STM32CubeMX uses the clock settings defined in the Clock tree view to generate the initialization C code for each peripheral clock Clock settings are performed in the generated C code as part of RCC initialization within the project main c and in stm32f4xx_hal_conf h HSE HSI
20. Includes include stm32f4xx hal h USER CODE BEGIN Includes USER CODE END Includes Private variables TIM HandleTypeDef htim3 USER CODE BEGIN PV Private variables USER CODE END PV Private function prototypes void SystemClock Config void static void MX GPIO Init void static void MX TIM3 Init void USER CODE BEGIN PPP USER CODE END PFP USER CODE BEGIN O USER CODE END D int main void USER CODE BEGIN 1 USER CODE END 1 MCU Configuration Reset of all peripherals Initializes the Flash interface and the Sy HAL Init Configure the system clock SystemClock Config Initialize all configured peripherals MX GPIO Init MX TIM3 Init USER CODE BEGIN 2 USER CODE END 2 y Infinite loop USER CODE BEGIN WHILE while 1 i USER CODE END WHILE USER CODE BEGIN 3 USER CODE END 3 Ln 51 Col 1 DoclD025776 Rev 12 UM1718 3 UM1718 4 Tutorial 1 From pinout to project C code generation using an STM32F4 MCU In the IAR IDE right click the project name and select Options Figure 141 IAR options e M32Cube SimpleLedToagle Configuration Files am B E BEET TAS TIETE NON He 3 Application x a 1 Drivers a 3 Example La 71 Output x x 5 Click the ST LINK category and make sure SWD is selected to communicate with the STM32F4DISCOVERY board Cl
21. LQFP1l44 RTC SALSDIO rMs2rF4 STMAaFA29 439 STMS2F43OZITx LQFPi44 RTGSALSDIO DEDI US LC AEN IO OON U Tc NS EE EE RT Err m This window can be shown hidden by selecting unselecting Outputs from the Window menu DoclD025776 Rev 12 45 200 q STM32CubeMX User Interface UM1718 4 6 Import Project window The Import Project menu eases the porting of a previously saved configuration to another MCU of the same series If the series do not match an error message is displayed and prevents to proceed further Figure 29 Error message obtained when importing from different series reni Ba x C STM32CubeMX_Projects 4_9 UM STM32F746Disco_projl STM32F746Disco_projl ioc project is defined for STM32F7 serie while the current mcu serie is STM32F4 By default the following settings are imported e Pinout tab MCU pins and corresponding peripheral modes The import fails if the same peripheral instances are not available in the target MCU e Clock configuration tab clock tree parameters e Configuration tab peripherals and middleware libraries initialization parameters e Project settings choice of toolchain and code generation options To import a project proceed as follows 1 Select the Import project icon 3 that appears under the File menu after starting a New Project and once an MCU has been selected The menu remains active as long as no user configuration settings ar
22. MHz e APB2 peripheral clocks MHz i6 APB2 timer clocks MHz i o 48MHz clocks MHz o Do you want to run automatic clock issues solver Otherwise you can do it later by dlicking on button Resolve Clock Issues 6 E Do not show this message again Remember my decision for next projects 96 I2S clocks MHz ve J Ww jJ Ee dock 88 200 DoclD025776 Rev 12 Ly UM1718 STM32CubeMX User Interface Table 12 Clock tree view widget Format i itane Format Instance Active clock sources Unavailable settings are blurred or grayed out clock sources dividers AHB Prescaler Gray drop down lists for prescalers dividers uides multipliers selection Multiplier selection User defined frequency values HSE OSC HCLK MHz Automatically derived frequency values User modifiable frequency field Right click blue border rectangles to lock unlock 0 a frequency field Lock to preserve the frequency lock V Unodd value during clock tree configuration updates 4 13 2 Recommendations The Clock tree view is not the only entry for clock configuration 1 Go first through the RCC IP pinout configuration in the Pinout view to enable the clocks as needed external clocks master output clocks and Audio 12S input clock when available see Figure 72 DoclD025776 Rev 12 89 200 q STM32CubeMX User Interface UM1718 Figure 72 Clock tre
23. OUT1 OUT2 Buffer ON W OUT1 Buffer OFF Middle OUT1 Buffer ON Middle c OUT1 Buffer ON Worst cc OUT2 Buffer OFF Middle OUT2 Buffer ON Middle c Warnings Warnings q DoclD025776 Rev 12 161 200 Tutorial 3 Using PCC to optimize the embedded application power consumption and more Step 7 Run DMA RTC USART e Actions Switch to Lower power run mode Use the power efficient LPUART peripheral Reduce the operating frequency to 1 MHz using the PCC interpolation feature e Results The current consumption is reduced from 1 92 uA to 42 pA see Figure 163 Figure 163 Step 7 optimization Edit Step Ex Power Memory Power Mode LOWPOWER_RUN v Power Range NoRange Edit Step FLASH ART Cache 2 4 p Clocks SYS VREFBUF COMP1 CPU Frequency 5 SYS VREFBUF COMP2 Interpolation ranges Interpolation ranges 100 0 kHz 2 0 MHz v User choice Hz User choice Hz 100000 Clock Configuration HSE Clock Configuration MSI Clock Source Frequency Clock Source Frequency 100 0 kHz Optional Settings Optional Settings Step Duration Step Duration 1 l ST OPAMP1 Additional Consumption 0 i Low Power Normal Results OPAMP2
24. The DMA request called channel for STM32F4 MCUs is used to reserve a stream to transfer data between peripherals and memories see Figure 67 The stream priority will be used to decide which stream to select for the next DMA transfer DMA controllers support a dual priority system using the software priority first and in case of equal software priorities a hardware priority that is given by the stream number DoclD025776 Rev 12 81 200 q STM32CubeMX User Interface UM1718 Figure 67 DMA Configuration DMA Configuration DMAI Stream Direction DMA1 Stream 0 i i DMA1 Stream 6 Memory To Peripheral Low Peripheral Memory Mode Normal Increment Add E E DMA Request Settings Use Fifo Thres Half Full Data Width Byte Byte Burst Size Single Single A o o WEE EE MEE SS Additional DMA configuration settings can be done through the DMA configuration window e Mode regular mode circular mode or peripheral flow controller mode only available for the SDIO IP e Increment Add the type of peripheral address and memory address increment fixed or post incremented in which case the address is incremented after each transfer Click the checkbox to enable the post incremented mode e Peripheral data width 8 16 or 32 bits e Switching from the default direct mode to the FIFO mode with programmable threshold a Click the Use FIFO checkbox b Then configure the peripheral and memory data width
25. 1 100 CONSTANT 1 CONSTANT 5 CONSTANT 2 CONSTANT 1 CODE BEGIN Private defines CODE END Private defines DoclD025776 Rev 12 13 200 STM32CubeMX User Interface UM1718 Figure 55 Using constants for peripheral parameter settings SDIO Configuration Parameter Settings ef User Constants e NVIC Settings f GPIO Settings Configure the below parameters H SDIO parameters SDIOCLK dock divide factor Creating editing user constants Click the Add button to open the User Constants window and create a new user defined constant see Figure 56 A constant consists of e Aname that must comply with the following rules t must be unique It shall not be a C C keyword t shall not contain a space It shall not start with digits e Avalue The constant value can be see Figure 53 for examples asimple decimal or hexadecimal value a previously defined constant aformula using arithmetic operators subtraction addition division multiplication and remainder and numeric value or user defined numeric constants as operands acharacter string the string value must be between double quotes example constant for usart Once a constant is defined its name and or its value can still be changed double click the row that specifies the user constant to be modified This opens the User Constants window 74 200 DoclD025776 Rev 12 Ly UM1718 STM32CubeMX User Interfac
26. 4 3 Main window Once an STM32 part number or a board has been selected or a previously saved project has been loaded the main window displays all STM32CubeMX components and menus see Figure 23 Refer to Section 4 3 for a detailed description of the toolbar and menus Figure 23 STM32CubeMX Main window upon MCU selection R Suie M keep current Signals Placement amp G Find A QA ev Show user Label pi Pinout Clock Configuration Configuration Power Consumption Calculator onfiguration MiddleWares sta BEERERPRPERPERPREPEEREE FREERTOS mi 5 e EIS e ur u ed al IF STM32F439VITx LQFP100 ae m e e N mal Ez EIE H H E H H H H H H H H H E H H H H H H H H H H MCUs Selection Series Mcu Package Required Peripherals STM32F4 STM32F429VETx LOFP 100 None STM32F4 STM32F429 439 STM32F429VGTx LOFP 100 None STM32F4 STM32F429 439 STM32F420VITX LOFP 100 None c ALLE at u EE FEE DoclD025776 Rev 12 39 200 q STM32CubeMX User Interface UM1718 Selecting a board while keeping the peripheral default modes option unchecked automatically sets the pinout for this board However no peripheral modes are set The user can then manually select from the peripheral tree the peripheral modes required for his application see Figure 24 Figure 24 STM32CubeMX Main window upon board selection
27. 8 16 or 32 bits C Select between single transfer and burst transfer If you select burst transfer choose a burst size 1 4 8 or 16 In case of memory to memory transfer MemtoMem the DMA configuration applies to a source memory and a destination memory 7 82 200 DoclD025776 Rev 12 UM1718 4 12 5 Note q STM32CubeMX User Interface Figure 68 DMA MemToMem configuration DMA Configuration MemToMem DMA Request stream Direction Priority DMA Stream Memory Ta Memory DMA Request Settings Mode Normal Increment Address Use Fifo Threshold Half Ful Data Width Byte Burst Size Single NVIC Configuration window Click NVIC in the Configuration pane to open the Nested Vector interrupt controller configuration window see Figure 69 The NVIC window will not show all possible interrupts but only the ones available for the IPs selected in the Pinout and Configuration panes Check Uncheck the Show only enabled interrupts box to filter or not on enabled interrupts Use the search field to filter out the interrupt vector table according to a string value For example after enabling UART IPs from the Pinout pane type UART in the NVIC search field and click the green arrow next to it all UART interrupts are displayed It is also possible to access IP dedicated interrupts using the NVIC window in the IP configuration window DoclD025776 Rev 12 83 200 STM32CubeMX User Interface
28. An IP configuration button is associated to each peripheral in the Configuration window see Table 10 Table 10 IP configuration buttons Peripheral Instance configuration status Available but not fully configured yet Click to open the configuration window Well configured with default or user defined settings that allows proceeding with the generation of corresponding initialization C code Click to open the configuration window Badly configured with some wrong parameter values Click to display the errors highlighted in red Other example UART Baud Rate X 1000000 Bits s TIM4 Configuration A Please select a Trigger Source in the Pinout view Dialog box that explains source of error It shall be fixed in another view DoclD025776 Rev 12 69 200 q STM32CubeMX User Interface UM1718 GPIO DMA and NVIC settings can be accessed either via a dedicated button like other IPs or via a tab in the other configuration windows of the IPs which use them see Figure 51 Figure 51 Configuration window tabs for GPIO DMA and NVIC settings STM32F4 series DIO Configuration Parameter Settings User Constants NVIC Settings GPIO Settings ef DMA Settings Search Signals Search CrH F E Show only Modified Pins Pin Name Signal on Pin GPIO mode GPIO Pull up Pull down Maximum output speed User Label Modified PCS DO Alternate Function Push Pull No pull up and no pull down PCa au
29. As window EES ES ESE SE ee hrs 122 Figure 108 Generate Project Report New project creation ESE EE SE EE ene 123 Figure 109 Generate Project Report Project successfully created EES ES cee 123 Figure 110 Clock tree view ss SS ES ESE SE es es ee ee Ee Ee ee se RR rns 124 Figure 111 HSI clock enabled ES SS SE SE SE eee eee ee ee ed 125 Figure 112 HSE clock source disabled SES SE SS es eee es ee 125 Figure 113 HSE clock source enabled iS SE SE Se se eee ee ee 125 Figure 114 External PLL clock source enabled 0 ec eee 125 Figure 115 Configuration VIEW SE SE SE ES ES eee es es es es ee ee 127 Figure 116 Case of IP without configuration parameters SS SS SS SE SE ees 127 Figure 117 Timer 3 configuration WiINdOW asana aaaea rr 128 Figure 118 Timer 3 configuration anana SE SS SS ee eee eens 129 Figure 119 Enabling Timer 3 interrupt 0 0 0 0 SE SE SS SS SS eee eee 129 Figure 120 GPIO configuration color scheme and tooltip llle 130 Figure 121 GPIO mode configuration a na aaa aaaea 130 Figure 122 DMA Parameters configuration window 2 0 eens 131 Figure 123 FatFs disabled 0 cc eee teens 132 Figure 124 USB Host configuration naana SS SS SES SS SE eee eens 132 Figure 125 FatFs over USB mode enabled 0 0 ccc teens 132 Figure 126 Configuration view with FatFs and USB enab
30. BEGIN 2 HAL TIM Base Start IT amp shtim3 USER CODE END 2 Infinite loop USER CODE BEGIN WHILE while 1 c Then add the following C code in User Section 4 Figure 145 User Section 4 USER CODE BEGIN 4 void HAL TIM PeriodElapsedCallback TIM HandleTypeDef htim 1 if htim gt Instance htim3 lnstance i HAL GPIO TogglePin GPIOD GPIO PIN 12 j USER CODE END 4 7 144 200 DoclD025776 Rev 12 UM1718 10 Tutorial 1 From pinout to project C code generation using an STM32F4 MCU This C code implements the weak callback function defined in the HAL timer driver stm32f4xx_hal_tim h to toggle the GPIO pin driving the green LED when the timer counter period has elapsed Rebuild and program your board using E Make sure the SWD ST LINK option is checked as a Project options otherwise board programming will fail Launch the program using z The green LED on the STM32F4DISCOVERY board will blink every second To change the MCU configuration go back to STM32CubeMX user interface implement the changes and regenerate the C code The project will be updated preserving the C code in the user sections if Keep Current Signals Placement Option in Project Settings is enabled 6 9 Switching to another MCU STM32CubeMxX allows loading a project configuration on an MCU of the same series Proceed as follows 1 2 Select File New Project Sele
31. Consumption 1 55 mA Without Peripherals 1 55 mA Peripherals Part OuA A 0 uA D 0 HA Ta Max C 104 74 Importing pinout Figure 84 illustrates the example of the ADC configuration in the Pinout view clicking Import Pinout in the PCC view selects the ADC IP and GPIO A Figure 85 The Import pinout button allows to automatically select the IPs that have been configured in the Pinout view 3 102 200 DoclD025776 Rev 12 UM1718 STM32CubeMX User Interface Figure 84 ADC selected in Pinout view 9 Ba a a a EE MEE EE ME OR File Project Pinout Window Help R 5 B E amp Cj Keep Current Signals Placement 3 amp j Find IA 4 V Showuserlabe 7 p Pinout Clock Configuration Configuration Power Consumption Calculator onfiguration MiddleWares EE FATFS E FREERTOS RRRE ERBRBERRBRERRERERE 3 9 ADC1 V INO V INI STM32F427VITx LQFP100 ADC1 INO 2509 ADC1 IN1 H5 eo e PAL PAL PALL PA10 PAS _ Pas PCS pcs _ PC PCE pD15 PD14 Poi PD12 Poil PD10_ PDS pos _ pis peia pens pe12 ADC1_IN2 E q DoclD025776 Rev 12 103 200 STM32CubeMX User Interface UM1718 Figure 85 PCC Step configuration window ADC enabled using import pinout 6 New Step Power Memory Power Mode RUN Power Scale Scale 1 High Memory Fetch Type Vdd Voltage Source Interpolation ranges User choice Hz Clock Configur
32. D LQFP100 D a ES TE GPIO Input g GPIO Input i O S E U a O g g O J y x xX n O H H U hard o TIM3 9 TIM4 s TIMS VREF GPIO Input TIM6 DDA GPIO_Input 9 te Te GPIO Input Z SEME GPIO Input 5 M9 GPIO Input f GPIO_Input 9 TIM10 TIM11 TIM12 TIM13 TIM14 UART4 9 UARTS UART7 UARTS USART1 USART2 GPIO Input GPIO Input GPIO Input do 3ndur old H H H H 2 E H 3 H amp E H D H amp i 5 H E EB amp H EB EZ E amp 4 ES H 5 H 9 4 H 5 ES g d 5 i E 4 8 Project Settings Window This window allows configuring the project project name project location choice of Integrated Development Environment tools Keil MDK ARM IAR EW ARM Attolic TrueStudio AC6 SWASTM32 and C code generation options There are several ways to enter project settings information 1 By selecting Project gt Settings from the STM32CubeMX menu bar see Figure 38 The code generation will then be generated in the project folder tree shown in Figure 39 7 94 200 DoclD025776 Rev 12 q UM1718 STM32CubeMX User Interface Figure 38 Project Settings window 5 Project Settings Code Generator Project Settings Project Name Projecti Project Location C Users VJohnDoe STM32Cube projects Toolchain Folder Location C Users JohnDoe STM32
33. E MCO2 sou rce Mux SYSCLK qP LSK HSE 4 PLLCLK MCO1 sou rce Mux at MHz MCO1 7 124 200 DoclD025776 Rev 12 UM1718 q Tutorial 1 From pinout to project C code generation using an STM32F4 MCU 2 First select the clock source HSE HSI or PLLCLK that will drive the system clock of the microcontroller In the example taken for the tutorial select HSI to use the internal 16 MHz clock see Figure 110 Figure 110 HSI clock enabled System Clock Mux HSI gt SYSCLE MHz To use an external clock source HSE or LSE the RCC peripheral shall be configured in the Pinout view since pins will be used to connect the external clock crystals see Figure 111 Figure 111 HSE clock source disabled Other clock configuration options for the STM32F4DISCOVERY board would have been To select the external HSE source and enter 8 in the HSE input frequency box since an 8 MHz crystal is connected on the discovery board Figure 112 HSE clock source enabled Input frequency kk To select the external PLL clock source and the HSI or HSE as the PLL input clock source Figure 113 External PLL clock source enabled DoclD025776 Rev 12 125 200 Tutorial 1 From pinout to project C code generation using an STM32F4 MCU UM1718 Note 6 6 6 6 1 Note 126 200 3 Keep the core and peripheral clocks to 16 MHz using HSI no PLL and no pre
34. E G q DoclD025776 Rev 12 175 200 STM32CubeMX pin assignment rules UM1718 A 3 One block one peripheral mode When a block of pins is fully configured in the Chip view shown in green the related peripheral mode is automatically set in the Peripherals tree Example of STM32F107x MCU Assigning the I2C1 SMBA function to PB5 automatically configures I2C1 peripheral in SMBus Alert mode see Peripheral tree in Figure 177 Figure 177 One block one peripheral mode 12C1_SMBA function assigned to PB5 STM32CubeMX Untitled STM32F107VBTx i M O M Rt File Project Pinout Window Help Rie El E G Keep current signals Placement 9 G Find ve Q X V Showuser Label p Pinout Clock Configuration I2C1 SMBA I2C1 SDA I2C1 SCL TER eed eel el ed ed s JE glelele JE HE Master Clock Output T2s3 9 IWDG RCC RTC SPIL Mode Disable Hardware NSS Signal 5 SPI2 SPI3 sys TIM1 STM32F 107 VBTx TIM2 vssa LQFP100 TIM3 VREF TIM4 p p TIM6 JEJE Jf J E EEE E E Jj JE E JE JS E JEJE m JE FAT uv Y Ns allele 8 3 8 818 S A 4 Block remapping STM32F10x only To configure a peripheral mode STM32CubeMX selects a block of pins and assigns each mode signal to a pin in this block In doing so it looks for the first free block to which the mode can be mapped When setting a peripheral mode if at
35. GPIO_Input GPIO_Input GPIO Input GPIO Input GPIO Input GPIO Input GPIO Input GPIO Input GPIO Input GPIO Input GPIO Input GPIO Input GPIO Input GPIO Input GPIO Input GPIO Input anduf olds STM32F429VITx LQFP100 ndur Old5 3ndur ordo 3ndur Old jnduf old ndur old 3nduf Old5 ndur Old Ndur old Ndur old dur olds 3ndur old 3nduf OIdS 3ndur ordo dur old 3ndur ordo 3ndur old 3ndur oldo 3ndur old 3ndur OIE ndur oldo O O J O U U U E i ds o OQ o o GE Bele lr GPIO Input GPIO Input GPIO Input GPIO Input GPIO Input GPIO Input DoclD025776 Rev 12 53 200 STM32CubeMX User Interface UM1718 Figure 37 Set unused GPIO pins with Keep Current Signals Placement unchecked File Project Pinout Window Help 3 Keep Current Signals Placement 9 G Find vs V Show user Label 1 p v onfiguration zi Middlewares i 5 FATFS FREERTOS s B E Lr ADC2 BE ed AE 8 g g ei ei et al ADC3 GPIO Input gj CANI SEN GPIO_Input fj DAC GPIO Input i DCMI DMA2D ETH GPIO Input Es FMC Rm 9 12C1 i o I2C2 GPIO Input t 203 GPIO Input 1282 1283 GPIO Input sek IWDG LTDC RCC 9 RNG GPIO Input jg 5 RTC 9 SAIL SDIO 9 SPIL GPIO Input SPI2 dar Duis GPIO Input 5 SPI4 GPIO Input o svs ero rea STM32F429VITx 5 TIM1 TIM2 M
36. Hz COMP OFF VREFBUF User choice Hz NEU Clock Configuration ALL CLOCKS OFF E COMP Ultra Low Pov Clock Configuration I2c2 STOPO Interpolation ranges Clock Source Frequency 0 Hz COMP Ultra Low Pov Clock Source Frequency 0 Hz AT F COMP Ultra Low Pov IWDG COMP Ultra Low Pov Optional Setti LCD COMP Ultra Low Pov r LPTIMi COMP_Ultra_Low_Pov LPTIM2 Additional Consumption l COMP Ultra Low Pov Additional Consumption Optional Settings Step Duration i z OPAMP1 Results I fr Results Low Power T l tor Without Peripherals 110 HA lt without Peripherals 6 65 yA ee Low Power Peripherals Part OpA A O uA D 0 HA Peripherals Part OpA A O uA D 0 HA i N I Ta Max C 104 99 USE OTG Ta Max C 105 Warnings Warnings DoclD025776 Rev 12 163 200 q Tutorial 3 Using PCC to optimize the embedded application power consumption and more Step 10 RTC USART e Actions Use the power efficient LPUART peripheral Reduce the operating frequency to 1 MHz e Results The current consumption is reduced from
37. May 2015 Added Section 3 2 2 Installing S TM32CubeMX from command line and y Section 3 4 2 Running STM32CubeMX in command line mode Added STLM32F7 and STM32L4 microcontroller series Added mport project feature Added Import function in Table 3 File menu functions Added Section 4 6 Import Project window Updated Figure 82 Power consumption sequence new step default view Figure 88 PCC Edit Step window Figure 83 Power consumption sequence new step configured STM32F4 example Figure 85 PCC Step configuration window ADC enabled using import pinout and Figure 91 Peripheral power consumption tooltip 09 Jul 2015 Updated command line to run STM32CubeMX in Section 3 4 2 Running STM32CubeMX in command line mode Updated note in Section 4 12 Configuration view Added new clock tree configuration functions in Section 4 13 1 Updated Figure 122 FatFs disabled Modified code example in Appendix B 1 STM32CubeMX generated C code and user sections Updated Appendix B 3 1 Overview Updated generated h files in Appendix B 3 4 FatFs 198 200 DoclD025776 Rev 12 7 UM1718 Table Revision history 16 Document revision history continued eae wel awe 7 16 Oct 2015 03 Dec 2015 3 Replace UM1742 by UM1940 in Section Reference documents Updated command line to run STM32CubeMX in command line mode in Section 3 4 2 Running STM32CubeMX in command line mode Modified Table 1 Command line summary Updated boar
38. Mo pull up and na Low GEEN SOR temet unco Noputsp edite hen ER E EED PB6 Configuration GPIO mode Al ternate Function Open Drain GPIO Pull up Pull down No pull up and no pull down Maximum output speed User Label E Group By IP A Group by IP checkbox allows to group all instances of a peripheral under a same window see Figure 64 Figure 64 GPIO configuration grouped by IP amp Pin Configuration E Show only Modified Pins GPIO mode GPIO Pull up Pu Maximum outpu Modified Alternate Functio No pull up and no Low a foe sn a S O Pi fac sca ateate Funct Nopuapandre tow FT PBIL DC2SDA AtemateFumdo Nopulupandmo low EI Pia lacis nlemsis cio Mee 0 ER ecs DC3sDA jAtemateFunco Nopulupandmo o 0O B Select Pins from table to configure them Multiple selection is Allowed DoclD025776 Rev 12 79 200 q STM32CubeMX User Interface UM1718 As shown in Figure 65 row multi selection can be performed to change a set of pins to a given configuration at the same time Figure 65 Multiple Pins Configuration Pin Configuration E Show only Modified Pins GPIO mode GPIO Pull up Pu Maximum outpu User Label Modified Alternate Functio No pull up and no Low EICi SC Alternate Functio No pd up and no im l 8 CENEEM C arte cio E Low r I2C2 SCL Alternate Functio Pull up Low I2C2 SDA Alternate Functio L
39. NSTMicroelectronicsNSTM32CubeNSTM32CubeMXNSTM32cubeMX exe i All the commands to be executed must be listed in the script file An example of script file content is shown below load STM32F417VETx project name MyFirstMXGeneratedProject project toolchain MDK ARM v4 project path C STM32CubeProjects STM32F417VETx project generate exit e Torun STM32CubeMX in command line mode getting commands from a scripts and without UI use the following command line java jar STM32CubeMX exe q script filename Here again the user can enter commands after the MX prompt See Table 1 for available commands Table 1 Command line summary o Comedies maas Bem commands load a ge load gt Load th lected MCU config load lt filename gt Load a previously saved configuration load configuration C Cube ccmram ccmram ioc config save lt filename gt Save the current configuration conngurauon bd C Cube ccmram ccmram ioc Save the current configuration with all parameters including config saveext lt filename gt those for which values have been kept to defaults unchanged by the user Save the current project under configuration saveas config saveas lt filename gt a new name CACubelccmram2lccmram2 ioc Export the current pin configuration as a csv file This file could later be imported into a board layout tool configuration saveext C Cube ccmram ccmram ioc csv pinout lt filename gt Csv pinout mypinout csv Run all co
40. Na XL TIM HLS MIEL Resolving pin conflicts To resolve the pin conflicts that may occur when some peripheral modes use the same pins SIM32CubeMX attempts to reassign the peripheral mode functions to other pins The peripherals for which pin conflicts could not be solved are highlighted in red or orange with a tooltip describing the conflict DoclD025776 Rev 12 65 200 STM32CubeMX User Interface UM1718 4 11 4 Note 66 200 If the conflict cannot be solved by remapping the modes the user can try the following e fthe IV Keep Current Signals Placement box is checked try to select the peripherals in a different sequence e Uncheck the Keep Current Signals Placement box and let STM32CubeMxX try all the remap combinations to find a solution e Manually remap a mode of a peripheral when you cannot use it because there is no pin available for one of the signals of that mode Keep Current Signals Placement This checkbox is available from the toolbar when the Pinout view is selected see Figure 26 and Table 5 It can be selected or unselected at any time during the configuration It is unselected by default It is recommended to keep the checkbox unchecked for an optimized placement of the peripherals maximum number of peripherals concurrently used The Keep Current Signals Placement checkbox should be selected when the objective is to match a board design Keep Current Signals Placement is unchecked This allows STM32Cube
41. Power Consumption panel The New Step window opens with empty step settings e Or select a step from the sequence table and click Duplicate A New Step window opens duplicating the step settings see Figure 82 Once a step is configured resulting current consumption and Tamax values are provided in the window DoclD025776 Rev 12 Ey 96 200 UM1718 STM32CubeMX User Interface Editing a step To edit a step double click it in the sequence table The Edit Step window opens see Figure 76 Figure 78 Edit Step window Edit Step EE ES Power Mode Power Range Memory Fetch Type Vdd Voltage Source Clocks CPU Frequency Interpolation ranges User choice Hz Clock Configuration HSEBYP PLL Clock Source Frequency 16 0 MHz Optional Settings Step Duration 6 65 mA Without Peripherals 6 3 mA Peripherals Part 352 pA A 0 pA D 352 HA Ta Max C 103 9 Moving a step By default a new step is added at the end of a sequence Click the step in the sequence table to select it and use the Up and Down buttons to move it elsewhere in the sequence q DoclD025776 Rev 12 97 200 STM32CubeMX User Interface UM1718 Deleting a step Select the step to be deleted and click the Delete button Using the transition checker Not all transitions between power modes are possible PCC proposes a transition checker to detect invalid transitions or restrict the sequence configuration to onl
42. Project settings Download now or Continue ad Continue Cancel 2 STM32CubeMX offers to download the relevant firmware package or to go on Click Download to obtain a complete project that is a project ready to be used in the selected IDE By clicking Continue only nc and Src folders will be created holding STM32CubeMX generated initialization files The necessary firmware and middleware libraries will have to be copied manually to obtain a complete project 7 136 200 DoclD025776 Rev 12 UM1718 Tutorial 1 From pinout to project C code generation using an STM32F4 MCU If the download fails the below error message is displayed Figure 131 Error during download r Problem during Download and or Unzip v Error during Access to HTTP Server Please check Proxy settings under Help Updater Settings Connection Parameters To solve this issue execute the next two steps Skip them otherwise 3 Select Help gt Updater settings menu and adjust the connection parameters to match your network configuration Figure 132 Updater settings for download n Updater Settings Proxy Server Type No Proxy Use System Proxy Parameters Manual Configuration of Proxy Server Proxy HTTP do it mycompany com Port 8080 Authentification v Require Authentification User Loggin JohnDoe Password eeeeeeeeeeeee 3X Check Connection 4
43. Rev 12 167 200 q FAQ 9 6 9 7 168 200 UM1718 How can I select LSE and HSE as clock source and change the frequency The LSE and HSE clocks become active once the RCC is configured as such in the Pinout view See Figure 169 for an example Figure 169 Pinout view Enabling LSE and HSE clocks 6 RCC High Speed Clock HSE Crystal Ceramic Resonator Low Speed Clock LSE Crystal Cer amic Resonator Master Clock Ouput 1 The clock source frequency can then be edited and the external source selected Figure 170 Pinout view Setting LSE HSE clock frequency 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 STM32CubeMX implements the restriction documented in the reference manuals as a footnote in table Output Voltage characteristics PC13 PC14 PC15 and PI8 are supplied through the power switch Since the switch only sinks a limited amount of current 3 mA the use of GPIOs PC13 to PC15 and PIG in output mode is limited the speed should not exceed 2 MHz with a maximum load of 30 pF and these l Os must not be used as a current source e g to drive a LED DoclD025776 Rev 12 Ly UM1718 STM32CubeMX pin assignment rules Appendix A STM32CubeMX pin assignment rules The following pin assignment rules are implemented in STM32CubeMX e Rule 1 Block consistency e Rule 2 Block inter dependency e Rule 3 One block one pe
44. Updated Section 3 1 3 Software requirements Added project settings in Section 4 6 Import Project window Updated Figure 30 Automatic project import modified Manual project import step and updated Figure 31 Manual project import and Figure 32 Import Project menu Try import with errors modified third step of the import sequence Updated Figure 71 Clock Tree configuration view with errors Added mxconstants h in Section 5 1 Standard STM32Cube code generation Updated Figure 156 Power Consumption Calculation example to Figure 165 Step 10 optimization Updated Figure 166 PCC Sequence results after optimizations DoclD025776 Rev 12 199 200 UM1718 IMPORTANT NOTICE PLEASE READ CAREFULLY STMicroelectronics NV and its subsidiaries ST reserve the right to make changes corrections enhancements modifications and improvements to ST products and or to this document at any time without notice Purchasers should obtain the latest relevant information on ST products before placing orders ST products are sold pursuant to ST s terms and conditions of sale in place at the time of order acknowledgement Purchasers are solely responsible for the choice selection and use of ST products and ST assumes no liability for application assistance or the design of Purchasers products No license express or implied to any intellectual property right is granted by ST herein Resale of ST products with provisions different from
45. WARNING Formatting the uSD card will delete all content on the device if if mkts i TCHAR const SD Path 0 0 FR OR FatFs Format Error set the red LED on HAL GPIO WritePin GPIOG GPIO PIN 10 GPIO PIN RESET while 1 else 4 Create amp Open a new text file object with write access if f open amp MyFile Hello txt FA CREATE ALWAYS FA WRITE FR OK Hello txt file Open for write Error set the red LED on HAL GPIO WritePin GPIOG GPIO PIN 10 GPIO PIN RESET while 1 else 5 Write data to the text file 4 HHH Hd HH HH FH HH HH res f write amp MyFile wtext sizeof wtext void amp byteswritten if byteswritten 0 res FR OK Hello txt file Write or EOF Error set the red LED on HAL GPIO WritePin GPIOG GPIO PIN 10 GPIO PIN RESET while 1 else 6 Successful open write set the blue LED on HAL GPIO WritePin GPIOG GPIO PIN 12 GPIO PIN RESET f close amp MyFile 7 Open the text file object with read access if f open amp MyFile Hello txt FA READ FR OK Hello txt file Open for read Error set the red LED on Ly 152 200 DoclD025776 Rev 12 UM1718 Tutorial 2 Example of FatFs on an SD card using STM32429I EVAL evaluation board HAL_GPIO_WritePin GPIOG GPIO PIN 10 GPIO PIN RESET while 1 else 8 Read data from the text file res f read amp MyFile rtext si
46. always backup your projects before loading the project especially when the project includes user code Opens the user manual New project window This window shows two tabs to choose from e The MCU selector tab offering a list of target processors e A Board selector tab showing a list of STMicroelectronics boards The MCU selector allows filtering on various criteria series lines packages peripherals and additional MCU characteristics such as memory size or number of VOs see Figure 21 The Board selector allows filtering on STM32 board types series and peripherals see Figure 22 Only the default board configuration is proposed Alternative board configurations obtained by reconfiguring jumpers or by using solder bridges are not supported When a board is selected the Pinout view is initialized with the relevant MCU part number along with the pin assignments for the LCD buttons communication interfaces LEDs etc see Figure 24 Optionally the user can choose to initialize it with the default peripheral modes see Figure 25 When a board configuration is selected the signals change to pinned i e they cannot be moved automatically by STM32CubeMX constraint solver user action on the peripheral tree such as the selection of a peripheral mode will not move the signals This ensures that the user configuration remains compatible with the board 7 DoclD025776 Rev 12 UM1718 STM32CubeMX User Interface Figure
47. and Daa ADC1 INO or and 1282 USART3 Synchronous or and 1283 ADC1 IN2 In the next example see Figure 45 the SDIO peripheral is partially available because at least one of its modes is unavailable the necessary pins are already assigned to the I2C mode of the I2C3 peripheral DoclD025776 Rev 12 63 200 q STM32CubeMX User Interface UM1718 Figure 45 Orange highlight and tooltip example some configurations unavailable 24 soo DTA Disable SPTL 6 SPD In this last example see Figure 46 I2C2 peripheral is unavailable because there is no mode function available A tooltip shows for each function where all the remapped pins have been allocated USART3 synchronous mode Figure 46 Tooltip example all configurations unavailable 3 I2C2 Dc Disable ud H 6 I2CIyEWr p s je Ds 12C Conflict with D Ds USART3 Mode Synchronous H 6 IW Hd amp Ror T 4 11 3 Chip view advanced actions Manually modifying pin assignments To manually modify a pin assignment follow the sequence below 1 Click the pin in the Chip view to display the list of all other possible alternate functions together with the current assignment highlighted in blue see Figure 47 2 Click to select the new function to assign to the pin Figure 47 Modifying pin assignments from the Chip view TIM2 CH3 USART3 TX USB OTG HS ULPT D3 GPIO Analog 7 64 200 DoclD025776 Rev 12 UM1718 Caution
48. and External clock values expressed in Hertz DoclD025776 Rev 12 123 200 Tutorial 1 From pinout to project C code generation using an STM32F4 MCU UM1718 Follow the sequence below to configure the MCU clock tree 1 Click the Clock Configuration tab to display the clock tree see Figure 109 The internal HSI LSI system SYSCLK and peripheral clock frequency fields cannot be edited The system and peripheral clocks can be adjusted by selecting a clock source and optionally by using the PLL prescalers and multipliers Figure 109 Clock tree view T STM32Cubel CubeMX Ur File Project Clock Configuration Window Help neu S AA NP s Pinout Clock Configuration Configuration Power Consumption Calculator DB Et RTC Clock Mux HSE RTC To RTC KHz Ethernet PTP clock MHz HCLK to AHB bus core 32 To IWDG KHz memory and DMA MHz System Clock Mux f 8 gt 2 re Cortex System timer MHz FCLK Cortex clock MHz SYSCLK MHz AHB Prescaler HCLK MHz APE1 Prescaler F 16 MH E i tuli APB1 peripheral clocks MHz 168 MHz max PLL Source Mux X1 APB1 Timer clocks MHz 1 APB2 Prescaler HSI L 2 7 PCLK2 e Css ji v 84 MHz max APB2 peripheral clocks MHz gt 16 1X192 v 2 iM N IP gt X1 APB2 timer clocks MHz la 48 48MHz clocks MHz Main PLL IQ I2S source Mux PLLI2SC 1K f f2 T gt G pLu2s N iR 96 12S clocks MHz Ext clock
49. configuration GPIO and Peripheral modes that influence the pinout can be set only from the Pinout view They are read only in the Configuration view In this view the MCU is shown on the left pane by its IP tree and on the right pane by the list of IPs organized in Middleware Multimedia Connectivity Analog System and Control categories Each peripheral instance has a dedicated button to edit its configuration as an example TIM1 and TIM3 TIM instances are shown as dedicated buttons in Figure 50 DoclD025776 Rev 12 Ly UM1718 STM32CubeMX User Interface Figure 50 STM32CubeMX Configuration view r aand STM32CubeMX STM32Cube SimpleLedToggle ioc STM32F407VGTx hy amt so File Project Window Help onfiguration Middlewares 9 FATFS v USB FREERTOS V Enabled 9 LWIP El Enabled Middlewares 9 USB HOST ay FREERTOS 40s wip SR USB HOST lt Class for FS IP MSC FS HIPS 2 d ADC1 IN10 Set 9 CAN1 nah Master Mode Set ADCI Will poma IT 9 CRC E Activated GIH eu 9 DAC FSMC NVIC A OUTI Configuration Set DAC I GPIO o gt dy DCMI USB FS ey RecN DCMI Slave 8 bits Embed ETH RNG e Mode MIT A FSMC _ NAND Flash 1 NCE2 chip select Set IWDG wo Activated
50. download 3 Select Help Update settings to open the Updater settings window and configure update mechanism settings proxy settings manual versus automatic updates DoclD025776 Rev 12 57 200 3 STM32CubeMX User Interface UM1718 4 10 4 11 Note 58 200 About Window This window displays STM32CubeMX version information To open it select Help About from the STM32CubeMX menu bar Figure 41 About window amp About Version 4 6 0 STM32Cube V1 0 http lwww st com stm32cube y lie augmented Pinout view The Pinout view helps the user configuring the MCU pins based on a selection of peripherals middleware and of their operating modes For some middleware USB FATS LwIP a peripheral mode must be enabled before activating the middleware mode Tooltips guide the user through the configuration For FatFs a user defined mode has been introduced This allows STM32CubeMX to generate FatFs code without a predefined peripheral mode Then it will be up to the user to connect the middleware with a user defined peripheral by updating the generated user diskio c h driver files with the necessary code Since STM32 MCUs allow a same pin to be used by different peripherals and for several functions alternate functions the tool searches for the pinout configuration that best fits the set of peripherals selected by the user STM32CubeMX highlights the conflicts that cannot be solved automatically The Pi
51. least one pin in the default block is already used STM32CubeMX tries to find an alternate block If none can be found it either selects the functions in a different sequence or unchecks Keep Current Signals Placement and remaps all the blocks to find a solution 176 200 DoclD025776 Rev 12 Ly UM1718 STM32CubeMX pin assignment rules Example STM32CubeMX remaps USARTS3 hardware flow control mode to the PD8 PD9 PD11 PD12 block because PB14 of USART3 default block is already allocated to the SPI2 MISO function see Figure 176 Figure 178 Block remapping example 2 USART3 ARTS USART3 CTS UEARTS RX UEARTS TX SPL MOI SRL MISO SPL2 SOM A 5 Function remapping To configure a peripheral mode STM32CubeMX assigns each signal of the mode to a pin In doing so it will look for the first free pin the signal can be mapped to Example using STM32F415x When configuring USART3 for the Synchronous mode STM32CubeMX discovered that the default PB10 pin for USART3 TX signal was already used by SPI It thus remapped it to PD8 see Figure 179 Figure 179 Function remapping example USART3 TX USART3 CK TT dd MOS Flds PLE Ra ELAYSTI q DoclD025776 Rev 12 177 200 STM32CubeMX pin assignment rules UM1718 A 6 Block shifting only for STM32F10x and when Keep Current Signals placement is unchecked If a block cannot be mapped and there are no free alternate solutions STM32CubeMX tries to fre
52. maximum CPU frequency limited to 4 2 MHz DoclD025776 Rev 12 Ly UM1718 STM32Cube embedded software packages Appendix E STM32Cube embedded software packages Along with STM32CubeMX C code generator embedded software packages are part of STM32Cube initiative refer to DB2164 databrief these packages include a low level hardware abstraction layer HAL that covers the microcontroller hardware together with an extensive set of examples running on STMicroelectronics boards see Figure 186 This set of components is highly portable across the STM32 series The packages are fully compatible with STM32CubeMX generated C code Figure 186 STM32Cube Embedded Software package Evaluation board Demonstration Discovery board Dedicated demoboard Demo builder Framework Demonstration demonstration Demo Middleware examples Fi TCP IP USB Graphical FAT Enhanced lwIP Polar 5L library STEmWin FATFS Driver Fm j E 7 e cm HE z 5 rT E E stack Host amp Device Library Filesystem NAND RTOS FreeRTOS HAL examples Hardware Hardware Abstraction Layer API Fvalboard drivers Note STM32CubeF0 STM32CubeF1 STM32CubeF2 STM32CubeF3 STM32CubeF4 STMS32CubeLO and STM32CubeL1 embedded software packages are available on st com They are based on STM32Cube release v1 1 other series will be introduced progressively and include the embedded software libraries used by STM32CubeMX for initializ
53. peripheral initialization 180 STM32CubeMX design choices and limitations for middleware initialization cll IRS 181 B 3 1 TAT ee eee 181 B 3 2 HEB IOS ia ie vov WU MEE Aire bes wa ea ean we ee Be A9 ug n NC 182 B 3 3 USB DEViE be Re diro BR di ater uh do ye adatta Mae oo i Rd 182 B 3 4 Eis AE AE N E N OT OE EE EE OE EE ON 182 DocID025776 Rev 12 5 200 Contents UM1718 B 3 5 FreeRT OS ae ee de maa poko EOD ae ew bbe da eee dae kee ew 183 B 3 6 ER AR ho ooo ban Oa New du dow een bb Be See we OOS EN 184 Appendix C STM32 microcontrollers naming conventions 186 Appendix D STM32 microcontrollers power consumption parameters 188 D 1 Power modes cess 188 D 1 1 STM32L 1series eec 188 D 1 2 STM32F4 series ens 189 D 1 3 STM32LO series llo 190 D 2 Power consumption ranges SE SES SE SE SE ee ees 191 D 2 1 STM32L1 series feature 3 VCORE ranges naana anaana 191 D 2 2 STM32F4 series feature several VCORE scales 192 D 2 3 STM32L0 series feature 3 VCORE ranges 200005 192 Appendix E STM32Cube embedded software packages 193 10 REVISI N NISIOlNY uaucaact daas do Hines cee sie En bt ee EED n a 194 6 200 DoclD025776 Rev 12 Ly UM1718 List of tables List of tables Table 1 Command line Summary SE cc ee eee eas 24 Table 2 Welcome page shortcuts SES ES ES
54. range STM32L1 or Power scale STM32F4 These parameters are set by software to control the power supply range for digital peripherals e Memory Fetch Type This field proposes the possible memory locations for application C code execution It can be either RAM FLASH or FLASH with ART ON or OFF only for families that feature a proprietary Adaptive real time ART memory accelerator which increases the program execution speed when executing from Flash memory The performance achieved thanks to the ART accelerator is equivalent to 0 wait state program execution from Flash memory In terms of power consumption it is equivalent to program execution from RAM In addition STM32CubeMX uses the same selection choice to cover both settings RAM and Flash with ART ON e Clock Configuration This operation sets the AHB bus frequency or the CPU frequency that will be used for computing the microcontroller power consumption When there is only one possible choice the frequencies are automatically configured The clock configuration drop down list allows to configure the application clocks The internal or external oscillator sources MSI HSI LSI HSE or LSE The oscillator frequency Other determining parameters PLL ON LSE Bypass AHB prescaler value LCD with duty e Peripherals The peripheral list shows the peripherals available for the selected power mode The power consumption is given assuming that peripherals are onl
55. series When it is enabled the transition checker detects invalid transitions within the currently configured sequence It ensures that only possible transitions are proposed to the user when a new step is added Building a power consumption sequence The default starting view is shown in Figure 74 Figure 74 Power Consumption Calculator default view 1 STM32CubeMX Untitlec File Project Power Window Help BEUR S se PS Pinout Clock Configuration Configuration Power Consumption Calculator i Microcontroller Selected Serie Line MCL Datasheet STM 32L0 STM32LUx3 STM32L053C8Tx 025844 Rev4 Parameter 5election Ambient Temperature C 25 Vdd Power Supply V Battery Selection Part PF Eu JEIELL Daler y Battery Capacity 0 0 mAh Self Discharge 0 0 month Nominal Voltage 0 0 V Max Cont Current 0 0 mA Max Pulse Current 0 0 mA In Series In Parallel Information Notes Help 94 200 7 DoclD025776 Rev 12 UM1718 STM32CubeMX User Interface Selecting a Vpp value From this view and when multiple choices are available the user must select a Vpp value Selecting a battery model optional Optionally the user can select a battery model This can also be done once the power consumption sequence is configured The user can select a pre defined battery or choose to specify a new battery that best matches his application see Figure 75 Figure 75
56. successfully that is in this case by unselecting the request for ADC2 and SPI1 imports The Show View function allows switching between the different configuration tabs pinout clock tree peripheral configuration for checking influence of the Try Import action before actual deployment on current project see Figure 33 DoclD025776 Rev 12 49 200 STM32CubeMX User Interface UM1718 Figure 32 Import Project menu Try import with errors Import Project Imported Project C STM32CubeMX User ManuallMX v4 12 Import IOC demo ioc Import MX Settings C Import PCC Settings C Import Project Settings Import Pinout Clock Configuration Configuration Settings 3 Automatic Import Manual Import Import Pinning Status Import Peripherals Configuration Peripheral List From STM32F427IGHX To STM32F401CBUx Ec ETH None CANI ADCI ADC2 import to ADC1 E ADCS El import to ADC1 V import to SPI3 V Show View Pinout Import Status e Import error ETH peripheral does not exist Import Try Importing Pinout Atry to import 2 different configuration in the same IP Mimport form ADC to ADC1 will not be done tJ SPI import failed error Mode Half Duplex Master conflicts with SPI1 Mode Full Duplex Master Importing IP configurations Import project completed 4 50 200 DoclD025776 Rev 12 Ly UM1718 STM32CubeMX User Interface Figure 33 Import Project menu Successful import after adjustments Imp
57. the clock is automatically configured to MSI STM32F4 series STM32F4 microcontrollers feature a total of 5 power modes including 4 low power modes Run mode This is the default mode at power on or after a system reset It offers the highest performance using HSE HSI clock sources The CPU can run at the maximum frequency depending on the selected power scale Sleep mode Only the CPU is stopped All peripherals continue to operate and can wake up the CPU when an interrupt even occurs The clock source is the clock that was set before entering Sleep mode Stop mode This mode achieves a very low power consumption using the RC oscillator as clock source All clocks in the 1 2 V domain are stopped as well as CPU and peripherals PLL HSI RC and HSE crystal oscillators are disabled The content of registers and internal SRAM are kept The voltage regulator can be put either in normal Main regulator mode MR or in Low power regulator mode LPR Selecting the regulator in low power regulator mode increases the wakeup time The Flash memory can be put either in Stop mode to achieve a fast wakeup time or in Deep power down to obtain a lower consumption with a slow wakeup time The Stop mode features two sub modes Stop in Normal mode default mode In this mode the 1 2 V domain is preserved in nominal leakage mode and the minimum V12 voltage is 1 08 V Stop in Under drive mode In this mode the 1 2 V domain is preser
58. the parameter configuration done in this view as well as the configuration done in the Clock tree view clock source frequencies prescaler values etc 7 DoclD025776 Rev 12 UM1718 Tutorial 1 From pinout to project C code generation using an STM32F4 MCU Figure 114 Configuration view r STM32CubeMX Untitled STM32F407VGTx File Project Window Help Pinout Clock Configuration Configuration Power Consumption Calculator DB Editor i MiddleWares FATFS F User defined FREERTOS T Enabled Peripherals 9 CRC i E Activated IWDG E Activated Middlewares RCC High Speed Clock HSE BYPASS Clock Source RNG i E Activated 6 TIM3 Clock Source Internal Clock 6 TIM6 Activated Multimedia One Pulse Mode TIM7 T Activated One Pulse Mode amp WWDG E Activated 6 6 2 Configuring the peripherals Each peripheral instance corresponds to a dedicated button in the main panel Some peripheral modes have no configurable parameters as illustrated below Figure 115 Case of IP without configuration parameters T RNG Configuration sm Warning This IP has no supported configuration parameters DoclD025776 Rev 12 127 200 q Tutorial 1 From pinout to project C code generation using an STM32F4 MCU UM1718 Follow the steps below to proceed with peripheral
59. the sequence below 1 Select the relevant IPs and their operating modes from the Pinout view 2 Configure the clock tree from the clock configuration view In the Pinout view configure the RCC peripheral by enabling the external clocks master output clocks audio input clocks when relevant for your application This automatically displays more options on the Clock tree view see Figure 23 3 Configure the parameters required to initialize the IP operating modes from the configuration view 4 Generate the initialization C code Welcome page The Welcome page is the first window that opens up when launching STM32CubeMX program It remains open as long as the application is running Closing it closes down the application Refer to Figure 20 and to Table 2 for a description of the Welcome page Figure 20 STM32CubeMX Welcome page r STM32CubeMX Untitled File Project Window Help 2p Help New Project Load Project DoclD025776 Rev 12 35 200 STM32CubeMX User Interface UM1718 4 2 36 200 Table 2 Welcome page shortcuts MK ENIGE ENE Launches STM32CubeMX new project creation by opening the New New Project project window select an MCU from the MCU selector tab or a board configuration from the Board selector tab Opens a browser window to select a previously saved configuration ioc file and loads it Load Project When upgrading to a new version of STM32CubeMX make sure to
60. valid value if user s choice was smaller than minimum threshold e Reset to maximum valid value if user s choice was greater than maximum threshold e eset to previous valid value if previous value was neither a maximum nor a minimum threshold value e Highlighted in red 1000000 Bits s 70 200 DoclD025776 Rev 12 Ly UM1718 STM32CubeMX User Interface Table 11 describes IP and middleware configuration buttons and messages Figure 52 IP Configuration window STM32F4 series SDIO Configuration ef Parameter Settings User Constants ae NVIC Settings GPIO Settings DMA Settings Configure the below parameters O SDIO parameters SDIOCLK dock divide factor SDIOCLK clock divide factor ClockDiv must be between 0 and 255 Parameter Description SDIO CK SDIOCLK CLKDIV 2 The output dock frequency can vary between 187 KHz and 24 MHz It is advised to keep the default ClockDiv value 0 to have a maximum SDIO CK frequency of 24 MHz Table 11 IP Configuration window buttons and tooltips Apply Saves the changes without closing the window Saves and closes the window Cancel Closes and resets previously saved parameter settings Shows and Hides the description pane DoclD025776 Rev 12 71 200 q STM32CubeMX User Interface UM1718 4 12 2 72 200 Table 11 IP Configuration window buttons and tooltips continued Guides the user through the settings of parameters with valid min m
61. 1 89 mA to 234 UA see Figure 165 The example given in Figure 166 shows an average current consumption reduction of 155 HA Figure 165 Step 10 optimization EditStep S c Edit Step r Clocks CPU Frequency Interpolation ranges User choice Hz Clock Configuration Clock Source Frequency r Optional Settings Step Duration Additional Consumption Results Step Consumption 1 89 mA Without Peripherals 1 81mA Peripherals Part 84 8 pA A 0 HA D 84 8 pA Ta Max C 104 8 UARTS COMP OFF VREFBUF ON I COMP Ultra Low Power COMP Ultra Low Power COMP Ultra Low Power COMP Ultra Low Power COMP Ultra Low Power COMP Ultra Low Power COMP Ultra Low Power S COMP Ultra Low Power TIM1 TIM2 TIM3 TIM4 TIM5 TIM6 TIM7 TIM8 TIM15 TIM16 TIM17 TS TSC UART4 USART1 USART2 USART3 r Power Memory Power Mode Power Range Memory Fetch Type Vdd RUN Range2 Medium FLASH ART Cache 2 4 Battery Clocks CPU Frequency Interpolation ranges User choice Hz Clock Configuration Clock Source Frequency 1 0 MHz HSE 1 0 MHz r Optional Settings Step Duration Additional Con
62. 12 UM1718 STM32CubeMX User Interface 4 11 5 Pinning and labeling signals on pins SIM32CubeMX comes with a feature allowing the user to selectively lock or pin signals to pins and label the signals User labels are used for code generation see Section 5 1 for details This will prevent STM32CubeMX from automatically moving the pinned signals to other pins when resolving conflicts There are several ways to pin unpin and label the signals 1 From the Chip view right click a pin with a signal assignment This opens a contextual menu a Forunpinned signals select Signal Pinning to pin the signal A pin icon is then displayed on the relevant pin The signal can no longer be moved automatically for example when resolving pin assignment conflicts b For pinned signals select Signal Unpinning to unpin the signal The pin icon is removed From now on to resolve a conflict such as peripheral mode conflict this signal can be moved to another pin provided the Keep user placement option is unchecked C Select Enter User Label to specify a user defined label for this signal The new label will replacing the default signal name in the Chip view 2 From the pinout menu select Pins Signals Options The Pins Signals Options window see Figure 49 lists all configured pins a Click the first column to individually pin unpin signals b Select multiple rows and right click to open the contextual menu and select Signal s Pinning or
63. 2 Init void hi2s2 Instance SPI2 hi2s2 Init Mode I2S MODE MASTER TX hi2s2 Init Standard I2S STANDARD PHILLIPS 7 DoclD025776 Rev 12 UM1718 B 3 B 3 1 3 STM32CubeMX C code generation design choices and limitations hi2s2 Init DataFormat I2S DATAFORMAT 16B hi2s2 Init MCLKOutput I2S MCLKOUTPUT DISABLE hi2s2 lInit AudioFreq I2S AUDIOFREQ 192K hi292 1Init CPOL I28 CPOL LOW hi2s2 Init ClockSource I2S CLOCK PLL hi2s2 Init FullDuplexMode I2S FULLDUPLEXMODE ENABLE HAL I2S Init amp hi2s2 By default the peripheral initialization is done in main c If the peripheral is used by a middleware mode the peripheral initialization can be done in the middleware corresponding C file Customized HAL IP Name Msplinit functions are created in the stm32fAxx hal msp c file to configure the low level hardware GPIO CLOCK for the selected IPs STM32CubeMX design choices and limitations for middleware initialization Overview STM32CubeMX does not support C user code insertion in Middleware stack native files although stacks such as LwIP might require it in some use cases STM32CubeMX generates middleware nit functions that can be easily identified thanks to the MX prefix MX LWIP Init defined in lwip h file MX USB HOST Init defined in usb host h file MX FATFS Init defined in fatfs h file Note however the following exceptions e No nit function is generated for FreeRTOS unl
64. 21 New Project window MCU selector LQFP 100 Flash gt 592 KBytes Ram gt 214 KBytes y 128 P MCUs List 8 Items ADC 12 bit 2 s NG e e e e g e g g e ei e g warT 1 DoclD025776 Rev 12 37 200 q STM32CubeMX User Interface UM1718 Figure 22 New Project window board selector Board Filter Vendor Type of Board STMicroelectronics vy Nudeo F Initialize all IP with their default Mode Peripheral Selection Boards List 12 Items Type Reference MCU dec O F030R8 STM32F030R8 deo O FOZORB STM32FOZORB deo O F072RB STM32F072RB O F091RC 32F091RC O F103RB STM32F 103RB Cleo CLEO F302R8 STM32F302R8 Nudeo NUCLEO F303RE STM32F303RE cleo CLEO F334R8 STM32F334R8 Cleo CLEO F401RE STM32F401RE dea CLEO F411RE STM32F411RE dec CLEO LO53R8 STM32L053R8 cieo CLEO L152RE STM32L152RE Keys Features On board ST LINK V2 1 USB VBUS ext VIN ext 5V ext 3 3V e STMicroelectronics Morpho connector 2 x 38 e STMicroelectronics Arduino connector 10 2 x 8 6 Push buttons User and Reset LEDs COM Power User LEDs OIG e FEA e e e eleleje e e e e e e e e e e e ee e e e c e ee 38 200 DoclD025776 Rev 12 Ly UM1718 STM32CubeMX User Interface
65. 2F417VGTx x File Project Pinout Window Help onfiguration Middlewares FATFS FREERTOS D wv STM32F417VGTx LGFP180 FFEEFFEEFEEFEEIEEEEEEFI EI IE LI ia o a LI i i i i e LI i a LI H H H H H H H H H H H al H H H H H H H H 7 120 200 DoclD025776 Rev 12 UM1718 6 2 q Tutorial 1 From pinout to project C code generation using an STM32F4 MCU Configuring the MCU pinout For a detailed description of menus advanced actions and conflict resolutions refer to Section 4 STM32CubeMX User Interface and Appendix A STM32CubeMxX pin assignment rules 1 2 By default STM32CubeMX shows the Pinout view By default _ Keep Current Signals Placement is unchecked allowing STM32CubeMX to move the peripheral functions around and to find the optimal pin allocation that is the one that accommodates the maximum number of peripheral modes Since the MCU pin configurations must match the STM32F4DISCOVERY board enable keep Current Signals Placement for STM32CubeMX to maintain the peripheral function allocation mapping to a given pin This setting is saved as a user preference in order to be restored when reopening the tool or when loading another project oelect the required peripherals and peripheral modes a Configure the GPIO to output the signal on the STM32F4DISCOVERY green LED by right clicking PD12 from th
66. 5 PCC Edit Step window SES ES SS ee ee ee ees 106 Power Consumption Peripherals Consumption Chart lus 107 Description of the Results area EES ES aaa SS res 108 DoclD025776 Rev 12 9 200 List of figures UM1718 Figure 92 Peripheral power consumption tooltip 00 cc ees 109 Figure 93 Labels for pins generating define statements 00 0000 cc ee eee 112 Figure 94 User constant generating define statements 0 0 0 cee es 112 Figure 95 Duplicate labels 2 0 0 RR Inr 112 Figure 96 extra templates folder default content 0 0 0 0 ees 115 Figure 97 extra templates folder with user templates SE SE SE EE eee ees 115 Figure 98 Project root folder with corresponding custom generated files 116 Figure 99 User custom folder for templates 20 0 0 ccc eens 116 Figure 100 Custom folder with corresponding custom generated files LLL 117 Figure 101 MCU selection 0 0 0 rre 118 Figure 102 Pinout view with MCUs selection 0 0 0 0 0 cee eens 119 Figure 103 Pinout view without MCUs selection window SE SE EE eee eens 120 Figure 104 GPIO pin configuration 1 nanana SS ESE eee eens 121 Figure 105 Timer configuration 2 anana aaa SE SS SE Se ee Se Ee SS ee eee eens 121 Figure 106 Simple pinout configuration SS SES ESE SE SS he 122 Figure 107 Save Project
67. 6 Rev 12 29 200 q Installing and running STM32CubeMX UM1718 Figure 14 Connection Parameters tab Use System proxy parameters mm sa Manual Configuration of Proxy Server Manual Configuration of Proxy Server Proxy HTTP myproxy mycompany com Port 1234 Authentification Require Authentification User Loggin JohnDoe Password eessessesesse 3 amp Check Connection 7 30 200 DoclD025776 Rev 12 UM1718 Installing and running STM32CubeMX Figure 15 Connection Parameters tab Manual Configuration of Proxy Server Updater Settings Updater Settings Connection Parameters Proxy Server Type No Proxy Use System Proxy Parameters Manual Configuration of Proxy Server Manual Configuration of Proxy Server Proxy HTTP myproxy mycompany com Port 1234 Authentification MM Require Authentification User Loggin JohnDoe Password LLL LEE ELE YT ef Check Connection OK Cae o Select Help gt Install New Libraries sub menu to select among a list of possible packages to install 6 Ifthe tool is configured for manual checks select Help gt Check for Updates to find out about new tool versions or firmware library patches available to install 3 5 2 Downloading new libraries To download new libraries follow the steps below 1 Select Help gt Install New Libraries to open the New Libraries Manager wind
68. 76 Rev 12 135 200 Tutorial 1 From pinout to project C code generation using an STM32F4 MCU UM1718 Figure 129 Project Settings menu Code Generator tab E Project Settings Project Code Generator STM32Cube Firmware Library Package Copy all library files into the project folder Copy only the necessary library files Add necessary library as reference in the toolchain project configuration file Generated files Generate peripheral initialization as a pair of c h files per IP Backup previously generated files when re generating v Keep User Code when re generating v Delete previously generated files when re generating HAL Settings v Set all free pins as analog to optimize the power consumption 6 7 2 Downloading firmware package and generating the C code 1 Click to generate the C code During C code generation STM32CubeMX copies files from the relevant STM32Cube firmware package into the project folder so that the project can be compiled When generating a project for the first time the firmware package is not available on the user PC and a warning message is displayed Figure 130 Missing firmware package warning message n Project Manager i A The Firmware Package STM32Cube FW F4 VO 8 2 required by the Project is not available in your STM32CubeMX Repository You can download the missing Firmware Package or you can continue and generate only source code without
69. 776 Rev 12 85 200 STM32CubeMX User Interface UM1718 STM32CubeMX proposes to switch to a different clock source or can even conclude that no solution matches the desired frequency e Lock the frequency fields for which the current value should be preserved Right click a frequency field and select Lock to preserve the value currently assigned when STM32CubeMX will search for a new clock configuration solution The user can unlock the locked frequency fields when the preservation is no longer necessary e Select the clock source that will drive the system clock SYSCLK External oscillator clock HSE for a user defined frequency Internal oscillator clock HSI for the defined fixed frequency Main PLL clock e Select secondary sources as available for the product A Low speed internal LSI or external LSE clock 2S input clock e Select prescalers dividers and multipliers values e Enable the Clock Security system CSS on HSE when it is supported by the MCU This feature is available only when the HSE clock is used as the system clock source directly or indirectly through the PLL It allows detecting HSE failure and inform the software about it thus allowing the MCU to perform rescue operations e Enable the CSS on LSE when it is supported by the MCU This feature is available only when the LSE and LSI are enabled and after the RTC or LCD clock sources have been selected to be either LSE or LSI e Reset the Cl
70. 84 200 Figure 69 NVIC Configuration window i mm n NVIC Configuration Priority Group 0 bits for pre emption priority 4 bits for subprio Sort by Premption Priority and Sub Prori Search Interrupt Table Enabled Priority Sub Priority Memory management aul E p Pre fetch fault memory accessfault o Z Do 3 13 defined instruction or illegal st Dp lg ee Lp p n servi m o 5p Ga Spem k mr W 9 B Flash global interrupt 0 0o 3 3p RCC global interrupt 0 Z JJ J DMA1 Stream0 global interrupt o o 0 3 33 0 EE as ede LL E OR i ir ey lo W 3 Pep S Ci event interrupt HR DCilemoriterupt 0o 332p DC2eventinreerrup 0 J J DC2emorierupt 0o OOPQ p SPN global interrupt 20 o 33 p DMA2 Streamg global interrupt 0 o DC3emorinerupt Jo J Enabled Preemption Priority bul Sub Priority hd MEE EE EE UM1718 STM32CubeMX NVIC configurat
71. Battery selection o File Project Power Window Help REE Gire Apis Pinout Clock Configuration Config Available batteries Microcontroller Selected Battery Database Management Add Battery MCU ilabl teri Datasheet Ar Bat ust Name Capacity mAh Self Discharge 9e Nominal Voltage V Max Cont Current Alkaline AA LR6 2850 0 0 3 1 5 1000 0 Default eae ens E s far Alkaline CLR14 8350 0 0 3 1 5 3000 0 Ambient Temperature C 25 Alkaline D LR 20 20500 0 EE EE eee Vdd Power Supply V 3 0 Alkaline 9V 625 0 LiMnO2 CR1225 48 0 Li MnO2 CR1632 125 0 Battery Selection Li MnO2 CR2032 225 0 Capacity mAh 0 0 LiMnO2 CR2430 285 0 En El Cnr Li SOCL2 AAA700 700 0 Battery AM 1j SOCL2 A3400 3400 0 Capacity 8 Li SOCL2 C9000 9000 0 Max Cont Current mA Self Discharge Li SOCL2 D19000 19000 0 Nominal Voltage L SOCL2 DD36000 36000 0 Max Cont Current M COD OE Max Pulse Current Ni Cd C3000 3000 0 Ni Cd D4400 4400 0 In Series Ni Cd F7000 7000 0 Ni MH AAAS800 800 0 In Parallel Ni MH AA1800 1800 0 Ni MH A2500 2500 0 Name Battery 29 Max Pulse Current mA Information Notes Help DoclD025776 Rev 12 95 200 q STM32CubeMX User Interface UM1718 Power sequence default view The
72. Click Check connection The check mark turns green once the connection is established Figure 133 Updater settings with connection Updater Settings Updater Settings Connection Parameters Proxy Server Type No Proxy Use System Proxy Parameters Manual Configuration of Proxy Server Manual Configuration of Proxy Server Proxy HTTP do itmycompany com Port 8080 Authentification v Require Authentification User Loggin JonnDoe Password eeeeeeeeeeeee Check Connection q DoclD025776 Rev 12 137 200 Tutorial 1 From pinout to project C code generation using an STM32F4 MCU UM1718 5 Once the connection is functional click to generate the C code The C code generation process starts and progress is displayed as illustrated in the next figures Figure 134 Downloading the firmware package Download selected Firmware amp Software Download File stm32cube_fw_f4_v080 zip 2 9 MBytes 54 8 MBytes Download and Unzip selected Files Unzip File stm32cube fw f v082 zip Download and Unzip selected Files OK 6 Finally a confirmation message is displayed to indicate that the C code generation has been successful Figure 136 C code generation completion message Code Generation 138 200 DoclD025776 Rev 12 7 UM1718 Caution q T Tutorial 1 From pinout to project C code generation using an STM32F4 MCU Click Open Fo
73. Cube projectslProject1l Firmware Package Name and Version STM32Cube FW F4 V1 5 0R Use latest available version DoclD025776 Rev 12 55 200 STM32CubeMX User Interface UM1718 Figure 39 Project folder Organize Include in library Share with Burn a m JohnDoe d di STM32Cube projects s di Drivers p di Project J EWARM Name Ji Inc ud Src _ mxproject Projectl ioc E s 2 By clicking Project gt Generate code for the first time see Figure 40 Figure 40 Project Settings Code Generator Project Settings Code Generator Copy only the necessary library files 3 Add necessary library files as reference in the toolchain project configuration file Generated files Generate peripheral initialization as a pair of c h files per IP Backup previously generated files when re generating Keep User Code when re generating Delete previously generated files when not re generated HAL Settings Set all free pins as analog to optimize the power consumption Enable Full Assert 56 200 DoclD025776 Rev 12 Ly UM1718 STM32CubeMX User Interface 3 Byselecting Save As for a project that includes C code generation and not only pin configuration Select the Code Generator tab to specify the following code generation options Copy all necessary libraries into the project folder STM32CubeMX will copy to the user project folder the drivers libraries HAL CMSIS and the mi
74. CubeMX standalone version To install STM32CubeMx follow the steps below 1 Download the latest STM32CubeMX installation package from http www st com stm32cube 2 Download STM32CubeMX setup zip to your local disk and extract the STM32CubeMx setup exe file 3 Double click STM32CubeMX setup exe to launch the installation wizard 4 Ifthe 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 9 FAQ for issues when installing the JRE 5 If the installation was successful the STM32CubeMX icon is displayed on the desktop and STM32CubeMX application is available from the Program menu STM32CubeMX Joc files are displayed with a cube icon and double clicking them opens up them using STM32CubeMX DoclD025776 Rev 12 17 200 Installing and running STM32CubeMX UM1718 Note 3 2 2 18 200 Only the latest installation of S TM32CubeMX will be enabled in the program menu Previous versions can be kept on your PC not recommended when different installation folders have been selected Otherwise the new installation overwrites the previous ones Installing STM32CubeMX from command line There are 2 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 fo
75. E Resulting generated code LSI VALUE 32000 peripheralParams get RCC get LSI_ VALUE To generate a custom code the user must place the Freemarker template file under SIM32CubeMX installation path within the db extra templates folder see Figure 96 extra_templates folder with user templates The template filename must follow the naming convention user filename gt _ lt file extension gt ftl in order to generate the corresponding custom file as user filename file extension By default the custom file is generated in the user project root folder next to the ioc file see Figure 97 Project root folder with corresponding custom generated files To generate the custom code in a different folder the user shall match the destination folder tree structure in the extra template folder see Figure 98 User custom folder for templates 7 DoclD025776 Rev 12 UM1718 STM32CubeMX C Code generation overview Organize Include in library Share with Burn 4 dy ST Microelectronics Name 4 STM32Cube m hu RTE Device h ftl 4 STM32CubeMX 4 6 sample h ftl 4 db di extra_templates b hb mcu MB de Figure 96 extra templates folder with user templates Include in library Share with Js STM32CubeMX 4 6 db d extra_templates 9 mcu dy plugins P templates 9 help DoclD025776 Rev 12 115 200 q STM32CubeMX C Code generation overview UM1718 Figure 97 Projec
76. E SS ES ES SS SE SE ee ee 33 Library deletion progress window EE EES SE SE SE eee ee ee 34 STM32CubeMX Welcome page SESSE SE SE SS ee eee eens 35 New Project window MCU selector 0 anaana aa ee eee 37 New Project window board selector SEE SS SS SES ee ee se 38 STM32CubeMX Main window upon MCU selection SEE SE SS SS SE ee 39 STM32CubeMX Main window upon board selection Peripheral default option unchecked SESSE ES SE eee eee 40 STM32CubeMX Main window upon board selection Peripheral default option checked 0 00 cc eee eee 41 Pinout menus Pinout tab selected llli 43 Pinout menus Pinout tab not selected nananana SE SE SE SE eee 43 MCU selection menu ESE SS ee ee ee ee ee es ee 45 Error message obtained when importing from different series LLL 46 New board project ready to be imported llli 46 Automatic project import 2 0 0 0 0 ee rr 47 Manual project IMD ON as acu Es qr oe om ae oe a ERN C ita pd We So oat d ee See 48 Import Project menu Try import with errors llle 50 Import Project menu Successful import after adjustments 0005 51 oet unused pins WINDOW ius nuca voce de RE shed EORR 3 d NEER DEE OE sagan eae has 52 Reset used pins window llle hrs 02 oet unused GPIO pins with Keep Current Signals Placement checked 53 Set unused GPIO pins with Keep Cur
77. ES ees 36 Table 3 FIG ment TUNCUONS asi id ER an ce ER HERE HR RR BAR RR EE a ea RE Oo N arie an 42 Table 4 mis eWi rl asse noe one bene ed Ae ee eee hee eee den woe ne ee Bes 42 Table 5 PINOUT MCN 44254 ORE EEN EE EE EG RO N a6 RGSHE EER NG 43 Table 6 Quae go seana OE N Ee EE N ER EE SE GO wate we FO 44 Table 7 HOD MENU RE EO Bh ete EER ER neha Ba RT ERK Be EE EE EN 45 Table 8 IP tree pane icons and color scheme SES SS SS SS eas 60 Table 9 STM32CubeMX Chip view Icons and color scheme nananana 62 Table 10 IP configuration buttons SES ES SE SS SE SE SS res 69 Table 11 IP Configuration window buttons and tooltIpS ESE SE SS SE SE SE ees 71 Table 12 Clock tree view widget 0 ccc eee ee ee ses 89 Table 13 Voltage scaling versus power over drive and HCLK frequency 04 92 Table 14 Relations between power over drive and HCLK frequency 0000008 92 Tape Io JXaloBSSS V a sa 48464605 beau Gd oe qo EE x X UP wee a EES DER ace EA eG eruta 9 Roi Bees 93 Table 16 Document revision history 0 00 00 eee eee eens 194 Ly DoclD025776 Rev 12 7 200 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
78. HA LTC j 8 RED G a RMG TA RTE 3 9 SAIL WYL Sai bees tia Series Lines ETWGzFA ELE do a3 ISTMSaPAZUVETE ETFi ETE ETEA T DoclD025776 Rev 12 59 200 q STM32CubeMX User Interface UM1718 4 11 1 IP tree pane In this pane the user can select the peripherals services DMA RCC middleware in the modes corresponding to the application Note The peripheral tree panel is also accessible from the Configuration view However only the peripherals and middleware modes without influence on the pinout can be configured through this menu Icons and color schemes Table 8 shows the icons and color scheme used in the IP tree pane Table 8 IP tree pane icons and color scheme Display Peripheral status The peripheral is not configured no mode is set and all modes are available The peripheral is configured at least one mode is set and all other modes are available The peripheral is configured one mode is set and at least one of its other modes is unavailable The peripheral is not configured no mode is set and at least one of its modes is unavailable The peripheral is not configured no mode is set and no mode is available Move the mouse over the IP name to display the tooltip describing the conflict Available peripheral mode configurations are shown in plain Mode Disable black ZA DCMI DCMI Disable zal 3 9 DMA Ege The warning ye
79. IDE specific project file launches the IDE and loads the project ready to be edited built and debugged DoclD025776 Rev 12 113 200 STM32CubeMX C Code generation overview UM1718 5 2 114 200 Custom code generation STM32CubeMX supports custom code generation by means of a FreeMarker template engine see http www freemarker org STM32CubeMX can generate a custom code based on a Freemarker template file ftl extension for any of the following MCU configuration information e List of MCU peripherals used by the user configuration e List of parameters values for those peripherals e List of resources used by these peripherals GPIO DMA requests and interrupts The user template file must be compatible with STM32CubeMX data model This means that the template must start with the following lines fEL list configs as dt assign data dt assign peripheralParams dt peripheralParams assign peripheralGPIOParams dt peripheralGPIOParams assign usedIPs dt usedIPs and end with list A sample template file is provided for guidance see Figure 95 extra_templates folder default content STM32CubeMxX will also generate user specific code if any is available within the template As shown in the below example when the sample template is used the ftl commands are provided as comments next to the data they have generated Freemarker command in template S peripheralParams get RCC get LSI VALU
80. INIM o N jN E je je e j h S e ol rm e ls Ia a ie 33 PC4 amp ETH_RXDO Mode MII 7102 H13 Tino Va Zino ova AG XY HLA Y H1 aJ ox H13 NJ XL H13 od DoclD025776 Rev 12 61 200 STM32CubeMX User Interface UM1718 Icons and color schemes Table 9 shows the icons and color scheme used in the Chip view Table 9 STM32CubeMX Chip view Icons and color scheme Tooltip indicates the selected pin current configuration alternate function name Reset state or GPIO mode Move your mouse over the pin name to display it When a pin features alternate pins corresponding to the function currently selected a popup message prompts the user to perform a CTRL click to display them The alternate pins available are highlighted in blue List of alternate functions that can be selected for a given pin By default no alternate function is configured pin in reset state Click the pin name to display the list When a function has been mapped to the pin it is highlighted in blue When it corresponds to a well configured peripheral mode the list caption is shown in green Boot and reset pins are highlighted in khaki Their configuration cannot be changed 62 200 DoclD025776 Rev 12 Ly UM1718 STM32CubeMX User Interface Table 9 STM32CubeMX Chip view Icons and color scheme continued Power dedicated pins are highlighted in yellow Their configuration cannot be changed N
81. IPS Voltage FLA ETT 5 0 MHz 0 MHz SEEP 50 Range FLASH Heb OME OWE RUN 3 0 Ramer FLASH HEP Bome BOME 7 98 200 DoclD025776 Rev 12 UM1718 STM32CubeMX User Interface Figure 81 Transition checker option show log le Log for current seguence Check transition between step 4 SLEEP RangeZ Medium and step 5 RUN Range1 High Possible next step s RUN Range1 High Range2 Medium Range3 Low EE Tramsilkan allowed Check transition between step 5 RUN Range1 High and step 6 STOP NoRange Possible next step s RUN Range1 High Range2 Medium Range3 Low Possible next step s LOWPOVWER RUN NoRange Possible next step s SLEEP Range1 High Range2 Medium Range3 Low Possible next step s LOWPOWER SLEEP NoRange Possible next step s STOP NoRange Transition allowed Check transition between step 6 STOP NoRange and step SLEEP Range1 High Possible next step s WU FROM STOP NoRange q DoclD025776 Rev 12 99 200 STM32CubeMX User Interface UM1718 Figure 82 Power consumption sequence new step default view Power Memory Power Mode Power Range Memory Fetch Type Vdd Voltage Source Clocks CPU Frequency Interpolation ranges User choice Hz Clock Configuration HSEBYP PLL Clock Source Frequency 16 0 MHz 6 65 mA Without Peripherals 6 3 mA Peripherals Part 352 pA A 0 pA D 352 HA Ta Max C 103 96 4 14 2 Configuring a step in the power sequence T
82. M32L053C8Tx Datasheet 025844 Rev4 Step Mode Vdd Range Sc Memory CPU Clock Config SrcFreq Step Duration DMIPS Volta TaMax Category 3 0 3 Low 100000 1 0 MHz 166 9 uA 1ms 0 95 attery 104 97 Interpolation Parameter Selection A 3 0 2 M 8 0 MHz 8 0 MHz 13mA ims 7 6 attery 104 79 tasheet 3 0 1 High 8 0 MHz jg 0 MHz 3 51mA ims 7 6 attery 104 42 tasheet Ambient Temperature C 25 3 0 1 High 8 0 MHz 0 MHz 380uA ims 7 6 attery 104 94 tasheet Vdd Power Supply V 3 0 ange3 Low 4 2 MHz 4 2 MHz bs 1 64mA ims 3 99 attery 104 73 tasheet 3 0 1 High 120000 12 0 MHz 2 33mA ims 11 4 attery 104 62 Interpolation 3 0 ange OHz OHZ 0 41pA ims 0 0 attery 105 tasheet Battery Selection Select Battery Battery Alkaline AA LR6 A Capacity 8550 0 mAh Plot Run Low Power Self Discharge 0 3 month Area Run Low Power Nominal Voltage 3 0V Me All Modes E Max Cont Current 3000 0 mA Pie Run ipod IP Consumption All Max Pulse Current 0 0 mA JIP Con tion Analog Tc In Series In Parallel Consumption mA 35 40 45 50 55 Information Notes Time ms Idd by Step Average Current Help r Results Summary Sequence Time Ta Max 7 ms 104 42 C Average Consumption 1 33 mA Battery Life Estimation 8 months 20 days amp 9 hours Average DMIPS 6 52 DMIPS
83. MX to remap previously mapped blocks to other pins in order to serve a new request selection of a new IP mode or a new IP mode function which conflicts with the current pinout configuration Keep Current Signals Placement is checked This ensures that all the functions corresponding to a given peripheral mode remain allocated mapped to a given pin Once the allocation is done STM32CubeMX cannot move a peripheral mode function from one pin to another New configuration requests are served if it is feasible within current pin configuration This functionality is useful to e Lock all the pins corresponding to peripherals that have been configured using the Peripherals panel e Maintain a function mapped to a pin while doing manual remapping from the Chip view Tip If a mode becomes unavailable highlighted in red try to find another pin remapping configuration for this mode by following the steps below 1 From the Chip view unselect the assigned functions one by one until the mode becomes available again 2 Then select the mode again and continue the pinout configuration with the new sequence see Appendix A STM32CubeMxX pin assignment rules for a remapping example This operation being time consuming it is recommended to unselect the Keep Current Signals Placement checkbox Even if Keep Current Signals placement is unchecked GPIO functions excepted GPIO EXTI functions are not moved by STM32CubeMX 7 DoclD025776 Rev
84. Note q STM32CubeMX User Interface Manually remapping a function to another pin To manually remap a function to another pin follow the sequence below 1 Press the CTRL key and click the pin in the Chip view Possible pins for relocation if any are highlighted in blue 2 Drag the function to the target pin A pin assignment performed from the Chip view overwrites any previous assignment Manual remapping with destination pin ambiguity For MCUs with block of pins consistency STM32F100x F101x F102x F103x and STM32F105x F107x the destination pin can be ambiguous e g there can be more than one destination block including the destination pin To display all the possible alternative remapping blocks move the mouse over the target pin A block of pins is a group of pins that must be assigned together to achieve a given peripheral mode As shown in Figure 48 two blocks of pins are available on a STM32F107xx MCU to configure the Ethernet Peripheral in RMII synchronous mode PC1 PA1 PA2 PA7 PC4 PC5 PB11 PB12 PB13 PB5 and PC1 PA1 PA2 PD10 PD9 PD8 PB11 PB12 PB13 PB5 Figure 48 Example of remapping in case of block of pins consistency PCO ETH RMII MDC ef STM32F107VBTx LQFP100 em ETH_RMII_TXD1 PE ETH RMII TXDO ETH RMII MOC 2 STM32F107VBTx LQFP1 00 PD1 ETH RMII RXD1 LE ETH RMII RXDO ed ETH RMII CRS DV ETH RMII REF Cu 253 236 ETH RMII TXD1 ETH RMII MDIO ZA 23A ETH RMII TXDO
85. OS enabled stack patch required e WIP EVENT API stack patch required In STM32CubeMX the user must enable FreeRTOS in order to use LwIP with the netconn and sockets APIs These APIs require the use of threads and consequently of an operating system Without FreeRTOS only the LwIP event driven raw API can be used q DoclD025776 Rev 12 185 200 STM32 microcontrollers naming conventions UM1718 Appendix Cc STM32 microcontrollers naming conventions 186 200 STM32 microcontroller part numbers are codified following the below naming conventions Device subfamilies The higher the number the more features available For example STM32LO line includes STM32L051 L052 L053 L061 L062 L063 subfamilies where STM32L06x part numbers come with AES while STM32L05x do not The last digit indicates the level of features In the above example 1 Access line 2 7 with USB 3 with USB and LCD Pin counts F 20 pins G 28 pins K 32 pins T 36 pins 9744 pins C 48 pins R 64 pins or 66 pins M 80 pins O 90 pins Va 100 pins Q 132 pins e g STM32L162QDH6 Z 144 176 25 B 208 pins e g STM32F429BIT6 N 216 pins Flash memory sizes 4 16 Kbytes of Flash memory 6 32 Kbytes of Flash memory 8 64 Kbytes of Flash memory B 128 Kbytes of Flash memory C 256 Kbytes of Flash memory D 384 Kbytes of Flash memo
86. P100 Example of block remapping with a STM32F107x MCU If the user assigns GPIO Output to PB6 STM32CubeMX automatically disables I2C1 SMBus Alert peripheral mode from the peripheral tree view and updates the other I2C1 pins PB5 and PB7 as follows e fthey are unpinned the pin configuration is reset pin grayed out e If they are pinned the peripheral signal assigned to the pins is kept and the pins are highlighted in orange since they no longer match a peripheral mode see Figure 172 7 170 200 DoclD025776 Rev 12 UM1718 STM32CubeMX pin assignment rules Figure 172 Block remapping File Project Pinout Window Help vs 9 9 V Show user Label p put 2C1 SMBA PIO Out 2C1 SDA tco a Hardware NSS Signal t 6 SPI2 6 SPD LQFP100 H SYS H 6 TIM1 t 9 TIM2 TIM3 9 TIMA S s TIM6 H TIM7 STM32F107VBTx EEEEEEEEEEEFEEEEEEEEEF For STM32CubeMX to find an alternative solution for the I2C peripheral mode the user will need to unpin I2C1 pins and select the I2C1 mode from the peripheral tree view see Figure 173 and Figure 174 q DoclD025776 Rev 12 171 200 STM32CubeMX pin assignment rules UM1718 Figure 173 Block remapping example 1 Bie UU d LO Keep current signals Placement 9 G Find Pinout Glock Configuration Configuration Power Consumption Calculator put 12C1 SDA PIO Out I2C1 SMBA 1
87. Repository Folder C Wsers JohnDoe STM32Cube Repository Browse Check and Update Settings Manual Check Automatic Check Interval between two Checks days 5 OK Cancel Ly 28 200 DoclD025776 Rev 12 UM1718 Installing and running STM32CubeMX 3 Inthe Connection Parameters tab specify the proxy server settings appropriate for your network configuration by selecting a proxy type among the following possibilities No Proxy see Figure 13 Use System Proxy Parameters see Figure 14 On Windows proxy parameters will be retrieved from the PC system settings Uncheck Require Authentication if a proxy server without login password configuration is used Manual Configuration of Proxy Server see Figure 15 Enter the Proxy server http address and port number Enter login password information or uncheck Require Authentication if a proxy server without login password configuration is used 4 Click the Check Connection button to verify if the connection works A green check mark appears to confirm that the connection operates correctly ef Check Connection Figure 13 Connection Parameters tab No proxy DO Use System Proxy Parameters Manual Configuration of Proxy Server Manual Configuration of Proxy Server Proxy HTTP myproxy mycompany com Port 1234 Authentification Require Authentification User Loggin JohnDoe Password ITIIITIIIITII DoclD02577
88. Rev 12 41 200 STM32CubeMX User Interface UM1718 4 4 1 File menu Refer to Table 3 for a description of the File menu and icons Table 3 File menu functions BINNEN oeenn New Proiect Opens a new project window showing all supported MCUs and J well as a set of STMicroelectronics boards to choose from Load Project Loads an existing STM32CubeMX project configuration by ae selecting an STM32CubeMX configuration ioc file Opens a new window to select the configuration file to be imported as well as the import settings The import is possible only if the following conditions are met Start from an empty MCU configuration The menu is disabled otherwise Select MCUs within the same series A status window displays the warnings or errors detected when checking for import conflicts The user can then decide to cancel the import Import Project Saves current project configuration pinout clock tree IP PCC as a new project This action creates an ioc file with user defined name and located in the destination folder w Save Project Saves current project Close Project Closes current project and switch back to the welcome page Recent i Displays the list of five most recently saved projects Proposes to save the project if needed then close the application 4 4 2 Project menu xi a Refer to Table 4 for a description of the Project menu and icons Table 4 Project menu Cem ome To pem Genera
89. SE SS es 130 6 6 4 Configuring the DMAS llle 131 6 6 5 Configuring the middleware esee 132 6 7 Generating a complete C project SESSE ES eee 135 6 7 1 Setting project options EES EES SES ee es 135 6 7 2 Downloading firmware package and generating the C code 136 6 8 Building and updating the C code project 0000 8 140 6 9 Switching to another MCU SS SS SE SE SE es 145 Tutorial 2 Example of FatFs on an SD card using STM32429I EVAL evaluation board 147 Tutorial 3 Using PCC to optimize the embedded application power consumption and more 154 8 1 OVGEIVIEW sone en voccm e GO ope ese eo ERE RUE EGRE eons DA 154 8 2 Application example description cee eee eee 155 8 3 Using the Power Consumption Calculator 155 8 3 1 Creating a PCC sequence EES ES SE SE SE SS se ee 155 8 3 2 Optimizing application power consumption 158 ginge 166 DoclD025776 Rev 12 Ly UM1718 9 1 9 2 9 3 9 4 9 5 9 6 9 7 Appendix A A 1 A 2 A 3 A 4 A 5 A 6 A T A 8 A 9 Appendix B B 1 B 2 B 3 Contents On the Pinout configuration pane why does STM32CubeMX move some functions when add a new peripheral mode 166 How can manually force a function remapping 166 Why are some pins highlighted in yellow or in lig
90. TM32F4 Firmware Package for Family STM32F4 Size 149 93 MB Technical Description 3 5 3 Removing libraries Proceed as follows to clean up the repository from old library versions thus saving disk space 1 Select Help gt Install New Libraries to open the New Libraries Manager window 2 Click a green checkbox to select a package available in stm32cube repository 3 Click the Remove Now button and confirm A progress window then opens to show the deletion status Refer to Figure 17 to Figure 19 for an example 7 32 200 DoclD025776 Rev 12 UM1718 Installing and running STM32CubeMX Figure 17 Removing libraries o amp New Libraries Manager ee STM32CubeMX Releases Software to configure and manage STM32 MCUs STM32CubeF7 Releases Firmware Package for Family STM32F7 Firmware Package for Family STM32F7 STM32CubeF4 Releases Firmware Package for Family STM32F4 Firmware Package for Family STM32F4 Firmware Package for Family STM32F4 Firmware Package for Family STM32F4 Firmware Package for Family STM32F4 Firmware Package for Family STM32F4 Size 149 93 MB Technical Description e Add support of System Workbench for STM32 SW4STM32 toolchain Maintenance release to fix known defects in HAL and Projects You are about to remove the following firmware pack s Please note Once Firmware pack will be removed You will not anymore be able to generate projects that were based on this pack
91. TM32F429xx Clock Tree configuration view SE SE SS ee es 88 Clock Tree configuration view with errors 0 ee eee ees 88 Clock tree configuration enabling RTC RCC Clock source and outputs from Pinout VieW naana anaa SS e eens 90 Clock tree configuration RCC Peripheral Advanced parameters 91 Power Consumption Calculator default view lellllslsn 94 Battery selection 6 cs dm ame RR oe Hei poe Do Rr b a e Xue a gd Sonn m GR DRIE we end 95 Building a power consumption seduenCce 0 aaea eens 96 Step management functions ES ES SS SE SE ee eee ee 96 Edit Step window SE SE SE eee eee eee eee 97 Enabling the transition checker option on an already configured sequence all transitions valid is vase ound Remo eee ae WE HD RRS des ACA rinde ECHO eo ein 98 Enabling the transition checker option on an already configured sequence at least one transition invalid EES ES SE SE ee ees 98 Transition checker option show log SEE SE ee ees 99 Power consumption sequence new step default View 200 100 Interpolated Power Consumption 0 SS SE SS ee eee eee 102 ADC selected in Pinout View 2 SES ESE ee ee eee 103 PCC Step configuration window ADC enabled using import pinout 104 Power Consumption Calculator view after sequence building 105 Sequence table management functions SESSE ce ee eee 10
92. Unpinning DoclD025776 Rev 12 67 200 STM32CubeMX User Interface UM1718 Note 4 12 Note 68 200 Figure 49 Pins Signals Options window ins Si i le Pin Name Signal Name User Label PADJANKLIP PA1 ETH RX CLK EFi DAC_OUT1 PAS DAC OUT2 PA7 TH RX ER E ETH TX EN E 252 SD J Ph I2S2 WS am O PBI PBID Pell j PBI PBIB PBl4 oo PBS PB9 mum C Select the User Label field to edit the field and enter a user defined label d Order list alphabetically by Pin or Signal name by clicking the column header Click once more to go back to default i e to list ordered according to pin placement on MCU Even if a signal is pinned it is still possible however to manually change the pin signal assignment from the Chip view click the pin to display other possible signals for this pin and select the relevant one Configuration view STM32CubeMX Configuration window see Figure 50 gives an overview of all the software configurable components GPIOs peripherals and middleware Clickable buttons allow selecting the configuration options of the component initialization parameters that will be included in the generated code The button icon color reflects the configuration status e Green checkmark correct configuration e Warning sign incomplete but still functional configuration e Red cross for invalid
93. a 68 STM32CubeMX Configuration VIEW 1 ee ee ee 69 Configuration window tabs for GPIO DMA and NVIC settings STMA2FASEIIES Prem 70 IP Configuration window STM32F4 series SE SE ce eee 71 User Constants window SESSE EE SE SS eee eee eee 73 Extract of the generated mxconstants h file SE SE SS ee 73 Using constants for peripheral parameter settingS 0 0 0 0 cee eee 74 Specifying user constant value and name SES SS SS ee ee 75 Deleting user constant not allowed when constant already used for another constant definition LL 75 Deleting a user constant used for parameter configuration Confirmation request 0 00 cc a 76 Deleting a user constant used for peripheral configuration Consequence on peripheral configuration EES SEE SE a 76 Searching user constants list for name ES SS SS ee ee TT Searching user constants list for value lll llle 77 GPIO Configuration window GPIO selection SESSE SS SS eee 78 GPIO Configuration window displaying GPIO settings llli 19 GPIO configuration grouped by IP SESSE SS SES ee eee 79 Multiple Pins Configuration ES SS SE ee eee eens 80 Adding anew DMA request 2 0 ee ee eee ees 81 DMA Configuration SE SE SE SE SE hrs 82 DMA MemToMem configuration llle 83 NVIC Configuration window SESSE EE SE SE ee ee eee eens 84 S
94. ample select eww file to load the project in the IAR EWARM IDE Figure 139 C code generation for EWARM File Edit View Tools Help Organize d Open Burn New folder STM32Cube simpleLedToggle Name N Drivers n EWARM i settings 7 28 2015 2 k Ai STM32Cube simpleLedToggle Configura 7 28 2015 2 42 m Prec L0 Projectemw STM324Cube simpleLedToggle ewd 7 28 2015 2 36 k n STM32Cube simpleLedToggle ewp 7 28 2015 2 33 saminda stm32f407xx flash icf 7 16 2015 5 52 Moe tm321407xx sram icf 1 16 2015 5 52 LL LL LL Tm sm Projecteww Date modified 7 28 2015 239 PM Date created 7 28 2015 2 39 PM 6 IAR IDE Workspace Size 169 bytes q DoclD025776 Rev 12 141 200 Tutorial 1 From pinout to project C code generation using an STM32F4 MCU 3 Select the main c file to open in editor Figure 140 STM32CubeMX generated project open in IAR IDE E Project IAR Embedded Workbench IDE Ele Edit View Project Tools Window Help ETTET Workspace STM32Cube_simnpleLedT oggle Configuration AM Files o GI STM32Cube_simpleLedToggle Ha G Application EWARM LA User main c stm32fdxx hal msp c stm32f4xx itc La G Drivers LA 73 Output STM32Cube_simpleLedToggle The htim3 structure handler system clock GPIO and TIM3 initialization functions are defined The initialization functions are called in the main c For now the user C code sections are empty 142 200
95. and 64 bit installations but make sure that the 64 bit version is at least Java 7 update 45 Some users Java developers for example may need to check the PC environment variables defining hard coded Java paths e g JAVA_HOME or PATH and update them so that they point to the latest Java installation On Windows 7 you can check your Java installation using the Control Panel To do this double click Jaa icon from Control Panel All Control Panel to open the Java settings window see Figure 167 DoclD025776 Rev 12 Ly UM1718 FAQ Figure 167 Java Control Panel f Java Control Panel General Java Security Advanced View and manage Java Runtime versions and settings for Java applications and applets Java Runtime Environment Settings User System You can also enter java version as an MS DOS command to check the version of your latest Java installation the Java program called here is a copy of the program installed under C Windows YSystem32 Java version 1 7 0 45 Java TM SE Runtime Environment build 1 7 0 45 D18 Java HotSpot TM 64 Bit Server VM build 24 45 b08 mixed mode 9 5 Why does the RTC multiplexer remain inactive on the Clock tree view To enable the RTC multiplexer the user shall enable the RTC IP in the Pinout view as indicated in below Figure 168 Pinout view Enabling the RTC RIC Alarm amp Internal Alarm Alarm B Disable Wakellp D sable DoclD025776
96. and selecting available STM32Cube firmware zip packages If the PC on which STM32CubeMX runs is connected to a computer network using a proxy server STM32CubeMX needs to connect to that server to access the internet get self updates and download firmware packages Refer to Section 3 5 1 Updater configuration for a description of this connection configuration To view Windows default proxy settings select Internet options from the Control panel and select LAN settings from the Connections tab see Figure 11 Figure 11 Displaying Windows default proxy settings Q Internet Properties E General Security Privacy Content Connections Programs Advanced E To set up an Internet connection click Setup Setup Dial up and Virtual Private Network settings Add Add VEN Choose Settings if you need to configure a proxy server for a connection Local Area Network LAN settings LAN Settings do not apply to dial up LAN settings connections Choose Settings above for dial up settings oeveral proxy types exist and different computer network configurations are possible e Without proxy the application directly accesses the web Windows default configuration e Proxy without login password e Proxy with login password when using an internet browser a dialog box opens and prompts the user to enter his login password e Web proxies with login password when using an
97. ation HSE PLL Clock Source Frequency 4 0 MHz Optional Settings Step Duration Additional Consumption Results Step Consumption 52 41 mA Without Peripherals 50 mA Peripherals Part 2 41mA A 1 6 mA D 812 28 pA Ta Max C 97 56 4 14 3 Managing user defined power sequence and reviewing results The configuration of a power sequence leads to an update of the PCC view see Figure 86 e The sequence table shows all steps and step parameters values A category column indicates whether the consumption values are taken from the datasheet or are interpolated e he sequence chart area shows different views of the power sequence according to a display type e g plot all steps plot low power versus run modes e The results summary provides the total sequence time the maximum ambient temperature TAMAx plus an estimate of the average power consumption DMIPS and battery lifetime provided a valid battery configuration has been selected 104 200 DoclD025776 Rev 12 Ly UM1718 STM32CubeMX User Interface Figure 86 Power Consumption Calculator view after sequence building sTM32CubeMX STM321053C8Tx sequence ioc STM32L053C8Tx W Bea MC m t t me e t File Project Power den Help ReBEUR Gire Apis Pinout Clock Configuration Configuration Power Consumption Calculator DB Editor Microcontroller Selected Series STM32L0 Line STM32L0x3 MCU ST
98. ation see Figure 59 Figure 59 Deleting a user constant used for peripheral configuration Consequence on peripheral configuration SDIO Configuration Configure the below parameters FA SDIO parameters SDIOCLK dack divide factor X CONSTANT 2 Ey 76 200 DoclD025776 Rev 12 q UM1718 STM32CubeMX User Interface Searching for user constants The Search Constants field allows searching for a constant name or value in the complete list of user constants see Figure 60 and Figure 61 SDIO Configuration Figure 60 Searching user constants list for name Search Constants CONSTANT 4 Constant Name CONSTANT 4 Constant Value CONSTANT 34CONSTANT 1 100 CONSTANT 1 Search Constants 10 Constant Name CONSTANT 1 Constant Value 10 DoclD025776 Rev 12 77 200 STM32CubeMX User Interface UM1718 4 12 3 GPIO Configuration window Click GPIO in the Configuration pane to open the GPIO configuration window that allows configuring the GPIO pin settings see Figure 62 The configuration is populated with default values that might not be adequate for some peripheral configurations In particular check if the GPIO speed is sufficient for the peripheral communication speed and select the internal pull up whenever needed Note It is also possible to access GPIO settings for a specific IP instance via the dedicated GPIO window in the IP instance configuration window Figure 62 GPIO Configuration window
99. ation C code generation The user should use STM32CubeMX to generate the initialization C code and the examples provided in the package to get started with STM32 application development DoclD025776 Rev 12 193 200 Revision history 10 194 200 UM1718 Revision history Table 16 Document revision history Dome Rem we OOOO 17 Feb 2014 Initial release i o Added support for STM32CubeF2 and STM32F2 series in cover page Section 2 2 Key features Section 4 12 1 IP and Middleware Configuration window and Appendix E STM32Cube embedded software packages Updated Section 6 1 Creating a new STM32CubeMX Project Section 6 2 Configuring the MCU pinout Section 6 6 Configuring the MCU initialization parameters Section Generating GPIO initialization C code move to Section 8 Tutorial 3 Generating GPIO initialization C code STM32F1 series only and content updated Added Section 9 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 Added support for STM32CubeLO and STM32L0 series in cover page Section 2 2 Key features Section 2 3 Rules and limitations and Section 4 12 1 IP and Middleware Configuration window Added board selection in Table 3 File menu functions Section 4 4 3 Pinout menu and Section 4 2 New project window Updated Table 5 Pinout menu Updated Figure 74 Power Consumption Calculator default view and added battery s
100. attery selection Menu 1 SES SS SS SE ee eee 157 PCC Sequence table EES SEE ee eee eee 157 PCC sequence results before optimization 0 0 ee 158 Step 1 optimization EES Rh 159 Step 5 OPUMIZANON iux ngon saw ee Saw GRE EWA a c Ew dox owe o we 160 Step 6 OPUMIZAUON an a2 tees seh oe ee BHO C ir RSG ee EE EE N 161 Step f OPUMIZAUON s was Gaede D eg a x OS na Dare WAS Rnd we ora ee ew Rae A RR CR d 162 Step 8 optimization EES ee ee eee ee 163 Step 10 opUmizallOll ue o OR ad dum det da OE EE s peas KR qx ede x 164 PCC Sequence results after optimizations ESE SS SE SS ee ee 165 Java Control Panel s au ie RE ES ROSS RED HE ORR x ao Re PVR RR SHES Redon aa es 167 Pinout view Enabling the RTC SS SS SE SE ee eee 167 Pinout view Enabling LSE and HSE clocks SS SS SS SS SS SS es eee 168 Pinout view Setting LSE HSE clock frequency nananana 0 00 cee eee 168 Blok MAPPING ERK ti EEn EEN EE OE OE N EE 170 Block remapPINg SES ES ES SS SE SE SS SS ES SS Se eee ee ee 171 Block remapping example T EE SES SE SE SS SE ee eee ee 172 Block remapping example 2 SESSE SE ee ee 173 Block inter dependency SPI signals assigned to PB3 4 5 SESSE ss 6 174 Block inter dependency SPI1_ MISO function assigned to PA6 175 One block one peripheral mode 12C1_SMBA function assigned to PB5 176 Block remapping example 2 SESSE SE SE SS SE ee ee
101. ax range To display it moves the mouse over a parameter value from a list of possible values EEN AAA aou oo ez Stop Bits zed Parameters OE UART_PARITY_EVEN Over Samnlinn Choose to display the field as an hexadecimal or a decimal value by clicking the arrow on the right v Decimal Hexadecimal vs decimal woman E Hexadecimal Timeout Time ns values TIMEOUT time must be between 25 000 000 and 35 000 000 Timeout Time ns 0x17d7840 Decimal imeout 0x00008000 v Hexadecimal User Constants configuration window A User Constants window is available to define user constants see Figure 53 Constants are automatically generated in the STM32CubeMX user project within the mxconstants h file see Figure 54 Once defined they can be used to configure peripheral and middleware parameters see Figure 55 7 DoclD025776 Rev 12 UM1718 q STM32CubeMX User Interface Figure 53 User Constants window SDIO Configuration oP User Constants Search Constants Constant Value ONSTANT 1 10 constanta SS _ CONSTANNT_3 CONSTANT_1 200 CONSTANT_1 Figure 54 Extract of the generated mxconstants h file Includes a eS Se eee USER USER CODE BEGIN Includes CODE END Includes 7 Private depline e EE SaaS SSS EE ee EE ey define define define define define USER USER CONSTANT 1 10 CONSTANT 2 Oxff CONSTANT 3 CONSTANT 1 CONSTANT 4 CONSTANT 3 CONSTANT
102. beMX 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 e Software reuse and application design portability are achieved through STM32Cube firmware solution proposing a common Hardware Abstraction Layer API across STM32 portfolio e 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 e Fast and easy configuration of the MCU pins clock tree and operating modes for the selected peripherals and middleware e Generation of pin configurat
103. beMX Pinout view Figure 43 Chip view Figure 74 Power Consumption Calculator default view Figure 75 Battery selection Figure 76 Building a power consumption sequence Figure 82 Power consumption sequence new step default view Figure 86 Power Consumption Calculator view after sequence building Figure 87 Sequence table management functions Figure 88 PCC Edit Step window Figure 83 Power consumption sequence new step configured STMS32F4 example Figure 84 ADC selected in Pinout view Figure 85 PCC Step configuration window ADC enabled using import pinout Figure 90 Description of the Results area Figure 91 Peripheral power consumption tooltip Figure 156 Power Consumption Calculation example Figure 155 Sequence table and Figure 156 Power Consumption Calculation results Updated Figure 50 STM32CubeMX Configuration view and Figure 39 STM32CubeMX Configuration view STM32F1 series titles Added STM32L1 in Section 4 14 Power Consumption Calculator PCC view Removed Figure Add a new step using the PCC panel from Section 8 1 1 Adding a step Removed Figure Add a new step to the sequence from Section 4 14 2 Configuring a step in the power sequence Updated Section 8 2 Reviewing results Updated appendix B 3 4 FatFs and Appendix D STM32 microcontrollers power consumption parameters Added Appendix D 1 3 STM32L0 series and D 2 3 STM32L0 series feature 3 VCORE ranges DoclD025776 Rev 12 195 200 Revision histo
104. ble Note Starting with STM32CubeMX 4 2 the user can skip the pinout configuration by directly loading ST Discovery board configuration from the Board selector tab 6 3 Saving the project 1 Click H to save the project When saving for the first time select a destination folder and filename for the project The ioc extension is added automatically to indicate this is an STM32CubeMX configuration file Figure 106 Save Project As window Save in STM32Cube simpleLedToggle STM32Cube simpleLedToggle ioc Documents A File name STM32Cube simpleLedToggle ioc Files of type STM32CubeMX project Files ioc 2 Click 4 to save the project under a different name or location 7 122 200 DoclD025776 Rev 12 UM1718 6 4 6 5 q Tutorial 1 From pinout to project C code generation using an STM32F4 MCU Generating the report Reports can be generated at any time during the configuration 1 Click amp to generate pdf and txt reports If a project file has not been created yet a warning prompts the user to save the project first and requests a project name and a destination folder see Figure 107 An ioc file is then generated for the project along with a pdf and txt reports with the same name Answering No will require to provide a name and location for the report only A confirmation message is displayed when the operation has been successful see
105. ble 6 Table 6 Window menu ee ee Outputs Opens the MCUs selection window at the bottom of STM32CubeMX Main window Ey 44 200 DoclD025776 Rev 12 UM1718 STM32CubeMX User Interface 4 4 5 Help menu Refer to Table 7 for a description of the Help menu and icons Table 7 Help menu el sd ee Help Content Opens the STM32CubeMX user manual Shows the software and firmware release updates available for download Check for Updates Shows all STM32CubeMX and firmware releases available for Install New Libraries installation Green check box indicates which ones are already installed on you PC and up to date Opens the updater settings window to configure manual versus automatic updates proxy settings for internet connections repository folder where the downloaded software and firmware releases will be stored Updater Settings 4 5 MCUS selection window This window lists all the MCUs of a given family that match the user criteria series peripherals package when an MCU was selected last Note Selecting a different MCU from the list resets the current project configuration and switches to the new MCU The user will be prompted to confirm this action before proceeding Figure 28 MCU selection menu McUs Selection Series Lines Micu Package Required Peripherals STMa2F4 STM32F 429 439 STMs2F429VETx LOFP 100 RTC SALSDBIO STMa2r4 STMA2rd29 439 STMA2FA28VGTX LQFPi00 RTCSALSDIO
106. configuration 1 Click the peripheral button to open the corresponding configuration window In our example a Click TIM3 to open the timer configuration window Figure 116 Timer 3 configuration window TIM3 Configuration Counter Settings Prescaler PSC 16 bits value 0 Counter Mode Up Counter Period AutoReload Register 16 bits value 0 Internal Clock Division CKD No Division Trigger Output TRGO Parameters Master Slave Mode Disable no sync between this TIM Master and its Slaves Trigger Event Selection Reset UG bit from TIMx_EGR 7 128 200 DoclD025776 Rev 12 UM1718 Tutorial 1 From pinout to project C code generation using an STM32F4 MCU b With a 16 MHz APB clock Clock tree view set the prescaler to 16000 and the counter period to 1000 to make the LED blink every millisecond Figure 117 Timer 3 configuration TIM3 Configuration Configure ihe belew parameters Counter Settings Prescaler PSC 16 bits value 180600 Counter Made Lin Counter Period AutoRakad Register 1 1000 Internal Clock Didsan CRD Ho Dhasion TAGO Farameters Tigger Source TRGO Reset UG bi from TIM EGRJ j Master slawe Mode Desable no sync between thes TIM Master and ES 2 Optionally and when available select The NVIC Settings tab to display the NVIC configuration and enable interruptions for this peripheral The DMA Settings tab to display the DMA confi
107. cons and color scheme Updated Section 4 12 1 IP and Middleware Configuration window Updated Figure 66 Adding a new DMA request and Figure 68 DMA MemToMem configuration Updated Section 4 13 1 Clock tree configuration functions Updated Figure 75 Battery selection Figure 76 Building a power consumption sequence Figure 88 PCC Edit Step window Added Section 5 2 Custom code generation Updated Figure 109 Clock tree view and Figure 114 Configuration view Updated peripheral configuration sequence and Figure 116 Timer 3 configuration window in Section 6 6 2 Configuring the peripherals Removed Tutorial 3 Generating GPIO initialization C code STM32F 1 series only Updated Figure 120 GPIO mode configuration Updated Figure 156 Power Consumption Calculation example and Figure 155 Sequence table Updated Appendix A 1 Block consistency A 2 Block inter dependency and A 3 One block one peripheral mode Appendix A 4 Block remapping STM32F10x only updated Section Example Appendix A 6 Block shifting only for STM32F10x and when Keep Current Signals placement is unchecked updated Section Example Updated Appendix A 8 Mapping a function individually Updated Appendix B 3 1 Overview Updated Appendix D 1 3 STM32L0 series DoclD025776 Rev 12 197 200 Revision history UM1718 Table 16 Document revision history continued ee wel awe Section 2 2 Key features removed Pinout initializa
108. ct an MCU belonging to the same series As an example you can select the STM32F429ZITx that is the core MCU of the 32F429IDISCOVERY board Select File Import project In the Import project window browse to the ioc file to load A message warns you that the currently selected MCU STM32F429ZITx differs from the one specified in the ioc file STM32F407VGTXx Several import options are proposed see Figure 146 Click the Try Import button and check the import status to verify if the import succeeded see Figure 147 Click OK to really import the project An output tab is then displayed to report the import results The green LED on 32F429IDISCOVERY board is connected to PG13 CTRL right click PD12 and drag and drop it on PG13 Select Project Settings to configure the new project name and folder location Click Generate icon to save the project and generate the code Select Open the project from the dialog window update the user sections with the user code making sure to update the GPIO settings for PG13 Build the project and flash the board Launch the program and check that LED blinks once per second DoclD025776 Rev 12 145 200 Tutorial 1 From pinout to project C code generation using an STM32F4 MCU UM1718 Figure 146 Import Project menu C Import Project Imported Project CHUSTM32CubeMX Projects 10 UMISTM32Cube simpleLedToggle 5TM32Cube simpleLedToagle ioc mn Import MX Settings Import PCC settings Import Pinout C
109. d 0524 0x05 0x55 0X26 USER CODE END PV b Insert main functional local variables int main void USER CODE BEGIN 1 FRESULT res FatFs function common result code uint32 t byteswritten bytesread File write read counts char rtext 256 File read buffer I USER CODE END 1 7 NOU COnLLIOUutHLlOfeeeeeeeeedeem EE EE ED DE EE EE ED ease J Reset of all peripherals Initializes the Flash interface and the Syercick J HAL Init DoclD025776 Rev 12 151 200 Tutorial 2 Example of FatFs on an SD card using STM32429lI EVAL evaluation board UM1718 c Insert user code in the main function after initialization calls and before the while loop to perform actual read write from to the SD card int main void MX FATFS Init USER CODE BEGIN 2 O Turn all LEDs off red green orange and blue HAL GPIO WritePin GPIOG GPIO PIN 10 GPIO PIN 6 GPIO PIN 7 GPIO PIN 12 GPIO PIN SET 1 FatFS Link the SD disk I O driver HPHH lf iretSD 0 success set the orange LED on HAL GPIO WritePin GPIOG GPIO PIN 7 GPIO PIN RESET 2 Register the file system object to the FatFs module if f mount amp SDFatFs TCHAR const SD Path 0 FR OK FatFs Initialization Error set the red LED on HAL GPIO WritePin GPIOG GPIO PIN 10 GPIO PIN RESET while 1 j else 3 Create a FAT file system format on the logical drive
110. d Figure 85 PCC Step configuration window ADC enabled using import pinout Added Figure 89 Power Consumption Peripherals Consumption Chart and updated Figure 91 Peripheral power consumption tooltip Updated Section 4 14 4 Power sequence step parameters glossary Updated Section 5 STM32CubeMX C Code generation overview Updated Section 6 1 Creating a new STM32CubeMX Project and Section 6 2 Configuring the MCU pinout Added Section 7 Tutorial 2 Example of FatFs on an SD card using STM32429I EVAL evaluation board and updated Section 8 Tutorial 3 Generating GPIO initialization C code STM32F1 series only Updated Section 4 14 2 Configuring a step in the power sequence 7 DoclD025776 Rev 12 UM1718 Table Revision history 16 Document revision history continued ee wel ewe 19 Jan 2015 Complete project generation power consumption calculation and clock tree configuration now available on all STM32 series Updated Section 2 2 Key features and Section 2 3 Rules and limitations Updated Eclipse IDEs in Section 3 1 3 Software requirements Updated Figure 12 Updater Settings window Figure 16 New library Manager window and Figure 22 New Project window board selector Updated Section 4 8 Project Settings Window and Section 4 9 Update Manager Windows Updated Figure 41 About window Removed Figure STM32CubeMX Configuration view STM32F1 series Updated Table 9 STM32CubeMX Chip view I
111. d selection in Section 4 2 New project window Updated Section 4 12 Configuration view overview Updated Section 4 12 1 IP and Middleware Configuration window Section 4 12 3 GPIO Configuration window and Section 4 12 4 DMA Configuration window Added Section 4 12 2 User Constants configuration window Updated Section 4 13 Clock tree configuration view and added reserve path Updated Section 6 1 Creating a new STM32CubeMX Project Section 6 5 Configuring the MCU Clock tree Section 6 6 Configuring the MCU initialization parameters Section 6 7 2 Downloading firmware package and generating the C code Section 6 8 Building and updating the C code project Added Section 6 9 Switching to another MCU Updated Section 7 Tutorial 2 Example of FatFs on an SD card using STM32429I EVAL evaluation board and replaced STM32F429l EVAL by STM32429I EVAL Updated Figure 16 New library Manager window and Section 3 5 4 Checking for updates Character string constant supported in Section 4 12 2 User Constants configuration window Updated Section 4 13 Clock tree configuration view Updated Section 4 14 Power Consumption Calculator PCC view Modified Figure 156 Power Consumption Calculation example Updated Section 8 Tutorial 3 Using PCC to optimize the embedded application power consumption and more Added Eclipse Mars in Section 3 1 3 Software requirements Code generation options now supported by the Project settings menu
112. ddleware libraries relevant to the user configuration e g FatFs USB Copy only the necessary library files STM32CubeMX will copy to the user project folder only the library files relevant to the user configuration e g SDIO HAL driver from the HAL library Add the required library as referenced in the toolchain project configuration file By default the required library files are copied to the user project Select this option for the configuration file to point to files in STM32CubeMX repository instead the user project folder will not hold a copy of the library files but only a reference to the files in STM32CubeMX repository HAL settings options are also offers For the generated initialization code to set all free pins as analog for power consumption optimization To use or not the Full Assert function the Define statement in the stm32xx hal conf h configuration file will be commented or uncommented respectively Note Useful tooltips are also available by hovering the mouse over the different options 4 9 Update Manager Windows Three windows can be accessed through the Help menu available from STM32CubeMX menu bar 1 Select Help Check for updates to open the Check Update Manager window and find out about the latest software versions available for download 2 Select Help gt Install new libraries to open the New Libraries Manager window and find out about the software packages available for
113. ding to user selection of clock sources clock frequencies and prescalers multipliers dividers values e Check the validity of user settings e Highlight invalid settings in red and provide tooltips to guide the user to achieve a valid configuration The Clock tree view is adjusted according to the RCC settings configured in RCC IP pinout and configuration views and vice versa e fin RCC Pinout view the external and output clocks are enabled they become configurable in the clock tree view e fin RCC Configuration view the Timer prescaler is enabled the choice of Timer clocks multipliers will be adjusted Conversely the clock tree configuration may affect some RCC parameters in the configuration view e Flash latency number of wait states automatically derived from Vpp voltage HCLK frequency and power over drive state e Power regulator voltage scale automatically derived from HCLK frequency e Power over drive is enabled automatically according to HCLK frequency When the power drive is enabled the maximum possible frequency values for AHB and APB domains are increased They are displayed in the Clock tree view The default optimal system settings that is used at startup are defined in the system stm32f4xx c file This file is copied by STM32CubeMX from the STM32CubeF4 firmware package The switch to user defined clock settings is done afterwards in the main function Figure 70 gives an example of Clock tree configura
114. down the STM32 portfolio by selecting STM32F4 as Series STM32F407 as Lines and LQFP100 as Package see Figure 100 Select the STM32F407VGTx from the MCU list and click OK Figure 100 MCU selection Lines z STM32F 407 417 Peripheral Selection MCUs List 4 Items Peripherals SIM32F40 VETx eet QFP100 512 ee le J NN ME 8 Ma 118 200 sra wen smGray mum bi usa MM SIM32FAI VGTXx STM32F 407 417 T 100 1024 192 i DoclD025776 Rev 12 UM1718 Tutorial 1 From pinout to project C code generation using an STM32F4 MCU SIM32CubeMX views are then populated with the selected MCU database see Figure 101 Figure 101 Pinout view with MCUs selection File Project Pinout Window Help fics uR amp G M keep current Signals Placement 9 G Find EACE onfiguration MiddleWares FATFS FREERTOS g v STM32F4 17V GTa LQFP 100 EFEEEEFFEFFEEEEEEEEEEIE be Be Be Bo Be Be Be Be Be Bo Be MCUs Selection Series MICU Package Required Peripherals STM32F4 STM3ZFAl7VETx LOFP100 None OSTM32F4 STM32F407 417 STM32FA17VGTx LOFP1D DoclD025776 Rev 12 119 200 q Tutorial 1 From pinout to project C code generation using an STM32F4 MCU UM1718 Optionally remove the MCUs Selection bottom window by unselecting Window gt Outputs sub menu see Figure 102 Figure 102 Pinout view without MCUs selection window STM32CubeMX Untitled STM3
115. e q for edition The change of constant name is applied wherever the constant is used This does not affect the peripheral or middleware configuration state However changing the constant value impacts the parameters that use it and might result in invalid settings e g exceeding a maximum threshold Invalid parameter settings will be highlighted in red with a red cross Figure 56 Specifying user constant value and name User Constants constant Name constant Value Deleting user constants Click the Remove button to delete an existing user defined constant The user constant is then automatically removed except in the following cases e When the constant is used for the definition of another constant In this case a popup window displays an explanatory message see Figure 57 Figure 97 Deleting user constant not allowed when constant already used for another constant definition Delete user constant warning e When the constant is used for the configuration of a peripheral or middleware library parameter In this case the user is requested to confirm the deletion since the constant removal will result in a invalid peripheral or middleware configuration see Figure 58 DoclD025776 Rev 12 75 200 STM32CubeMX User Interface UM1718 Figure 58 Deleting a user constant used for parameter configuration Confirmation request Delete user constant warning Clicking Yes leads to an invalid peripheral configur
116. e 6 TIM Prescaler Selection Disabled Power Parameters Power Regulatror Voltage Scale Power Regulator Voltage Scale 3 Power Over Drive Disabled 4 13 3 STM32F43x 42x power over drive feature STM32F42x 43x MCUs implement a power over drive feature allowing to work at the maximum AHB APB bus frequencies e g 180 MHz for HCLK when a sufficient Vpp supply voltage is applied e g Vpp gt 2 1 V Table 13 lists the different parameters linked to the power over drive feature and their availability in S TM32CubeMX user interface DoclD025776 Rev 12 91 200 q STM32CubeMX User Interface UM1718 Table 13 Voltage scaling versus power over drive and HCLK frequency Vpp voltage Configuration RCC User defined within a pre defined range Impacts power over drive Power Regulator l Automatically derived from HCLK frequency and Voltage scaling SE HS power over drive see Table 14 This value is conditioned by HCLK and Vpp value see Table 14 It can be enabled only if Vpp 2 2 2 V Power Over Drive Configuration RCC When Vpp 22 2 V it is either automatically derived from HCLK or it can be configured by the user if multiple choices are possible e g HCLK 130 MHz Displayed in blue to indicate the maximum HCLK AHB clock possible value For example maximum value is maximum frequency Clock Configuration 168 MHz for HCLK when power over drive value cannot be activated when Vpp s 2 1 V otherwise it is 180 MHz APB1 APB2 cl
117. e Chip view then select GPIO output Figure 103 GPIO pin configuration GPIO Output b Enable a timer to be used as timebase for toggling the LED This is done by selecting Internal Clock as TIM3 Clock source from the peripheral tree see Figure 104 Slave Mode Disable me Trigger Source Disable Clock Source Internal Clock Channelt Disable Channel2 Disable Channel Disable Channeld Disable Combined Channels Disable Use ETR as Clearing Source KOR activation One Pulse Mode DoclD025776 Rev 12 121 200 Tutorial 1 From pinout to project C code generation using an STM32F4 MCU UM1718 C You can also configure the RCC in order to use an external oscillator as potential clock source see Figure 105 This completes the pinout configuration for this example Figure 105 Simple pinout configuration STM32CubeMX STM32Cube_simpleLedToggle ioc STM32F407VGTx 6 a cm File Project Pinout Window Help RoE ws eS p Keep current Signals Placements e G Q HR Pinout Clock Configuration Configuration Power Consumption Calculator TEITE Ef High Speed Clock HSE BYPASS Clock Source Low Speed Clock LSE Disable __ Master Clock Ouput 1 Master Clock Ouput 2 Audio Clock Input I2S_CKIN Af EC E93 E EH EH EH L N Om w Slave Mode Disable Trigger Source Disa
118. e configuration enabling RTC RCC Clock source and outputs from Pinout view STM32CubeMX Untitied STO ATE aime pe o File Project Pinout Window Help HIES E qi a Keep Current Signals Placement g ds Find f E CL E V Show user Label E LTDC High Speed Clock HSE BYPASS Clock Source Low Speed Clock LSE Crystal Ceramic Resonator i V Master Clock Output 1 Audio Clock Input 128 CKIN U 6 RNG j RTC Alarm A Internal Alarm Marne Dabe WakeUp Disable mu Ma STM32 F429VITx Timestamp Routed to AF1 LOFP100 7 Tamper 1 Routed to AF1 Calibration Disable a El Reference dock detection H SAI H A SDIO SPIL B SPI2 5 9 SPD SPIA 2 Then goto the RCC IP configuration in the Configuration view The settings defined there for advanced configurations will be reflected in the clock tree view The settings 7 90 200 DoclD025776 Rev 12 UM1718 STM32CubeMX User Interface defined in the clock tree view may change the settings in the RCC configuration see Figure 73 Figure 73 Clock tree configuration RCC Peripheral Advanced parameters Configure the below parameters H System Parameters VOD voltage V 3 3V Instruction Cache Enabled Prefetch Buffer Enabled Data Cache Enabled Flash Latency W5 OWS 1 CPU cyde j RCC Parameters HSI Calibration Valu
119. e defined for the new project that is just after the MCU selection It is disabled as soon as a user action is performed on the project configuration 2 Select File gt Import Project for the dedicated Import project window to open This window allows to specify the following options The STM32CubeMX configuration file ioc pathname of the project to import on top of current empty project Whether to import the PCC configuration defined in the Power Consumption Calculator tab or not Whether to import the project settings defined through the Project Settings menu IDE selection and code generation options Whether to attempt to import the whole configuration Automatic import or only a subset Manual Import 7 46 200 DoclD025776 Rev 12 UM1718 q STM32CubeMX User Interface a Automatic project import see Figure 30 Figure 30 Automatic project import amp Import Project Imported Project CrISTM32CubeMX User Manual MX v4 12 Import IOC demo ioc Import MX Settings C Import PCC Settings C Import Project Settings Import Pinout Clock Configuration Configuration Settings Automatic Import Manual Import Import Pinning Status Import Peripherals Configuration Peripheral List From STM32F427IGHx To STM32F401CBUx ETH None CANI None S O ADCi ADC2 mar to ADC1 ADC3 import to ADC1 RCC WIREE eee SPI1 SPIS mai pr o to SPI2 SPI6 import to SPI3 Try Import Show View Pin
120. e ees 177 Function remapping example SEE EE ES ES ESE ee eee eee 177 Block shifting not applied EES ESE eee eens 178 Block shifting applied EES EE ES SE SS SE eee eee ees 179 FreeRTOS HOOK functions to be completed by user SES SS SS SE eee 183 FreeRTOS elements nnana naana anaa ee ee ee rre 184 LwIP configuration SS SS ee ee eee eee 185 STM32 microcontroller part numbering scheme 0 0 00 cece eee 187 STM32Cube Embedded Software package SESSE SS SE SS eee 193 DoclD025776 Rev 12 11 200 STM32Cube overview UM1718 1 12 200 STM32Cube overview STMCube is an STMicroelectronics original initiative to ease developers life by reducing development efforts time and cost STM32Cube covers STM32 portfolio STM32Cube includes e he STM32CubeMNX a graphical software configuration tool that allows to generate C initialization C code using graphical wizards e Acomprehensive embedded software platform delivered per series Such as STM32CubeF2 for STM32F2 series and STM32CubeF4 for STM32F4 series The STM32Cube HAL an STM32 abstraction layer embedded software ensuring maximized portability across STM32 portfolio A consistent set of middleware components such as RTOS USB TCP IP Graphics All embedded software utilities coming with a full set of examples DoclD025776 Rev 12 Ly UM1718 2 2 1 3 Getting started with STM32CubeMX Getting started with STM32Cu
121. e the pins by remapping all the peripheral modes impacted by the shared pin Example With the Keep current signal placement enabled if USART3 synchronous mode is set first the Asynchronous default block PB10 PB11 is mapped and Ethernet becomes unavailable shown in red see Figure 180 Unchecking keep Current Signals Placement allows STM32CubeMX shifting blocks around and freeing a block for the Ethernet MII mode see Figure 181 Figure 180 Block shifting not applied ETE m File Project Pinout Window Help V IV Show user Label Pinout clock Configuration Configuration Power Consumption Calculator ADA ADC2 LG CAN1 CAN2 elelelelelelslelelelelelelslelelelele es G 6 CRC ajla Q m PE2 PA10 a 6 1283 PAS i IWDG small H 6 RCC SH a RTC a gr SPI1 PC6 s spa PDis a SPI3 ED B e SYS d H TIM1 STM32F107VBTx PD11 PD10 PD9 PDs PB15 PB 14 PB 13 e TIM2 LQFP100 TIM3 5 5 TING B 6 TIM6 D H 6 TIMZ 42ra USART3 CK i UART4 i UARTS i USARTi i USART2 Tad TT ad XL t1Nvsn ils XM ELAYSN 7 178 200 DoclD025776 Rev 12 UM1718 A 7 A 8 A 9 q STM32CubeMX pin assignment rules Figure 181 Block shifting applied n STM32CubeMX Untitled STM32F107VBTx co mes File Project Pinout Window Help V V Show user Label deos IWDG 0 9 RCC 0 9 RTC x SPI i
122. eMX generated C code and user sections The C code generated by STM32CubeMX provides user sections as illustrated below They allow user C code to be inserted and preserved at next C code generation User sections shall neither be moved nor renamed Only the user sections defined by STM32CubeMX are preserved User created sections will be ignored and lost at next C code generation USER CODE BEGIN O s USER CODE END O STM32CubeMX may generate C code in some user sections It will be up to the user to clean the parts that may become obsolete in this section For example the while 1 loop in the main function is placed inside a user section as illustrated below Infinite loop USER CODE BEGIN WHILE while 1 USER CODE END WHILE USER CODE BEGIN 3 USER CODE END 3 STM32CubeMX design choices for peripheral initialization STM32CubeMX generates peripheral nit functions that can be easily identified thanks to the MX prefix static void MX GPIO Init void static void MX Peripheral Instance Name Init void static void MX I2S2 Init void An MX peripheral instance name Init function exists for each peripheral instance selected by the user e g MX 1252 Init It performs the initialization of the relevant handle structure e g amp hi2s2 for 12S second instance that is required for HAL driver initialization e g HAL 12S Init and the actual call to this function void MX I2S
123. eady marked as configured Click FatFs and USB buttons to display default configuration settings You can also change them by following the guidelines provided at the bottom of the window Figure 126 FatFs IP instances FATFS Configuration v Bs instances amp Set Defines Configure the below parameters USBH USBH instance USB Host MSC FS Apply Ok Cancel DoclD025776 Rev 12 133 200 Tutorial 1 From pinout to project C code generation using an STM32F4 MCU UM1718 Figure 127 FatFs define statements FATFS Configuration f Set Defines Configure the below parameters Function Parameters FS TINY Disabled FS READONLY Read only mode Disabled FS MINIMIZE Minimization level Disabled M LLLI USE STRFUNC Use String Functions Enabled with LF gt CRLF conversion USE MKFS Enabled USE FORWARD Disabled USE LABEL Disabled USE FASTSEEK Enabled Locale and Namespace Parameters Physical Drive Parameters System Parameters FS MINIMIZE Minimization level FS MINIMIZE Parameter Description The FS MINIMIZE option defines minimization level to remove some functions 0 Full function 1 f stat f getfree f unlink f mkdir f chmod f truncate f utime and f rename are removed 2 f opendir and f readdir are removed in addition to 1 3 f_lseek is removed in addition to 2 134 200 DoclD025776 Rev 12 Ly UM1718 Tutorial 1 From pinout to proj
124. ect C code generation using an STM32F4 MCU 6 7 Generating a complete C project 6 7 1 Setting project options Default project settings can be adjusted prior to C code generation as described in Figure 128 1 Select Settings from the Project menu to open the Project settings window 2 Select the Project Tab and choose a Project name location and a toolchain to generate the project see Figure 128 Figure 128 Project Settings and toolchain choice Project Settings Project Code Generator Project Settings Project Name STM32Cube SimpleLedToaale Project Location C Users JohnDoe STM32Cube projects Project Folder C Users JohnDoe STM32Cube projects STM32Cube_SimpleLedTogqle Toolchain IDE EWARMGZ0 N EWARM 6 70 MDK ARM 4 73 TrueSTUDIO 4 3 1 Mcu Reference STM32F407VGTX Firmware Package Name and Version STM32Cube FW_F4 VO 8 2 3 Select the Code Generator tab to choose various C code generation options The library files copied to Projects folder C code regeneration e g what is kept or backed up during C code regeneration HAL specific action e g set all free pins as analog I Os to reduce MCU power consumption In the tutorial example select the settings as displayed in the figure below and click OK Note A dialog window appears when the firmware package is missing Go to next section for explanation on how to download the firmware package q DoclD0257
125. ed will be called during each tick interrupt if USE TICK HOOK is set to 1 Enabled then the application must define a tick hook function void vApplicationTickHook void if USE TICK HOOK is set to 0 Disabled then the tick hook function will not be called even if one is Ly DoclD025776 Rev 12 183 200 STM32CubeMX C code generation design choices and limitations UM1718 Through STM32CubeMX FreeRTOS configuration window the user can configure all the resources required for the real time OS application tasks queues semaphores and timers The corresponding freeRTOS elements will be defined and created in the generated code see Figure 183 Figure 183 FreeRTOS elements amp FREERTOS Configuration Tasks Name Task Priority Stark size Entry function defaultTask asPriorityMormal 128 StartDefaultTask osPriorityIdle 128 StartTask 2 B 3 6 LwIP LwIP initialization function is defined in wip c while LwIP configuration is available in Iwipopts h generated file STM32CubeMX supports LwIP over Ethernet only The Ethernet peripheral initialization is done within the middleware initialization C code STM32CubeMX does not support user C code insertion in stack native files However some LwIP use cases require modifying stack native files e g cc h mib2 c user modifications shall be backed up since they will be lost at next STM32CubeMX generation SIM32CubeMX LwIP configuration does not support IPv6 DHCP
126. eed since reducing the operating frequency can increase energy consumption if the microcontroller has to remain for a long time in an active operating mode to perform a given operation e Enabling only the peripherals relevant for the current application state and clock gating the others e When relevant using the peripherals with low power features e g waking up the microcontroller with the I2C e Minimizing the number of state transitions e Optimizing memory accesses during code execution Prefer code execution from RAM to Flash memory When relevant consider aligning CPU frequency with Flash memory operating frequency for zero wait states The following tutorial will show how STM32CubeMX PCC feature can help to tune an application to minimize its power consumption and extend the battery life PCC does not account for I O dynamic current consumption and external board components that can also affect current consumption For this purpose an additional consumption field is provided for the user to specify such consumption value 7 DoclD025776 Rev 12 UM1718 8 2 8 3 8 3 1 Tutorial 3 Using PCC to optimize the embedded application power consumption and Application example description The application is designed using the NUCLEO L476RG board based on a STM32L4 76RGTx device and supplied by a 2 4 V battery The main purpose of this application is to perform ADC measurements and transfer the conversion resul
127. election in Section 4 14 1 Building a power consumption sequence Updated note in Section 4 14 Power Consumption Calculator PCC view Updated Section 6 1 Creating a new STM32CubeMX Project Added Section 9 5 Why does the RTC multiplexer remain inactive on the Clock tree view Section 9 6 How can select LSE and HSE as clock source and change the frequency and Section 9 7 Why STMS32CubeMX does not allow me to configure PC13 PC14 PC15 and PI8 as outputs when one of them is already configured as an output 7 DoclD025776 Rev 12 UM1718 Table Revision history 16 Document revision history continued me wel ewe 3 Added support for STM32CubeF0 STM32CubeF3 STM32F0 and STM32F3 series in cover page Section 2 2 Key features Section 2 3 Rules and limitations Added board selection capability and pin locking capability in Section 2 2 Key features Table 2 Welcome page shortcuts Section 4 2 New project window Section 4 4 Toolbar and menus Section 4 7 Set unused Reset used GPIOs windows Section 4 8 Project Settings Window and Section 4 11 Pinout view Added Section 4 11 5 Pinning and labeling signals on pins Updated Section 4 12 Configuration view and Section 4 13 Clock tree configuration view and Section 4 14 Power Consumption Calculator PCC view Updated Figure 23 STM32CubeMX Main window upon MCU selection Figure 38 Project Settings window Figure 41 About window Figure 42 STM32Cu
128. er sections delimiters are renamed DoclD025776 Rev 12 139 200 Tutorial 1 From pinout to project C code generation using an STM32F4 MCU UM1718 6 8 Building and updating the C code project This example explains how to use the generated initialization C code and complete the project within IAR EWARM toolchain to have the LED blink according to the TIM3 frequency A folder is available for the toolchains selected for C code generation the project can be generated for more than one toolchain by choosing a different toolchain from the Project Settings menu and clicking Generate code once again 1 Open the project directly in the IDE toolchain by clicking Open Project from the dialog window or by double clicking the relevant IDE file available in the toolchain folder under STM32CubeMX generated project directory see Figure 136 Figure 138 C code generation output Projects folder Ele Edit View Tools Help Organize Include in library Share with Burn New folder 4 STM32Cube simpleledToggle Name gt Drivers bai EWARM do Drivers Ji inc 4 EWARM E MDK ARM M Inc B E MDK ARM N SRST n TrueSTUDIO 2 4 TrueSTUDIO mxpraject STM32Cube simpleLedToggle ioc Lj STM32Cube simpleLedToggle txt ST M32Cube simpleLedToggle Configuratian pdf 11 items 7 140 200 DoclD025776 Rev 12 UM1718 Tutorial 1 From pinout to project C code generation using an STM32F4 MCU 2 Asan ex
129. ess the user chooses from the Project settings window to generate nit functions as pairs of c h files Instead a StartDefault Task function is defined in the main c file and CMSIS RTOS native function osKernelStart is called in the main function If FreeRTOS is enabled the nit functions for the other middlewares in use are called from the StartDefaultTask function in the main c file Example void StartDefaultTask void const argument init code for FATFS MX FATFS Init init code for LWIP MX LWIP Init init code for USB HOST MX USB HOST Init USER CODE BEGIN 5 Infinite loop DoclD025776 Rev 12 181 200 STM32CubeMX C code generation design choices and limitations UM1718 B 3 2 B 3 3 B 3 4 182 200 fori osDelay 1 USER CODE END 5 USB Host USB peripheral initialization is performed within the middleware initialization C code in the usbh conf c file while USB stack initialization is done within the usb host c file When using the USB Host middleware the user is responsible for implementing the USBH UserProcess callback function in the generated usb host c file From STM32CubeMX user interface the user can select to register one class or all classes if the application requires switching dynamically between classes USB Device USB peripheral initialization is performed within the middleware initialization C code in the usbd conf c file whi
130. ew by default the corresponding SPI signals are assigned to PB3 PB4 and PB5 pins see Figure 175 If the user assigns to PA6 the SPI1_MISO function currently assigned to PB4 STM32CubeMX clears the PB4 pin from the SPI1 MISO function as well as all the other pins configured for this block and moves the corresponding SP11 functions to the relevant pins in the same block as the PB4 pin see Figure 176 by pressing CTRL and clicking PB4 to show PAG alternate function in blue then drag and drop the signal to pin PAG DoclD025776 Rev 12 173 200 STM32CubeMX pin assignment rules UM1718 Figure 175 Block inter dependency SPI signals assigned to PB3 4 5 STM32CubeMxX Untitled STM32F107VBTx File Project Pinout Window Help B gt GE amp Deep current signals Placement 9 G Find PI1 MOSI 4 PI1 MISO PI1 SCK I un m m a a D a PE STM32F107VBTx LQFP100 7 174 200 DoclD025776 Rev 12 UM1718 STM32CubeMX pin assignment rules Figure 176 Block inter dependency SPI1 MISO function assigned to PA6 STM32CubeMX Untitled STM32F107VBTx File Project Pinout Window Help X amp El E d amp Cj Keep current signals Placement 9 G Find v SV V Show user Label i yp Pinout TIM3 bcn STM32F107VBTx TIMS LQFP100 TIM6 6 TIM7 UART4 6 UARTS USART1 T dic wile J o USART3 USB OTG FS i MM FEEEEEELEIEEREEEERFEEEEF E
131. 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 SITM32CubeMX 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 Starting from the previously defined pinout the user can proceed with the configuration of middleware clock tree services RNG CRC etc and IP 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 From the Project settings menu the user can select t
132. gnals that are used are highlighted in blue Out of range configured values are highlighted in red to flag potential issues A solver feature is proposed to automatically resolve such configuration issues see Figure 71 Reverse path is supported just enter the required clock speed in the blue filed and STM32CubeMX will attempt to reconfigure multipliers and dividers to provide the requested value The resulting clock value can then be locked by right clicking the field to prevent modifications STM32CubeMX generates the corresponding initialization code e main c with relevant HAL_RCC structure initializations and function calls e Stm32xxxx hal conf h for oscillator frequencies and Vpp values Clock tree configuration functions External clock sources When external clock sources are used the user must previously enable them from the Pinout view available under the RCC peripheral Peripheral clock configuration options Some other paths corresponding to clock peripherals are grayed out To become active the peripheral must be properly configured in the Pinout view e g USB This view allows to e Enter a frequency value for the CPU Clock HCLK buses or peripheral clocks STM32CubeMX tries to propose a clock tree configuration that reaches the desired frequency while adjusting prescalers and dividers and taking into account other peripheral constraints such as USB clock minimum value If no solution can be found DoclD025
133. guration and to configure DMA transfers for this peripheral In the tutorial example the DMA is not used and the GPIO settings remain unchanged The interrupt is enabled as shown in Figure 118 The GPIO Settings tab to display the GPIO configuration and to configure the GPIOs for this peripheral 3 Modify and click Apply or OK to save your modifications Figure 118 Enabling Timer 3 interrupt TIM3 Configuration of iC Setinas f DMA Settings Interrupt Table Preemption Priority Sub Priority M3 global interrupt 0 0 DoclD025776 Rev 12 129 200 q Tutorial 1 From pinout to project C code generation using an STM32F4 MCU UM1718 6 6 3 Configuring the GPIOs The user can adjust all pin configurations from this window A small icon along with a tooltip indicates the configuration status Figure 119 GPIO configuration color scheme and tooltip GPIO General Purpose Input Output This IP is correctly configured You can generate code using current vale Follow the sequence below to configure the GPIOS 1 Click the GPIO button in the Configuration view to open the Pin Configuration window below 2 The first tab shows the pins that have been assigned a GPIO mode but not for a dedicated IP Select a Pin Name to open the configuration for that pin In the tutorial example select PD12 and configure it in output push pull mode to drive the STM32F4DISCOVERY LED see Figure 120 Figure 120 GPIO mode configuration
134. he development tool chain 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 DoclD025776 Rev 12 15 200 Getting started with STM32CubeMX UM1718 2 3 16 200 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 graphical 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 will be updated accordingly Invalid settings and limitations are highlighted and documented with tool tips Automatic updates of STM32CubeMX and STM32Cube firmware 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 Report generation pdf and csv reports can be ge
135. he step configuration is performed from the Edit Step and New Step windows The graphical interface guides the user by forcing a pre defined order for setting parameters Their naming may differ according to the selected MCU series For details on each parameter refer to Section 4 14 4 Power sequence step parameters glossary glossary and to Appendix D STM32 microcontrollers power consumption parameters or to the electrical characteristics section of the MCU datasheet 7 100 200 DoclD025776 Rev 12 UM1718 STM32CubeMX User Interface The parameters are set automatically by the tool when there is only one possible value in this case the parameter cannot be modified and is grayed out The tool proposes only the configuration choices relevant to the selected MCU Proceed as follow to configure a new step 1 Click Add or Duplicate to open the New step window or double click a step from the sequence table to open the Edit step window 2 Within the open step window select in the following order The Power Mode Changing the Power Mode resets the whole step configuration The Peripherals Peripherals can be selected unselected at any time after the Power Mode is configured The Power scale The power scale corresponds to the power consumption range STM32L 1 or the power scale STM32F4 Changing the Power Mode or the Power Consumption Range discards all subsequent configurations The Memory Fetch Type The Vpp value if mu
136. ht green in the Chip view Why cannot change the function of some pins when click some pins nothing happens 166 Why do get the error Java 7 update 45 when installing Java 7 update 45 or a more recent version of the JRE 166 Why does the RTC multiplexer remain inactive on the Clock tree view 167 How can select LSE and HSE as clock source and change the frequency 0 ce ee eee 168 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 0 0 0 0 SE Se ee eee 168 STM32CubeMX pin assignment rules 169 Block consistency EE EE EE SE SE eee eee 169 Block inter dependenCY SESSE ESE SE SE ee ene 173 One block one peripheral mode SESSE SES SE eee 176 Block remapping STM32F10x only anaana aaaea 176 Function remapping 0 ee ee eee 177 Block shifting only for STM32F10x and when Keep Current Signals placement is unchecked 178 Setting and clearing a peripheral mode 0000 0 eee 179 Mapping a function individually 0 0 00 cee ee 179 GPIO signals mapping 2 0 0 ce ee ees 179 STM32CubeMX C code generation design choices and limitations RE RR EE 180 STM32CubeMX generated C code and user sections 180 STM32CubeMX design choices for
137. ick OK r Figure 142 SWD connection q Options for node STM32Cube SimpleLedToggle Category General Options C C Compiler Assembler Output Converter Custom Build Build Actions Linker Debugger Simulator Angel CMSIS DAP GDB Server IAR ROM monitor I jet JTAGjet J Aink J Trace TI Stellaris Macraigor PE micro RDI ST LINK Third Party Driver TI XDS 100 200 Factory Settings ST LINK Reset Normal Interface Clock setup JTAG CPUclock 720 SWO clock Auto 2000 Cancel DoclD025776 Rev 12 143 200 Tutorial 1 From pinout to project C code generation using an STM32F4 MCU UM1718 6 Select Project gt Rebuild all Check if the project building has succeeded Figure 143 Project building log Messages stm3zfdxx hal tim c stm32fdxx hal tim exc stm32tfdxx it c stm32tfdxx sdmmec c svstem stm3ztdxx c Linking Total number of errors 0 Total number of warnings O 7 Add user C code in the dedicated user sections only Note The main while 1 loop is placed in a user section For example a Edit the main c file b To start timer 3 update User Section 2 with the following C code Figure 144 User Section 2 HAL Init Configure the system clock SystemClock Config Initialize all configured peripherals MX GPIO Init MX TIM3 Init USER CODE
138. igure 157 PCC Vpp and battery selection menu Microcontroller Selected A Series sTM32L4 Line STM32L4x6 MCU STM32L476RGTX Datasheet 025976 Rev3 Parameter Selection amp Ambient Temperature C 25 Vdd Power Supply V 24 Battery 5election amp Battery Li MnO2 CR 2032 In Series 1 In Parallel 1l Capacity 225 0 mAh Self Discharge 0 12 month Nominal Voltage 6 0 V Max Cont Current 3 0 mA Max Pulse Current 15 0 mA 5 Enable the Transition checker to ensure the sequence is valid see Figure 157 This option allows verifying that the sequence respects the allowed transitions implemented within the STM32L476RG 6 Click the Add button to add steps that match the sequence described in Figure 157 By default the steps last 1 ms each except for the wakeup transitions that are preset using the transition times specified in the product datasheet see Figure 158 Some peripherals for which consumption is unavailable or negligible are highlighted with see Figure 156 Figure 158 PCC Sequence table CPU BusF Clock Config SrcFreq Peripherals Add Current Step Current Duration 24 0 MHz SE 24 0 MHz ADC 1 fs_10 0 mA 9 29 mA 1ms 0 Hz SI RTC 37 0 kHz RTC 0 mA 0 46 pA 1ms 4 0 MHz SI FAST 40 MHz OmA 1 7 mA 20 1us 16 0 MHz 16 0 MHz RTC p mA 2 19 mA 1ms 16 0 MHz 16 0 MHz
139. internet browser a web page opens and prompts the user to enter his login password DoclD025776 Rev 12 27 200 Installing and running STM32CubeMX UM1718 If necessary contact your IT administrator for proxy information proxy type http address port STM32CubeMX does not support web proxies In this case the user will not be able to benefit from the update mechanism and will need to manually copy the STM32 firmware packages from http www st com stm32cube to the repository To do it follow the sequence below 1 Go to http www st com stm32cube and download the relevant STM32Cube firmware package from the Associated Software section 2 Unzip the zip package to your STM32Cube repository Find out the default repository folder location in the Updater settings tab as shown in Figure 12 you might need to update it to use a different location or name 3 5 1 Updater configuration To perform STM32Cube new library package installation or updates the tool must be configured as follows 1 Select Help gt Updater Settings to open the Updater Settings window 2 From the Updater Settings tab see Figure 12 a Specify the repository destination folder where the downloaded packages will be stored b Enable Disable the automatic check for updates Figure 12 Updater Settings window Updater Settings T Updater Settings Connection Parameters Firmware Repository
140. ion consists in selecting a priority group enabling disabling interrupts and configuring interrupts priority levels pre emption and sub priority levels Select a priority group Several bits allow to define NVIC priority levels These bits are divided in two priority groups corresponding to two priority types pre emption priority and sub priority For example in the case of STM32F4 MCUs the NVIC priority group 0 corresponds to 0 bit pre emption and 4 bit sub priority In the interrupt table click one or more rows to select one or more interrupt vectors Use the widgets below the interrupt table to configure the vectors one by one or several at a time 1 Enable checkbox check uncheck to enable disable the interrupt Pre emption priority select a priority level The pre emption priority defines the ability of one interrupt to interrupt another Sub priority select a priority level The sub priority defines the interrupt priority level Click Apply to save changes and OK to close the window DoclD025776 Rev 12 3 UM1718 4 13 4 13 1 3 STM32CubeMX User Interface Clock tree configuration view STM32CubeMX Clock configuration window see Figure 23 provides a schematic overview of the clock paths clock sources dividers and multipliers Drop down menus and buttons allow modifying the actual clock tree configuration to meet user application requirements Actual clock speeds are displayed and active The clock si
141. ion report for board designers e 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 imported 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 DoclD025776 Rev 12 13 200 Getting started with STM32CubeMX UM1718 Figure 1 Overview of STM32CubeMX C code generation flow STM32CubeF4 Firmware Package STM32 MCU Reference Manual amp Datasheet Documentation Utilities Middleware Libraries freeRTOS USB TCPIIP FatFS Graphics Drivers including STM32CubeMx Unalog STM32RABETR ot the common API Hardware File Project Pinout Window Help BuU amp tp ep om spasma TY Abstraction Layer Firmware Library p tans FREERTOS Peg SE STM32CubeMX generated C code project peepee Copy of IDE Specific project files M l 3 t STM32CubeF4 Libraries Generated i A anc N T oc3 Drivers b JL CMSIS gt JL STM32F4xx_HAL_Driver 4 Middlewares pk ST gt JL Third Party Projects 4 EWARM JL MDK ARM J RIDE J TrueSTUDIO be opooes CANI v Master Mode CANO crac V aand DAC pow DAAD m c nca nc ene pc uc ns n
142. is still functional but with slow read access time Flash Program and erase operations are no longer available DoclD025776 Rev 12 191 200 STM32 microcontrollers power consumption parameters UM1718 D 2 2 D 2 3 192 200 STM32F4 series feature several Vcore scales The scale can be modified only when the PLL is OFF and when HSI or HSE is selected as system clock source e Scale 1 V12 voltage range limited to 1 26 1 40 V default mode at reset HCLK frequency range 144 MHz to 168 MHz 180 MHz with over drive This is the default mode at reset e Scale 2 V12 voltage range limited to 1 20 to 1 32 V HCLK frequency range is up to 144 MHz 168 MHz with over drive e Scale 3 V12 voltage range limited to 1 08 to 1 20 V default mode when exiting Stop mode HCLK frequency 120 MHz The voltage scaling is adjusted to fc x frequency as follows e STM32F429x 39x MCUs Scale 1 up to 168 MHz up to 180 MHz with over drive Scale 2 from 120 to 144 MHz up to 168 MHz with over drive Scale 3 up to 120 MHz e STM32F401x MCUs No Scale 1 Scale 2 from 60 to 84 MHz Scale 3 up to 60 MHz e STM32F40x 41x MCUs Scale 1 up to 168 MHz Scale 2 up to 144 MHz STM32LO series feature 3 VcoRE ranges e Range 1 Vpp range limited to 1 71 to 3 6 V with CPU running at a frequency up to 32 MHz e Range 2 full Vpp range with a maximum CPU frequency of 16 MHz e Range 3 full Vpp range with a
143. its Standby mode in 60 us when an external reset NRST pin or a rising edge on one of the three WKUP pin occurs The RTC the IWDG and the corresponding clock sources are not stopped automatically by entering Stop or Standby mode The LCD is not stopped automatically by entering Stop mode Power consumption ranges STM32 MCUs power consumption can be further optimized thanks to the dynamic voltage scaling feature the main internal regulator output voltage V12 that supplies the logic CPU digital peripherals SRAM and Flash memory can be adjusted by software by selecting a power range STM32L1 and STM32L0 or power scale STM32 F4 Power consumption range definitions are provided below refer to STM32 MCU datasheets for full details STM32L1 series feature 3 VcoRE ranges e High Performance Range 1 Vpp range limited to 2 0 3 6 V with the CPU running at up to 32 MHz The voltage regulator outputs a 1 8 V voltage typical as long as the Vpp input voltage is above 2 0 V Flash program and erase operations can be performed e Medium Performance Range 2 full Vpp range with a maximum CPU frequency of 16 MHz At 1 5 V the Flash memory is still functional but with medium read access time Flash program and erase operations are still possible e Low Performance Range 3 full Vpp range with a maximum CPU frequency limited to 4 MHz generated only with the multispeed internal RC oscillator clock source At 1 2 V the Flash memory
144. ject Pinout Window Help es LJ E amp j V Keep Current Signals Placement 9 amp G Find v amp Q V Show user Label 17 p amp Pinout Clock Configuration Configuration Power Consumption Calculator onfiguration MiddleWares He FATFS a Q a H S FREERTOS UI IU i s E s RETE E dE p AAA A els A els a p a 8 EE sl zz oe HPs HA ADC1 HA ADC2 HA ADC3 mo CAN1 SCL ACP RF SCL go CAN2 NET 123 SDA ACP RF SDA HA DAC EM Et DCMI H DMA2D H E ETH PE DOTCLX LCT RGB_DOTCLK BLL SDRAM U N30 SDRAM L EA 1 z H Q 1201 H Q 1202 H 1203 EQ 1252 HEY 1253 H IWDG H LTDC EA RCC H RNG H A RTC H A SAIL HA SDIO HA SPI1 H Q SPI2 Hs SPI3 SPI4 iH SPIS 5 6 SPI6 R7 SPI5 SCK L3G020 SOLSPC TET wu SPI5 MISO L3G020 S00 N SPI5 MOSI L3GD20 SDA SOI SDO EE ENABLE LCD RGB ENABLE EM PHO OSC IN ET PHi OSC OUT ll sae STM32F429ZITx NCS MEMS SPI L3GD20_CS jac sery Ed LQFP144 CSX LCD RGB CSX B1 Blue Push amp utton I MEMS_INT1 L3G020_INT1 BT MEMS INT2 L3G020_INT2 Ge Ise cOV ol osd 5 510 MES LO 20 Ss DLO 4 4 q Toolbar and menus The following menus are available from STM32CubeMX menu bar File menu Project menu Pinout menu displayed only when the Pinout view has been selected Window menu Help menu STM32CubeMX menus and toolbars are described in the sections below DoclD025776
145. lder to display the generated project contents or click Open Project to open the project directly in your IDE Then proceed with Section 6 8 Figure 137 C code generation output folder woo 0039 7 l QC Lb STM3 STM32Cube Si gt File Edit View Tools Help Organize M 4j Open Include in library 4 STM32Cube SimpleLedToggle a Drivers i Drivers Inc Inc Middlewares i Middlewares Projects i Projects Src Src STM32Cube_SimpleLedToggle ioc 4 HI Be Projects Date modified 2 3 2014 10 05 AM File folder The generated project contains The STM32CubeMX ioc project file located in the root folder It contains the project user configuration and settings generated through STM32CubeMX user interface The Drivers and Middlewares folders hold copies of the firmware package files relevant for the user configuration The Projects folder contains IDE specific folders with all the files required for the project development and debug within the IDE The nc and Src folders contain STM32CubeMX generated files for middleware peripheral and GPIO initialization including the main c file The STM32CubeMX generated files contain user dedicated sections allowing to insert user defined C code C code written within the user sections is preserved at next C code generation while C code written outside these sections is overwritten User C code will be lost if user sections are moved or if us
146. le Clears signal assignments to pins for signals that have no Mapped Signals associated mode highlighted in orange and not pinned Opens a window to specify the number of GPIOs to be Set unused configure among the total number of GPIO pins that are not GPIOs used yet Specify their mode Input Output or Analog recommended configuration to optimize power consumption No icon Reset used Opens a window to specify the number of GPIOs to be freed GPIOs among the total number of GPIO pins that are configured G amp S ede CSV Generates pin configuration as a csv text file text pinout file IE Collapse All Collapses the IP Middleware tree view Resets to Disabled all peripherals and middleware modes that have been enabled The pins configured in these modes green Disable Modes color are consequently reset to Unused gray color IPs and middleware labels change from green to black when unused or gray when not available Expand Al Expands the IP Middleware tree view to display all functional modes Best Fit Adjusts the chip pinout diagram to the best fit size Available from toolbar only Keep current Prevents moving pin assignments to match a new IP operating signals mode It is recommended to use the new pinning feature that Placement can block each pin assignment individually and leave this checkbox unchecked No icon 4 4 4 Window menu The Window menu allows to access the Outputs function see Ta
147. le USB stack initialization is done within the usb device c file USB VID PID and String standard descriptors are configured via STM32CubeMX user interface and available in the usbd desc c generated file Other standard descriptors configuration interface are hard coded in the same file preventing support for USB composite devices When using the USB Device middleware the user is responsible for implementing the functions in the usbd classname if c class interface file for all device classes e g usbd storage if c USB MTP and CCID classes are not supported FatFs FatFs configuration is available in the ffconf h generated file The initialization of the SDIO peripheral for the FatFs SD Card mode and of the FMC peripheral for the FatFs External SDRAM and External SRAM modes are kept in the main c file oome files need to be modified by the user to match user board specificities BSP drivers in STM32Cube embedded software package can be used as example e bsp driver sd c h generated files when using FatFs SD Card mode e bsp driver sram c h generated files when using FatFs External SRAM mode e bsp driver sdram c h generated files when using FatFs External SDRAM mode Multi drive FatFs is supported which means that multiple logical drives can be used by the application External SDRAM External SRAM SD Card USB Disk User defined However support for multiple instances of a given logical drive is not available e g FatF
148. led ESE SE SE 00 cee eee 133 Figure 127 FatFs IP Instances 2 444 exa ge bk ESE eu 0260 ans ss de ea e mee EROR de Re seaweed 133 Figure 128 FatFs define statements nananana SE ES SS ee eee eee 134 Figure 129 Project Settings and toolchain Choice 1 EES ES ESE SS SE SE Se ss es eee 135 Figure 130 Project Settings menu Code Generator tab SS ES ESE SE SE SE ss ee ee 136 Figure 131 Missing firmware package warning message SS SE SS SE SE ee ees 136 Figure 132 Error during download nananana aaa SS SE SS SEE ee eee ee ee 137 Figure 133 Updater settings for download SES SE SE SE ee eee 137 Figure 134 Updater settings with connection 0 SES ESE SE SE SE ES SE SS eee 137 Figure 135 Downloading the firmware package nannaa aana aa ees 138 Figure 136 Unzipping the firmware package 0 0 cc eens 138 Figure 137 C code generation completion message ES aa SE SE SE eee 138 Figure 138 C code generation output folder 0 SS SE SS SE ees 139 Figure 139 C code generation output Projects folder llle 140 Figure 140 C code generation for EWARM celles 141 Figure 141 STM32CubeMX generated project open in IAR IDE SS SE 00 00 eee 142 Figure 142 IAR ODUONS iss va bee see36 20 SS ORE 54 04 Uke does eked awe OSS eee odes oe mee 143 Figure 143 SWD connection 0 20 0 teen eens 143 10 200 DoclD025776 Rev 12 Ly
149. ling STM32CubeMX standalone version 17 3 2 1 Installing STM32CubeMX standalone version 17 3 2 2 Installing STM32CubeMX from command line 18 3 2 3 Uninstalling STM32CubeMX standalone version 20 3 3 Installing STM32CubeMX plug in version lesus 20 9 9 1 Downloading STM32CubeMX plug in installation package 20 3 3 2 Installing STM32CubeMX as an Eclipse IDE plug in 21 9 9 9 Uninstalling STM32CubeMX as Eclipse IDE plug in 22 3 4 Launching STM32CubeMX selle 23 3 4 1 Running STM32CubeMX as standalone application 23 3 4 2 Running STM32CubeMX in command line mode 23 3 4 3 Running STM32CubeMX plug in from Eclipse IDE 25 3 5 Getting STM32Cube updates SS EES ES ee 27 3 5 1 Updater configuration SES ESE SE SE SE SS SS SE ee ees 28 3 5 2 Downloading new libraries SEE SE SE SS ees 31 3 5 3 Removing libraries llleelel RI 32 3 5 4 Checking for updates ESE SE SE ES ES SE EE eee 34 4 STM32CubeMX User Interface ee 35 4 1 Welcome page elleeeeeeel rr 35 4 2 New project WINdOW leer 36 2 200 DoclD025776 Rev 12 Ly UM1718 4 3 4 4 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 Contents Va dk eie TTC 39 Toolbar and menus 1 eens 41 4 4 1 File menu uses
150. llation has completed successfully Y Isle augmented An uninstaller program has been created in C Program Files STMicroelectronics STM32Cube STM32CubeMx_4 8 AS Wninstaller STMicreelectronics You can then launch the installation just by typing the following command java jar SetupSTM32CubeMX 4 8 0 exe auto install xml q DoclD025776 Rev 12 19 200 Installing and running STM32CubeMX UM1718 Figure 4 Auto install command line Administrator C Windows system32 cmd exe The SIM32CubeMA installer you are attempting to run seems to have a copy already running his could be from a previous failed installation attempt or you may have accide mtally launched the installer twice The recommended action is to select No and wait for the ol ther copy of the installer to start If you are sure there is no other copy of the installer running click the Yes button to allow this installer to run Are you sure you want to continue with this installation Enter Y for Yes N for No y Starting automated installation set uninstallName STM32CubeM amp 22 Starting to unpack 1 Processing package Core 1 3 Processing package Old DataBases 2 3 Processing package Help 3 73 Unpacking finished Writing the uninstaller data Automated installation done WWUsers gt a 3 2 3 Uninstalling STM32CubeMX standalone version To uninstall STM32CubeMX follow the steps below 1 Open the Wind
151. llow icon indicates that at least one mode A ETH Slave 8 bits Embedded Synchro T a EE configuration is no longer available H 9 Dci H T2C2 H I2C3 MEEIH When no more configurations are left for a given peripheral Mode Disable mode this peripheral is highlighted in red je Some modes depends on the configuration of other oe EE ogists peripherals or middleware modes A tooltip explains the ps Active only with ETH IP configured dependencies when the conditions are not fulfilled 60 200 DoclD025776 Rev 12 ky UM1718 4 11 2 STM32Cube STM32CubeMX User Interface Chip view The Chip view shows for the selected part number e The MCU in a specific package BGA LQFP e The graphical representation of its pinout each pin being represented with its name e g PC4 pin 4 of GPIO port C and its current function assignment e g ETH MII RXDO see Figure 43 for an example The Chip view is automatically refreshed to match the user configuration performed via the peripheral tree It shows the pins current configuration state Assigning pins through the Chip view instead of the peripheral pane requires a good knowledge of the MCU since each individual pin can be assigned to a specific function Tips and tricks e Use the mouse wheel to zoom in and out e Click and drag the chip diagram to move it Click best fit to reset it to best suited position and size see Table 5 e Use Pinout gt Ge
152. llowing command java jar SetupSTM32CubeMX 4 8 0 exe console At each installation step an answer is requested see Figure 2 below Figure 2 Example of STM32CubeMX installation in interactive mode EA Administrator C Windows system32 cmd exe Press 1 to accept 2 to reject 3 to redisplay 1 Select target path G Program Files S5TMicroelectronics SIM32Cuhbe 5TM32GuheMs 1 C Program FilesMa set uninstallName amp TH32CuheMa 32 Press 1 to continue 2 to quit 3 to redisplay 1 Create shortcuts in the Start Menu Enter Y for Ves M for Ho n Create additional shortcuts on the desktop Enter Y for Yes M for Ho n create shortcut for all users Enter Y for Yes M for Ho n Starting to unpack 1 L Processing package Core 1 3 L Processing package Old DataBases tard L Processing package Help 4 32 L Unpacking finished Generate an automatic installation script Enter Y for Ves M for Ho n Installation was successful application installed on C Program Files Ma Writing the uninstaller data Console installation done PERSIEI gt DoclD025776 Rev 12 3 UM1718 Installing and running STM32CubeMX 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 below Figure 3 STM32Cube Installation Wizard Lar Insta
153. lock Configuration Configuration Settings Automatic Import 5 Manual Import Import Pinning Status Import Peripherals Configuration Peripheral List NVIC RCC TIM3 GPIO Try Import Show View Pinout Import Status Import Analysis C XSTM32CubeMX Projects 4 10 UMXSTM32Cube simpl A The Mcu SIM32F407VGIx found in the Project being imported ia Show View Pinout Import Status The Mcu SIM32F407VGIx found in the Project being imported Import Iry Importing Pinout Importing IP configurations Import project completed 146 200 DoclD025776 Rev 12 7 UM1718 Tutorial 2 Example of FatFs on an SD card using STM32429I EVAL evaluation board 7 Tutorial 2 Example of FatFs on an SD card using STM32429l EVAL evaluation board The tutorial consists in creating and writing to a file on the STM32429I EVAL 1 SD card using the FatFs file system middleware To generate a project and run tutorial 2 follow the sequence below 1 Launch STM32CubeMX Select File New Project The Project window opens Click the Board Selector Tab to display the list of ST boards Select EvalBoard as type of Board and STM32F4 as series to filter down the list Leave the option Initialize all IPs with their default mode unchecked so that the code is generated only for the IPs used by the application 6 Select the STM32429I EVAL board and click OK The Pinout view is loaded matching the MCU pinout configuration on the e
154. ltiple choices available The voltage source battery or VBUS A Clock Configuration Changing the Clock Configuration resets the frequency choices further down When multiple choices are available the CPU Frequency STM32F4 and the AHB Bus Frequency CPU Frequency STM32L 1 or for active modes a user specified frequency In this case the consumption value will be interpolated see Section Using interpolation 3 Optionally set A step duration 1 ms is the default value An additional consumption value expressed in mA to reflect for example external components used by the application external regulator external pull up LEDs or other displays This value added to the microcontroller power consumption will impact the step overall power consumption 4 Once the configuration is complete the Add button becomes active Click it to create the step and add it to the sequence table Using interpolation For steps configured for active modes Run Sleep frequency interpolation is supported by selecting CPU frequency as User Defined and entering a frequency in Hz see Figure 83 3 DoclD025776 Rev 12 101 200 STM32CubeMX User Interface UM1718 Figure 83 Interpolated Power Consumption Memory Fetch Type Vdd Interpolation ranges 8 0 MHz 16 0 MHz User choice Hz 8000000 Clock Configuration HSEBYP Clock Source Frequency 8 0 MHz Optional Settings Step Duration Additional Consumption Results Step
155. m pinout to project C code generation using an STM32F4 MCU UM1718 6 6 5 Configuring the middleware This is not required for the example taken for the tutorial If a peripheral is required for a middleware mode the peripheral must be configured in the Pinout view for the middleware mode to become available A tooltip can guide the user as illustrated in the FatFs example below Figure 122 FatFs disabled Configuration HiddleWares a FATFS External SRAM SD Card USB Disk 1 Configure the USB IP from the Pinout view Figure 123 USB Host configuration USB OTG FS Mode Host Only Activate SOF i E Activate VBUS 2 Select MSC FS class from USB Host middleware 3 Select the checkbox to enable FatFs USB mode in the tree panel Figure 124 FatFs over USB mode enabled MiddleWares FATFS EE External SORAM External SRAM SD Card J USB Disk i Pm User defined B FREERTOS ie se 5 USB HOST 7 Class for H5 IP Disable Class for FS IP Mass Storage Host Class 7 132 200 DoclD025776 Rev 12 UM1718 Tutorial 1 From pinout to project C code generation using an STM32F4 MCU 4 Select the Configuration view FatFs and USB buttons are then displayed Figure 125 Configuration view with FatFs and USB enabled Middlewares FATFS e cs USB HOST Analog USB FS A 5 FatFs and USB using default settings are alr
156. m the user repository STM32CubeMX repository folder is specified in the Help gt Updater settings menu 2 It copies from the firmware package the relevant files in Drivers CMSIS and Drivers STM32F4 HAL Driver folders and in the Middleware folder if a middleware was selected 3 It generates the initialization C code c h files corresponding to the user MCU configuration and stores it in the nc and Src folders By default the following files are included stm32f4xx_hal_conf h file this file defines the enabled HAL modules and sets some parameters e g External High Speed oscillator frequency to pre defined default values or according to user configuration clock tree stm32f4xx_hal_msp c MSP MCU Support package this file defines all initialization functions to configure the IP instances according to the user configuration pin allocation enabling of clock use of DMA and Interrupts main c is in charge of Resetting the MCU to a known state by calling the HAL_init function that resets all peripherals initializes the Flash memory interface and the SysTick Configuring and initializing the system clock Configuring and initializing the GPIOs that are not used by IPs Defining and calling for each configured IP an IP initialization function that defines a handle structure that will be passed to the corresponding IP HAL init function which in turn will call the IP HAL MSP initialization function Note that when LwIP re
157. ment In this case the tool performs an automatic remapping to optimize your placement How can manually force a function remapping You should use the Manual Remapping feature 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 click some pins nothing happens These pins are specific pins such as power supply or BOOT which are not available as peripheral signals Why dol get the error Java 7 update 45 when installing Java 7 update 45 or a more recent version of the JRE The problem generally occurs on 64 bit Windows operating system when several versions of Java are installed on your computer and the 64 bit Java installation is too old During STM32CubeMX installation the computer searches for a 64 bit installation of Java e f one is found the Java 7 update 45 minimum version prerequisite is checked If the installed version is older an error is displayed to request the upgrade e Ifno 64 bit installation is found STM32CubeMX searches for a 32 bit installation If one is found and the version is too old the Java 7 update 45 error is displayed The user must update the installation to solve the issue To avoid this issue from occurring it is recommended to perform one of the following actions 1 Remove all Java installations and reinstall only one version 32 or 64 bits Java 7 update 45 or more recent 2 Keep 32 bit
158. middleware a Atstartup all LEDs are OFF b Thered LED is turned ON to indicate that an error occurred FatFs initialization file read write access errors C The orange LED is turned ON to indicate that the FatFs link has been successfully mounted on the SD driver d The blue LED is turned ON to indicate that the file has been successfully written to the SD Card e The green LED is turned ON to indicate that the file has been successfully read from file the SD Card 16 For use case implementation update main c with the following code a Insert main c private variables in a dedicated user code section USER CODE BEGIN PV po PEISQDE Vania lee SELA DODE eee zr FATFS SDFatFs File system object for SD card logical drive FIL MyFile File object const char wtext Hello World const uint8 t imagel bmp 0x42 0x4d 0X36 0x84 0x03 0x00 0x00 0x00 0x00 0x 00 0236 0 00 0x00 0200 0x28 0200 0x00 0x00 0x40 0201 0200 0x00 0520 0200 0200 0200 0201 0200 x18 0x00 0x00 0x00 0x00 0x00 03x00 0x94 0x03 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0z00 Ux00 0x00 0x29 0x74 Dx51 0x06 0x63 0x30 0x04 0x4c 0x1d 0x0EL 0x x56 0x x25 0x11 0x7 9 0x41 0x1lf 0x85 0x6 0x25 0x79 0x7e6 0x27 0x72 0x72 0x0b 0x50 0x43 0x00 0x44 0x15 xOD 0x4D O0Ox r 0x00 0x1a 0x15 0x07 0x50 0x16 0x05 0x54 0x22 0x23 0x70 0x65 0x30 0x82 0x 60 0x02 0x6c 0x36 0x22 0x60 055
159. mmands in the script script lt filename gt file There must be one script myscript txt command per line 7 24 200 DoclD025776 Rev 12 UM1718 3 4 3 Installing and running STM32CubeMX Table 1 Command line summary continued This code generation option allows choosing between 0 for generating the peripheral initializations in the main or 1 for generating each peripheral initialization in dedicated c h files Generate only STM32CubeMX generated code and not a complete project that would include STM32Cube firmware libraries and Toolchains project files To generate a project use project generate project couplefilesbyip lt 0 1 gt generate code path Specify the tool chain to be used for the project Then use the project generate command to generate the project for that tool chain project toolchain lt toolchain gt project name lt name gt project generate exit To run STM32CubeMX plug in from Eclipse 1 2 2 4 3 Launch Eclipse environment Once Eclipse IDE is open click open new perspective Generate the full project End STM32CubeMX process Running STM32CubeMX plug in from Eclipse IDE project couplefilesbyip 1 generate code C mypath project toolchain EWARM project toolchain MDK ARM Va project toolchain MDK ARM V5 project toolchain TrueSTUDIO project toolchain SW4STM32 Specify the path where to project paii pain generate the p
160. mption is higher than the max continuous current 3 mA of the battery selection 7 160 200 DoclD025776 Rev 12 UM1718 Tutorial 3 Using PCC to optimize the embedded application power consumption and Step 6 Sleep DMA ADC RTC e Actions Switch to Lower power sleep mode BAM mode Reduce the operating frequency to 2 MHz e Results The current consumption is reduced from 703 pA to 93 uA see Figure 162 Figure 162 Step 6 optimization r Edit Step Edit Step User choice Hz Clock Configuration Interpolation ranges HSE Clock Source Frequency 16 0 MHz r Optional Settings Step Duration Additional Consumption Results Step Consumption Without Peripherals Peripherals Part Ta Max C 703 2 pA 589 HA 114 2 A A 16 6 pA D 97 6 HA 104 92 Interpolation ranges User choice Hz Clock Configuration Clock Source Frequency OUT1 0UT2 Buffer_OFF M Optional Settings Step Duration Additional Consumption OUT2 Buffer ON Worst cc Results Without Peripherals 93 4 uA Peripherals Part OpA A 0 uA D 0 HA Ta Max C 104 99 OUT1 OUT2 Buffer ON Mi
161. must be disabled to configure a static IP address see Figure 184 184 200 DoclD025776 Rev 12 Ly UM1718 STM32CubeMX C code generation design choices and limitations Figure 184 LwIP configuration LWIP Configuration General ef All LwIP Options ef Debug Configure the below parameters DHCP Options LWWIP_DHCP DHCP Module IP Address Settings P ADDRESS IP Address NETMASK ADDRESS Metmask Address GATEWAY ADDRESS Gateway Address RTOS Settings WITH RTOS Use RTOS Protocols Options LWIP_ICMP CMP Module Activation LWWIP_IGMP IGMP Module LWWIP_DNS DNS Module LIP UDP JDP Module MEMP_NUM_UDP_PCB Number of UDP Conn LWIP DHCP DHCP Module LVWIP_DHCP Diagnostic Dependency Lise LWIP DHCP requires L WIP UDP 1 000 000 000 d0 000 000 000 0 000 000 000 DON Disabled Enabled Disabled Disabled Enabled 4 Enabled Apply Ok Cancel STM32CubeMX generated C code will report compilation errors when specific parameters are enabled disabled by default The user must fix the issues with a stack patch downloaded from Internet or user C code The following parameters generate an error e MEM USE POOLS user C code to be added either in wipopts h or in cc h stack file e PPP SUPPORT PPPOE SUPPORT user C code required e MEMP SEPARATE POOLS with MEMP OVERFLOW CHECK gt 0 a stack patch required e MEM LIBC MALLOC amp RT
162. n Calculator Table 5 Pinout menu Cem e m im ma o wo Undoes last configuration steps one by one Redoes steps that have been undone one by one Opens a window showing the list of all the configured pins together with the name of the signal on the pin and a Label field allowing the user to specify a label name for each pin of the list For this menu to be active at least one pin must have been Pins Signals Configured Options Click the pin icon to pin unpin signals individually Select multiple rows then right click to open contextual menu and select action to pin or unpin all selected signals at once Click column header names to sort alphabetically by name or according to placement on MCU No icon Allows the user to search for a pin name signal name or signal Pinout search label in the Pinout view When it is found the pin or set of pins field that matches the search criteria blinks on the Chip view Click the Chip view to stop blinking Show user Allows showing on the Chip view the user defined labels labels instead of the names of the signals assigned to the pins DoclD025776 Rev 12 43 200 q STM32CubeMX User Interface UM1718 Table 5 Pinout menu continued o em ome N Beni N Clears user pinout configuration in the Pinout window Note that No icon Clear Pinouts this action clears from the configuration window the IPs that have an influence on the pinout No icon Clear Sing
163. n mode 20 in Sleep and 50 in Stop the user must configure a 3 step sequence consisting in 30 ms in Run 20 ms in Sleep and 50 ms in Stop Additional Consumption This field allows entering an additional consumption resulting from specific user configuration e g MCU providing power supply to other connected devices Battery glossary Capacity mAh Amount of energy that can be delivered in a single battery discharge Self discharge 9o month This percentage over a specified period represents the loss of battery capacity when the battery is not used open circuit conditions as a result of internal leakage Nominal voltage V Voltage supplied by a fully charged battery Max Continuous Current mA This current corresponds to the maximum current that can be delivered during the battery lifetime period without damaging the battery Max Pulse Current mA This is the maximum pulse current that can be delivered exceptionally for instance when the application is switched on during the starting phase 7 DoclD025776 Rev 12 UM1718 5 5 1 3 STM32CubeMX C Code generation overview STM32CubeMX C Code generation overview Refer to Section 4 4 2 Project menu for code generation and C project settings related topics Standard STM32Cube code generation During the C code generation process STM32CubeMX performs the following actions 1 If it is missing it downloads the relevant STM32Cube firmware package fro
164. nerated to document user configuration work Rules and limitations C code generation covers only peripheral and middleware initialization It is based on STM32Cube HAL firmware libraries STM32CubeMX configuration files ioc extension can be saved in the same folder when they target pin configuration only but require a dedicated folder when they cover configuration for C code generation 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 DoclD025776 Rev 12 Ly UM1718 3 3 1 3 2 3 2 1 Installing and running STM32CubeMX Installing and running STM32CubeMX System requirements Supported operating systems and architectures e Windows XP 32 bit x86 e Windows 7 32 bit x86 64 bit x64 e Windows 8 32 bit x86 64 bit x64 Memory prerequisites e Recommended minimum RAM 2 Gbytes Software requirements The following software must be installed e Java Run Time Environment for 1 7 0 45 and 1 7 0 80 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 e For Eclipse plug in installation only install one of the following IDE Eclipse IDE Juno 4 2 Eclipse Luna 4 4 Eclipse Kepler 4 3 Eclipse Mars 4 5 Installing uninstalling STM32CubeMX standalone version Installing STM32
165. neration dialog window see Figure 154 This opens the project directly in the IDE Figure 154 C code generation completion message Code Generation 13 In the IDE check that heap and stack sizes are sufficient right click the project name and select Options then select Linker Check Override default to use the icf file from STM32CubeMX generated project folder Adjust the heap and stack sizes see Figure 155 Figure 155 IDE workspace Options for node fatfs sd test Category General Options Static Analysis Runtime Checking C C Compiler Output Converter Linker configuration file Custom Build Build Actions Override default SPROJ DIRS stm321429xx flash icf Debugger st Angel CMSIS DAP Configuration file symbol definitions one per line GDB Server TAR ROM monitor Ijet JTAGjet J4ink J Trace TI Stellaris Macraigor PE micro RDI STINK Third Party Driver TI XDS Linker configuration file editor 3 150 200 DoclD025776 Rev 12 UM1718 Note q Tutorial 2 Example of FatFs on an SD card using STM32429lI EVAL evaluation board When using the MDK ARM toolchain go to the Application MDK ARM folder and double click the startup xx s file to edit and adjust the heap and stack sizes there 14 Goto the Application User folder Double click the main c file and edit it 15 The tutorial consists in creating and writing to a file on the evaluation board SD card using the FatFs file system
166. neric CSV pinout text file to export the pinout configuration into text format e Some basic controls such as insuring blocks of pins consistency are built in See Appendix A STM32CubeMX pin assignment rules for details Figure 43 Chip view File Project Pinout Window Help RO RH E amp j ViKeep current Signals Placement o amp G Find v 4 4 V Show user Label 1 p amp Pinout Clack Configuration Configuration Power Consumption Calculator I Middlewares FATFS FREERTOS Hi LWIP Mode MII FMC 1201 1202 1203 1252 1253 IWDG LIDC RCC RNG RIC A SAn SDIO SPI1 SPI2 SPI3 SPI4 A svs He H E E EH EH EH EB EO EH EH EB EH EH ER EH H9 TIM10 TIM11 TIM12 TIM13 TIM14 UART4 UARTS UARTZ UARTS H USARTI E E BE FH a el A Ol a ale rn o m d QS usus x a Ou ao a fa m amp a a ol oll of a a gt amp amp elg amp s GT amp alal aja ETH_TXD3 HH HI RISIRIPPEPIE TII E l g lg I8 lg zl x xls GIS I8 5 e ie ie ie oO je N jw D O o sl gt o ETH_MDC D g ed to ETH TXD2 ETH Tx Gk ff STM32F439VITx Mor LQFP100 m Iur ETH_CRS ETH RX CLK fj ETH TXD1 ETH TXDO 2 2 EREREREIERE EB lI IE IE ETH MDIO GEI c Ip I l lt l lt D mm m m im m im m
167. ng imported is not the 5s i Import error CAN peripheral does not exist amp Import error ETH peripheral does not exist The Peripheral List indicates The peripheral instances configured in the project to be imported The peripheral instances if any exists for the MCU currently selected to which the configuration has to be imported If several peripheral instances are candidate for the import the user needs to choose one Conflicts might occur when importing a smaller package with less pins or a lower end MCU with less peripheral options Click the Try Import button to check for such 48 200 DoclD025776 Rev 12 Ly UM1718 STM32CubeMX User Interface conflicts the Import Status window and the Peripheral list get refreshed to indicate errors warnings and whether the import has been successful or not Warning icons indicate that the user has selected a peripheral instance more than once and that one of the import requests will not be performed Figure 32 shows an example where the ADC1 instance has been selected twice Across sign indicates that there is a pinout conflict and that the configuration can not be imported as such In Figure 32 the SPI6 instance configuration can not be imported on SPI3 because it conflicts with the previously selected SPI1 configuration The manual import can be used to refine import choices and resolve the issues raised by the import trial Figure 33 shows how to complete the import
168. nout view left panel shows the IP tree and the right pane a graphical representation of the pinout for the selected package e g BGA OFP where each pin is represented with its name e g PC4 and its current alternate function assignment if any 7 DoclD025776 Rev 12 UM1718 STM32CubeMX User Interface SIM32CubeMX offers two ways to configure the microcontroller e From the IP tree by clicking the peripheral names and selecting the operating modes see Section 4 11 1 IP tree pane e For advanced users by clicking a pin on the Chip view to manually map it to a peripheral function see Section 4 11 2 Chip view In addition selecting Pinout Set unused GPIOs allows configuring in one shot several unused pins in a given GPIO mode Note The Pinout view is automatically refreshed to display the resulting pinout configuration Pinout relevant menus and shortcuts are available when the Pinout view is active see the menu dedicated sections for details on the Pinout menus Figure 42 STM32CubeMX Pinout view e X Project iach STMZFASNTTS File Project naut Window Help BEURS F Ecierral BRAN ED Card LB nr fat Lisa sche fireced 3 9 pANI 4 9 GANZ Ec DAD 9 OUT Configuration MT OUT Curficuratinn Exterral Trigger gh OC Fi 8 DMAGE En ETH Mock MI ER n M 3 58 TEER FR KA ET 3 5 Dx fo Ta Mode Ful Dupdex Master STM32F439VITx L E Master Clock Cuiput m dx cis voe LQFP100 jo qwmG EE
169. o not exit the device from VBAT operation Increasing Vpp to reach the minimum threshold does STM32LO series STM32L0 microcontrollers feature up to 8 power modes including 7 low power modes to achieve the best compromise between low power consumption short startup time and available wakeup sources e Run mode This mode offers the highest performance using HSE HSI clock sources The CPU can run up to 32 MHz and the voltage regulator is enabled e Sleep mode This mode uses HSE or HSI as system clock sources The voltage regulator is enabled and only the CPU is stopped All peripherals continue to operate and can wake up the CPU when an interrupt event occurs e Low power run mode This mode uses the internal regulator in low power mode and the multispeed internal MSI RC oscillator set to the minimum clock frequency 131 kHz In Low power run mode the clock frequency and the number of enabled peripherals are both limited e Low power sleep mode This mode is achieved by entering Sleep mode with the internal voltage regulator in low power mode Both the clock frequency and the number of enabled peripherals are limited Event or interrupt can revert the system to Run mode with regulator on e Stop mode with RTC The Stop mode achieves the lowest power consumption with while retaining the RAM register contents and real time clock The voltage regulator is in low power mode LSE or LSI is still running All clocks in the VeoRE domain are
170. ock maximum frequency Clock Configuration value Displayed in blue to indicate maximum possible value Table 14 gives the relations between power over drive mode and HCLK frequency Table 14 Relations between power over drive and HCLK frequency HCLK frequency range Vpp gt 2 1 V required to enable power over drive POD Scale 3 120 MH Corresponding voltage scaling and power over drive POD Scale 2 120 to 14 MH Scale 1 when POD is disabled 144 to 168 MH POD must be enabled 168 to 180 MHz Scale 1 otherwise frequency range not supported 7 92 200 DoclD025776 Rev 12 UM1718 4 13 4 4 14 3 STM32CubeMX User Interface Clock tree glossary Table 15 Glossary High Speed Internal oscillator enabled after reset lower accuracy than HSI HSE High Speed External oscillator requires an external clock circuit Phase Locked Loop used to multiply above clock sources Low Speed Internal clock low power clocks usually used for watchdog timers Power Consumption Calculator PCC view For an ever growing number of embedded systems applications power consumption is a major concern To help minimizing it STM32CubeMX offers the Power Consumption Calculator PCC tab see Figure 74 which given a microcontroller a battery model and a user defined power sequence provides the following results e Average current consumption Power consumption values can either be taken from the datasheet or interpola
171. ock tree default settings by using the toolbar Reset button This feature reloads STM32CubeMX default clock tree configuration e Undo Redo user configuration steps by using the toolbar Undo Redo buttons e Detect and resolve configuration issues Erroneous clock tree configurations are detected prior to code generation Errors are highlighted in red and the Clock Configuration view is marked with a red cross see Figure 71 Issues can be resolved manually or automatically by clicking the Resolve Clock Issue button which is enabled only if issues have been detected The underlying resolution process follows a specific sequence a Setting HSE frequency to its maximum value optional b Setting HCLK frequency then peripheral frequencies to a maximum or minimum value optional c Changing multiplexers inputs optional d Finally iterating through multiplier dividers values to fix the issue The clock tree is cleared from red highlights if a solution is found Otherwise an error message is displayed Note To be available from the clock tree external clocks 12S input clock and master clocks shall be enabled in RCC configuration in the Pinout view This information is also available as tooltips 86 200 DoclD025776 Rev 12 Ly UM1718 3 STM32CubeMX User Interface The tool will automatically perform the following operations e Adjust bus frequencies timers peripherals and master output clocks accor
172. on configured pins are shown in gray default state When a signal assignment corresponds to a peripheral mode without ambiguity the pin color switches to green When the signal assignment does not correspond to a valid peripheral mode configuration the pin is shown in orange Additional pins need to be configured to achieve a valid mode configuration RCC OSC32 IM When a signal assignment corresponds to a peripheral mode without ambiguity the pins are shown in green Lace SD As an example assigning the PF2 pin to the I2C2 SMBA signal matches 2C2 SCL to I2C2 mode without ambiguity and STM32CubeMX configures DO MAA automatically the other pins PFO and PF1 to complete the pin mode i configuration Tooltips Move the mouse over IPs and IP modes that are unavailable or partially available to display the tooltips describing the source of the conflict that is which pins are being used by which peripherals As an example see Figure 44 the Ethernet ETH peripheral is no longer available because there is no possible mode configuration left A tooltip indicates to which signal are assigned the pins required for this mode ADC1 INO signal USART3 synchronous signal etc Figure 44 Red highlights and tooltip example no mode configuration available ETH HB ooie FMC DEI Mode Conflict with pc pc ADC3 INO or and 202 Active only when TIM2 has enabled the Pulse Per Second Output or and HE visable ADC1 IN1 or
173. oo or ook Sarah ee oo oo KERSE ee oe ow ye be Rg hs 42 4 4 2 Project menu ESE EE SE eee ees 42 4 4 3 Pinout Menu io si G9 a ener ore ke Ody el noe eie dad ee ee eee Sea 43 4 4 4 Window MCN RE NE EE 65506 be Gu dew Gees ee SS 44 4 4 5 ud RE ER RE EE OR Bk eae FEE oe 45 MCUs selection window EES SE SE ee ee ee 45 Import Project window EES SE SE SS SE ee 46 oet unused Reset used GPIOs windows llus 51 Project Settings Window ees 54 Update Manager Windows llle 57 ADOULVVINOOW OR OE EE EN AE doirte EE N N eai 58 Pinout view 1 ee eee eee 58 4 11 1 IP tree pane SE SE ES SE IRR 60 4 11 2 GCHIDWEW se ss ses 4n 993 319 r3 9939 EORR RUE RACE RUE ARR OUR SLE Roh 3 d 61 4 11 3 Chip view advanced actions llle 64 4 11 4 Keep Current Signals Placement ESE ES EE SE SE Se ee 66 4 11 6 Pinning and labeling signals on pins EES ES ES ES cee eee 67 Configuration view EES ES SE SS ee eee ees 68 4 12 1 IP and Middleware Configuration window 70 4 12 2 User Constants configuration window SESSE SE SE eee eee 72 4 12 3 GPIO Configuration window SE SE ES ees 78 4 12 4 DMA Configuration window 0 0 0 ees 80 4 12 5 NVIC Configuration window 0 0 ee eee 83 Clock tree configuration view ES ES a ee 85 4 13 1 Clock tree configuration functions 0 0 0 0 eee ee 85
174. opment see Appendix E STM32Cube embedded software packages for details on STM32Cube embedded software offer Although STM32CubeMX offers a user interface and generates a C code compliant with STM32 MCU design and firmware solutions it is recommended to refer to the product technical documentation for details on actual implementation of microcontroller peripherals and firmware Reference documents The following documents are available from http www st corm e STM32 microcontroller reference manuals e STM32 microcontroller datasheets e SIMS32Cube HAL driver user manuals for STM32F0 UM1785 STM32F1 UM1850 STM32F2 UM1940 STM32F3 UM1786 STM32F4 UM1725 STM32F7 UM1905 STM32L0 UM1749 STM32L1 UM1816 and STM32L4 UM1884 e M SIMA December 2015 DoclID025776 Rev 12 1 200 www st com Contents UM1718 Contents 1 STM32Cube overview 0 00 cee eee 12 2 Getting started with STM32CubeMX ss eee 13 2 1 il ele ER EE OE Cees dee ee beg eee bw ee see Y 13 2 2 ENE PA od shag ee ooh EE RE ER EE ON peas eens 15 2 3 Rules and limitations a na naaa EE ES eens 16 3 Installing and running STM32CubeMX ss Re 17 3 1 System requirements SS SE SE SE ee eee 17 3 1 1 Supported operating systems and architectures 17 3 1 2 Memory prerequisites SS SS SE SE ee eee 17 3 1 3 Software requirements SS ES ES SE SS ee ee 17 3 2 Installing uninstal
175. or not on the toolbar STM32CubeMX conflict solver will be able to move or not the GPIO signals to other unused GPIOs When Keep Current Signals Placement is off unchecked STM32CubeMX conflict solver can move the GPIO signals to unused pins in order to fit in another peripheral mode When Keep Current Signals Placement is on checked GPIO signals will not be moved and the number of possible peripheral modes becomes limited Refer to Figure 36 and Figure 37 and check the limitation in available peripheral modes Figure 35 Reset used pins window Reset used GPIOs a Number of GPIOs Cancel 52 200 DoclD025776 Rev 12 Ly UM1718 Figure 36 Set unused GPIO pins with Keep Current Signals Placement checked AX Untitle File Project Pinout Window Help STM32CubeMX User Interface Bou Pinout onfiguration Middlewares i FATFS FREERTOS Eh HPs E A ADC1 ADC2 EE ADC3 H CANL E 9 CAN2 H Q DAC EE DCMI DMA2D H O ETH i FMC Be 1201 H Q 1202 H 1203 Q 1252 H 1283 H IWDG EO LTDC dar H 9 RNG DA RTC SAIL H SDIO H9 SPIL H SPI2 i SPI3 EQ SPI4 HA sys HA TIM1 EA TIM2 H TIM3 E TIM4 EA TIMS TIM6 H TIMZ H A TIM EA TIMS H TIM10 H S TIM11 H A TIM12 H TIM13 H TIM14 H S UART4 cH UARTS H Q UART H UARTS USART1 H USART2 vs 4 4 M Show user Label 7 p GPIO_Input
176. ort Project Imported Project C 1STM32CubeMX User ManuallMX v4 12 Import IOCM4 demo ioc Import MX Settings Import PCC Settings C Import Project Settings Import Pinout Clock Configuration Configuration Settings 3 Automatic Import Manual Import M Import Pinning Status Import Peripherals Configuration Peripheral List Ed Hone apa L mpribADI E import to ADC1 RCC SPIS F Show View Pinout Import Status Importing IP configurations Import project completed Import Try Importing Pinout Importing IP configurations Import project completed 3 Choose OK to import with the current status or Cancel to go back to the empty project without importing Upon import the Import icon gets grayed since the MCU is now configured and it is no more possible to import a non empty configuration 4 7 Set unused Reset used GPIOs windows These windows allow configuring several pins at a time in the same GPIO mode To open them e Select Pinout gt Set unused GPIOs from the STM32CubeMX menu bar Note The user selects the number of GPIOs and lets STM32CubeMX choose the actual pins to be configured or reset among the available ones q DoclD025776 Rev 12 51 200 STM32CubeMX User Interface UM1718 Figure 34 Set unused pins window e Select Pinout Reset used GPIOs from the STM32CubeMX menu bar Depending whether the Keep Current Signals Placement option is checked
177. out Import Status Loading C XBUCKETSXSTM32CubeMX User ManualMMX v4 12 user quide updates Import IO Import Analysis C XBUCKETSXASTM32CubeMX User Manual MX v4 12 user guide updates Ir A The Mcu SIM32F4271GHx found in the Project being imported is not the same tha LX Import error CAN1 peripheral does not exist t Import error ETH peripheral does not exist b Manual project import In this case checkboxes allow to manually select the set of peripherals see Figure 31 Select the Try Import option to attempt importing DoclD025776 Rev 12 47 200 STM32CubeMX User Interface UM1718 Figure 31 Manual project import e impos Project Imported Project CrISTM32CubeMX User Manual MX v4 12 Import IOCY4 demo ioc Import MX Settings Import PCC Settings Import Project Settings maa Pinout Clock Configuration Configuration Settings Automatic Import Manual Import Import Pinning Status Import Peripherals Configuration Peripheral List From STM32F427IGHx To STM32F40 1CBUx ETH None CANT Nene AD WE ADC2 limparttaADE1 o EI LLL B V importto SPI2 0 0 050 055 5 5 V importto SPI3 V impertto SPI3 000 00000 Try Import Show View Pinout Import Status Loading C BUCKETS STIM32 CubeMX User Manual Me v4 12 user guide updates Im Import Analysis C XBUCKETSXSTM32CubeMX User Manual ME v4 12 user guide upc r Ihe Meu 5IM32F4271GHx found in the Project bei
178. ow If the installation was performed using STM32CubeMNX all the packages available for download are displayed along with their version including the version currently installed on the user PC if any and the latest version available from http www st com If no Internet access is available at that time choose Local File Then browse to select the zip file of the desired STM32Cube firmware package that has been previously downloaded from st com An integrity check is performed on the file to ensure that it is fully supported by STM32CubeMX The package is marked in green when the version installed matches the latest version available from hitp www st com 2 Click the checkbox to select a package then Install Now to start the download oee Figure 16 for an example DoclD025776 Rev 12 31 200 q Installing and running STM32CubeMX UM1718 Figure 16 New library Manager window New Libraries Manager All Softwares and Firmwares Releases y Releases Information was last checked 4 days ago Sel Description Installed Version Available Version STM32CubeMX Releases Software to configure and manage STM32 MCUs STM32CubeF7 Releases Firmware Package for Family STM32F7 Firmware Package for Family STM32F7 STM32CubeF4 Releases Firmware Package for Family STM32F4 Firmware Package for Family STM32F4 Firmware Package for Family STM32F4 Firmware Package for Family STM32F4 NEN Firmware Package for Family S
179. ow CS SDA To o Pep endnes hem TERT PB10 PB11 Configuration GPIO mode GPIO Pull up Pull down Pul up Maximum output speed User Label GPIO Speed Group By IP 4 12 4 DMA Configuration window Click DMA in the Configuration pane to open the DMA configuration window This window allows to configure the generic DMA controllers available on the MCU The DMA interfaces allow to perform data transfers between memories and peripherals while the CPU is running and memory to memory transfers if supported Note Some IPs such as USB or Ethernet have their own DMA controller which is enabled by default or via the IP configuration window Clicking Add in the DMA configuration window adds a new line at the end of the DMA configuration window with a combo box proposing to choose between possible DMA requests to be mapped to peripherals signals see Figure 66 7 80 200 DoclD025776 Rev 12 UM1718 STM32CubeMX User Interface Figure 66 Adding a new DMA request DMA Configuration DMA Request Stream Direction Priority Peripheral Memory DMA Request Settings Mode Normal Increment Address Use Fifo Threshold Qne Quarter Full Data Width Burst Size Selecting a DMA request automatically assigns a stream among all the streams available a direction and a priority When the DMA channel is configured it is up to the application code to fully describe the DMA transfer run time parameters such as the start address etc
180. ower consumption and more Figure 156 Power Consumption Calculation example STM32CubeMX Sequencel ioc STM32L476RGTx NUCLEO L476RG File Project Power Window Help GERUG S ve apis Pinout Clock Configuration Configuration Power Consumption Calculator Microcontroller Selected load save Deaete comme _ Series STM32L4 Line STM32L4x6 MCU STM32L476RGTx Datasheet 025976 Rev3 CPU Bus Clock Config SrcFreq Peripherals Add Curr Step Curr Duration 24 0 MHz SE 24 0 MHz ADC1 fs 1 0 mA 9 29 mA EET STANDBY 24 NoRange omz 37 0 KHz Ambient Temperature C 25 Vdd Power Supply V 2 4 X FLASH ART C 37 0 kHz RTC Battery Li MnO2 CR2032 In Series 15 In Parallel 1 Delete Duplicate Up Down Undo Capacity Self Discharge Nominal Voltage Consumption Profile by Step Max Cont Current Max Pulse Current Consumption mA RUN 5 RUN 3 WU_aPROM_STANDBY 11 STANDBY N 4 5 5 0 Dia Time ms Idd by Step Average Current Results Summary Sequence Time TaMax 9ms 104 0 C Average Consumption 2 01 mA Battery Life Estimation 4 days amp 15 hours Battery compatibility not garanteed with defined step s Average DMIPS 22 0 DMIPS 156 200 DoclD025776 Rev 12 Ly UM1718 Tutorial 3 Using PCC to optimize the embedded application power consumption and F
181. ows Control panel 2 Select Programs and Features to display the list of programs installed on your computer 3 Right click on STM32CubeMX and select the uninstall function 3 3 Installing STM32CubeMX plug in version STM32CubeMX plug in can be installed within Eclipse IDE development tool chain Installation related procedures are described in this section 3 3 1 Downloading STM32CubeMX plug in installation package To download STM32CubeMX plug in follow the sequence below 1 Go to http www st com stm32cube 2 Download STM32CubeMX Eclipse plug in zip file to your local disk 7 20 200 DoclD025776 Rev 12 UM1718 Installing and running STM32CubeMX 3 3 2 Installing STM32CubeMX as an Eclipse IDE plug in To install STM32CubeMX as an Eclipse IDE plug in follow the sequence below 1 2 pr oe oS DN M Launch the Eclipse environment Select Help Install New Software from the main menu bar The Available Software window appears Click Add The Add Repository window opens Click Archive The Repository archive browser opens oelect the STM32CubeMX Eclipse plug in zip file that you downloaded and click Open see Figure 5 Click OK in the Add Repository dialog box Check STM32CubeMX Eclipse plug in and click Next see Figure 6 Click Next in the Install Details dialog box Click accept the terms of the license agreement in the Review Licenses dialog box and then click Finish Click OK in the Sec
182. p is triggered by an event or an interrupt the system returns to the Run mode with the regulator ON e Stop mode This mode achieves the lowest power consumption while retaining RAM and register contents Clocks are stopped The real time clock RTC an be backed up by using LSE LSI at 32 kHz 37 kHz The number of enabled peripherals is limited The voltage regulator is in low power mode The device can be woken up from Stop mode by any of the EXTI lines e Standby mode This mode achieves the lowest power consumption The internal voltage regulator is switched off so that the entire Vcogg domain is powered off Clocks are stopped and the real time clock RTC can be preserved up by using LSE LSI at 32 kHz 37 kHz DoclD025776 Rev 12 Ly UM1718 Note D 1 2 3 STM32 microcontrollers power consumption parameters RAM and register contents are lost except for the registers in the Standby circuitry The number of enabled peripherals is even more limited than in Stop mode The device exits Standby mode upon reset rising edge on one of the three WKUP pins or if an RTC event occurs if the RTC is ON When exiting Stop or Standby modes to enter the Run mode STM32L1 MCUs go through a state where the MSI oscillator is used as clock source This transition can have a significant impact on the global power consumption For this reason STM32CubeMX PCC introduces two transition steps WU FROM STOP and WU_FROM_STANDBY During these steps
183. rent Signals Placement unchecked 54 Project Settings window ss 0c ee Es RR RR RR ks RE ee eg 55 siese die ol e cia ace NE ER OH Ge a EE NE ER OE SET N HE N 56 Project Settings Code Generator 0 SES SS SE SS eee eee 56 POOUIWINOOW N chance ek eee eee hed ON ER EE OE eo FEE N 58 STM32CubeMX Pinout view ss SE ES SE SE SE ee eee ees 59 Ceu ERENS OE EE eel eee eel Share eres E 61 Red highlights and tooltip example no mode configuration available 63 Orange highlight and tooltip example some configurations unavailable 64 DoclD025776 Rev 12 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 Ky List of figures Tooltip example all configurations unavailable eee 64 Modifying pin assignments from the Chip vieW 0 0 0 ccc eee ee 64 Example of remapping in case of block of pins consistency 20005 65 Pins Signals Options WiINdOW SESSE SE SS
184. ripheral mode e Rule 4 Block remapping only for STM32F 10x e Rule 5 Function remapping e Rule 6 Block shifting only for STM32F 10x e Rule 7 Setting or clearing a peripheral mode e Rule 8 Mapping a function individually if Keep Current Placement is unchecked e Rule 9 GPIO signals mapping A 1 Block consistency When setting a pin signal provided there is no ambiguity about the corresponding peripheral mode all the pins signals required for this mode are mapped and pins are shown in green otherwise the configured pin is shown in orange When clearing a pin signal all the pins signals required for this mode are unmapped simultaneously and the pins turn back to gray Example of block mapping with a STM32F107x MCU If the user assigns I2C1 SMBA function to PB5 then STM32CubeMX configures pins and modes as follows e 2C1 SCL and l2C1 SDA signals are mapped to the PB6 and PB pins respectively see Figure 171 e 2C1 peripheral mode is set to SMBus Alert mode Ly DoclD025776 Rev 12 169 200 STM32CubeMX pin assignment rules UM1718 Figure 171 Block mapping File Project Pinout Window Help R E amp d G Keep current Signals Placement 3 S Find Pinout B 9 Ici Mode Half Duplex Slave Master Clock Output 6 9 IWDG amp RCC RIC amp SPIi Hardware NSS Signal 6 SPI3 6 SYS 6 TIM1 6 TIM2 TIM3 TIM4 TIM5 TIM6 STM32F107VBTx LQF
185. roject project path C Cube ccmram project generate exit Select STM32CubeMX to open STM32CubeMX as a perspective see Figure 9 STM32CubeMX perspective opens see Figure 10 Enter STM32CubeMX user interface via the Welcome menus DoclD025776 Rev 12 25 200 Installing and running STM32CubeMX Figure 9 Opening Eclipse plug in Open Perspective Ec C C default la CVS Repository Exploring Debug 3 GDB Trace Ia Git Repository Exploring VW LTTng Kernel Planning ZARemote System Explorer lf Resource STM32CubeMX amp P Team Synchronizing Em Tracing Figure 10 STM32CubeMX perspective STM32CubeMX Eclipse File Edit Navigate Search Project Run Window Help Eu GOLF ve o v gt Quick Access STM32CubeMX File Project Window Help UM1718 ES Facsc s STM32CubeMX mL noWwwuw g v New Project Load Project Help 26 200 DoclD025776 Rev 12 7 UM1718 3 9 q Installing and running STM32CubeMX Getting STM32Cube updates STM32CubeMX implements a mechanism to access the internet and to e Perform self updates of STM32CubeMX and of the STM32Cube firmware packages installed on the user computer e Download new firmware packages and patches Installation and update related sub menus are available under the Help menu Off line updates can also be performed on computers without internet access see Figure 16 This is done by browsing the filesystem
186. rts in dedicated windows see Figure 89 Right click on the chart to access the contextual menus Properties Copy Save as png picture file Print Zoom menus and Auto Range to reset to the original view before zoom operations Zooming can also be achieved by mouse selecting from left to right a zone in the chart and Zoom reset by clicking the chart and dragging the mouse to the left 106 200 DoclD025776 Rev 12 Ly UM1718 STM32CubeMX User Interface Figure 89 Power Consumption Peripherals Consumption Chart amp Current Sequence MCU Settings Results Summary STM32L053C8Tx Sequence Time Ta Max 7 ms f 104 42 C 3 0V Average Consumption 1 33 mA 025844 Rev4 Average DMIPS 6 52 DMIPS Alkaline AA LR amp Battery Life Estimation 8 months 20 days amp 9 hours Rang s Clock SrcF Perip FT Dura DMIPS Volta TaMax Cate ve FLASH 10000 SI j saue 104 97 Rm ao ange RASH se FE Bome Oma rama jme 75 her 0479 Pas SEEP 50 Range FLASH SOM HS Bowie Om opa ims 7 6 Battery 10494 ates RUN B 0 hange FLASH 4 2MHz MSI amp 2MHr ADCC Oma L 4mA ims 3 99 Battery 104 73 Datas STOP 30 Notangelnis Hz Wa elons m papa ims joo Battery 105 Datas Activated Peripherals Consumption All Peripherals Current Consumption HA 100 150 200 250 300 350 400 450 500 550 600 650 Foo 750 Uo EE m a eno LiB au zu e IE vlg slee n s O OO r ca
187. ry E 512 Kbytes of Flash memory F 68 Kbytes of Flash memory G 1024 Kbytes of Flash memory 2048 Kbytes of Flash memory Packages B SDIP H BGA DoclD025776 Rev 12 Ly UM1718 STM32 microcontrollers naming conventions M SO P TSSOP T LQFP U VFQFPN Y WLCSP Figure 185 shows an example of STM32 microcontroller part numbering scheme Figure 185 STM32 microcontroller part numbering scheme Example SIM32 F 439V T 6 Device family STM32 ARM based 32 bit microcontroller Product type F general purpose Device subfamily 437 STM32F437xx USB OTG FS HS camera interface Ethemet cryptographic acceleration 439 STM32F439xx USB OTG FS HS camera interface Ethemet LCD TFT cryptographic acceleration Pin count V 100 pins Z 144 pins A 169 pins 176 pins B 208 pins N 216 pins Flash memory size G 1024 Kbytes of Flash memory 2048 Kbytes of Flash memory Package T LOFP H BGA Y WLCSP Temperature range 6 Industrial temperature range 40 to 85 C T Industrial temperature range 40 to 105 C Options XXX programmed parts TR tape and reel DoclD025776 Rev 12 187 200 q STM32 microcontrollers power consumption parameters UM1718 Appendix D STM32 microcontrollers power consumption D 1 D 1 1 188 200 parameters This section provides an overview on how to use STM32CubeMX Power Consumption Calculator PCC
188. ry 196 200 Table UM1718 16 Document revision history continued eae even awe Added support for STM32CubeL1 series in cover page Section 2 2 Key features Section 2 3 Rules and limitations Updated Section 3 2 3 Uninstalling S TM32CubeMX standalone version Added off line updates in Section 3 5 Getting STM32Cube updates modified Figure 16 New library Manager window and Section 3 5 2 Downloading new libraries Updated Section 4 STM32CubeMX User Interface introduction Table 2 Welcome page shortcuts and Section 4 2 New project window Added Figure 22 New Project window board selector Updated Figure 40 Project Settings Code Generator Modified step 3 in Section 4 8 Project Settings Window Updated Figure 39 STM32CubeMX Configuration view STM32F1 series Added STM32L1 in Section 4 12 1 IP and Middleware Configuration window Updated Figure 62 GPIO Configuration window GPIO selection Section 4 12 3 GPIO Configuration window and Figure 68 DMA MemToMem configuration Updated introduction of Section 4 13 Clock tree configuration view Updated Section 4 13 1 Clock tree configuration functions and Section 4 13 2 Recommendations Section 4 14 Power Consumption Calculator PCC view Figure 82 Power consumption sequence new step default view Figure 86 Power Consumption Calculator view after sequence building Figure 83 Power consumption sequence new step configured STM32F4 example an
189. s Function Push Pull No pull up and no pull down PCIO Do pz Mense Funcion Pash Pues pulup andro padom gh PCI EDIo D3 Alternate Funcion Push Pul No pulup andno pulldown fi EE cur poro cr iese Funcion Push PA No pul eet ee ER PD2 DIO CMD Alternate Function Push Pull No pul up and no pul down Hd O Select Pins from table to configure them Multiple selection is Allowed 4 12 1 IP and Middleware Configuration window This window is open by clicking the IP instance or Middleware name from the Configuration pane It allows to configure the functional parameters that are required for initializing the IP or the middleware in the selected operating mode This configuration is used to generate the corresponding initialization C code Refer to Figure 52 for an IP Configuration windows example The configuration window includes several tabs e Parameter settings to configure library dedicated parameters for the selected peripheral or middleware e NVIC GPIO and DMA settings to set the parameters for the selected peripheral see Section 4 12 5 NVIC Configuration window Section 4 12 3 GPIO Configuration window and Section 4 12 4 DMA Configuration windowfor configuration details e User constants to create one or several user defined constants common to the whole project see Section 4 12 1 IP and Middleware Configuration window for user constants details Invalid settings are detected and are either Reset to minimum
190. s using two instances of USB hosts or several RAM disks 7 DoclD025776 Rev 12 UM1718 STM32CubeMX C code generation design choices and limitations NOR and NAND Flash memory are not supported In this case the user shall select the FatFs user defined mode and update the user_diskio c driver file generated to implement the interface between the middleware and the selected peripheral B 3 5 FreeRTOS FreeRTOS configuration is available in FreeRTOSConfig h generated file When FreeRTOS is enabled all other selected middleware modes e g LwIP FatFs USB will be initialized within the same FreeRTOS thread in the main c file When GENERATE RUN TIME STATS CHECK FOR STACK OVERFLOW USE IDLE HOOK USE TICK HOOK and USE MALLOC FAILED HOOK parameters are activated STM32CubeMX generates freertos c file with empty functions that the user shall implement This is highlighted by the tooltip see Figure 182 Figure 182 FreeRTOS HOOK functions to be completed by user FREERTOS Configuration Hook function related definitions USE IDLE HOOK Disabled USE MALLOC FAILED HOOK Disabled CHECK FOR STACK OVERFLOW Disabled Run time and task stats gathering related def USE TRACE FACILITY GENERATE RUN TIME STATS Co routine related definitions USE CO ROUTINES MAX CO ROUTINE PRIORITIES USE TICK HOOK configUSE TICK HOOK Parameter Description The tick hook function is a hook or callback function that if defined and configur
191. sa TOG Configuration and Initialization Files Generated C Code SE EE lc Iwip c lc main c lc stm32f4xx_hal_msp c lc usb_host c C usbh_conf c STM32 MCU Configuration using STM32CubeMX ethernetif h Iwip h Iwipopts h Iwippools h stm32f4xx hal conf h usb host h usbh conf h 14 200 DoclD025776 Rev 12 Ly UM1718 2 2 3 Getting started with STM32CubeMX 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 projects come in two flavors MCU configuration only ioc file can be saved anywhere MCU configuration with C code generation in this case ioc files are saved in a project dedicated folder along with the generated source C code 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
192. scaling Optionally further adjust the system and peripheral clocks using PLL prescalers and multipliers Other clock sources independent from the system clock can be configured as follows USB OTG FS Random Number Generator and SDIO clocks are driven by an independent output of the PLL 2S peripherals come with their own internal clock PLLI2S alternatively derived by an independent external clock source USB OTG HS and Ethernet Clocks are derived from an external source 4 Optionally configure the prescaler for the Microcontroller Clock Output MCO pins that allow to output two clocks to the external circuit 5 Click H to save the project 6 Goto the Configuration tab to proceed with the project configuration Configuring the MCU initialization parameters Reminder The C code generated by STM32CubeMX covers the initialization of the MCU peripherals and middlewares using the STM32Cube firmware libraries Initial conditions Select the Configuration tab to display the configuration view see Figure 114 Peripherals and middleware modes without influence on the pinout can be disabled or enabled in the IP Tree panel The modes that impact the pin assignments can only be selected through the Pinout tab In the main panel tooltips and warning messages are displayed when peripherals are not properly configured see Section 4 STM32CubeMX User Interface for details The RCC peripheral initialization will use
193. spectively USB middleware is used the initialization C code for the underlying Ethernet respectively USB IP is moved from main c to LwIP respectively USB initialization C code itself mxconstants h file This file contains the define statements corresponding to the pin labels set from the Pinout tab as well as the user project constants added from the Configuration tab refer to Figure 92 and Figure 93 for examples define MyTimeOut 10 define LD4 Pin GPIO PIN 12 define LD4 GPIO Port GPIOD define LD3 Pin GPIO PIN 13 define LD3 GPIO Port GPIOD define LD5 Pin GPIO_PIN_14 define LD5 GPIO Port GPIOD define LD6 Pin GPIO PIN 15 DoclD025776 Rev 12 111 200 STM32CubeMX C Code generation overview UM1718 112 200 define LD6 GPIO Port GPIOD Figure 92 Labels for pins generating define statements QJ Parameter Settings User Constants a f NVIC Settings GPIO Settings Search Constants In case of duplicate labels a unique suffix consisting of the pin port letter and the pin index number is added and used for the generation of the associated define statements In the example of a duplicate I2C1 labels shown in Figure 94 the code generation produces the following code keeping the I2C1 label on the original port B pin 6 define statements and adding B7 suffix on pin 7 define statements define I2C1 Pin GPIO PIN 6 define I2C1 GPIO Port GPIOB define I2C1B7 Pin GPIO PIN 7
194. stopped the PLL MSI RC HSE crystal and HSI RC oscillators are disabled some peripherals featuring wakeup capability can enable the HSI RC during Stop mode to detect their wakeup condition The device can be woken up from Stop mode by any of the EXTI line in 3 5 us and the processor can serve the interrupt or resume the code e Stop mode without RTC This mode is identical to Stop mode with RTC except for the RTC clock which is stopped here e Standby mode with RTC The Standby mode achieves the lowest power consumption with the real time clock running The internal voltage regulator is switched off so that the entire VeoRE domain DoclD025776 Rev 12 Ly UM1718 Note D 2 D 2 1 STM32 microcontrollers power consumption parameters is powered off The PLL MSI RC HSE crystal and HSI RC oscillators are also switched off The LSE or LSI is still running After entering Standby mode the RAM and register contents are lost except for registers in the Standby circuitry wakeup logic IWDG RTC LSI LSE Crystal 32 KHz oscillator RCC_CSR register The device exits Standby mode in 60 us when an external reset NRST pin an IWDG reset a rising edge on one of the three WKUP pins RTC alarm Alarm A or Alarm B RTC tamper event RTC timestamp event or RTC Wakeup event occurs e Standby mode without RTC This mode is identical to Standby mode with RTC except that the RTC LSE and LSI clocks are stopped The device ex
195. sumption 1 0 Results Without Peripherals 232 HA Peripherals Part 2 2uA A OHA D 2 2 pA N Ta Max O 104 97 Warnings Warni 164 200 DoclD025776 Rev 12 3 UM1718 Tutorial 3 Using PCC to optimize the embedded application power consumption and see Figure 166 for the sequence overall results 7 ms duration about 2 month battery life and an average current consumption of 165 25 HA Use the compare button to compare the current results to the original ones saved as SequenceOne pcs Figure 166 PCC Sequence results after optimizations Results Charts Consumption Profile by Step 2 25 2 00 V gam ROM STANDBY Le 1 50 8 WU FROM STOP1 HE E LI 1 00 0 75 0 50 5 LOWPOWER_RUN Consumption mA 11 STANDBY pu d LI IE 0 00 0 0 0 5 1 0 l5 2 0 2 5 3 0 ELE 4 0 4 5 5 0 55 6 0 6 5 7 0 75 Time ms jdd by Step Average Current Results Summary Sequence Time Ta Max fms 104 77 C Average Consumption 155 62 DA Battery Life Estimation 2 months amp 2 hours Average DMIPS 2 46 DMIF q DoclD025776 Rev 12 165 200 FAQ 9 1 9 2 9 3 9 4 Note 166 200 UM1718 FAQ On the Pinout configuration pane why does STM32CubeMX move some functions when add a new peripheral mode You may have unselected Keep Current Signals Place
196. t root folder with corresponding custom generated files e EE EE TEE GO dJi Custom Code project CustomCodeGen gt X E Search Cus P Organize Include in library Share with Burn New folder HE 4 CustomCodeGen Name p i Drivers J i i Drivers nc I dJ Mylnc di Inc i MylInc gt ie Projects J Projects A Src Sre E a mxproject CustomCodeGen ioc Organize Include in library Share with 4 STM32CubeMX 4 6 mm 4 db Inc h ftl EE iL s extra Gr gt meu gt IM plugins D di templates i help 3 116 200 DoclD025776 Rev 12 UM1718 STM32CubeMX C Code generation overview Figure 99 Custom folder with corresponding custom generated files 4 E Mar Ue customCodesen mine Tel Search ne P Organize Include in library Share with Bum gt a di CustomCodeGen DoclD025776 Rev 12 117 200 q Tutorial 1 From pinout to project C code generation using an STM32F4 MCU UM1718 6 Tutorial 1 From pinout to project C code generation using an STM32F4 MCU This section describes the configuration and C code generation process It takes as an example a simple LED toggling application running on the STM32F4DISCOVERY board 6 1 Creating a new STM32CubeMX Project 1 MCU Selector MCU Filters series E STM32F4 Select File gt New project from the main menu bar or New project from the Welcome page Select the MCU Selector tab and filter
197. ted from a user specified bus or core frequency e Battery life e Average DMIPs DMIPs values are directly taken from the MCU datasheet and are neither interpolated nor extrapolated e Maximum ambient temperature TAMAX According to the chip internal power consumption the package type and a maximum junction temperature of 105 C the tool computes the maximum ambient temperature to ensure good operating conditions Current Tamax implementation does not account for VO consumption For an accurate Tamax estimate I O consumption must be specified using the Additional Consumption field The formula for VO dynamic current consumption is specified in the microcontroller datasheet DoclD025776 Rev 12 93 200 STM32CubeMX User Interface UM1718 4 14 1 The PCC view allows developers to visualize an estimate of the embedded application consumption and lower it further at each PCC power sequence step e Make use of low power modes when any available e Adjust clock sources and frequencies based on the step requirements e Enable the peripherals necessary for each phase For each step the user can choose VBUS as possible power source instead of the battery This will impact the battery life estimation If power consumption measurements are available at different voltage levels STM32CubeMX will also propose a choice of voltage values see Figure 82 An additional option the transition checker is available for STM32L0 STM32L1 and STM32L4
198. tes C initialization C code for current configuration 3 Generate Code pinout clocks peripherals and middleware Opens a window for project settings if they have not been defined previously G Generate Generates current project configuration as a pdf file and a text Report file Opens the project settings window to configure project name Settings folder select a toolchain and C code generation options If the project was previously saved the reports are generated at the same location as the project configuration ioc file Otherwise the user can choose the destination folder and whether to save the project configuration as an ioc file or not UM1718 STM32CubeMX User Interface 4 4 3 Pinout menu The Pinout menu and sub menus shortcuts are available only when the Pinout tab is selected see Figure 26 They are hidden otherwise see Figure 27 Refer to Table 5 for a description of the Pinout menu and icons Figure 26 Pinout menus Pinout tab selected STM32CubeMX Untitled STM32F439VGTx File Project Pinout Window Help E Em Ll Ei e 2 ua Show user Label I D Pinout Clock Configuration Configuration Power Consumption Calculator E Configuration rMiddlewares e FATFS E e FREERTOS apa 2 2 HUHE Figure 27 Pinout menus Pinout tab not selected STM32CubeMX Untitled STM32F439V File Project Window Help BERUS PT Pinout Clock Configuration Configuration Power Consumptio
199. the Pinout view see Figure 151 Figure 151 RCC peripheral configuration RCC High Speed Clock HSE Crystal Ceramic Resonator LOW Speed Clock LSE Disable Master Clock Output 1 148 200 DoclD025776 Rev 12 Ly UM1718 Tutorial 2 Example of FatFs on an SD card using STM32429I EVAL evaluation board b Configure the clock tree from the clock tab see Figure 152 Figure 152 Clock tree view System Clock Mux HSI Kisi SYSCLK MHz AHB Prescaler HCLK MHz PLL Source Mux HSI r Input frequency He 725 v X 336 N Main PLL 10 In the Project Settings menu specify the project name and destination folder Then select the EWARM IDE toolchain Figure 153 Project Settings menu Code Generator tab Project Settings Project Project Settings Project Name fatfs_sd_test Project Location C ISTM32CubeMX PrajectsETM32F429NI STM32F 4291 EVAL1 Toolchain Folder Location C STM32CubeMX_ Projects STM32F429NI STM32F4291 EVAL 1Matfs sd test Toolchain IDE EWARM Mcu and Firmware Package Mcu Reference STM32F329NIHx Firmware Package Name and Version STM32Cube FW F4 V1 8 0 Use latest available version q DoclD025776 Rev 12 149 200 Tutorial 2 Example of FatFs on an SD card using STM32429lI EVAL evaluation board UM1718 11 Click Ok Then in the toolbar menu click d to generate the project 12 Upon code generation completion click Open Project in the Code Ge
200. the information set forth herein shall void any warranty granted by ST for such product ST and the ST logo are trademarks of ST All other product or service names are the property of their respective owners Information in this document supersedes and replaces information previously supplied in any prior versions of this document 2015 STMicroelectronics All rights reserved 7 200 200 DoclD025776 Rev 12
201. tion 158 200 Let us now take several actions to optimize the overall consumption and the battery lifetime These actions are performed on step 1 4 5 6 7 8 and 10 The next figures show on the left the original step and on the right the step updated with several optimization actions Step 1 Run e Findings All peripherals are enabled although the application requires only the RTC e Actions Lower the operating frequency A Enable solely the RTC peripheral To reduce the average current consumption reduce the time spent in this mode e Results The current is reduced from 9 05 mA to 2 16 mA see Figure 160 7 DoclD025776 Rev 12 UM1718 Tutorial 3 Using PCC to optimize the embedded application power consumption and Figure 160 Step 1 optimization r Edit Step C OPAMP1 CPU Frequency 16 0 MHz Interpolation ranges Interpolation ranges User choice Hz User choice Hz Clock Configuration HSE j Clock Configuration HSE 24 0 MHz EE Clock Source Frequency 156 0 MHz Without Peripherals 3 18 mA 2 16 mA Ei OPAMP1 Peripherals Part 5 87 mA A 296 25 pA D 5 57 mA i Lgitow Power OpA A O UA D O HA Ta Max C 104 02 7 Normal 104 77
202. tion C code generation for STM32F1 series from updated Complete project generation Updated Figure 16 New library Manager window Figure 22 New Project window board selector Updated IDE list in Section 4 8 Project Settings Window and modified Figure 38 Project Settings window Updated Section 4 13 1 Clock tree configuration functions Updated Figure 70 STM32F429xx Clock Tree configuration view Section 4 14 Power Consumption Calculator PCC view added transition checker option Updated Figure 74 Power Consumption Calculator default view Figure 75 Battery selection and Figure 76 19 Mar 2015 7 Building a power consumption sequence Added Figure 79 Enabling the transition checker option on an already configured sequence all transitions valid Figure 80 Enabling the transition checker option on an already configured sequence at least one transition invalid and Figure 81 Transition checker option show log Updated Figure 86 Power Consumption Calculator view after sequence building Updated Section Managing sequence steps Section Managing the whole sequence load save and compare Updated Figure 88 PCC Edit Step window and Figure 90 Description of the Results area Updated Figure 156 Power Consumption Calculation example Figure 155 Sequence table Figure 156 Power Consumption Calculation results and Figure 158 Power consumption results IP consumption chart Updated Appendix B 3 1 Overview and B 3 5 FreeRTOS 28
203. tion view for an STM32F429x MCU and Table 12 describes the widgets that can be used to configure each clock DoclD025776 Rev 12 87 200 STM32CubeMX User Interface UM1718 Figure 70 STM32F429xx Clock Tree configuration view EICOU UL c d O File Project Clock Configuration Window Help Be fg d Q SG uuvecoe i Pinout Clock Configuration Configuration Power Consumption Calculator DB Editor RTC Clock Mux HSE _ RTC 2 v To RTC KHz OE jesesecere doek 1 HCLK to AHB bus core To IWDG KHz System Clock Mux fon gt ag Te Cortex System timer MHz 180 MHz max am i PCLK2 a Q a fi Le APB2 peripheral clocks MHz Input frequency Y ii zz DERE 4 26 MHz 48MHz clocks MHz 125 docks MHz SAI A clocks MHz MCO2 source Mux Quee PLLI2SCLK s SYSCLK File Project Clock Configuration Window Help BREBHHE amp G 498 OO RAP K Pinout amp Clock Configuration Configuration Power Consumption Calculator RTC Clock Mux HSE RTC LE To RTC KHz sw Jetherne oc 1 HCLK to AHB bus core To IWDG KHz memory and DMA MHz System Clock Mux f 1 gt is __ ro Cortex System timer MHz 16 FCUK Cortex clock MHz AHB Prescaler HOK MHz APB1 Prescaler 4a ov 4 v OE sl 4 APB1 peripheral clocks MHz 45 MHz max 180 MHz max Oos APB1 Timer clocks
204. ts over UART It uses e Multiple low power modes Low power run Low power sleep Sleep Stop and Standby e Multiple peripherals USART DMA Timer COMP DAC and RTC The RTC is used to run a calendar and to wake up the CPU from Standby when a specified time has elapsed The DMA transfers ADC measurements from ADC to memory The USART is used in conjunction with the DMA to send receive data via the virtual COM port and to wake up the CPU from Stop mode The process to optimize such complex application is to start describing first a functional only sequence then to introduce on a step by step basis the low power features provided by the STM32L476RG microcontroller Using the Power Consumption Calculator Creating a PCC sequence Follow the steps below to open PCC and create the sequence see Figure 156 1 Launch STM32CubeMX 2 Click new project and select the Nucleo L476RG board from the Board tab 3 Click the Power Consumption Calculator tab to select the Power Consumption Calculator view A first sequence is then created as a reference 4 Adaptit to minimize the overall current consumption To do this a Select 2 4 V Vpp power supply This value can be adjusted on a step by step basis see Figure 157 b Select the Li MnO2 CR2032 battery This step is optional The battery type can be changed later on see Figure 157 DoclD025776 Rev 12 155 200 Tutorial 3 Using PCC to optimize the embedded application p
205. ure 7 Closing STM32CubeMX perspective Quick Access ES E C C STM32CubeMX 7 22 200 DoclD025776 Rev 12 UM1718 Installing and running STM32CubeMX Figure 8 Uninstalling STM32CubeMX plug in Uninstall Uninstall Details Review and confirm the items to be uninstalled Name Version 4 STM32CubeMX 4 0 0 201402171115 com st mit 4 Details STM32CubeMX is a graphical tool enabling users to configure lt Back 3 4 Launching STM32CubeMX 3 4 1 Running STM32CubeMX as standalone application To run STM32CubeMX as a standalone application e Select STM32CubeMX from Program Files ST Microelectronics STM32CubeMX e Ordouble click STM32CubeMX icon on your desktop 3 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 e Load an MCU e Load an existing configuration e Save acurrent configuration e Set project parameters and generate corresponding code Three command line modes are available e Torun STM32CubeMX in interactive command line mode use the following command line java jar STM32CubeMX exe i DoclD025776 Rev 12 q Installing and running STM32CubeMX UM1718 The MX prompt will be displayed ready to accept commands e Torun STM32CubeMX in command line mode getting commands from a script use the following command line java jar C Program Files
206. urity Warning menu Click OK when requested to restart Eclipse IDE see Section 3 4 2 Running STM32CubeMX in command line mode Figure 5 Adding STM32CubeMX plug in archive DoclD025776 Rev 12 21 200 Installing and running STM32CubeMX UM1718 Figure 6 Installing STM32CubeMX plug in Snu e ebete s w so s N N ee d Check the items that you wish to install 8 Available Software Work with STM32CubeMX update site jarfile C Users fra09031 Documents lemp STM32CubeMX eclipseplugin v Add Find more software by working with the Available Software Sites preferences type filter text Name Version 4 00 STM32CubeMX Eclipse Plugin VO All items are installed SelectAll Deselect All Details V Show only the latest versions of available software V Hide items that are already installed Group items by category What is already installed Show only software applicable to target environment Contact all update sites during install to find required software Cancel 3 3 3 Uninstalling STM32CubeMX as Eclipse IDE plug in To uninstall STM32CubeMX plug in in Eclipse IDE follow sequence below 1 dn 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 6 Fig
207. user can now proceed and build a power sequence see Figure 76 Figure 76 Building a power consumption sequence STM32CubeMX Untitled STM32L053C8Tx E N File Project Power Window Help n us uu d s LET ET Pinot it Clock k Configuration Configuration Power Consumption Calculator Transitions checker Microcontroller Selected Q J E Serie STM32L0 Line STM32L0x3 MCU STM32L053C8Tx Datasheet Load ave Delete Compare Enabled r Sequence Table 025844_Rev4 Step Mode Range Memory Clock C SrcFreq CPU Bu Periphe Add C Step Cu Duration DMIPS Voltage Parameter Selection Ambient Temperature C 25 Vdd Power Supply V 3 0 Battery Selection Battery Alkaline AA LR6 Capacity 2850 0 mAh Self Discharge Nominal Voltage Max Cont Current 0 3 month 1 5V 1000 0 mA Max Pulse Current 0 0mA In Series In Parallel Information Notes Help Managing sequence steps Steps can be reorganized within a sequence Add new Delete a step Duplicate a step move Up or Down in the sequence using the set of Step buttons see Figure 77 The user can undo or redo the last configuration actions by clicking the Undo button in the PCC view or the Undo icon from the main toolbar Figure 77 Step management functions Adding a step There are two ways to add a new step e Click Add in the
208. valuation board see Figure 146 ps Qe n Figure 148 Board selection New Project MCU Selector Board Selector Board Filter Vendor Type of Board STMicroelectronics EvalBoard Initialize all IP with their default Mode Peripheral Selection Boards List 5 Items Peripherals Type Reference MCU Accelerometer I EvalBoard STM3240G EVAL STM32F4071G EvalBoard STM3241G EVAL Audio Line In Audio Line Out EvalBoard STM32439I EVAL2 Button To 3 EvalBoard ISTM32446E EVAL STM32F446ZE Digital 1 0 Eeprom we Ethernet Flash Memory Graphic Lcd Display IrDA Joystick Led Memory Card icro Potentiometer I Rs232 I SRAM SDRAM Speaker DoclD025776 Rev 12 147 200 q Tutorial 2 Example of FatFs on an SD card using STM32429I EVAL evaluation board UM1718 7 From the Peripheral tree on the left expand the SDIO IP and select the SD 4 bits wide bus see Figure 149 Figure 149 SDIO IP configuration 2 4 SDIO Mode SD 4 bits Wide bus 8 Under the Middlewares category check SD Card as FatFs mode see Figure 150 Figure 150 FatFs mode configuration onfiguration MiddleWares EF 6 FATFS EE External SDRAM External SRAM V SD Card USB Disk 9 Configure the clocks as follows a Select the RCC peripheral from
209. ved in reduced leakage mode and V12 voltage is less than 1 08 V The regulator in Main or Low power mode is in under drive or low voltage mode The Flash memory must be in Deep power down mode The wakeup time is about 100 us higher than in normal mode Standby mode This mode achieves very low power consumption with the RC oscillator as a clock source The internal voltage regulator is switched off so that the entire 1 2 V domain is powered off CPU and peripherals are stopped The PLL the HSI RC and the HSE crystal oscillators are disabled SRAM and register contents are lost except for registers in the backup domain and the 4 byte backup SRAM when selected Only RTC and LSE oscillator blocks are powered The device exits Standby mode when an DoclD025776 Rev 12 189 200 STM32 microcontrollers power consumption parameters UM1718 D 1 3 190 200 external reset NRST pin an IWDG reset a rising edge on the WKUP pin or an RTC alarm wakeup tamper time stamp event occurs e Vaar Operation It allows to significantly reduced power consumption compared to the Standby mode This mode is available when the VaAT pin powering the Backup domain is connected to an optional standby voltage supplied by a battery or by another source The VBAT domain is preserved RTC registers RTC backup register and backup SRAM and RTC and LSE oscillator blocks powered The main difference compared to the Standby mode is external interrupts and RTC alarm events d
210. y clocked e g not in use by a running program Each peripheral can be enabled or disabled Peripherals individual power consumptions are displayed in a tooltip An overall consumption due 7 108 200 DoclD025776 Rev 12 UM1718 STM32CubeMX User Interface to peripheral analog and digital parts is provided in the step Results area see Figure 91 The user can select the peripherals relevant for the application None Disable All Some using IP individual checkbox Al Activate All Orall from the previously defined pinout configuration Import Pinout Only the selected and enabled peripherals are taken into account when computing the power consumption Figure 91 Peripheral power consumption tooltip Power Memory Power Mode Power Scale Memory Fetch Type Vdd Voltage Source 180 0 MHz HSE PLL Clock Source Frequency 4 0 MHz Optional Settings Step Duration Additional Consumption Results Step Consumption 116 15 mA Without Peripherals 57 mA Peripherals Part 59 15mA A 5 6 mA D 53 55 mA e Step duration The user can change the default step duration value When building a sequence the user can either create steps according to the application actual power sequence or q DoclD025776 Rev 12 109 200 STM32CubeMX User Interface UM1718 4 14 5 110 200 define them as a percentage spent in each mode For example if an application spends 30 in Ru
211. y valid transitions Enabling the transition checker option prior to sequence configuration ensures the user will be able to select only valid transition steps Enabling the transition checker option on an already configured sequence will highlight the sequence in green green frame if all transitions are valid see Figure 79 or in red if at least one transition is invalid red frame with description of invalid step highlighted in red see Figure 80 In this case the user can click the Show log button to find out how to solve the transition issue see Figure 81 Figure 79 Enabling the transition checker option on an already configured sequence all transitions valid Sequence Transitions checker ee dl ee ass Sequence Table Mode Vdd Ecl Memory Clock C Src Freg CPUjBu Periphe Add C Step Cu Duration DMIPS Voltage R F sed 0 MHz 2 ee 1 mA ims sed RUN 5 0 kegel Raas Pers eor iewe oma 25ma ims 26 24 Battery RA 8 Rame ASH pereu lie ovet 20mm ABCC pm JLm amp ime 282 Boter 30 Range2 FLASH HSEBYP amp OMHz aomh mA JGwA fims 328 Battery pun 50 Ranger RAS jse Bome Bome pma LSm ms 856 Betey so 55 NeRange he Trao ptr oHe COMPIC 0mA 5 678 ims 0 0 Battery Figure 80 Enabling the transition checker option on an already configured sequence at least one transition invalid Memory Clock C SrcFreg CPU Bu Periphe Add C StepCu Duration DM
212. zeof wtext amp bytesread if stremp rtext wtext 0 res FR OK Hello txt file Read or EOF Error set the red LED on HAL GPIO WritePin GPIOG GPIO PIN 10 GPIO PIN RESET while 1 else Successful read set the green LED On HAL GPIO WritePin GPIOG GPIO PIN 6 GPIO PIN RESET 9 Close the open text file didddddididdsdddg HH f close amp MyFile SR 10 Unlink the micro SD disk I O driver FATFS UnLinkDriver SD Path USER CODE END 2 Infinite loop USER CODE BEGIN WHILE while 1 q DoclD025776 Rev 12 153 200 Tutorial 3 Using PCC to optimize the embedded application power consumption and more 8 8 1 Note 154 200 Tutorial 3 Using PCC to optimize the embedded application power consumption and more Overview This tutorial focuses on STM32CubeMX Power Consumption Calculator PCC feature and its benefits to evaluate the impacts of power saving techniques on a given application sequence The key considerations to reduce a given application power consumption are e Reducing the operating voltage e Reducing the time spent in energy consuming modes It is up to the developer to select a configuration that will give the best compromise between low power consumption and performance e Maximizing the time spent in non active and low power modes e Using the optimal clock configuration The core should always operate at relatively good sp

Download Pdf Manuals

image

Related Search

Related Contents

Saint-Bonnet-près-Riom, une histoire    - Mobiletech Blog  

Copyright © All rights reserved.
Failed to retrieve file