首页
Python
Java
IOS
Andorid
NodeJS
JavaScript
HTML5
freertos任务调度进入hardfault中断
2024-09-02
FreeRTOS 中断优先级嵌套错误引发HardFault异常解决
最近在使用FreeRTOS的时候,突然发现程序在运行了几分钟之后所有的任务都不再调用了,只有几个中断能正常使用,看来是系统挂掉了,连续测试了几次想找出问题,可是这个真的有点不知所措. 我先看了下文档里的常见错误,发现和我现在有关系的也就堆栈大小的设置和中断嵌套优先级的设置了,不过我这几个任务都是比较简单的,没有太多的变量,那么现在设置的堆栈大小是够的,不然也不会运行一段时间才奔溃,应该一运行就会奔溃的.那么把问题就集中到了中断嵌套优先级里,我尝试了把 configKERNE
FreeRTOS——任务调度—抢占式,时间片和合作式
以下转载自安富莱电子: http://forum.armfly.com/forum.php 本章教程为大家将介绍 FreeRTOS 操作系统支持的任务调度方式:抢占式,时间片和合作式,这部分算是 FreeRTOS 操作系统的核心了. 对于初学者来说,要一下子就能够理解这些比较困难,需要多花些时间把这些基本概念搞清楚,然后阅读下源码,深入理解实现方法. 关于合作式调度器的特别说明 FreeRTOS 支持的调度方式FreeRTOS 操作系统支持三种调度方式:抢占式调度,时间片调度和合作式调度. 实际
[原创]RTX使用printf输出后进入hardfault中断的处理方法 - 讨论
今天我用到RTX里面使用printf ,发现程序死掉了 我发现很多人遇到了这样的问题 找了网上很多的文章,说是这个是RTX的一个先天不足的问题 我发现了正点原子的 原子哥的解决方案,如下所示: ------------------------------------------------------------------------------- 产生原因: 使用库里的printf函数在输出结束后会调用__used void _mutex_acquire (OS_ID *mutex)这个方法
FreeRTOS 时间片,外部中断,任务优先级的一个疑问
时间片1ms 假设有两个任务,A和B,A任务等待中断里面发出的信号量,B任务在运行 此时,B任务运行了300us的时候中断发生,发出信号量,那么任务A接收到信号量,A任务优先级高,A任务运行 有个问题,假设B任务运行了300us,那么B任务是运行完剩下的700us,才切换到任务A(任务调度),还是立马切换到任务A(任务调度)? 我觉的应该是里面切换到任务A,任务A运行了700us,之后,时间片够1ms,再执行一次任务调度.
FreeRTOS不允许在中断服务程序和临界段中执行不确定的性的操作
举例 等待事件标志组的任务,要是在中断服务程序中设置事件标志组,但不知道当前有多少个任务在等待此事件标志,这个操作即为不确定性操作,为了不在中断服务程序中执行此不确定性操作,只在中断服务程序中给一确定任务发送消息,而在此确定任务中执行事件标志组置位操作,对于临界段的处理,则是将临界段改为调度锁来完成
FreeRTOS 调度锁,任务锁和中断锁
以下转载自安富莱电子: http://forum.armfly.com/forum.php 调度锁调度锁就是 RTOS 提供的调度器开关函数,如果某个任务调用了调度锁开关函数,处于调度锁开和调度锁关之间的代码在执行期间是不会被高优先级的任务抢占的,即任务调度被禁止.这一点要跟临界段的作用区分开,调度锁只是禁止了任务调度,并没有关闭任何中断,中断还是正常执行的.而临界段进行了开关中断操作. 中断锁中断锁就是 RTOS 提供的开关中断函数,FreeRTOS 没有专门的中断锁函数,使用 前一节里面介绍
freeRTOS中文实用教程3--中断管理之中断嵌套
1.前言 最新的 FreeRTOS 移植中允许中断嵌套.中断嵌套需要在 FreeRTOSConfig.h 中设置configKERNEL_INTERRUPT_PRIORITY 和configMAX_SYSCALL_INTERRUPT_PRIORITY 2.控制中断嵌套的常量 常量 描述 configKERNEL_INTERRUPT_PRIORITY 设置系统心跳时钟的中断优先级.如 果 在 移 植 中 没 有 使 用 常 量configMAX_SYSCALL_INTERRUPT_PRIORITY
FreeRTOS 临界段和开关中断
以下转载自安富莱电子: http://forum.armfly.com/forum.php 临界段代码的临界段也称为临界区,一旦这部分代码开始执行,则不允许任何中断打断.为确保临界段代码的执行不被中断,在进入临界段之前须关中断,而临界段代码执行完毕后,要立即开中断. FreeRTOS 临界段相关知识补充FreeRTOS 的源码中有多处临界段的地方, 临界段虽然保护了关键代码的执行不被打断, 但也会影响系统的实时性.比如此时某个任务正在调用系统 API 函数,而且此时中断正好关闭了,也就是进入到了
【FreeRTOS学习06】深度解剖中断与任务之间同步的具体使用场景
嵌入式系统中中断是必不可少的一部分: [FreeRTOS实战汇总]小白博主的RTOS学习实战快速进阶之路(持续更新) 文章目录 1 前言 2 中断特点 3 延迟中断处理 3.1 信号量的使用 3.2 vSemaphoreCreateBinary 3.3 xSemaphoreTake 3.4 xSemaphoreGiveFromISR 4 计数信号量 5 总结 1 前言 本文会在中断基础上对FreeRTOS的中断管理做一个介绍,读者需要掌握中断的概念,本文暂不会对此进行深入介绍:再操作系统中,中断
2、FreeRTOS任务相关API函数
1.任务相关的API函数 函数存在于task.c中,主要的函数有: xTaskCreate():使用动态的方法创建一个任务: xTaskCreatStatic():使用静态的方法创建一个任务(用的非常少): xTaskCreateRestricted():创建一个使用MPU进行限制的任务: vTaskDelete():删除一个任务: vTaskSuspend():挂起一个任务: vTaskResume():恢复一个任务的运行: vTaskResumeFromISR():中断服务函数中恢复一个任务
freeRTOSConfig.h文件对FreeRTOS进行系统配置
FreeRTOS内核是高度可定制的,使用配置文件FreeRTOSConfig.h进行定制.每个FreeRTOS应用都必须包含这个头文件,用户根据实际应用来裁剪定制FreeRTOS内核.这个配置文件是针对用户程序的,而非内核,因此配置文件一般放在应用程序目录下,不要放在RTOS内核源码目录下. 在下载的FreeRTOS文件包中,每个演示例程都有一个FreeRTOSConfig.h文件.有些例程的配置文件是比较旧的版本,可能不会包含所有有效选项.如果没有在配置文件中指定某个选项,那么RTOS内核会使
FreeRTOS
一.内核配置 1.configUSE_PREEMPTION 设置为1,使用抢先式内核:设置为0,为合作轮转内核. 2.configCPU_CLOCK_HZ 内部处理器执行的频率.这个值需要正确配置外围定时器. 3.configTICK_RATE_HZ(1-1000) RTOS时间片中断的频率. 时间片中断用来测量时间.因此更高时间片频率意味着时间测量可以有更高分辨率,同时意味着内核占用更多的CPU(效率很低). 多个任务共有同一优先级.通过切换任务,在每一个RTOS时间片内,内核将在同一优先级的
FreeRTOS基础篇教程目录汇总
以下教程(大部分章节)(尤其理论介绍部分)转载自安富莱电子,官网链接: http://forum.armfly.com/forum.php 然后根据安富莱的教程自己做了分析和测试,希望大家共同进步. 其中也有个别章节是正点原子和野火的教程. 提高篇开始是自己根据使用经验的原创,期间也有参考官方资料的原创.主要先使用安富莱的教程达到入门水平.有需要时还得分析源码. 目录 1.FreeRTOS——1 2.FreeRTOS基础知识 3.FreeRtos——移植 4.FreeRtos——单任务 5.Fr
FreeRTOS笔记
任务的创建和删除(静态方法) 任务创建后要开启调度器. FreeRTOSConfig.h 1. 改宏 使能静态创建函数. 会出现,有两个函数未定义. Cortex-M中断管理(上) NVIC:嵌套向量中断控制器. 与中断有关的寄存器都在NVIC和SCB中 Cortex-M中断管理(下) 中断优先级设置 IP[240U] 中断向量表中定义具体对应关系. IP[0] IP[1] IP[2] port.c 中设置PendSV和SysTick优先级 中断屏蔽寄存器有三个: PRIMASK FAULTMA
不可被忽视的操作系统( FreeRTOS )【2】
本文章总结基于官方FreeRTOS手册,测试系统为ESP32的IDF 4.0 本篇续上一篇<不可被忽视的操作系统( FreeRTOS )[1]> 其中上一篇主要内容为: FreeRTOS介绍 FreeRTOS在ESP32中的特殊性 任务相关函数 队列相关函数 本篇内容主要有: 信号量相关函数 计时器相关函数 事件组相关函数 任务通知相关函数 信号量 reertos / include / freertos / semphr.h 信号量是操作系统中重要的一部分,信号量一般用来进行资源管理和任务同
FreeRTOS相关转载-(朱工的专栏)
FreeRTOS系列第1篇---为什么选择FreeRTOS? 1.为什么学习RTOS? 作为基于ARM7.Cortex-M3硬件开发的嵌入式工程师,我一直反对使用RTOS.不仅因为不恰当的使用RTOS会给项目带来额外的稳定性风险,更重要的是我认为绝大多数基于ARM7.Cortex-M3硬件的项目,还没复杂到使用RTOS的地步,使用状态机就足够了. 对于现代的微处理器,特别是资源相对丰富ARM7.Cortex-M3硬件来说,RTOS占用的硬件资源已经越来越可以忽略.所以在当今环境下,我们无需担心R
【freertos】005-启动调度器分析
前言 本节主要讲解启动调度器. 这些都是与硬件相关,所以会分两条线走:posix和cortex m3. 原文:李柱明博客:https://www.cnblogs.com/lizhuming/p/16076476.html 调度器的基本概念 调度器 调度器就是使用相关的调度算法来决定当前需要执行的任务. 调度器特点: 调度器可以区分就绪态任务和挂起任务. 调度器可以选择就绪态中的一个任务,然后激活它. 不同调度器之间最大的区别就是如何分配就绪态任务间的完成时间. 嵌入式实时操作系统的核心就是调度器
FreeRTOS 事件标志组
以下转载自安富莱电子: http://forum.armfly.com/forum.php 为什么要使用事件标志事件标志组是实现多任务同步的有效机制之一.也许有不理解的初学者会问采用事件标志组多麻烦,搞个全局变量不是更简单?其实不然,在裸机编程时,使用全局变量的确比较方便,但是在加上 RTOS 后就是另一种情况了. 使用全局变量相比事件标志组主要有如下三个问题: 使用事件标志组可以让 RTOS 内核有效地管理任务,而全局变量是无法做到的,任务的超时等机制需要用户自己去实现. 使用了全局变量就
FreeRTOS 中断优先级配置(重要)
以下转载自安富莱电子: http://forum.armfly.com/forum.php NVIC 的全称是 Nested vectored interrupt controller,即嵌套向量中断控制器.对于 M3 和 M4 内核的 MCU,每个中断的优先级都是用寄存器中的 8 位来设置的. 8 位的话就可以设置 2^8 = 256 级中断,实际中用不了这么多,所以芯片厂商根据自己生产的芯片做出了调整.比如 ST的 STM32F1xx 和 F4xx 只使用了这个 8 位中的高四位[7:4],
FreeRtos——移植
现在准备的简单程序LED灯的工程目录中增加freertos文件夹: 在 source目录下的portable目录下只留下下面的文件夹: 为什么呢? 把对应文件移植在工程中之后,添加头文件路径如下图: 编译之后,报错如下: 提示少了配置文件,那么我们可以在官方demo文件目录下复制一个到我们工程中来. 这个时候需要观察一下这个config.h文件, 这里更改一点代码: 那个条件编译最后就是为了定义CLOCK_HZ的,cpu的频率根据硬件平台的不同,要做适当处理,所以我们直接把这个宏定义出来,180
记一次FreeRTOS错误配置导致无法进入临界区
最近项目用到FreeRTOS,在实际调试中发现我自己的一段代码本来好用的(在无RTOS的情况下),但是当我在带RTOS的情况下把代码放到一个单独的任务中运行时我发现本来好用的代码莫名其妙的出现问题,有一定的概率会失败,考虑到应该是内核发生了调度导致代码中时序比较严格的地方被打断因此会出现时好时不好的现象,因此我对时序严格的地方调用了taskENTER_CRITICAL();和taskEXIT_CRITICAL();进行任务切换保护和中断但是结果还是一样,由此一来这个问题困扰了好久,我就开始怀疑f
热门专题
opollo 配置详解
idea2021删除project
matlap用牛顿下山法求不动点
centos能ping 不能访问外网,
句子种类 练习 陈述句 疑问句 祈使句 感叹句
writerow全部用法
@DisallowConcurrentExecution意义
Python 修改系统print
通过JSP网页连接Mysql数据库实现增删改
postgresql 读等待锁
linux(( )) 算术用法
matlab 使用latex
X-Password”和“X-Datebase怎么提取资料的
php 日期加15个月
jenkins 聚合工程选项发布
gin框架参数tag默认值设置的作用
python 网页转二维码
用maven创建模块没有创建类的
H5嵌入app 上传图片
linux 模糊查询tomcat日志