FreeRTOS軟件定時器apollo中斷狀態(tài)判斷
問題場景
開發(fā)中發(fā)現(xiàn)FreeRTOS軟件定時器不走了,具體表現(xiàn)在軟件定時器中斷進不去。
分析問題
觀察發(fā)現(xiàn)只有在某個任務執(zhí)行期間,F(xiàn)reeRTOS的軟件定時器才會不走,其他任務執(zhí)行時正常,排查后是此任務的優(yōu)先級比定時器任務高,且占用時間比較長,導致任務切不出去。
解決問題
在FreeRTOSConfig.h中修改定時器任務優(yōu)先級為最高解決問題
apollo中斷狀態(tài)判斷
在看apollo3 代碼時發(fā)現(xiàn)下面這個函數
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發(fā)送一個事件標志組,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
以上就是FreeRTOS軟件定時器apollo中斷狀態(tài)判斷的詳細內容,更多關于FreeRTOS定時器apollo中斷判斷的資料請關注腳本之家其它相關文章!
相關文章
FreeRTOS實時操作系統(tǒng)的多優(yōu)先級實現(xiàn)
這篇文章主要為大家介紹了FreeRTOS實時操作系統(tǒng)的多優(yōu)先級實現(xiàn),有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步早日升職加薪2022-04-04FreeRTOS實時操作系統(tǒng)在Cortex-M3上的移植過程
這篇文章主要為大家介紹了FreeRTOS實時操作系統(tǒng)在Cortex-M3上的移植過程的示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步早日升職加薪2022-04-04