当前位置:网站首页>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.
边栏推荐
- 学习笔记11--局部轨迹直接构造法
- 4、yolov5-6.0 ERROR: AttributeError: ‘Upsample‘ object has no attribute ‘recompute_scale_factor‘ 解决方案
- 包、类及四大权限和static
- Domino服务器SSL证书安装指南
- Js array operating mobile for encapsulation
- 606. 根据二叉树创建字符串(视频讲解!!!)
- Re16: Read the paper ILDC for CJPE: Indian Legal Documents Corpus for Court Judgment Prediction and Explanation
- MySQL installation tutorial [installation version]
- A new generation of free open source terminal tool, so cool
- Meikle Studio - see the actual combat notes of Hongmeng equipment development five - drive subsystem development
猜你喜欢

In the robot industry professionals, Mr Robot industry current situation?

Security Thought Project Summary
容器技术 -- 简单了解 Kubernetes 的对象

百度推广助手遇到重复关键字,验证错误,怎么一键删除多余的
![MySQL installation tutorial [installation version]](/img/e9/9c7b0e3aac22206d126de428c1a4bd.png)
MySQL installation tutorial [installation version]

Detailed explanation of JVM memory layout, class loading mechanism and garbage collection mechanism

水电表预付费系统

flowable工作流所有业务概念

Domino Server SSL Certificate Installation Guide

SST-Calib:结合语义和VO进行时空同步校准的lidar-visual外参标定方法(ITSC 2022)
随机推荐
PyQt5-在窗口上绘制文本
唯物辩证法-条件论
Alibaba Cloud OSS Object Storage
软考 系统架构设计师 简明教程 | 系统运行与软件维护
In the robot industry professionals, Mr Robot industry current situation?
Re21: Read the paper MSJudge Legal Judgment Prediction with Multi-Stage Case Representation Learning in the Real
水电表预付费系统
判断一颗树是否为完全二叉树——视频讲解!!!
快解析结合任我行crm
在机器人行业的专业人士眼里,机器人行业目前的情况如何?
Materialist Dialectics - Conditionalism
【深度学习】(问题记录)<对一个变量求梯度得到什么>-线性回归-小批量随机梯度下降
容器技术 -- 简单了解 Kubernetes 的对象
js对数组操作移动进行封装
你真的懂Redis的5种基本数据结构吗?
OC-关于alloc和dealloc(还没开始写)
论文阅读:SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers
这种叫什么手法
Practical Walkthrough | Calculate Daily Average Date or Time Interval in MySQL
[100个Solidity使用技巧]1、合约重入攻击