当前位置:网站首页>[STM32] stm32cubemx tutorial II - basic use (new projects light up LED lights)
[STM32] stm32cubemx tutorial II - basic use (new projects light up LED lights)
2022-07-01 21:58:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
Preface
The configured CubeMX after , Is the beginning of the new project , So first we need some preparation , We will introduce this blog in detail STM32CubeMx And how to create a new project and light it up LED The lamp For beginners If you want to create a project quickly , You can skip the function introduction directly , Watch the project creation column
also , When building a new project , We divide it into specific processes 1~7 If you don't want to see the explanation of each part , Just follow the process ,5 Minutes to successfully light LED The lamp
install STM32CubeMx Please see 《STM32 CubeMx Use tutorial one – Installation tutorial 》
Preparation :
1、STM32 Hardware ( My is STM32F407ZE and STM32F103ZE)
2、STM32CubeMx Software 、 IDE Keil(MDK-ARM) Software
3、STM32F4xxHAL library
New project
1 Select... In the main interface File–>New Project Or click directly ACCEE TO MCU SELECTOR
The chip model selection... Appears Generally, we can directly search the model of our own chip
If you are designing a product and want to choose a chip Under the search bar , Various search methods provided , You can choose the chip core , model , wait , Help you find the right chip
Specific process 1:
- 1 Search chip model
- 2 Select chip
- 3 Create a project
Then the next is the highlight of our whole process
Here we are divided into three parts to explain
1MCU Peripheral resource selection
Here you can choose MCU Various resources and peripherals
There are two ways
- Categories Type selection
take MCU Classification of various peripherals and resources , For users to choose
- A-Z Sequence selection
MCU For peripheral resources, press A-Z Sort , For users to choose
2 Peripheral configuration
Here you can set various functions of the peripherals you choose
Here is the serial port 1 For example We can choose the serial port mode ( asynchronous , Sync , Half duplex ) Serial receive interrupt , And serial port DMA Transmission and so on
It is basically the same as when we configure library functions , however STM32CubeMx Convert these into Graphics and options , We don't need to configure all kinds of things when configuring , We can configure the peripherals we need only by foolproof operation This is CubeMx At the heart of
3 Preview interface
Here is divided into Pin Preview and System Preview
Pin preview is to view what functions are configured on that pin , And each pin position
Click on any pin , Various functions of this pin can be set
This color means Non configurable pin Power dedicated pins are highlighted in yellow . Its configuration Can't change
This color means You configured a I/O The function of the mouth , However, the corresponding peripheral functions are not initialized Pin in no mode state
Green indicates successful configuration
System Preview
System preview is to view various peripherals and configurations GPIO The state of
No problem
A warning , There is a problem with the corresponding configuration Click this option to Peripheral configuration Interface view
Specific configuration of each function (UATR/DMA/ADC/TIM…) We will explain them one by one in the next article , There's no more to it
Specific process 2:
Here we just need to put our LED The corresponding pin is set to GPIO_Output that will do
2 Clock source settings
In fact, it is 32 Clock tree block diagram Let you configure The default clock is the internal clock RC oscillator (HSI)
If you don't understand, please read 《【STM32】 The system clock RCC Detailed explanation ( Hyperdetail , Super comprehensive )》
Specific process 3:
Or first configure it as 72MHz that will do
- Need configuration RCC To use an external clock source
3. engineering management
Set the MCU After each configuration of , The third is the setting of engineering documents
Specific process 4:
Here are the various configurations of the project We only use a limited number of , Other defaults are fine IDE We use MDK5
- The storage directory cannot have Chinese
And then click Code Generator, For further configuration ( a key )
take HAL All of the library .C and .H All copied into the project
advantage : In this way, if other peripherals need to be added later, they may not be used anymore STM32CubeMX It will be very convenient when
shortcoming : Large size , Long compilation time ( For a long )
Just copy what you need .C and .H ( recommend )
advantage : Relatively small volume , The compilation time is short , And the project can be copied
shortcoming : When adding peripherals, you need to reuse STM32CubeMX Import
Does not copy files , Import directly from the package storage location .C and .H
advantage : Small volume , Save hard disk space
shortcoming : Copy to another computer or package location changes , You need to modify the corresponding path
Choose your own way
Specific process 5:
And then click GENERATE CODE Create a project
Create success , Open the project
Specific process 6:while Add the following two lines of code in a loop
HAL_Delay(500);
HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_15);Configure the download tool
Specific process 7:
All configurations of the new project are default We need to choose our own download mode , Check the reset operation after loading and downloading
All your own code, please put it in /* USER CODE BEGIN XXX */ /* USER CODE END XXX */ Between
In this way, when we modify the project, the code you write will not be deleted
Here we are ,STM32CubeMX The introduction to the basic use of , Next, we'll update CubeMX and HAL Library Configuration STM32 Of UART ADC DMA Timer PWM wait
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/130467.html Link to the original text :https://javaforall.cn
边栏推荐
- [monomer] recommended configuration of streaming information i-bpsv3 server
- 二叉树的基本操作
- latex如何打空格
- 【直播回顾】战码先锋首期8节直播完美落幕,下期敬请期待!
- 编程英语生词笔记本
- 芭比Q了!新上架的游戏APP,咋分析?
- Introduction à l'ingénierie logicielle (sixième édition) notes d'examen de Zhang haifan
- 基于LSTM模型实现新闻分类
- 打出三位数的所有水仙花数「建议收藏」
- Tops, the unit of computing power of the processor, can be carried out 1 trillion times per second
猜你喜欢

从MLPerf谈起:如何引领AI加速器的下一波浪潮

News classification based on LSTM model

【Opencv450】HOG+SVM 与Hog+cascade进行行人检测

Basic operation of binary tree

ICML2022 | 基于元语义正则化的介入性对比学习

上半年暂停考试要补考?包含监理工程师、建筑师等十项考试

【深度学习】利用深度学习监控女朋友的微信聊天?

Microsoft, Columbia University | Godel: large scale pre training of goal oriented dialogue
![[noip2013] building block competition [noip2018] road laying greed / difference](/img/d1/a56231cd4eb3cc1d91d8a55048ccfe.png)
[noip2013] building block competition [noip2018] road laying greed / difference

Do you want to make up for the suspended examination in the first half of the year? Including ten examinations for supervision engineers, architects, etc
随机推荐
What is the difference between consonants and Initials? (difference between initials and consonants)
vscode的使用
业务可视化-让你的流程图'Run'起来
物联网rfid等
"The silk road is in its youth and looks at Fujian" is in the hot collection of works in the Fujian foreign youth short video competition
Icml2022 | interventional contrastive learning based on meta semantic regularization
测试撤销1
Talking from mlperf: how to lead the next wave of AI accelerator
从20s优化到500ms,我用了这三招
Manually implement function isinstanceof (child, parent)
Pytest collection (2) - pytest operation mode
名单揭晓 | 2021年度中国杰出知识产权服务团队
基于LSTM模型实现新闻分类
从20s优化到500ms,我用了这三招
杰理之蓝牙耳机品控和生产技巧【篇】
股票手机开户哪个app好,安全性较高的
idea中类中显示成员变量和方法
Yan Rong looks at how to formulate a multi cloud strategy in the era of hybrid cloud
Halcon知识:三维重构的一个尝试
基于K-means的用户画像聚类模型