女人自慰AV免费观看内涵网,日韩国产剧情在线观看网址,神马电影网特片网,最新一级电影欧美,在线观看亚洲欧美日韩,黄色视频在线播放免费观看,ABO涨奶期羡澄,第一导航fulione,美女主播操b

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

FreeRTOS中Systick的問題

撞上電子 ? 2023-12-15 08:00 ? 次閱讀

在Cortex-M內(nèi)核中,系統(tǒng)節(jié)拍由Systick時鐘提供,當(dāng)配置好系統(tǒng)滴答時鐘后,每次時鐘中斷就會觸發(fā)中斷處理數(shù)xPortSysTickHandler()。

void xPortSysTickHandler( void ){ /* The SysTick runs at the lowest interrupt priority, so when this interrupt * executes all interrupts must be unmasked. There is therefore no need to * save and then restore the interrupt mask value as its value is already * known - therefore the slightly faster vPortRaiseBASEPRI() function is used * in place of portSET_INTERRUPT_MASK_FROM_ISR(). */ vPortRaiseBASEPRI();//屏蔽歸屬FreeRTOS的中斷優(yōu)先級 { /* Increment the RTOS tick. */ if( xTaskIncrementTick() != pdFALSE )//時鐘計(jì)數(shù)處理 { /* A context switch is required. Context switching is performed in * the PendSV interrupt. Pend the PendSV interrupt. */ portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;//如果需要切換上下文操作,PendSV標(biāo)記置位 } }

vPortClearBASEPRIFromISR();}

這部分主要是依靠 xTaskIncrementTick(),來判斷任務(wù)切換是否在此次系統(tǒng)時鐘中斷時被需要。如果是,則PendSV標(biāo)記置位,等待觸發(fā)PendSV中斷。來看看 xTaskIncrementTick()。

BaseType_t xTaskIncrementTick( void ){ TCB_t * pxTCB; TickType_t xItemValue; BaseType_t xSwitchRequired = pdFALSE;

/* Called by the portable layer each time a tick interrupt occurs. * Increments the tick then checks to see if the new tick value will cause any * tasks to be unblocked. */ traceTASK_INCREMENT_TICK( xTickCount );

if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) //調(diào)度是否被掛起,默認(rèn)為否 { /* Minor optimisation. The tick count cannot change in this * block. */ const TickType_t xConstTickCount = xTickCount + ( TickType_t ) 1;

/* Increment the RTOS tick, switching the delayed and overflowed * delayed lists if it wraps to 0. */ xTickCount = xConstTickCount;

if( xConstTickCount == ( TickType_t ) 0U ) /*lint !e774 'if' does not always evaluate to false as it is looking for an overflow. 如果xConstTickCount為0,說明溢出了*/ { taskSWITCH_DELAYED_LISTS();/*切換延遲列表*/ } else { mtCOVERAGE_TEST_MARKER(); }

