GD32F303 移植freertos 中断管理设定。。。。

2023-05-16

       之前做项目时,使用GD32F303并移植了freertos。移植过程网上有很多教程,根据这些教程移植就可以。移植完后注意FreeRTOSConfig.h中关于RTOS中断管理的设置。 我移植时在官网下的是当时最新的RTOS版本为:FreeRTOS V202112.00。 移植完后,建立了4个任务,测试没有问题。进行了后续代码编写。在做CAN中断时,使和了二值信号量,测试了下没有问题。但在长时间运行测试时,出现的CAN任务死机(假死)现象。这个坑让我好苦恼,由于项目急没有办法CAN中断最后没有使用二值信号量。 

       后来有时间仔细研究了下FreeRTOSConfig.h文件,发现之前的中断管理设置不对。

在官网下的 FreeRTOS V202112.00版FreeRTOSConfig.h文件关于中断管理内容如下:

/* This is the raw value as per the Cortex-M3 NVIC.  Values can be 255
(lowest) to 0 (1?) (highest). */
#define configKERNEL_INTERRUPT_PRIORITY 		255
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 	191 /* equivalent to 0xb0, or priority 11. */


/* This is the value being used as per the ST library which permits 16
priority values, 0 to 15.  This must correspond to the
configKERNEL_INTERRUPT_PRIORITY setting.  Here 15 corresponds to the lowest
NVIC value of 255. */
#define configLIBRARY_KERNEL_INTERRUPT_PRIORITY	15

这段代码设置的中断管理范围为:11~15

在我的项目中CAN中断的优先级为0。

nvic_irq_enable(USBD_LP_CAN0_RX0_IRQn,0,0);/* configure CAN0 NVIC */

经过查阅资料与使用STM32cubeMX生成代码测试,基本确定问题所在。

       引用《FreeRTOS源码详解与应用---基于STM32》这本书中关于【FreeRTOS中断配置宏】中的一段话和图片。

      低于configMAX_SYSCALL_INTERRUPT_PRIORITY  191(equivalent to 0xb0, or priority 11)这个优先级的中断可以安全的调用 FreeRTOS API函数,高于此优先级的中断FreeRTOS是不能禁止的,中断服务函数不能调用 FreeRTOSR 的API函数。

       之后又参考了下STM32cubeMX生成的带有FreeRTOS的代码FreeRTOSConfig.h中关于中断管理设置,代码如下:

/* Cortex-M specific definitions. */
#ifdef __NVIC_PRIO_BITS
 /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */
 #define configPRIO_BITS         __NVIC_PRIO_BITS
#else
 #define configPRIO_BITS         4
#endif

/* The lowest interrupt priority that can be used in a call to a "set priority"
function. */
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY   15

/* The highest interrupt priority that can be used by any interrupt service
routine that makes calls to interrupt safe FreeRTOS API functions.  DO NOT CALL
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5

/* Interrupt priorities used by the kernel port layer itself.  These are generic
to all Cortex-M ports, and do not rely on any particular library functions. */
#define configKERNEL_INTERRUPT_PRIORITY 		( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 	( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )

我们可以看到这里将中断管理范围设置为:5~15

再查看STM32cubeMX创建的CAN外设的初始化关于中断的设置,

    /* CAN1 interrupt Init */
    HAL_NVIC_SetPriority(USB_LP_CAN1_RX0_IRQn, 5, 0);
    HAL_NVIC_EnableIRQ(USB_LP_CAN1_RX0_IRQn);

STM32cubeMX创建的UART5外设的初始化关于中断的设置,

    /* UART5 interrupt Init */
    HAL_NVIC_SetPriority(UART5_IRQn, 5, 0);
    HAL_NVIC_EnableIRQ(UART5_IRQn);

中断优先级都为5,这样在中断中使用FreeRTOS的API经过测试没有出现 假死 现象。

综上所述。移植FreeRTOS后要注意中断管理设置,否则会出现想不到的结果,给我们的测试、调试带来不可预测的 。。。坑~!

这里仅仅表达我对FreeRTOS中断管理的理解,有不足之处请多指教~!希望我的写的东西能对您有所帮助~!

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

