当前位置:网站首页>STM32CubeMX configuration to generate FreeRTOS project
STM32CubeMX configuration to generate FreeRTOS project
2022-07-30 10:15:00 【luobeihai】
文章目录
1. 安装STM32CubeMX软件
STThe company now has a better packageHAL库,并且搭配STM32CubeMXThe software automatically generates code related to initializing peripherals,You no longer have to write initialization-related code yourself,非常方便.
1.1 下载安装
STM32CubeMX是STcompany's free software,我们去ST的官网:
Find the interface for getting the software below,下载相应版本即可
注意:STM32CubeMX是JAVA写的,所以需要安装JAVA的运行环境,怎么安装JAVAFind the operating environment yourself online.
1.2 Install the chip package to be used
安装完CubeMX后,打开界面如下,然后点击Install/Remove,如下:

Let's first install some chip packages that we will use,Because of what I useSTM32F407ZGT6芯片,所以我选择的是F4软件包.如下:
2. 配置FreeRTOS项目
2.1 创建工程

Then enter to select the chip model,这里我用的是STM32F407ZGT6芯片.

2.2 配置SYS

2.3 配置RCC
We enable the external crystal.注意:If the external low-speed crystal oscillator is not used,Do not enable the external low-speed crystal oscillator,Otherwise, the program will die in the code related to the clock setting when it is powered on.
2.4 Configure the system operating clock
We configure to playRCC外设之后,Then you can configure the clock that each peripheral of the system runs.如下图,The external crystal oscillator my development board is8MHz,So the input crystal oscillator should be selected8.In fact, other configurations can be set according to the prompts of the software,If the configured operating frequency exceeds the maximum operating frequency of the chip,The software will highlight it.

2.5 配置UART1Serial port as debug code
在右侧Connectivity栏,然后选中USART1,Then configure the following interface:
Because we use the interrupt method to receive serial data,So it still needs to be enabledUSATR1的中断,and configure interrupt priority:
2.6 配置一个LED引脚的GPIO
We configure a controlLED亮灭的GPIO引脚,用于测试程序.on my development boardLED引脚是PE3,So I configure this pin.

2.7 使能FreeRTOS组件
CubeMXcan be enabled directlyFreeRTOS组件,这里我选择V1版本,V1、V2I don't know exactly what the difference is.
然后其他的FreeRTOS相关的配置参数,Just the default configuration,Change it later when needed.

3. 生成代码
生成代码前,Configure the relevant ones first Project Manager 选项.

The file organization of the configuration code,Check the options below,There will be a corresponding code for each peripheral generated in this way .c/.h 文件,Unchecked will add all the code tomain文件上.Then click Generate Code in the upper right corner.
说明:CubeMX生成的FreeRTOS代码,他把FreeRTOSAll operations are encapsulated again,在文件cmsis_os.c文件中.我们使用了ST封装的FreeRTOS接口的话,Even if our future code uses a different versionFreeRTOS,Then the user code does not need to be modified.
4. Test the generated project code
生成代码后,在freertos.c文件中,CubeMXA default task will be generated,We go to the task function of the task to add serial port printing andLEDOn and off code,如下:
void StartDefaultTask(void const * argument)
{
/* USER CODE BEGIN StartDefaultTask */
uint8_t str[] = "hello world";
/* Infinite loop */
for(;;)
{
HAL_UART_Transmit(&huart1, str, sizeof(str), 500); // 串口1输出一串字符
HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_3); // LEDLights cycle on and off
osDelay(1000);
}
/* USER CODE END StartDefaultTask */
}
添加完代码后,编译下载到开发板.
然后打开串口调试工具,You can see that the serial port normally outputs the following print information,说明使用CubeMX创建的FreeRTOS工程没问题.
to this configuration creationFreeRTOSEngineering project completed.
边栏推荐
- PyQt5 - draw sine curve with pixels
- The thread pool method opens the thread -- the difference between submit() and execute()
- Beijing suddenly announced big news in the Metaverse
- 分页 paging
- 大根堆的创建(视频讲解)
- mysql安装教程【安装版】
- CVTE school recruitment written test questions + summary of knowledge points
- leetcode 剑指 Offer 58 - I. 翻转单词顺序
- Re19: Read the paper Paragraph-level Rationale Extraction through Regularization: A case study on European Court
- leetcode 剑指 Offer 57. 和为s的两个数字
猜你喜欢

快解析结合友加畅捷通t1飞跃版

快解析结合任我行crm

Paper reading: SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers

水电表预付费系统

论文阅读:SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers

Re15: Read the paper LEVEN: A Large-Scale Chinese Legal Event Detection Dataset

你真的懂Redis的5种基本数据结构吗?

Flink_CDC搭建及简单使用

PyQt5 - draw sine curve with pixels

leetcode 剑指 Offer 63. 股票的最大利润
随机推荐
js对数组操作移动进行封装
ospf2双点双向重发布(题2)
MySQL |子查询
Four ways the Metaverse is changing the way humans work
OC-手动引用计数内存管理
分页 paging
编译报错: undefined reference to `google::FlagRegisterer::FlagRegisterer解决方法
学习笔记11--局部轨迹直接构造法
2022年顶会accepted papers list
Online target drone prompt.ml
Day113. Shangyitong: WeChat login QR code, login callback interface
Redis Desktop Manager 2022.4.2 发布
【HMS core】【Analytics Kit】【FAQ】如何解决华为分析付费分析中付款金额显示为0的问题?
Re21: Read the paper MSJudge Legal Judgment Prediction with Multi-Stage Case Representation Learning in the Real
线上靶机prompt.ml
大数据产品:标签体系0-1搭建实践
idea2021+Activiti [the most complete note one (basic use)]
leetcode 剑指 Offer 15. 二进制中1的个数
Paper reading: SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers
【深度学习】(问题记录)<对一个变量求梯度得到什么>-线性回归-小批量随机梯度下降