/* See if this tick has made a timeout expire. Tasks are stored in * the queue in the order of their wake time - meaning once one task * has been found whose block time has not expired there is no need to * look any further down the list. */ if( xConstTickCount >= xNextTaskUnblockTime ) { for( ; ; ) { if( listLIST_IS_EMPTY( pxDelayedTaskList ) != pdFALSE ) { /* The delayed list is empty. Set xNextTaskUnblockTime * to the maximum possible value so it is extremely * unlikely that the * if( xTickCount >= xNextTaskUnblockTime ) test will pass * next time through. */ xNextTaskUnblockTime = portMAX_DELAY; /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ break; } else { /* The delayed list is not empty, get the value of the * item at the head of the delayed list. This is the time * at which the task at the head of the delayed list must * be removed from the Blocked state. */ pxTCB = listGET_OWNER_OF_HEAD_ENTRY( pxDelayedTaskList ); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */ xItemValue = listGET_LIST_ITEM_VALUE( &( pxTCB->xStateListItem ) );

關(guān)鍵問題是,這個函數(shù)使用到了pxDelayedTaskList, 這定義在本文件

PRIVILEGED_DATA static List_t * volatile pxDelayedTaskList;

該變量初始化為0,該變量正常初始化位置在創(chuàng)建 Task 對象等的函數(shù)中, 也就是說,如果在Tick中斷到來時,如果還沒有任務(wù)被創(chuàng)建,就會導(dǎo)致不可預(yù)期的結(jié)果,中斷服務(wù)函數(shù)會使用這個野指針,執(zhí)行任務(wù)切換。這會導(dǎo)致觸發(fā)棧溢出鉤子函數(shù),或者是直接Hardfault。有些硬件初始化需要借助delay功能,不得不在初始化之前配置SysTick。而又不希望在硬件初始化階段觸發(fā)這個Bug。所以在配置SysTick之前,先創(chuàng)建一個初始化任務(wù),初始化 pxDelayedTaskList 這個指針,在初始化任務(wù)里配置SysTick,和其他初始化,這樣能夠避免此類問題。或者是在配置SysTick的時候屏蔽中斷,一切準(zhǔn)備就緒后,開啟中斷。執(zhí)行vTaskStartScheduler()默認(rèn)創(chuàng)建一個空閑任務(wù)。

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報(bào)投訴
  • 內(nèi)核
    +關(guān)注

    關(guān)注

    3

    文章

    1408

    瀏覽量

    41084
  • FreeRTOS
    +關(guān)注

    關(guān)注

    12

    文章

    488

    瀏覽量

    63725
  • Systick
    +關(guān)注

    關(guān)注

    0

    文章

    63

    瀏覽量

    13473
收藏 人收藏

    評論

    相關(guān)推薦
    熱點(diǎn)推薦

    FreeRTOS內(nèi)核默認(rèn)會初始化systick是必須的嗎?

    FreeRTOS內(nèi)核默認(rèn)會初始化systick;原子哥的視頻教程里的例程也會使用delay_init初始化systick。請問是否是必須,有無影響?
    發(fā)表于 07-20 08:03

    使用FreeRTOSSystick時鐘的配置分享

    FreeRTOS按照教程移植好之后就可以使用了。需要注意的是從官網(wǎng)下載的針對keil環(huán)境下STM32F103的FreeRTOS文件,使用systick時鐘作為rtos的時鐘,而這個systic
    發(fā)表于 07-30 11:39

    SysTicK的函數(shù)重復(fù)定義

    ).原因使用KEIL時在Manage Run-Time Environment勾選的HAL庫,然后添加FreeRTOS操作系統(tǒng)時,工程會出現(xiàn)問題首先是下圖SysTicK的函數(shù)重復(fù)定義,是因?yàn)樘砑拥?/div>
    發(fā)表于 08-04 07:55

    使用CubeMX 6為freeRTOS生成代碼的問題如何解決?

    我認(rèn)為在使用 freeRTOS 生成代碼時,新的 CubeMX 6.0 存在錯誤。可能只是從舊的 CubeMX 項(xiàng)目遷移到新的項(xiàng)目時,我不確定。我將使用 CubeMX 5.3 構(gòu)建的項(xiàng)目更新為
    發(fā)表于 01-31 08:56

    系統(tǒng)節(jié)拍定時(SysTick)

    SysTick 是一個簡單的系統(tǒng)時鐘節(jié)拍計(jì)數(shù)器,它屬于 ARM Cortex-M3 內(nèi)核嵌套向量中斷 控制器 NVIC 里的一個功能單元,而非片內(nèi)外設(shè)。SysTick 常用于操作系統(tǒng)(如:μC/OS-II、 FreeRTOS
    發(fā)表于 01-13 16:34 ?8次下載

    如何使用STM32實(shí)現(xiàn)systick的精確延時

    SYSTICK寄存器初始化 void SysTick_Configuration(void) { if (SysTick_Config(SystemCoreClock / 100
    發(fā)表于 11-21 15:54 ?6095次閱讀

    STM32SysTick時鐘源來自哪里?

    STM32的SysTick時鐘源來自哪里?
    的頭像 發(fā)表于 03-03 14:32 ?8180次閱讀

    如何使用STM32單片機(jī)systick來實(shí)現(xiàn)延時定時功能

    SysTick 控制及狀態(tài)寄存器的使能位清除,就永不停息。這樣可以用systick來實(shí)現(xiàn)延時定時功能,不用再占用系統(tǒng)定時器。systick也多用做系統(tǒng)的時鐘節(jié)拍,如
    的頭像 發(fā)表于 02-14 06:25 ?7325次閱讀
    如何使用STM32單片機(jī)<b class='flag-5'>systick</b>來實(shí)現(xiàn)延時定時功能

    STM32—關(guān)于SYSTICK系統(tǒng)時鐘的詳解及學(xué)習(xí)筆記

    /*配置SYSTICK很簡單,只需在SySTick_Config寫入一個不大于2^24次方的數(shù),就可以產(chǎn)生systick中斷1.無需對NVIC進(jìn)行配置,在
    發(fā)表于 11-30 15:51 ?15次下載
    STM32—關(guān)于<b class='flag-5'>SYSTICK</b>系統(tǒng)時鐘的詳解及學(xué)習(xí)筆記

    STM32_SysTick—系統(tǒng)定時器

    SysTick 的簡介和寄存器的詳細(xì)描述。因?yàn)?SysTick 是屬于CM3 內(nèi)核的外設(shè),有關(guān)寄存器的定義和部分庫函數(shù)都在 core_CM3.h 這個頭文件實(shí)現(xiàn)。所以學(xué)習(xí) SysTick
    發(fā)表于 12-23 19:56 ?2次下載
    STM32_<b class='flag-5'>SysTick</b>—系統(tǒng)定時器

    systick定時器 延時計(jì)時

    是cortex M內(nèi)核的單片機(jī),都擁有這個24位的systick定時器。systick定時器是一個24位遞減計(jì)時器,用戶至于要掌握CMSIS包SysTick_Config 函數(shù)進(jìn)行
    發(fā)表于 01-18 10:28 ?7次下載
    <b class='flag-5'>systick</b>定時器 延時計(jì)時

    STM32單片機(jī)systick使用注意事項(xiàng)

    寄存器自動重裝載定時初值。只要不把它在SysTick 控制及狀態(tài)寄存器的使能位清除,就永不停息。這樣可以用systick來實(shí)現(xiàn)延時定時功能,不用再占用系統(tǒng)定時器。
    發(fā)表于 01-18 10:35 ?1次下載
    STM32單片機(jī)<b class='flag-5'>systick</b>使用注意事項(xiàng)

    什么是FreeRTOS的延時

    FreeRTOS的時鐘節(jié)拍通常由**SysTick**提供,它周期性的產(chǎn)生定時中斷,所謂的時鐘節(jié)拍管理的核心就是這個定時中斷的服務(wù)程序。**FreeRTOS**的時鐘節(jié)拍isr核心的
    的頭像 發(fā)表于 02-14 09:45 ?3928次閱讀
    什么是<b class='flag-5'>FreeRTOS</b>的延時

    SysTick時鐘

    Cortex-M3內(nèi)核的處理器,內(nèi)部包含了一個SysTick定時器,SysTick是一個24位的倒計(jì)數(shù)定時器,當(dāng)計(jì)數(shù)到0時,將從ReLoad寄存器自動重裝載定時初值,開始新一輪計(jì)數(shù)。只要不把它在
    的頭像 發(fā)表于 03-01 17:40 ?1049次閱讀
    <b class='flag-5'>SysTick</b>時鐘

    systick_handler無法進(jìn)入怎么解決

    在嵌入式系統(tǒng)SysTick是一個用于定時器和延時的模塊,通常用于處理實(shí)時任務(wù)、中斷和延時等。然而,在某些情況下,SysTick中斷處理函數(shù)(systick_handler)可能無法
    的頭像 發(fā)表于 12-01 15:36 ?6370次閱讀