GD32F303 移植freertos 中断管理设定。。。。 的相关文章

  • JWT禁用问题

    JWT禁用问题 前言 需求 前言 需求 token颁发给用户后 在有效期内服务端都会认可 但是如果在token的有效期内需要让token失效 该怎么办 此问题的应用场景 用户修改密码 需要颁发新的token 禁用还在有效期内的老token
  • 对象存储——七牛云存储

    七牛云存储 前言 需求 编码 前言 需求 在项目中 如用户头像 文章图片等数据需要使用文件存储系统来保存 方案 自己搭建文件系统服务 选用第三方对象存储服务 我们在头条项目中使用七牛云对象存储服务 http www qiniu com 使用
  • 对象存储——CDN

    文章目录 前言常见问题 前言 使用第三方OSS服务的好处是集成了CDN服务 xff0c 下面来了解一下什么是CDN CDN 全称 Content Delivery Network或Content Distribute Network xff
  • HTTP通信

    通过网络访问接口实现HTTP通信 mainwindow h span class token macro property span class token directive hash span span class token dire
  • onmouseover和onmouseout事件小结

    前言 onmouseover和onmouseout事件是在pc端上使用非常广泛的鼠标划入划出事件 顾名思义 onmouseover是进入到dom元素中时触发的事件 而onmouseout是移出dom元素时触发的事件 它们即使在ie低版本也有
  • 获取网络接口信息

    获取网络接口信息 mainwindow h span class token macro property span class token directive hash span span class token directive ke
  • UDP通信

    udp发送端 UdpSenderDialog h span class token macro property span class token directive hash span span class token directive
  • TCP通信(01)

    服务器端向客户端发送数据 客户端 span class token macro property span class token directive hash span span class token directive keyword
  • TCP通信(02)

    客户端向服务端发送数据 客户端 span class token macro property span class token directive hash span span class token directive keyword
  • QT 5.15前版本QTcpSocket::error,QAbstractSocket::error信号无法关联槽

    QT5 15版本中 xff0c QAbstractSocket Class将原来的 span class token keyword void span span class token function error span span c
  • 进程通信(02)

    一 xff0c C 43 43 常用进程间通信 管道 Pipe xff1a 管道可用于具有亲缘关系进程间的通信 xff0c 允许一个进程和另一个与它有共同祖先的进程之间进行通信 命名管道 named pipe xff1a 命名管道克服了管道
  • 线程(01)

    使用QThread启动线程 span class token macro property span class token directive hash span span class token directive keyword if
  • 线程(02)——线程同步

    线程同步 互斥锁 QMutex读写锁QReadWriteLock信号量QSemaphore条件变量 QWaitCondition span class token macro property span class token direct
  • 网口调试助手

    一 前言 xff08 1 xff09 TCP通信 xff08 2 xff09 UDP通信 UDP xff08 User Datagram Protocol 用户数据报协议 xff09 是一个轻量级 不可靠 面向数据报的 无连接的协议 xff
  • 低延迟声音效果(01)

    span class token macro property span class token directive hash span span class token directive keyword ifndef span span
  • datax 同步mongodb数据库到hive(hdfs)和elasticserch(es)

    一 同步环境 1 mongodb版本 xff1a 3 6 3 xff08 有点老了 xff0c 后来发现flinkcdc都只能监控一张表 xff0c 多张表无法监控 xff09 2 datax版本 xff1a 自己编译的DataX data
  • Qt播放音视频文件报错DirectShowPlayerService::doRender: Unresolved error code 0x80040266或DirectShowPlayerServi

    Qt播放音视频文件报错DirectShowPlayerService doRender Unresolved error code 0x80040266或DirectShowPlayerService doSetUrlSource Unre
  • 基本图形的绘制与填充

    span class token macro property span class token directive hash span span class token directive keyword ifndef span span
  • 2D坐标变换

    span class token macro property span class token directive hash span span class token directive keyword ifndef span span
  • c++中常量的两种定义方式

    常量是定以后 xff0c 在程序运行中不能被改变的标识符 C 43 43 中定义常量可以用 define const 这两种方法 例如 define PRICE 10 定义单价常量10 const int PRICE 61 10 定义单价常

