版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、<p><b> 中文3920字</b></p><p><b> 畢業(yè)設(shè)計(jì)翻譯文獻(xiàn)</b></p><p> 文獻(xiàn)題目:Construction of Embedded System Platform which Based on μC/OS-Ⅱ and ARM7 Kernel Microprocessor</p>
2、<p> 構(gòu)建基于μC/ OS-Ⅱ和ARM7內(nèi)核微處理器的嵌入式系統(tǒng)平臺</p><p> 學(xué)生姓名: </p><p> 學(xué) 院: 信息與通信工程學(xué)院 </p><p> 專 業(yè): 電子信息工程 </p><p>
3、; 指導(dǎo)教師: </p><p> 2015年 5 月 10 日</p><p> 構(gòu)建基于μC/ OS-Ⅱ和ARM7內(nèi)核微處理器的嵌入式系統(tǒng)平臺</p><p> Yujun Bao Xiaoyan Jiang </p><p><b> 摘 要</b&g
4、t;</p><p> 今天,嵌入式系統(tǒng)被廣泛地應(yīng)用于各行各業(yè)。引入嵌入式操作系統(tǒng)在嵌入式發(fā)展中已經(jīng)是一種趨勢。嵌入式操作系統(tǒng)能夠適用于不同的系統(tǒng)硬件,并能夠顯著的減少開發(fā)費(fèi)用,縮短研究周期。μC/ OS-Ⅱ是一款優(yōu)秀的開源,輕型內(nèi)核,占用少量資源并且在實(shí)時(shí)性方面有著高性能的嵌入式操作系統(tǒng)。μC/ OS-Ⅱ適用于越來越多的32位ARM7核微處理器,本文介紹了基于ARM7微處理器的μC/ OS-Ⅱ嵌入式操作系統(tǒng)的
5、移植方法。最終實(shí)現(xiàn)了構(gòu)建基于μC/ OS-Ⅱ和ARM7內(nèi)核處理器的嵌入式開發(fā)平臺。該平臺能有效的簡化軟件程序開發(fā)流程,并縮短工程研究的周期和顯著提高系統(tǒng)的執(zhí)行效率。</p><p> 關(guān)鍵字:嵌入式系統(tǒng);嵌入式操作系統(tǒng);ARM7內(nèi)核;μC/ OS-Ⅱ</p><p><b> 介紹</b></p><p> 所謂的操作系統(tǒng)移植是一個(gè)實(shí)時(shí)操
6、作系統(tǒng)內(nèi)核可以在運(yùn)行在其他微處理器上。移植部分對于不同的CPU具有對應(yīng)的不同的代碼。大多數(shù)μC / OS-Ⅱ代碼是用C編程語言編寫的,這對于移植μC / OS -Ⅱ是非常方便的。但根據(jù)不同的微處理器,用戶仍然需要使用匯編語言編寫一些有關(guān)不同微處理器的硬件的程序。這是因?yàn)楫?dāng)μC / OS-Ⅱ讀或?qū)懠拇嫫鲿r(shí),它只依賴于匯編語言。</p><p> 因?yàn)棣藽 / OS -Ⅱ操作系統(tǒng)的要求,有三個(gè)文件需要當(dāng)μC / O
7、S-Ⅱ移植到一個(gè)特定的微處理器。整個(gè)移植工作主要圍繞創(chuàng)建這三個(gè)文件。這些文件顯示如下:</p><p> 1、在C語言中的頭文件OS_CPU中,一些與編譯器無關(guān)的數(shù)據(jù)</p><p> 類型需要定義OS_CPU中。</p><p> 這些數(shù)據(jù)類型包括使用的堆棧數(shù)據(jù)類型和堆棧的增長方向。一些與ARM7內(nèi)核相關(guān)的軟件中斷也被定義在該文件中。</p>
8、<p> 2、另一個(gè)OS_CPU_C.C是一個(gè) C源文件程序。該文件主要包括μC / OS-Ⅱ的任務(wù)堆棧的初始化函數(shù)和一些被μC / OS-Ⅱ操作系統(tǒng)調(diào)用的用戶函數(shù)。</p><p> 3、最后一個(gè)OS_CPU_A.S文件是一個(gè)匯編程序源文件。這是一個(gè)時(shí)鐘中斷服務(wù)函數(shù)在運(yùn)行的時(shí)候,也包含了一個(gè)用于引起中斷的任務(wù)切換函數(shù),并且也具有總是運(yùn)行最高優(yōu)先級的任務(wù)當(dāng)μC / OS-Ⅱ系統(tǒng)首次進(jìn)入多任務(wù)環(huán)境時(shí)。
9、</p><p> 創(chuàng)建OS_CPU.H文件</p><p> A、定義與編譯器有關(guān)的數(shù)據(jù)類型</p><p> 因?yàn)椴煌奈⑻幚砥饔胁煌淖珠L度,所以μC / OS-Ⅱ的移植包含一系列的數(shù)據(jù)類型的定義,這使移植能夠?qū)崿F(xiàn)。尤其是在C語言中使用的數(shù)據(jù)類型,例如短型、整型、長型等等,這些數(shù)據(jù)類型不能直接用于μC / OS-Ⅱ。因?yàn)檫@些數(shù)據(jù)類型與編譯器類型有關(guān),它們
10、不能被移植。所以這些數(shù)據(jù)類型都定義為整型數(shù)據(jù)結(jié)構(gòu),在許多情況下,他們是可移植的。</p><p> B、系統(tǒng)軟中斷函數(shù)的定義</p><p> 中斷是一種硬件機(jī)制,但在μC / OS -Ⅱ操作系統(tǒng),一些重要的任務(wù)函數(shù)的實(shí)現(xiàn)應(yīng)該取決于中斷級的代碼。所以,這種情況下,μC / OS-Ⅱ操作系統(tǒng)需要一條預(yù)處理器指令來模擬中斷。它類似于一個(gè)硬件中斷,所以它被稱為軟中斷。大多數(shù)微處理器的內(nèi)核可以
11、提供這種類型的軟中斷指令。在ARM7內(nèi)核,它是“SWI”。</p><p> 為了使底層接口函數(shù)是獨(dú)立的處理器狀態(tài)并且底層任務(wù)函數(shù)不需要知道調(diào)用函數(shù)的準(zhǔn)確的地址當(dāng)任務(wù)被調(diào)用時(shí)。SWI指令應(yīng)該用作底層接口。并且不同的函數(shù)能夠通過不同的軟件中斷函數(shù)編號的方法進(jìn)行區(qū)分。ADS1.2編譯器總是使用“_swi”來聲明一個(gè)不存在的函數(shù)。而一旦不存在的函數(shù)被調(diào)用時(shí),一條SWI的指令應(yīng)該插入調(diào)用函數(shù)并指定函數(shù)編號的位置。這里顯
12、示一些在μC / OS-Ⅱ中重要功能的軟中斷函數(shù)</p><p> _swi(0x00) void OS_TASK_SW(void);//在任務(wù)間切換功能</p><p> _swi(0x01) void _OSStartHighRdy(void);//首先運(yùn)行最高優(yōu)先級任務(wù)</p><p> _swi(0x02) void OS_ENTER_CRITICAL
13、(void);//關(guān)中斷</p><p> _swi(0x03) void OS_EXIT_CRITICAL(void);//開中斷</p><p> _swi(0x80) void ChangeToSYSMode(void);//切換到系統(tǒng)模式</p><p> 這些函數(shù)的具體代碼在文件OS_CPU_C.C和OS_CPU_A.S中。根據(jù)μC / OS-Ⅱ的要
14、求,所有在應(yīng)用系統(tǒng)中的C文件必須包括文件INCLUDES.H。所以正常的做法是使INCLUDES.H文件包含OS_CPU.H文件。</p><p> 三、創(chuàng)建OS_CPU_C.C文件</p><p> 在OS_CPU_C.C文件中,μC / OS-Ⅱ操作系統(tǒng)的移植規(guī)范要求創(chuàng)建十個(gè)簡單的函數(shù)OSTaskStkInit(),OSTaskCreateHook(), OSTaskSwHook(
15、), OSTaskDelHook(), OSTaskIdleHook(),OSTimeTickHook(), OSTaskStatHook(),OSInitHookBegin(), OSInitHookEnd(),OSTCBInitHook()。除了OSTaskStkInit()函數(shù)外并非所有的函數(shù)都必須創(chuàng)建。在符合μC / OS -Ⅱ操作系統(tǒng)的規(guī)范要求下, 如果用戶不想使用這些函數(shù),停用另外9個(gè)函數(shù)的功能并可以設(shè)置為空函數(shù)。</
16、p><p> A. 編寫OSTaskStklnit()函數(shù)</p><p> 在μC / OS -Ⅱ操作系統(tǒng),這兩個(gè)函數(shù)OSTaskCreate()和OSTaskCreateExt()通過調(diào)用OSTaskStkInit()函數(shù)的方法初始化任務(wù)的堆棧結(jié)構(gòu),并保存所有寄存器數(shù)據(jù)到各自的堆棧中。當(dāng)調(diào)用函數(shù)實(shí)現(xiàn)初始化后,它清除有關(guān)符合ARM7內(nèi)核微處理器的實(shí)際堆棧方向寄存器(堆棧方向是降序排列),
17、并且最后返回堆棧頂?shù)闹羔樦怠?lt;/p><p> 圖1 堆棧結(jié)構(gòu)初始化(參數(shù)pdata被傳遞給堆棧)</p><p> 圖1展示了OSTaskStkInit ( )函數(shù)初始化堆棧的過程當(dāng)μC/OS-Ⅱ操作系統(tǒng)創(chuàng)建任務(wù)的時(shí)候。在初始化后,OSTaskStkInit ( )最后返回了堆棧頂?shù)闹羔槨?lt;/p><p> B、系統(tǒng)軟件中斷函數(shù)</p><
18、;p> 在文件OS_CPU_C.C中,用C語言寫的軟中斷函數(shù)總是第一個(gè)被介紹。該文件包含所有的軟件中斷函數(shù)除了函數(shù)編號為0的任務(wù)(OS_TASK_SW())和函數(shù)編號為1的OSStartHighRdy()。在文件OS_CPU_A.S中,函數(shù)編號為0和為1的是用匯編語言編寫的。這是因?yàn)镃語言不能確切提供這兩個(gè)函數(shù)要求的堆棧結(jié)構(gòu)。另一個(gè)原因,如果用于切換任務(wù)的函數(shù)用匯編語言編寫的話,能很方便的實(shí)現(xiàn)跳轉(zhuǎn)。由C語言編寫的軟中斷函數(shù)的性質(zhì)
19、的介紹如下:由于使用了軟中斷,在更改了ARM7內(nèi)核SPSR寄存器的相應(yīng)控制位值后,當(dāng)軟中斷結(jié)束后,通過將SPSR寄存器的值復(fù)制到GPSR寄存器中特定的方式,更改微控制器的運(yùn)行模式的目的能夠?qū)崿F(xiàn)。</p><p> 四、創(chuàng)建OS_CPU_A.S文件</p><p> 根據(jù)μC / OS-Ⅱ操作系統(tǒng)的移植規(guī)范,有四個(gè)函數(shù)OSCtxSw(),OSIntCtxSw(),OSTickISR(),
20、OSStartHighRdy(),需要編寫,而且必須用匯編語言編寫。在這個(gè)文件中,用于提取編號0和編號1的軟中斷函數(shù)編號的函數(shù)也應(yīng)該用匯編語言編寫。</p><p> A.提取軟中斷的函數(shù)編號</p><p> 圖2 提取軟中斷號</p><p> 系統(tǒng)根據(jù)不同的軟中斷函數(shù)編號總是執(zhí)行不同的函數(shù)。在ARM7內(nèi)核微處理器家族,LR寄存器總是用于存儲子程序或異常
21、的返回地址。LR寄存器可以獲得SWI指令代碼。并且軟件中斷的編號包含在SWI指令中。所以軟中斷對應(yīng)的函數(shù)編號可以通過讀取指令代碼的對應(yīng)位段來得到。考慮到ARM7內(nèi)核的三級流水線架構(gòu)和程序的運(yùn)行狀態(tài)可能是ARM態(tài)或Thumb狀態(tài),所以他們必須對應(yīng)不同的處理方式。圖2顯示了具體的流程圖。</p><p> B、編寫OSStartHighRdy(),OSCtxSw()和OSIntCtxSw()函數(shù)</p>
22、<p> μC / OS-Ⅱ操作系統(tǒng)的調(diào)度函數(shù)OSSched()是通過調(diào)用實(shí)現(xiàn)任務(wù)切換功能OS_TASK_SW()函數(shù)和OS_TASK_SW()函數(shù)完成整個(gè)任務(wù)切換,OS_TASK_SW()函數(shù)和OS_TASK_SW()函數(shù)是通過調(diào)用函數(shù)OSCtxSw()函數(shù)實(shí)現(xiàn)的。</p><p> OSCtxSw()函數(shù)調(diào)用了OS_TASK_SW()用于最后切換任務(wù)。OSIntCtxSw()函數(shù)的大多數(shù)源代
23、碼幾乎與OSCtxSw()函數(shù)相同。它們具體的區(qū)別是OS_TASK_SW()函數(shù)需要存儲CPU寄存器值。根據(jù)μC / OS-Ⅱ操作系統(tǒng)的要求,中斷服務(wù)程序(ISR)已經(jīng)存儲了CPU寄存器值。所以,OSIntExit()函數(shù)將不會(huì)處理在最后的中斷處理后(如果中斷嵌套的存在)。這個(gè)時(shí)候,任務(wù)切換不需要再次存儲CPU寄存器的值。</p><p> 在μC / OS-Ⅱ操作系統(tǒng)的移植過程中,為了使系統(tǒng)的代碼高度可靠的,
24、 OSIntCtxSw()函數(shù)可以通過調(diào)用OSCtxSw()函數(shù)的方式實(shí)現(xiàn)。具體的實(shí)現(xiàn)方法是再次保存CPU寄存器的值,但它對整個(gè)系統(tǒng)沒有任何影響。因?yàn)镃PU寄存器必須在OSCtxSw()函數(shù)寫操作的時(shí)候執(zhí)行,所以O(shè)SCtxSw()函數(shù)應(yīng)該用匯編語言編寫。圖3顯示該函數(shù)的流程圖。</p><p> 該函數(shù)與μC / OS -Ⅱ操作系統(tǒng)的要求相比有一些差異移植,但這并不影響系統(tǒng)的執(zhí)行。在某種程度上,這證明了μC /
25、 OS-Ⅱ是一個(gè)非常優(yōu)秀的嵌入式操作系統(tǒng),它可以根據(jù)系統(tǒng)的需要進(jìn)行裁剪。</p><p> 最后圖3的流程圖執(zhí)行了‘LDMFD SP !,{R0 - R12,LR、PC } ‘ARM指令。因?yàn)樵讦藽 / OS-Ⅱ操作系統(tǒng)中,任務(wù)在異常模式中執(zhí)行,它只可以在用戶或系統(tǒng)模式中執(zhí)行。</p><p> μC / OS-Ⅱ操作系統(tǒng)通過調(diào)用OSStart()函數(shù),OSStart()最終調(diào)用OSS
26、tartHighRdy()函數(shù)的方式開始任務(wù)環(huán)境。OSStartHighRdy()函數(shù)的編寫應(yīng)遵循μC / OS-Ⅱ操作系統(tǒng)的移植規(guī)范。具體的方法是通OSCtxSw()函數(shù)一樣。它們兩者間唯一的區(qū)別是當(dāng)?shù)谝淮螆?zhí)行任務(wù)調(diào)度的時(shí)候OSStartHighRdy()函數(shù)不必存儲寄存器的值。</p><p> 圖3. OSCtxsw()函數(shù)流程圖</p><p> 創(chuàng)建了幾個(gè)移植文件后,理論上,
27、μC / OS -Ⅱ操作系統(tǒng)可以正常的在ARM7內(nèi)核微處理器上執(zhí)行了。但是在μC / OS-Ⅱ操作系統(tǒng)第一次執(zhí)行前,需要提供OSTickISR()系統(tǒng)時(shí)鐘函數(shù)。這是系統(tǒng)時(shí)間的函數(shù)一定是寫。</p><p> μC / OS-Ⅱ操作系統(tǒng)需要用戶提供周期的時(shí)鐘,并且時(shí)鐘可以實(shí)現(xiàn)延遲函數(shù)和超出時(shí)間函數(shù)。通常,周期時(shí)鐘是由中斷函數(shù)OSTickISR()實(shí)現(xiàn)。事實(shí)上,調(diào)用OSTimeTick()函數(shù)的實(shí)質(zhì)是通過調(diào)用OST
28、ickISR()函數(shù)實(shí)現(xiàn)的。因此,中斷任務(wù)OSTickISR()必須通過ARM7內(nèi)核微處理器的硬件定時(shí)器實(shí)現(xiàn),并且中斷級應(yīng)該設(shè)置為最高。</p><p> 圖4. μC/OS-Ⅱ操作系統(tǒng)中斷服務(wù)程序流程圖 (系統(tǒng)定時(shí)中斷舉例。)</p><p> 在μC / OS -Ⅱ操作系統(tǒng)的移植上,中斷服務(wù)子程序必須用匯編語言編寫。圖4顯示了關(guān)于ARM7內(nèi)核中斷服務(wù)程序的流程圖的寫作規(guī)范。<
29、/p><p> 圖4顯示系統(tǒng)定時(shí)器中斷的實(shí)現(xiàn)OSTimeISR()函數(shù)通過從執(zhí)行用戶程序轉(zhuǎn)換到μC / OS-Ⅱ()操作系統(tǒng)OSTimeTick()執(zhí)行的方式實(shí)現(xiàn)。</p><p> 同樣重要的是,如圖4所示,已經(jīng)實(shí)現(xiàn)了中斷和退出中斷處理,系統(tǒng)應(yīng)再次選擇任務(wù)列表中最高優(yōu)先級的任務(wù),然后系統(tǒng)切換到最高的任務(wù)。保存在OS_CPU_A.S函數(shù)OSIntCtxSw任務(wù)切換函數(shù)工作已經(jīng)完成。也就是說
30、在任務(wù)列表種的初始中斷任務(wù)不一定是最高優(yōu)先級的任務(wù)。因?yàn)楸瘸跏既蝿?wù)更高優(yōu)先級的一個(gè)更高優(yōu)先級的任務(wù)可能在中斷處理中已經(jīng)被執(zhí)行。</p><p> 當(dāng)然,當(dāng)所有的中斷已經(jīng)執(zhí)行后,如果初始中斷任務(wù)在任務(wù)列表中仍然是最高優(yōu)先級的任務(wù), 系統(tǒng)不需要切換任務(wù),它再次直接通過恢復(fù)CPU任務(wù)寄存器的值的方式執(zhí)行。</p><p><b> 結(jié)論</b></p>&
31、lt;p> 到目前為止,所有μC / OS-Ⅱ操作系統(tǒng)的移植到ARM7內(nèi)核微處理器的工作已經(jīng)完成。為了證明移植的正確性和合理性,在正常使用前,整個(gè)代碼必須進(jìn)行測試。測試方法可以根據(jù)實(shí)際的應(yīng)用程序微處理器模式編寫幾個(gè)小任務(wù)的方式實(shí)現(xiàn)。測試可以有助于找到移植移植代碼的缺陷,也可以修改移植代碼。</p><p> 在移植沒有漏洞后,可以將應(yīng)用程序的任務(wù)運(yùn)行在基于μC / OS -Ⅱ操作系統(tǒng)和ARM7內(nèi)核微處理
32、器系統(tǒng)平臺上。</p><p><b> 引用</b></p><p> [1] Jean J. Labrosse (USA), μC/OS, The Real-Time Kernel [M], Beijing:BEIHANG UNIVERSITY PRESS, 2003.5</p><p> [2] Xiong Zhenhua, Lia
33、o Jiaping, Based on S3C44B0x microprocessor and UCOS-Ⅱ operating system [J],China Water Transport,,(2006)01.</p><p> [3] Xiang Huaikun, Liang Songfeng, Yuan Yuan, Design of Network-Enabled Traffic Signal Co
34、ntroller Based on CAN and uCOS-Ⅱ[J],Journal of Shenzhen Polytechnic, (2008)03.</p><p> [4] Liu Miao, Wang Tianmiao, Wei Hongxing, Real-time Analysis of Embedded CNC System Based on uCOS-II[J], Computer Engi
35、neering,(2006)22.</p><p> [5] Wang Lei, Wang Yaonan, Chen Sisi, The Application Of ucos-ii In Embedded Intelligent Vision Surveillance System [J], Control & Automation,(2008)04.</p><p> [6
36、] Li Bei, Peng Chuwu, Building Hardware Application Layer in UCOS Transplanting[J], Electronic Engineering & Product World, (2006)16.</p><p> Construction of Embedded System Platform which Based on μC/O
37、S-Ⅱ and ARM7 Kernel Microprocessor</p><p><b> Yujun Bao</b></p><p> School of Electronic Information & Electric Engineering,Changzhou Institute of Technology CZU Changzhou, Chi
38、na</p><p> Xiaoyan Jiang </p><p> School of Electronic Information & Electric Engineering,Changzhou Institute of TechnologyCZU Changzhou, China</p><p><b> Abstract</
39、b></p><p> Embedded System has more and more applications today. Introduced Embedded Operating System in Embedded System has been a tendency of Embedded system development.Embedded Operating System can a
40、void different Embedded System hardware’s difference, it can greatly reduce the development costs, shorten the research cycle. μC/OS-Ⅱ is a kind of excellent Embedded Operating System which is an open source, tiny kernel
41、, consuming little resource and high performance in real-time feature. In accordance wit</p><p> Keywords: Embedded System;Embedded Operating System;ARM7 kernel; μC/OS-Ⅱ</p><p> I. INTRODUCTIO
42、N</p><p> The so-called Operating System transplantation is that a real time Operating System kernel can be operated in others Microprocessors. That is special code for special CPU. Most codes of μC/OS-Ⅱ ar
43、e written by C programming language,and this is very convenient to transplant μ C/OS- Ⅱ.But according to the different Microprocessors, the users still need using assembly language to write some programs which are relate
44、d to the different Microprocessors’ hardware. This is because when μC/OS-Ⅱ reads or </p><p> mainly surrounds the work which creating these three files.These files showed next:</p><p> ◆ In th
45、e C language header file OS_CPU.H, some data types which are not concerned in compiler needed to be defined. These data types include the used stack data type and its growing direction. Some soft interrupts which are con
46、cerned in ARM7 kernel are defined in this file, too.</p><p> ◆ Another one OS_CPU_C.C is a source file of C program. The file mainly includes the task stack initialization function of μC/OS-Ⅱ and some user
47、functions which called by μC/OS-Ⅱ Operating System.</p><p> ◆ The last one OS_CPU_A.S is a assemble program source file. It is a clock ticks interrupt service function in practice. It is also a task switch
48、function which used to quit interrupt. And it always runs the task of highest priority when μC/OS-Ⅱ enters the multitask environment firstly.</p><p> II. CREATING THE FILE OS_CPU.H</p><p> A.
49、Defining data types which are concerned in complier </p><p> Because different Microprocessors have different word length, so the transplantation of μC/OS-Ⅱ includes a series of data types’ definition, and
50、this make the transplantation possible. Especially for the data types used in C language, such as ‘short’, ‘int’, ‘long’ and so on, these data types can’t used in μC/OS-Ⅱ directly. Because these data types are concerned
51、in the compliers’ type, they can’t be transplanted. So these data types are always defined as Integer Data Structures in many cases, th</p><p> B. Definition of system soft interrupt functions</p>&l
52、t;p> Interrupt is a kind of hardware mechanism, but in μC/OS-Ⅱ Operating System, some important task functions’ implementation are supposed to depend on interrupt level code.So, at this time, μC/OS-Ⅱ Operating System
53、 needs a piece of preprocessor directive to simulate the interrupt. It’s like a hardware interrupt, so it is called soft interrupt. Most Microprocessors’ kernel can provide this kind of soft interrupt directive. And in A
54、RM7 kernel, it is the ‘SWI’.</p><p> In order to make the bottom layer interface function be independent of Microprocessor’s state, and the responded task function needn’t know the function’s exact location
55、 when the task called. The used SWI directive should be as bottom layer</p><p> interface. And the different functions can be distinguished by means of different soft interrupt Function Number. The ADS1.2 c
56、ompiler always uses ‘_swi’ to declare a non-existent function. And once the non-existent function is called, a piece of SWI directive should be inserted where the called function, and specifying the Function Number.Here
57、shows some important functions’ soft interrupt function in μC/OS-Ⅱ:</p><p> _swi(0x00) void OS_TASK_SW(void);//Switching function between tasks</p><p> _swi(0x01) void _OSStartHighRdy(void);//
58、 Running the task of highest priority firstly</p><p> _swi(0x02) void OS_ENTER_CRITICAL(void);// Interrupt Off</p><p> _swi(0x03) void OS_EXIT_CRITICAL(void);// Interrupt On</p><p&g
59、t; _swi(0x80) void ChangeToSYSMode(void);//Switching to system model</p><p> These functions’ concrete codes existed in the files OS_CPU_C.C and OS_CPU_A.S.</p><p> According to the requireme
60、nts of μC/OS-Ⅱ, all the C files in the application system must include the file INCLUDES.H.So a normal practice is make the file OS_CPU.H be included in the file INCLUDES.H.</p><p> III. CREATING THE FILE O
61、S_CPU_C.C</p><p> In the file OS_CPU_C.C, the transplantation specification of μC/OS-Ⅱ Operating System requires to create ten simple functions: OSTaskStkInit( ), OSTaskCreateHook( ),OSTaskDelHook( ), OSTas
62、kSwHook( ), OSTaskIdleHook( ),</p><p> OSTaskStatHook( ), OSTimeTickHook( ), OSInitHookBegin(), OSInitHookEnd( ), OSTCBInitHook( ). But not all the functions must be created except OSTaskStkInit ( ) functio
63、n. In accordance with the μ C/OS- Ⅱ Operating System’s requirements, the hinder nine functions can be set to empty functions if users don’t want to use.</p><p> A. Writing the function OSTaskStklnit( )</
64、p><p> In μ C/OS- Ⅱ Operating System, the two functions OSTaskCreate ( ) and OSTaskCreateExt( ) initialize task’s stack structure by means of calling OSTaskStkInit ( ) function, and all the registers are store
65、d in their respective stacks. When the called function implement the initialization, it clears the concerned registers in accordance with the ARM7 kernel Microprocessor’s practical stack direction (Provided the stackdire
66、ction is Full Descending.), and returns the stack top’s pointer at last.</p><p> Figure 1. Stack structure’s initialization (The parameter pdata is sent to stack.)</p><p> Fig.1 shows the proc
67、ess that OSTaskStkInit ( ) initializes the task stack when μC/OS-Ⅱ Operating System creates task.After the initialization, the OSTaskStkInit ( ) returns the stack top’s pointer at last.</p><p> B. System so
68、ft interrupt functions</p><p> In the file OS_CPU_C.C, the soft interrupt functions which written by C language are always introduced first. These include all the soft interrupt functions except function Nu
69、mber Zero (OS_TASK_SW ( ) ) and function Number One (OSStartHighRdy ( ) ). And the functions Number Zero and Number One are written by assembly language in the file OS_CPU_A.S. This because C language can’t provide exact
70、 stack structure which required by these two functions. And another reason, if the function which used to</p><p> IV. CREATING THE FILE OS_CPU_A.S</p><p> According to transplantation specific
71、ation of μC/OS-ⅡOperating System, there are four functions ( OSStartHighRdy(), OSCtxSw( ), OSIntCtxSw( ), OSTickISR( ) ) needed to write, and they must be written in assembly language. And the function which used to extr
72、act the Number Zero and Number One soft interrupts’ Function Number should be written by assembly language in this file, too.</p><p> A. Extracting the soft interrupt’s Function Number</p><p>
73、 The system always carries out different functions in accordance with different soft interrupt Function Number. In ARM7 kernel Microprocessor family, the LR register is always used to store the return address of subrouti
74、ne or anomaly. The LR register can get the code of SWI directive.[3] And the soft interrupt’s Function Number is included in the code of SWI directive. So the soft interrupt’s corresponding Function Number can be get by
75、reading the directive code’s corresponding bit filed. In cons</p><p> Figure 2. Extracting the soft interrupt’s Function Number</p><p> B. Writing the functions OSStartHighRdy ( ), OSCtxSw ( )
76、 and OSIntCtxSw ( )</p><p> In μC/OS-Ⅱ Operating System, the dispatching function OSSched ( ) is realized by calling Task Switching Function OS_TASK_SW ( ), and OS_TASK_SW ( ) function finishes the whole ta
77、sk switching by calling function OSCtxSw ( ).</p><p> The function OSCtxSw ( ) calls the function OS_TASK_SW ( ) which is used to switch task finally. And most source codes of function OSIntCtxSw ( ) are al
78、most same as OSCtxSw ( ) function. The concrete difference between them is that the function OS_TASK_SW ( ) needed to store CPU registers. The interrupt service program (ISR) has been stored CPU registers according to th
79、e μC/OS-Ⅱ Operating System’s requirements. So, the function OSIntExit ( ) would quit after the final interrupt has been processe</p><p> During μC/OS-Ⅱ Operating System’s transplantation, in order to make t
80、he system code be highly capable, the function OSIntCtxSw ( ) can be implemented by means of calling the function OSCtxSw ( ). And the concrete realization method is storing CPU registers again, but it doesn’t have any a
81、ffection for the whole system.[5]</p><p> Because the CPU registers must be operated during writing the function OSCtxSw ( ), so, the function OSCtxSw ( ) should be written by assembly language. Fig.3 shows
82、 the function’s flow chart.</p><p> The function has some differences compares with the requirements of μ C/OS- Ⅱ Operating System’s transplantation, but it doesn’t affect the system’s operation.</p>
83、<p> And to some extent, it has exemplified that μC/OS-Ⅱ is really a very excellent Embedded Operating System, it can be cut according to the system’s need.</p><p> The last flow in Fig.3 is realized
84、 by running ARM directive‘LDMFD SP!, {R0 – R12, LR, PC}^’. Because in μC/OS-Ⅱ,task can’t be operated in anomaly model, and it only can be operated in user or system model.[4]</p><p> μC/OS-Ⅱ Operating Syste
85、m starts tasking environment by means of the function OSStart ( ), and OSStart ( ) calls the function OSStartHighRdy ( ) finally. The OSStartHighRdy ( ) function’s writing should be followed the requirements of μ C/OS-Ⅱ
86、Operating System’s transplantation. And the concrete method is same as OSCtxSw ( ) function. The only difference between them is the function OSStartHighRdy ( ) needn’t store registers when operates task dispatching firs
87、t.</p><p> After having created the several transplantation files, in theory, μ C/OS- Ⅱ Operating System can be operated in ARM7 kernel Microprocessor normally. But before μC/OS-ⅡOperating System’s first op
88、eration, the function OSTickISR ( )</p><p> which is the system time function must have been written.</p><p> μC/OS-Ⅱ Operating System requires users to provide a periodical time source, and t
89、he time source can realize the functions of delaying time and overtime. Usually, the periodical time source is provided by interrupt function OSTickISR ( ). [6]And in fact, the implementation is essentially OSTickISR ( )
90、 function calling the function OSTimeTick ( ). So, the interrupt task OSTickISR ( ) must be implemented by ARM7 kernel Microprocessor’s hardware timer practically, and the interrupt level should be </p><p>
91、 Figure 3. OSCtxsw()function’s flow chart</p><p> In μ C/OS- Ⅱ Operating System’s transplantation, the interrupt service subroutine must be written by assembly language. And Fig.4 shows the writing specific
92、ations about ARM7 kernel interrupt service program’s flow chart.</p><p> Fig.4 shows that the realization of system timer interrupt function OSTimeISR ( ) by means of changing the part of carrying out user
93、program into the system function</p><p> OSTimeTick ( ) of μC/OS-Ⅱ Operating System.</p><p> It is also important to note that after all interrupts in Fig.4 having been implemented and quit th
94、e interrupt processing, the system should choose the highest priority task of task list again. And then the system is switched to the highest task. The</p><p> switching work has been finished by the functi
95、on OSIntCtxSw which existed in the file OS_CPU_A.S. That is to say the initial interrupted task is not necessarily the highest priority task in task list at this time. Because a higher priority task which than</p>
96、<p> the initial task may be activated during the interrupt’s implementation process. Certainly, if the initial interrupted task is still the highest priority task in task list when all interrupts have been finish
97、ed, the system need not to switch tasks, it runs again by means of recovering the task’s CPU registers directly.</p><p> V. CONCLUSIONS</p><p> So far, all μC/OS-Ⅱ Operating System’s transplan
98、tation into ARM7 kernel Microprocessor have been finished. In order to prove the transplantation’s correctness and reasonableness, the whole code must be tested before normal use. This can be realized by means of writing
99、 several small tasks which according to the practical Microprocessor model of application system. The test can be useful to finding the transplantation code’s defects, and the transplantation can also be improved by modi
100、fying.</p><p> The application tasks may be added in the Embedded System Platform which Based on μ C/OS- Ⅱ Operating System and ARM7 Kernel Microprocessor after the transplantation having been proved accura
101、tely.</p><p> Figure 4. Interrupt service program’s flow chart of μC/OS-ⅡOperating System. ( Take system time interrupt for instance.)</p><p> REFERENCES</p><p> [1] Jean J. Labr
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 眾賞文庫僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 基于ARM7微處理器工業(yè)應(yīng)用嵌入式網(wǎng)絡(luò)協(xié)議研究及實(shí)現(xiàn).pdf
- 基于ARM處理器和μC-OS-Ⅱ的嵌入式系統(tǒng)研究和實(shí)現(xiàn).pdf
- 基于32位ARM微處理器與μC-OS-Ⅱ?qū)崟r(shí)操作系統(tǒng)的嵌入式系統(tǒng)的研究.pdf
- 基于ARM微處理器的嵌入式數(shù)控系統(tǒng)的研究.pdf
- 基于ARM7嵌入式平臺的數(shù)據(jù)廣播接收系統(tǒng).pdf
- 嵌入式處理器
- 基于ARM處理器的嵌入式系統(tǒng)實(shí)現(xiàn).pdf
- 基于ARM7嵌入式處理器的語音信令平臺的硬件設(shè)計(jì)與實(shí)現(xiàn).pdf
- 微處理器系統(tǒng)結(jié)構(gòu)與嵌入式系統(tǒng)設(shè)計(jì)
- 基于ARM7內(nèi)核的嵌入式系統(tǒng)開發(fā)-實(shí)驗(yàn)平臺的設(shè)計(jì)與實(shí)現(xiàn).pdf
- 嵌入式信道微處理器的設(shè)計(jì).pdf
- 基于ARM微處理器的嵌入式數(shù)控系統(tǒng)的設(shè)計(jì)與實(shí)現(xiàn).pdf
- 基于ARM微處理器的嵌入式指紋識別系統(tǒng)設(shè)計(jì).pdf
- 基于ARM微處理器和uC-OS-Ⅱ操作系統(tǒng)的嵌入式傳感網(wǎng)絡(luò)節(jié)點(diǎn)的研究.pdf
- 基于ARM微處理器與μC-OS-Ⅱ?qū)崟r(shí)操作系統(tǒng)的嵌入式多軸控制器的開發(fā).pdf
- 基于ARM微處理器的嵌入式以太網(wǎng)接口的研究.pdf
- 基于ARM7嵌入式系統(tǒng)的無線通信平臺設(shè)計(jì).pdf
- 外文翻譯--基于arm7的嵌入式家電控制系統(tǒng)的設(shè)計(jì)
- 基于ARM7TDMI內(nèi)核嵌入式開發(fā)平臺的開發(fā).pdf
- 基于ARM7的嵌入式微處理器存儲管理單元的設(shè)計(jì)與實(shí)現(xiàn).pdf
評論
0/150
提交評論