当前位置:网站首页>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.
边栏推荐
- CVTE school recruitment written test questions + summary of knowledge points
- 连接mysql报错WARN: Establishing SSL connection without server‘s identity verification is not recommended
- 4、yolov5-6.0 ERROR: AttributeError: ‘Upsample‘ object has no attribute ‘recompute_scale_factor‘ 解决方案
- Re15:读论文 LEVEN: A Large-Scale Chinese Legal Event Detection Dataset
- A new generation of free open source terminal tool, so cool
- 时刻铭记:总有一天你将破蛹而出
- Re17: Read the paper Challenges for Information Extraction from Dialogue in Criminal Law
- Unified exception handling causes ResponseBodyAdvice to fail
- Flink_CDC construction and simple use
- spark udf 接受并处理 null值.
猜你喜欢

Security Thought Project Summary

leetcode 剑指 Offer 12. 矩阵中的路径

leetcode 剑指 Offer 22. 链表中倒数第k个节点

一个近乎完美的 Unity 全平台热更方案

The thread pool method opens the thread -- the difference between submit() and execute()

快解析结合用友时空

Do you really understand the 5 basic data structures of Redis?

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

Study Notes 11--Direct Construction of Local Trajectories
![MySQL installation tutorial [installation version]](/img/e9/9c7b0e3aac22206d126de428c1a4bd.png)
MySQL installation tutorial [installation version]
随机推荐
Flask's routing (app.route) detailed
Multi-threading scheme to ensure that a single thread opens a transaction and takes effect
nacos实战项目中的配置
实战演练 | 在 MySQL 中计算每日平均日期或时间间隔
shell脚本
Re19:读论文 Paragraph-level Rationale Extraction through Regularization: A case study on European Court
Domino服务器SSL证书安装指南
Meikle Studio - see the actual combat notes of Hongmeng device development 4 - kernel development
PyQt5-在窗口上绘制文本
flowable工作流所有业务概念
梅科尔工作室-看鸿蒙设备开发实战笔记五——驱动子系统开发
Re15:读论文 LEVEN: A Large-Scale Chinese Legal Event Detection Dataset
EViews 12.0 software installation package download and installation tutorial
debian10 install djando
BERT pre-training model series summary
leetcode 剑指 Offer 47. 礼物的最大价值
hcip06 ospf特殊区域综合实验
快解析结合用友时空
Security思想项目总结
shell script