随机推荐

  • c++中的floor, ceil, round

    xfeff xfeff 2 1 2 6 2 1 2 6 floor 不大于自变量的最大整数 2 2 3 3 ceil 不小于自变量的最小整数 3 3 2 2 round 四舍五入到最邻近的整数 2 3 2
  • 用conat修饰的类成员——常成员函数、常成员数据、常引用

    xfeff xfeff include lt iostream gt include lt cstdlib gt using namespace std class R public R int r1 int r2 m iR1 r1 m i
  • 对象的生存期——变量的生存期与可见性

    include lt iostream gt using namespace std int i 61 1 i为全局变量 xff0c 具有静态生存期 void other a b是静态局部变量 xff0c 具有静态生存期 xff0c 局部可
  • 类的友元

    include lt iostream gt include lt cstdlib gt using namespace std class Point public Point int x int y friend float dist
  • 树莓派全系列对比

    树莓派全系列参数介绍如下 xff1a 再附上 知乎 64 少数派 的一张图 xff1a Raspberry官网对过去使用的博通Soc的描述 BCM2837B0 This is the Broadcom chip used in the Ra
  • Runtime类

    xfeff xfeff 在每一个java应用程序中 xff0c 都有唯一一个RunTime对象 xff0c 该唯一的RunTime对象可通过getRunTime 方法获得 应用程序不能创建自己的RunTime队象 xff0c package
  • 动态二维数组

    include lt iostream gt include lt cstdlib gt using namespace std class Point public Point cout lt lt 34 执行无参构造函数 34 lt l
  • 获得服务器硬件信息(CPUID、硬盘号、主板序列号、IP地址等)

    获得服务器硬件信息 xff08 CPUID 硬盘号 主板序列号 IP地址等 xff09 linux命令 获取IP地址 ifconfig a 获取CPU信息 dmidecode t processor grep ID lscpu cat pr
  • MySQL备份和还原操作

    MySQL备份和还原操作 目标 备份的概念 Mysqldump备份操作 MySQL还原操作 MySQL双机热备份 概述 在数据库表丢失或损坏的情况下 xff0c 备份数据库是很重要的 如果发生系统崩溃 xff0c 能够将表尽可能丢失最少的数
  • MySQL性能优化

    MySQL性能优化 目标 调优思路系统优化mysql服务优化应用优化方式SQL语句调优启用mysql慢查询 调优思路 数据库设计与规划 以后再修该很麻烦 xff0c 估计数据量 xff0c 使用什么存储引擎数据的应用 怎样取数据 xff0c
  • Hadoop伪分布模式安装

    Hadoop伪分布模式安装 Hadoop的运行模式分为3种 xff1a 本地运行模式 xff0c 伪分布运行模式 xff0c 完全分布运行模式 xff08 1 xff09 本地模式 xff08 local mode xff09 这种运行模式
  • 云的几种部署模式

    云的几种部署模式 定义 xff1a 特点云的部署模式 定义 xff1a 云 是一种计算模式 xff0c 利用互联网技术把大量可扩展和弹性的IT相关能力作为 一种服务提供给多个客户 特点 服务化 弹性 多租户 云的部署模式 公有云 混合云 内
  • 通过git 上传本地代码至码云

    实验步骤 1 配置ssh xff08 1 xff09 在本地生成sshkey xff0c 打开git命令终端 git bash 窗口 ssh keygen t rsa C 34 xxxxx 64 xxxxx com 34 你的邮箱 xff0
  • git常见命令

    常见命令 1 初始化本地仓库 git init 2 需要与码云保持一致 git config global user name 34 用户姓名 34 git config global user email 34 用户邮箱 34 3 设置远
  • 【python】详解threading模块:lock、Rlock的使用(二)

    在之前的 python 详解threading模块 xff1a 基本概念 join阻塞和setDaemon守护主线程 xff08 一 xff09 一文中 xff0c 是有对多线程进行一个详细的梳理的 其中就提到了线程锁这一功能 主要基于Rl
  • 定位导航——旋转矩阵,IMU,左右乘

    我们先明确一下这里所说的一些概念 IMU IMU全称Inertial Measurement Unit xff0c 惯性测量单元 xff0c 主要用来检测和测量加速度与旋转运动的传感器 起初只是用来测量角度的 xff0c 后来随着其他传感器
  • scp命令详解

    相关知识 scp是secure copy的简写 xff0c 用于在Linux下进行远程拷贝文件的命令 xff0c 和它类似的命令有cp xff0c 不过cp只是在本机进行拷贝不能跨服务器 xff0c 而且scp传输是加密的 可能会稍微影响一
  • H3C命令详解(笔记)

    1 常用命令 lt gt xff1a 用户视图模式 xff0c 仅仅能配置基本参数 xff0c 调试命令 xff0c 权限较小 xff1a 系统视图模式 xff0c 可以做高级配置 system view 进入系统视图 quit 退出当前模
  • 解决Ubuntu18.04 安装ROS中 sudo rosdep init 和 rosdep update 失败问题

    解决Ubuntu18 04 安装ROS中 sudo rosdep init 和 rosdep update 失败问题 目录 解决Ubuntu18 04 安装ROS中 sudo rosdep init 和 rosdep update 失败问题
  • GD32F303 移植freertos 中断管理设定。。。。

    之前做项目时 xff0c 使用GD32F303并移植了freertos 移植过程网上有很多教程 xff0c 根据这些教程移植就可以 移植完后注意FreeRTOSConfig h中关于RTOS中断管理的设置 我移植时在官网下的是当时最新的RT