STM32 Cube MXTraining
STM32 Cube MXTraining
What it is STM32CubeMX ?
Pinout Wizard Clock Tree Wizard Peripherals & Middleware Power Consumption
Wizard Wizard
STM32CubeMX
Step by step:
• MCU selector
• Pinout configuration
• Peripherals and
middleware parameters
• Code generation
• Power consumption
calculator
New Project 5
MCU Selector
Easy Optional filtering:
• Series
• Line
• Package
• Peripherals
New Project 6
Board Selector
Easy Optional filtering:
• Type of board
• MCU Series
• Peripherals
• Optional init
STM32CubeMX: Pinout configuration 7
• Pinout from:
• Peripheral tree
• Manually
• Automatic signal
remapping
• Management of
dependencies
between
peripherals and/or
middleware
(FatFS, LWIP, …)
STM32CubeMX: Pinout configuration 8
• Design view
• Rotate (Top/Bottom view for BGA)
MCU Replacement 10
• Compatible MCUs
• Select compatible MCU
• Automatically replaced
Pinout creation
• Select NUCLEO-F446RE board
• Configure signals
• LED = PA5 (Already done)
• UART = USART2 (TBD)
• BP = PC13 (Already done)
STM32CubeMX: Clock tree 12
• Immediate
display of all
clock values
• Management
of all clock
constraints
• Highlight of
errors
STM32CubeMX: Clock tree 13
• First choose in the pinout view the desired external clock (RCC)
• Highlight of
configuration errors
+ Not configured
ⱱ OK
x Error
• Parameters with
management of
dependencies and
constraints
• Interruptions
• GPIO
• DMA
STM32CubeMX: Peripheral and
middleware configuration 16
• Manage Interruptions
• priorities can only be set in the
NVIC global view
• Manage DMA
• Configure all the parameters of the
DMA request
• Runtime parameters (start
address, …) are not managed
NVIC Panel 17
• Manage all
interruptions
• Manage priorities
and sort by
priorities
• Search for a
specific interrupt in
the list
DMA Panel 18
• Set specific
parameters
GPIO Panel 19
Peripherals configuration
• BP external interrupt
• Do NOT forget to validate NVIC !
• Usart
• Communication parameters 9600Bits/s
• Data flow configuration
• IT
STM32CubeMX: Code generation 21
• Help->Updater settings
• Choose location of STM32CubeFx firmware libraries repository
• Choose manual or automatic check
• Set Connection proxy
• Inside ST use lps5.sgp.st.com port 8080 with your windows login name and password
• GPIO settings
You can choose to set all the remaining pins to analog to optimize power
consumption don’t forget to reserve debug pins before, this option is set by
default in the 4.0 (unset by default in future versions)
STM32CubeMX: Generated code 25
• By default:
• main.c:
• GPIO configuration
• Clock configuration
• The main() function calling all the initialization code
• stm32f4xx_hal_msp.c:
• Initialization code for all Ips
• Middlewares are in separated files
• stm32f4xx_it.c:
• Management of the interrupts
Application code
• Synchonous
• Toggle LED (PA5) every 500ms
• Asynchonous
• Send message to PC using USART every time BP is pressed (External Interrupt)
• Power step
definitions
• Battery selection
• Creation of
consumption
graph
• Display of
• Average
consumption
• Average DMIPS
• Battery lifetime
• Supported for L1
and F4
STM32CubeMX: Power consumption
calculator 28
www.st.com/stm32cube
Exercice solution (1/2) 30
• Private variables
• STM32CubeMX
• http://www.st.com/en/development-tools/stm32cubemx.html
• SW4STM32
• http://www.st.com/en/development-tools/sw4stm32.html