国产毛片a精品毛-国产毛片黄片-国产毛片久久国产-国产毛片久久精品-青娱乐极品在线-青娱乐精品

電子工程網(wǎng)

標(biāo)題: FreeRTOS 定時(shí)器精度研究 [打印本頁(yè)]

作者: 小融一號(hào)    時(shí)間: 2016-10-11 10:52
標(biāo)題: FreeRTOS 定時(shí)器精度研究

背景介紹                       
FreeRTOS 以其移植方便,高度可定制,footprint 小,使其在嵌入式操作系統(tǒng)中的份額不容小覷! 尤以免費(fèi) license,頗受開發(fā)者青睞。

問題描述
客戶在基于cortex-m3的平臺(tái)上使用FreeRTOS系統(tǒng)提供的定時(shí)器功能時(shí),意外發(fā)現(xiàn)定時(shí)器的精確度不夠高。譬如,設(shè)置1秒鐘的定時(shí)器,理論上1秒超時(shí),并且執(zhí)行相應(yīng)的回調(diào)函數(shù)。但是調(diào)試卻發(fā)現(xiàn),有時(shí)回調(diào)函數(shù)是在1.4秒后被執(zhí)行!這對(duì)于精度要求較高的實(shí)時(shí)系統(tǒng),是不能接受的!

問題復(fù)現(xiàn)與分析
首先在stm32f407-discovery平臺(tái)移植FreeRTOS,并創(chuàng)建一個(gè)定時(shí)器,在其回調(diào)函數(shù)里toggle led燈,并測(cè)量被執(zhí)行的時(shí)間。鑒于FreeRTOS是一個(gè)多任務(wù)可搶占式系統(tǒng),這個(gè)問題需要在多種情況下分析。
Case 1 :
單任務(wù),即系統(tǒng)里僅有timertask和idle task。整個(gè)系統(tǒng)最高優(yōu)先級(jí)為4,Timer task的優(yōu)先級(jí)為默認(rèn)優(yōu)先級(jí)2。
在這種環(huán)境下,回調(diào)函數(shù)能精確的以1秒的時(shí)長(zhǎng)超時(shí)執(zhí)行回調(diào)函數(shù)。雖然此刻精度能滿足要求,但是實(shí)際的系統(tǒng)一般會(huì)包含多個(gè)task。
以下為測(cè)試的日志,顯而易見,該定時(shí)器嚴(yán)格1秒鐘超時(shí)。
expired 1000
expired 2000
expired 3000
expired 4000
expired 5000
expired 6000
Case 2 :
多任務(wù),即系統(tǒng)里不僅有timertask和idle task,還有用戶創(chuàng)建的task。整個(gè)系統(tǒng)最高優(yōu)先級(jí)為4,Timer task的優(yōu)先級(jí)為默認(rèn)優(yōu)先級(jí)2。
以下為測(cè)試的日志。
UART Printf Example:retarget the C library printf function to the UART
UART Printf Example:retarget the C library printf function to the UART
UART Printf Example:retarget the C library printf function to the UART
expired 1000
UART Printf Example:retarget the C library printf function to the UART
UART Printf Example:retarget the C library printf function to the UART
UART Printf Example:retarget the C library printf function to the UART
UART Printf Example:retarget the C library printf function to the UART
UART Printf Example:retarget the C library printf function to the UART
expired 3000
UART Printf Example:retarget the C library printf function to the UART
UART Printf Example:retarget the C library printf function to the UART
UART Printf Example:retarget the C library printf function to the UART
expired 4000
UART Printf Example:retarget the C library printf function to the UART
UART Printf Example:retarget the C library printf function to the UART
expired 5000
UART Printf Example:retarget the C library printf function to the UART
UART Printf Example:retarget the C library printf function to the UART
UART Printf Example:retarget the C library printf function to the UART
expired 6000
此時(shí)定時(shí)器回調(diào)函數(shù)有時(shí)能準(zhǔn)確地被調(diào)度執(zhí)行,有時(shí)則偏差較大,與期望值整整延遲了1秒鐘。
Case 3 :
多任務(wù),即系統(tǒng)里不僅有timer task和idle task,還有用戶創(chuàng)建的task。整個(gè)系統(tǒng)最高優(yōu)先級(jí)為4,Timertask的優(yōu)先級(jí)為默認(rèn)優(yōu)先級(jí)4。這樣設(shè)置優(yōu)先級(jí),是希望能通過將timer task設(shè)置為最高優(yōu)先級(jí),以期望調(diào)度器能優(yōu)先調(diào)度執(zhí)行timer task。
以下為實(shí)測(cè)的日志。
UART Printf Example:retarget the C library printf function to the UART
UART Printf Example:retarget the C library printf function to the UART
UART Printf Example:retarget the C library printf function to the UART
expired 1000
UART Printf Example:retarget the C library printf function to the UART
UART Printf Example:retarget the C library printf function to the UART
UART Printf Example:retarget the C library printf function to the UART
UART Printf Example:retarget the C library printf function to the UART
UART Printf Example:retarget the C library printf function to the UART
expired 3000
UART Printf Example:retarget the C library printf function to the UART
UART Printf Example:retarget the C library printf function to the UART
UART Printf Example:retarget the C library printf function to the UART
expired 4000
UART Printf Example:retarget the C library printf function to the UART
UART Printf Example:retarget the C library printf function to the UART
expired 5000
UART Printf Example:retarget the C library printf function to the UART
UART Printf Example:retarget the C library printf function to the UART
UART Printf Example:retarget the C library printf function to the UART
expired 6000
雖然調(diào)整了timertask的優(yōu)先級(jí)至最高,但是依然會(huì)出現(xiàn)嚴(yán)重的偏差。

