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.
 
 

1 Creating a new STM32CubeMX Project

1. Select File > New project from the main menu bar or New project from the Home page.
STM32CubeMX Tutorial: From pinout to project C code generation using an MCU of the STM32F4 Series
 
 
2. Select the MCU Selector tab and filter down the STM32 portfolio by selecting STM32F4 as 'Series', STM32F407 as 'Lines', and LQFP100 as 'Package’ 
STM32CubeMX Tutorial: From pinout to project C code generation using an MCU of the STM32F4 Series
 
 
3. Select the STM32F407VGTx from the MCU list and click OK.
STM32CubeMX Tutorial: From pinout to project C code generation using an MCU of the STM32F4 Series
 
STM32CubeMX views are then populated with the selected MCU database .
Optionally, remove the MCUs Selection bottom window by deselecting Window> Outputs submenu .
STM32CubeMX Tutorial: From pinout to project C code generation using an MCU of the STM32F4 Series

 

 

2 Configuring the MCU pinout 

1. By default, STM32CubeMX shows the Pinout view.
2. By default,STM32CubeMX Tutorial: From pinout to project C code generation using an MCU of the STM32F4 Series 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, enableSTM32CubeMX Tutorial: From pinout to project C code generation using an MCU of the STM32F4 Series 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.
STM32CubeMX Tutorial: From pinout to project C code generation using an MCU of the STM32F4 Series
3. Select the required peripherals and peripheral modes:
a) Configure the GPIO to output the signal on the STM32F4DISCOVERY green LED by right-clicking PD12 from the Pinout view, then select GPIO_output:
STM32CubeMX Tutorial: From pinout to project C code generation using an MCU of the STM32F4 Series
 
 
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.
STM32CubeMX Tutorial: From pinout to project C code generation using an MCU of the STM32F4 Series
 
 
c) You can also configure the RCC to use an external oscillator as potential clock source.
STM32CubeMX Tutorial: From pinout to project C code generation using an MCU of the STM32F4 Series
 
 
 

3 Saving the project

1. 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.
STM32CubeMX Tutorial: From pinout to project C code generation using an MCU of the STM32F4 Series

 

STM32CubeMX Tutorial: From pinout to project C code generation using an MCU of the STM32F4 Series

STM32CubeMX Tutorial: From pinout to project C code generation using an MCU of the STM32F4 Series

STM32CubeMX Tutorial: From pinout to project C code generation using an MCU of the STM32F4 Series

STM32CubeMX Tutorial: From pinout to project C code generation using an MCU of the STM32F4 Series

STM32CubeMX Tutorial: From pinout to project C code generation using an MCU of the STM32F4 Series

相关文章:

  • 2021-07-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-27
  • 2022-02-27
猜你喜欢
  • 2022-12-23
  • 2022-02-05
  • 2021-08-22
  • 2021-05-25
  • 2022-01-29
  • 2021-06-23
  • 2022-12-23
相关资源
相似解决方案