網站首頁 編程語言 正文
問題場景
開發中發現FreeRTOS軟件定時器不走了,具體表現在軟件定時器中斷進不去。
分析問題
觀察發現只有在某個任務執行期間,FreeRTOS的軟件定時器才會不走,其他任務執行時正常,排查后是此任務的優先級比定時器任務高,且占用時間比較長,導致任務切不出去。
解決問題
在FreeRTOSConfig.h中修改定時器任務優先級為最高解決問題
apollo中斷狀態判斷
在看apollo3 代碼時發現下面這個函數
void WsfSetOsSpecificEvent(void) { if(xRadioTaskEventObject != NULL) { BaseType_t xHigherPriorityTaskWoken, xResult; if(xPortIsInsideInterrupt() == pdTRUE) { // Send an event to the main radio task xHigherPriorityTaskWoken = pdFALSE; xResult = xEventGroupSetBitsFromISR(xRadioTaskEventObject, 1, &xHigherPriorityTaskWoken); // If the radio task is higher-priority than the context we're currently // running from, we should yield now and run the radio task. // if ( xResult != pdFAIL ) { portYIELD_FROM_ISR(xHigherPriorityTaskWoken); } } else { xResult = xEventGroupSetBits(xRadioTaskEventObject, 1); // // If the radio task is higher priority than the context we're currently // running from, we should yield now and run the radio task. // if ( xResult != pdFAIL ) { portYIELD(); } } } }
這是FreeRTOS發送一個事件標志組,xPortIsInsideInterrupt
這個函數判斷是否在中斷中,進而調用判斷是否調用FromISR結尾的api,下面看下原理
static portFORCE_INLINE BaseType_t xPortIsInsideInterrupt( void ) { uint32_t ulCurrentInterrupt; BaseType_t xReturn; /* Obtain the number of the currently executing interrupt. */ __asm { mrs ulCurrentInterrupt, ipsr } if( ulCurrentInterrupt == 0 ) { xReturn = pdFALSE; } else { xReturn = pdTRUE; } return xReturn; }
讀IPSR寄存器,0表示當前沒有中斷在運行,非0表示正在運行的中斷號,即處于中斷中,所以要用FromISR結尾的api
原文鏈接:https://blog.csdn.net/weixin_41572450/article/details/109637997
相關推薦
- 2022-08-03 python數據類型可變與不可變深入分析_python
- 2022-07-26 Fatal error in launcher: Unable to create process
- 2022-04-21 sql更新語句中update?set?from用法實現_MsSql
- 2022-03-15 request doesn‘t contain a multipart/form-data or m
- 2022-08-21 C語言實現隊列的示例詳解_C 語言
- 2022-03-24 Android實現旋轉動畫_Android
- 2022-05-29 C#+EmguCV使用攝像頭讀取、保存視頻_C#教程
- 2022-05-26 C++?棧和隊列的實現超詳細解析_C 語言
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支