解決方案   
考慮到FreeRTOS定時(shí)器的精準(zhǔn)性不高,建議客戶使用SysTick或者M(jìn)CU的外設(shè)硬件定時(shí)器。
重要通知 - 請(qǐng)仔細(xì)閱讀
意法半導(dǎo)體公司及其子公司(“ST”)保留隨時(shí)對(duì)ST 產(chǎn)品和/ 或本文檔進(jìn)行變更、更正、增強(qiáng)、修改和改進(jìn)的權(quán)利,恕不另行通知。買方訂貨之前應(yīng)獲取關(guān)于ST 產(chǎn)品的最新信息。ST 產(chǎn)品的銷售依照訂單確認(rèn)時(shí)的相關(guān)ST 銷售條款。
買方自行負(fù)責(zé)對(duì)ST 產(chǎn)品的選擇和使用, ST 概不承擔(dān)與應(yīng)用協(xié)助或買方產(chǎn)品設(shè)計(jì)相關(guān)的任何責(zé)任。
ST 不對(duì)任何知識(shí)產(chǎn)權(quán)進(jìn)行任何明示或默示的授權(quán)或許可。
轉(zhuǎn)售的ST 產(chǎn)品如有不同于此處提供的信息的規(guī)定,將導(dǎo)致ST 針對(duì)該產(chǎn)品授予的任何保證失效。
ST 和ST 徽標(biāo)是ST 的商標(biāo)。所有其他產(chǎn)品或服務(wù)名稱均為其各自所有者的財(cái)產(chǎn)。
本文檔中的信息取代本文檔所有早期版本中提供的信息。




文章來源:微信公眾號(hào)  融創(chuàng)芯城(一站式電子元器件、PCB、PCBA購(gòu)買服務(wù)平臺(tái),項(xiàng)目眾包平臺(tái))







歡迎光臨 電子工程網(wǎng) (http://m.qingdxww.cn/) Powered by Discuz! X3.4
主站蜘蛛池模板: 亚洲国产欧美在线 | 4hu四虎永久地址 | 国产精品原创巨作无遮挡 | a久久久久一级毛片护士免费 | 亚洲精品国精品久久99热 | 欧美视频网站免费看 | 青青青国产免费手机视频在线观看 | 国内在线观看精品免费视频 | 青青草网站在线观看 | 在线国产毛片 | 日本韩国在线 | 久久福利影院 | 日韩亚洲精品不卡在线 | 春日迟迟再出发综艺在线观看免费 | 国内精品久久久久久影院老狼 | 性欧美黑人 | 亚洲精品国产精品国自产网站 | 热99热| 国产精品密播放国产免费看 | 国产欧美亚洲精品综合在线 | 欧美一区a | 神兵小将第一季免费播放 | 四虎影院永久网址 | 农村寡妇一级毛片免费看视频 | 国产在线播放91 | 97视频福利 | 亚洲国产精品91 | 久久久久久久久久毛片精品美女 | 黄色片手机在线观看 | 免费一级毛片在线观看 | 免费观看欧美 | 在线观看麻豆国产精品 | 国产在线播放网址 | 香蕉草莓丝瓜茄子番茄绿巨人 | 亚洲精品国产高清不卡在线 | 成年人视频免费在线播放 | 欧美一区二区三区在线 | 午夜影剧院 | 国产免费131美女视频 | 日本高清视频网站www | 污网站在线观看 |