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

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.
 
 
2. Select the MCU Selector tab and filter down the STM32 portfolio by selecting STM32F4 as 'Series', STM32F407 as 'Lines', and LQFP100 as 'Package’ 
 
 
3. Select the STM32F407VGTx from the MCU list and click OK.
 
STM32CubeMX views are then populated with the selected MCU database .
Optionally, remove the MCUs Selection bottom window by deselecting Window> Outputs submenu .

 

 

2 Configuring the MCU pinout 

1. By default, STM32CubeMX shows the Pinout view.
2. By default, 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 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.
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:
 
 
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.
 
 
c) You can also configure the RCC to use an external oscillator as potential clock source.
 
 
 

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.

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章