设为首页 加入收藏

TOP

STM32F429 Discovery开发板应用:使用FreeRTOS队列+DMA双缓存实现串口数据接收(一)
2023-07-23 13:25:35 】 浏览:58
Tags:STM32F429 Discovery 应用 使用 FreeRTOS 队列 DMA 双缓存

 

参考帖子:https://blog.csdn.net/freedompoi/article/details/122350866

目前想要实现STM32F4自带的DMA双缓冲区,尝试过一版,结果不能预期,就使用了RxHalfCplt和RxCplt去实现DMA双缓冲区的效果。

现在有时间了,又重新实现STM32F4自带的DMA双缓冲区,作为参考。

 

MCU:STM32F429ZIT6

开发环境:STM32CubeMX+MDK5

 

此时,双击完后会关闭此界面,然后打开一个新界面。

 

然后,我们开始基本配置。

 

现在我们选择一个LED作为系统LED,该步骤可以忽略,只是本人喜欢这样子。以硬件原理图的LD3为例子。

 

基本配置除了时钟树外,基本上已经配置好了。

现在配置时钟树

 

基本配置已经配置完,现在开始配置实验使用的内容。

配置USART1,打开USART中断。并打开DMA。

 

配置FreeRTOS

 

配置完成,完善工程,生成工程。

到此,STM32CubeMX工具的使用结束!可以发现在桌面已经生成了DMA_DoubleBuf工程。

 

使用MDK5打开SDCard_rw工程打开。点击魔法棒,勾选微库。选择对应的下载器,勾选下载完复位允许。

在usart.h文件中,加入内容。

 1 /* USER CODE BEGIN Header */
 2 /**
 3   ******************************************************************************
 4   * @file    usart.h
 5   * @brief   This file contains all the function prototypes for
 6   *          the usart.c file
 7   ******************************************************************************
 8   * @attention
 9   *
10   * Copyright (c) 2023 STMicroelectronics.
11   * All rights reserved.
12   *
13   * This software is licensed under terms that can be found in the LICENSE file
14   * in the root directory of this software component.
15   * If no LICENSE file comes with this software, it is provided AS-IS.
16   *
17   ******************************************************************************
18   */
19 /* USER CODE END Header */
20 /* Define to prevent recursive inclusion -------------------------------------*/
21 #ifndef __USART_H__
22 #define __USART_H__
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 /* Includes ------------------------------------------------------------------*/
29 #include "main.h"
30 
31 /* USER CODE BEGIN Includes */
32 #include "cmsis_os.h"
33 #include <semphr.h>
34 /* USER CODE END Includes */
35 
36 extern UART_HandleTypeDef huart1;
37 
38 /* USER CODE BEGIN Private defines */
39 
40 #define UART_BUFF_SIZE  30
41  
42 #pragma pack(4)
43 typedef struct
44 {
45     uint16_t len;
46     uint8_t  data[UART_BUFF_SIZE];
47 }usart_multibuffer_data;
48 #pragma pack()
49 
50 /* USER CODE END Private defines */
51 
52 void MX_USART1_UART_Init(void);
53 
54 /* USER CODE BEGIN Prototypes */
55 void UART_DMA_MultiBuffer(void);
56 /* USER CODE END Prototypes */
57 
58 #ifdef __cplusplus
59 }
60 #endif
61 
62 #endif /* __USART_H__ */

在usart.c文件中,加入内容。

  1 /* USER CODE BEGIN Header */
  2 /**
  3   ******************************************************************************
  4   * @file    usart.c
  5   * @brief   This file provides code for the configuration
  6   *          of the USART instances.
  7   ******************************************************************************
  8   * @attention
  9   *
 10   * Copyright (c) 2023 STMicroelectronics.
 11   * All rights reserved.
 12   *
 13   * This software is licensed under terms that can be found in the LICENSE file
 14   * in the root directory of this software component.
 15   * If no LICENSE file comes with this software, it is provided AS-IS.
 16   *
 17   ******************************************************************************
 18   */
 19 /* USER CODE END Header */
 20 /* Includes ------------------------------------------------------------------*/
 21 #include "usart.h"
 22 
 23 /* USER CODE BEGIN 0 */
 24 QueueHandle_t           queue_mes;  
 25 usart_multibuffer_data     uart_buf[2];
首页 上一页 1 2 3 4 下一页 尾页 1/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇树莓派+阿里云+frp 实现内网穿透 下一篇微控制器实时操作系统实践4选择正..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目