当前位置:网站首页>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.
边栏推荐
- hcip06 ospf特殊区域综合实验
- JCL 学习
- leetcode 剑指 Offer 22. 链表中倒数第k个节点
- 百度推广助手遇到重复关键字,验证错误,怎么一键删除多余的
- debian10 install djando
- 梅科尔工作室-看鸿蒙设备开发实战笔记五——驱动子系统开发
- JVM内存布局、类加载机制及垃圾回收机制详解
- [100个Solidity使用技巧]1、合约重入攻击
- hcip06 ospf special area comprehensive experiment
- By building a sequence table - teach you to calculate time complexity and space complexity (including recursion)
猜你喜欢

hcip06 ospf special area comprehensive experiment

【HMS core】【Analytics Kit】【FAQ】如何解决华为分析付费分析中付款金额显示为0的问题?

ospf2双点双向重发布(题2)

If someone asks you about distributed transactions again, throw this to him

PyQt5-在窗口上绘制文本

多线程保证单个线程开启事务并生效的方案

Re15:读论文 LEVEN: A Large-Scale Chinese Legal Event Detection Dataset

Re20:读论文的先例:普通法的信息理论分析

JCL learning

Re17:读论文 Challenges for Information Extraction from Dialogue in Criminal Law
随机推荐
容器技术 -- 简单了解 Kubernetes 的对象
leetcode 剑指 Offer 22. 链表中倒数第k个节点
Four ways the Metaverse is changing the way humans work
唯物辩证法-条件论
你真的懂Redis的5种基本数据结构吗?
论文阅读:SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers
Multithreading--the usage of threads and thread pools
A near-perfect Unity full-platform hot update solution
(C语言)文件操作
Soft test system architects introductory tutorial | system operation and software maintenance
The thread pool method opens the thread -- the difference between submit() and execute()
Mysterious APT Attack
Re20:读论文的先例:普通法的信息理论分析
柱状图 直方图 条形图 的区别
在机器人行业的专业人士眼里,机器人行业目前的情况如何?
leetcode 剑指 Offer 15. 二进制中1的个数
通过构建一个顺序表——教你计算时间复杂度和空间复杂度(含递归)
Shell系统学习之函数
flyway的快速入门教程
分页 paging