当前位置:网站首页>Introduction to development using Hal library, stm32cubemx and keil 5 (I): turn on an LED light (nucleo-f411re)
Introduction to development using Hal library, stm32cubemx and keil 5 (I): turn on an LED light (nucleo-f411re)
2022-04-22 15:10:00 【Charming Sun】
This tutorial to light up a lamp LED Light for the purpose of demonstration for everyone STM32CubeMX、Keil、ST-Link Development STM32 The general method of procedure .
One 、 Preparation before study
Hardware : A piece of STM32 Development board , One ST-Link;( The development board I use is NUCLEO-F411RE)
Software : packed ST-Link Driver program , packed STM32CubeMX, packed Keil;
file : The schematic diagram of the development board 、 Chip reference manual and HAL Driving instructions .
attach :STM32F4xx HAL Driving instructions
Two 、 Create a new STM32CubeMX engineering
open STM32CubeMX, And then click New Project:
choice Series( series )、Lines( series )、Package( encapsulation ), Then select yourself MCU Model , Click on OK:( my MCU yes STM32F411RE,64 Pin LQFP encapsulation )
At this point STM32CubeMX The project has been established :

3、 ... and 、 Configure corresponding pins , Then generate Keil engineering
Open the development board schematic , see LED The pin corresponding to the lamp :( As shown in the figure , Give Way PA5 When the pin outputs high level, it will light up LED)
Click on Pinout, And then click LED The pin corresponding to the lamp , choice GPIO_Output Pattern :( take PA5 Set to the output mode of general input and output port , Please refer to Reference manual Medium GPIO introduction)
Since this routine does not need to configure the clock 、 Middleware and peripherals , There is no need to calculate power consumption , therefore Clock Configurantion、Configuration、Power Consumption Caculator Keep default .
Click on the menu bar Project->Settings, Input STM32CubeMX Project name 、 Save the path and your own tool chain / Integrated compilation environment ,Code Generator The settings in remain the default , And then click OK:( my STM32CubeMX The name of the project is LD2, Save path as desktop , The integrated compilation environment is Keil 5)
Then click... On the menu bar Project->Generate Code, Or click
Shortcut key generation contains HAL Library Keil Project and initialization code . At this point, a message appears on the corresponding path STM32CubeMX Folder with project name . Open the folder on the corresponding path , Among them .ioc A file with an extension is STM32CubeMX Engineering documents of , The folder with the name of integrated compilation environment contains this STM32CubeMX The project file of this integrated compilation environment with the project name ,Drivers The directory contains drivers ,Inc The directory contains header files ,Src The directory contains the source code :(LD2.ioc The file is just created STM32CubeMX engineering ,MDK-ARM In folder LD2.uvprojx The file is just generated Keil engineering )

Four 、 stay Keil Add your own code to the project , Then compile 、 download
open Keil engineering , Find where to add code according to the comments . Please do not add code beyond the prompt , Otherwise, generate... Again STM32CubeMX The project will be deleted :( because STM32CubeMX The initialization code has been generated for us , So we just need to /* USER CODE BEGIN 2 / And / USER CODE END 2 */ Add a sentence between to make PA5 Output high level code )
open HAL The driver manual finds what we need API, Then add the code according to the instructions :( According to the instructions, make PA5 The code of output high level is HAL_GPIO_WritePin (GPIOA, GPIO_PIN_5, GPIO_PIN_SET);)
Add code to the project , And then click
compile , use ST-Link After connecting the computer and the development board, click
download :

5、 ... and 、 Reset the development board after downloading , Then the development board LD2( A green light ) bright

版权声明
本文为[Charming Sun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221504282893.html
边栏推荐
- 【深入理解TcaplusDB技术】更替列表指定位置数据接口说明——[List表]
- STM32 saves the collected data in the form of TXT file in the operation practice of SD card. The small single chip microcomputer system can also take out a large amount of local data (SD card + FatFs)
- flinkSQL 只有输入和输出的情况下,会合并成一个子任务,这种情况就无法显示出输入输出的数据量?
- Computer Vision L8 -- Synthesis
- Analysis on the characteristics of the official game economic model launched by platoffarm
- The memory expansion application of STM32 is realized, and the single chip microcomputer with small memory can also do great things (FSMC + SRAM)
- 【深入理解TcaplusDB技术】异步扫描数据示例代码——[Generic表]
- 中国海油上交所上市:市值6515亿 年利润703亿
- 带你了解极具弹性的Spark架构的原理
- 思科模拟器EVE-NG如何导入镜像
猜你喜欢

Android UI - zoomcontrols zoom in and out pictures, Android interview resume template

Development trend of C in 2022

2022年C#发展趋势
![【深入理解TcaplusDB技术】更新数据示例代码——[Generic表]](/img/7b/8c4f1549054ee8c0184495d9e8e378.png)
【深入理解TcaplusDB技术】更新数据示例代码——[Generic表]

数学——贝塞尔曲线

2022危险化学品经营单位主要负责人考试题模拟考试题库模拟考试平台操作

预处理是程序的历程
![[Mysql] CHAR_LENGTH函数](/img/1c/57bc70f35429d0add2dbee99e06c1c.png)
[Mysql] CHAR_LENGTH函数

*CTF2022 - Web

2022 tea artist (intermediate) examination questions and answers
随机推荐
[*CTF2022]oh_my_lotto_revenge
About STS access control of Alibaba cloud OSS resources
使用HAL库、STM32CubeMX和Keil 5开发入门教程(一):点亮一盏LED灯(NUCLEO-F411RE)
ODPS SQL节点参数怎么设置呢?
824. Goat Latin
这两种人是做不好自媒体的,一辈子都赚不到大钱
leetcode746. 使用最小花费爬楼梯(简单)
@Resources and constructors
2022年化工自动化控制仪表考试题库及在线模拟考试
思科模拟器EVE-NG如何导入镜像
*CTF2022 - Web
[World Earth Day] Huawei cloud market | witness the beautiful changes of nature with science and technology
The memory expansion application of STM32 is realized, and the single chip microcomputer with small memory can also do great things (FSMC + SRAM)
vscode处理代码合并冲突
【深入理解TcaplusDB技术】读取列表所有数据示例代码——[List表]
TcaplusDB君 · 行业新闻汇编(四)
leetcode746. Climb stairs with minimum cost (simple)
Introduction notes to golang - redis
【网络】传输层-UDP协议
记录一个sql,查询用户最后任职的一家公司,并根据企业名称+用户名称进行搜索