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

本文介绍使用STM32CubeMX工具创建并配置STM32F4DISCOVERY板上LED闪烁项目的详细步骤。从新建项目到配置GPIO、定时器及RCC,最后保存项目,覆盖了整个配置流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值