2023年全國碩士研究生考試考研英語一試題真題(含答案詳解+作文范文)_第1頁
已閱讀1頁,還剩20頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、<p>  畢業(yè)設(shè)計(jì)(論文)外文資料翻譯</p><p>  系 : 電氣工程學(xué)院 </p><p>  專 業(yè): 電氣工程及其自動(dòng)化 </p><p>  附件1:外文資料翻譯譯文</p><p>  嵌

2、入式系統(tǒng)程序的下載和調(diào)試</p><p>  當(dāng)你已經(jīng)在主機(jī)上有了一個(gè)可執(zhí)行二進(jìn)制映像文件的時(shí)候,你就需要有一種途徑來把這個(gè)映像文件下載到嵌入式系統(tǒng)運(yùn)行了,可執(zhí)行二進(jìn)制影響一般是要下載到目標(biāo)板上的存儲(chǔ)器里并在那里執(zhí)行,并且如果你配備了適當(dāng)?shù)墓ぞ叩脑?,還可以在程序里設(shè)置斷點(diǎn)或以一種不干擾的方式來觀察運(yùn)行情況,本章介紹了可用于下載,運(yùn)行和調(diào)試嵌入式軟件是各種技術(shù)。</p><p>  4.1

3、在ROM中的時(shí)候…….</p><p>  下載嵌入式軟件的最明顯的方式,是把二進(jìn)制映像載入一片存儲(chǔ)片并把它插在目標(biāo)板上,雖然一個(gè)整整的只讀是不能再覆蓋寫入的,不過你會(huì)在第六章“存儲(chǔ)器”里看到,嵌入式系統(tǒng)通常使用了一種特殊的只讀存儲(chǔ)器,這種存儲(chǔ)器可以用特殊的編程器來編程(或重新寫入程序).編程器是一種計(jì)算機(jī)系統(tǒng),它上面有各種各樣的形狀和大小的芯片插座,可以用來為各種存儲(chǔ)芯片編程。</p><p

4、>  在一個(gè)理想的開發(fā)條件下,設(shè)備編程器應(yīng)該和主機(jī)接在同一個(gè)網(wǎng)絡(luò)上。這樣,可執(zhí)行二進(jìn)制映像文件就很容易傳給它來對ROM芯片編程。首先把映像文件傳到編程器,然后把存儲(chǔ)器芯片插入大小形狀何時(shí)的插座里并沖編程器屏幕上的菜單里懸著芯片的型號(hào)。實(shí)際的編程過程可能需要幾秒到幾分鐘,這要看二進(jìn)制映像文件的大小和你所用的芯片型號(hào)來定。</p><p>  變成結(jié)束以后,你就可以把ROM插進(jìn)板上的插座了,當(dāng)然,不能在嵌入式系

5、統(tǒng)還在加電的時(shí)候做這件事。應(yīng)該在插入芯片之前關(guān)掉電源,插入之后在打開。</p><p>  一旦加電,處理器就開始從ROM里取出代碼并執(zhí)行。不過,要注意到每一種處理器對第一條指令的位置都有自己的要求。例如,當(dāng)Intel80188EB處理器復(fù)位以后,它就會(huì)取位于物理地址FFFF0h的指令來執(zhí)行。這個(gè)地址叫做復(fù)位地址,位于那里的指令就叫復(fù)位代碼。</p><p>  如果你的程序看起來像是沒有

6、正確運(yùn)行,那可能是你復(fù)位代碼出了問題。你必須保證ROM里你的二進(jìn)制映像格式要遵從目標(biāo)處理器的復(fù)位要求。在開發(fā)過程中,我發(fā)現(xiàn)在復(fù)位代碼執(zhí)行之后打開板子上的一個(gè)LED非常有用,這樣我一眼就知道我的芯ROM程序是不是滿足了處理器的基本要求。</p><p>  注意:調(diào)試技巧#1:一個(gè)最簡單的調(diào)試技巧就是利用LED來指示成功或者失敗?;舅悸肥锹貜腖ED驅(qū)動(dòng)代碼過渡到更大的程序,把LED驅(qū)動(dòng)代碼挪到下一個(gè)運(yùn)行標(biāo)記的

7、地方。這個(gè)方式最適合啟動(dòng)代碼那樣簡單的,線性執(zhí)行的程序。如果你沒有本章后面提到的遠(yuǎn)程調(diào)試器或者任何其他調(diào)試工具的話,這也許是你唯一的調(diào)試辦法了。</p><p>  Arcom電路板 特殊的在線可編程存儲(chǔ)器,叫做快閃存儲(chǔ)器(簡稱閃存),它可以在不從板上移走的情況下編程。實(shí)際上,板上的另外一塊存儲(chǔ)器中已經(jīng)包含了可以對這個(gè)快閃存儲(chǔ)器編程的功能。你知道嗎,Arcom電路板上實(shí)際帶了兩個(gè)只讀存儲(chǔ)器,一個(gè)是真正的ROM,其

8、中包含了可以讓用戶對另外一片(即快閃存儲(chǔ)器)在線編程的簡單程序。主機(jī)只需通過一個(gè)串行通信口和一個(gè)終端程序就可以和這個(gè)監(jiān)控程序溝通了。隨板提供的“Target188EB Monitor User’s Manual”包含了把一個(gè)Intel十六進(jìn)制格式文件,比如blink.hex,載入到閃存里的指令。</p><p>  這種下載技術(shù)的最大缺點(diǎn)是沒有一種簡單的方法來調(diào)試運(yùn)行在ROM外面的軟件,處理器以一種很高的速度提取

9、指令并執(zhí)行,并沒有提供任何使你觀察程序內(nèi)部狀態(tài)的手段。這在你已經(jīng)知道你的軟件工作正常并且你在計(jì)劃分發(fā)這個(gè)系統(tǒng)的時(shí)候看起來是不錯(cuò)的,不過對于正在開發(fā)的軟件是一點(diǎn)用多沒有。當(dāng)然,你還是可以檢查LED的狀態(tài)和其他外部可視硬件指示,但這永遠(yuǎn)不會(huì)比一個(gè)調(diào)試器提供更多的信息和反饋。</p><p>  4.2 遠(yuǎn)程調(diào)試器</p><p>  如果可能的話,一個(gè)遠(yuǎn)程調(diào)試器可以通過主機(jī)和目標(biāo)機(jī)之間的串行

10、網(wǎng)絡(luò)連接來下載、執(zhí)行和調(diào)試嵌入式軟件。一個(gè)遠(yuǎn)程調(diào)試器的前端和你可能用過的其他調(diào)試器都一樣,通常有一個(gè)基于文本或GUI(圖形用戶界面)的主窗口和幾個(gè)小一點(diǎn)的窗口來顯示正在運(yùn)行的程序的源代碼、寄存器內(nèi)容和其他相關(guān)信息。所不同的是,在嵌入式系統(tǒng)的情況下,調(diào)試器和被調(diào)試的軟件分別運(yùn)行在兩臺(tái)不同的計(jì)算機(jī)上。</p><p>  一個(gè)遠(yuǎn)程調(diào)試器實(shí)際上包含兩部分軟件。前端運(yùn)行在主機(jī)上并提供前述的人機(jī)界面。但還有一個(gè)運(yùn)行在目標(biāo)處

11、理器上的隱藏的后端軟件來負(fù)責(zé)通過某種通信鏈路和前端通信。后端一般被稱作調(diào)試監(jiān)控器,它提供了對目標(biāo)處理器的低層控制。</p><p>  監(jiān)視控制器通常是你或生產(chǎn)廠以前講過的方式放置在ROM里的,它在目標(biāo)處理器復(fù)位的時(shí)候會(huì)自動(dòng)啟動(dòng)。它監(jiān)控和主機(jī)的通信鏈路并對遠(yuǎn)程調(diào)試器的請求做出回應(yīng)。當(dāng)然,這些請求和監(jiān)控器的響應(yīng)必須符合某種預(yù)先定義好的通信協(xié)議,而且這些協(xié)議通常是很底層的。遠(yuǎn)程調(diào)試器的請求的一些示例就如“讀寄存器x”

12、、“修改寄存器y”、讀從address開始的內(nèi)存的n字節(jié)”還有“修改位于address的數(shù)據(jù)”等等。遠(yuǎn)程調(diào)試器通過組合利用這些低層命令來完成諸如下載程序、單步執(zhí)行和設(shè)置斷點(diǎn)等高級(jí)調(diào)試任務(wù)。</p><p>  GUN調(diào)試器(gdb)就是這樣一個(gè)調(diào)試器,像其他GUN工具一樣,它一開始是被設(shè)計(jì)用來完成本機(jī)調(diào)試,后來才具有了跨平臺(tái)調(diào)試的能力。所以你可以創(chuàng)建一個(gè)運(yùn)行在任何被支持的主機(jī)上的GDB前端,它就會(huì)理解任何被支持的

13、目標(biāo)上的操作碼和寄存器名稱。一個(gè)兼容的調(diào)試兼容器的源代碼包含在GDB軟件包里面,并需要被移植到目標(biāo)平臺(tái)上,不過,要知道這個(gè)移植可能需要一些技巧,特別是如果你的配置里只能通過LED來調(diào)試的話(參見調(diào)試技巧#1)。</p><p>  GDB前端和調(diào)試監(jiān)控器之間的通信專門被設(shè)計(jì)來通過串行連接進(jìn)行字節(jié)傳輸。表4-1顯示了命令格式和一些主要的命令。這些命令示范了發(fā)生在典型的遠(yuǎn)程調(diào)試器前端和調(diào)試器之間的交互類型。</

14、p><p>  遠(yuǎn)程調(diào)試器是嵌入式軟件里最常用到的下載和測試工具。這主要是因?yàn)樗鼈円话惚容^便宜。嵌入式軟件開發(fā)人員已經(jīng)有了所需的主機(jī)了,任何一個(gè)遠(yuǎn)程調(diào)試器的價(jià)格并不會(huì)在全套跨平臺(tái)開發(fā)工具(編譯器、連接器、定址器等等)的價(jià)格上增加多少,還有調(diào)試器的供應(yīng)商們通常會(huì)提供他們的調(diào)試監(jiān)控器的源代碼,以增加他們的用戶群。</p><p>  Arcom電路板在交付的時(shí)候在快閃存儲(chǔ)器里包含了一個(gè)免費(fèi)的調(diào)試系

15、統(tǒng)。和Arcom提供的主機(jī)軟件一起使用,這個(gè)調(diào)試監(jiān)控器就可以把程序直接下載到目標(biāo)板的RAM里并運(yùn)行,你可以用tload工具來完成這一任務(wù)。按照“SourceVIEW forTarget188EB User’s Manual”的指示簡單地把SourceVIEW串行通信適配器接到目標(biāo)板和主機(jī)上,然后在主機(jī)PC上執(zhí)行下述命令:</p><p>  tload -g blink.exe</p><p&

16、gt;  SourceView Target Loader v1.4</p><p>  Copyright (c) Arcom Control Systems Ltd 1994</p><p>  Opening 'blink.exe'... download size 750H bytes (2K)</p><p>  Checking C

17、OM1 (press ESC key to exit)...</p><p>  Remote ident: TDR188EB version 1.02</p><p>  Download successful</p><p>  Sending 'GO' command to target system</p><p> 

18、 -g選項(xiàng)告訴調(diào)試監(jiān)控器程序下載一結(jié)束就馬上開始運(yùn)行,這樣一來,運(yùn)行就是和ROM里的程序完全對應(yīng)的RAM里的程序了。在這種情況下,我們也許會(huì)以可重定址程序來開始,那么tload工具也會(huì)自動(dòng)地在RAM里第一個(gè)可利用的地址處為我們的程序重新定址。</p><p>  對于遠(yuǎn)程調(diào)試的目的,Arcom的調(diào)試監(jiān)控器可以用Borland的Turbo Debugger做前端。然后Turbo Debugger就可以單步執(zhí)行你的C

19、/C++和匯編程序,在程序里設(shè)置斷點(diǎn),并可以在程序運(yùn)行時(shí)監(jiān)控變量、寄存器和堆棧(注1),下面是你可能用來啟動(dòng)一個(gè)對閃爍LED程序的調(diào)試會(huì)話的命令:</p><p>  tdr blink.exe</p><p>  tver -3.1</p><p>  Target Debugger Version Changer v1.2</p><p

20、>  Copyright (c) Arcom Control Systems Ltd 1994</p><p>  Checking COM1 (press ESC key to exit)...</p><p>  Remote ident: TDR188EB version 1.02</p><p>  TDR88 set for TD version 3

21、.1</p><p>  td -rp1 -rs3 blink.exe</p><p>  Turbo Debugger Version 3.1 Copyright (c) 1988,92 Borland International</p><p>  Waiting for handshake from remote driver (Ctrl-Break to q

22、uit)</p><p>  Tdr命令實(shí)際是調(diào)用另外兩個(gè)命令的一個(gè)批處理文件。第一個(gè)命令告訴板上的調(diào)試監(jiān)控器你用的是哪個(gè)版本的Turbo Debugger,第二個(gè)才實(shí)際調(diào)用Turbo Debugger,每一次用Arcom板啟動(dòng)一個(gè)調(diào)試會(huì)話的時(shí)候都會(huì)發(fā)出這兩條命令、tdr.bat批處理文件只是用來把它們組合成一個(gè)單一的命令。這里我們再一次使用了程序的可重定址版本,因?yàn)槲覀円殉绦蛳螺d到RAM里并在那里執(zhí)行它。調(diào)試

23、器啟動(dòng)選項(xiàng)-rpl和-rp3設(shè)置了到調(diào)試監(jiān)控器的通信鏈路的參數(shù)。-rpl代表“remote-port(遠(yuǎn)程端口)=1”(COM1),-rp3代表“remote-speed(遠(yuǎn)程速率)=3”(38400波特率),這些是同Arcom調(diào)試監(jiān)控器通信所要求的參數(shù)。在建立了和調(diào)試監(jiān)控器的聯(lián)系后,Turbo Debugger就可以開始運(yùn)行了。如果沒成功的話,可能是串行連接出了問題。把你的安裝過程和Source View用戶手冊中的描述對照一下。&l

24、t;/p><p>  一旦進(jìn)入Turbo Debugger,你就會(huì)看到一個(gè)對話框顯示“Program out of date on remote,sent over link?(遠(yuǎn)程的程序已過期,是否通過鏈路發(fā)送?)”,選擇“yes”后,blink.exe的內(nèi)容就會(huì)被下載到目錄RAM中,然后調(diào)試器會(huì)在main處設(shè)置第一個(gè)斷點(diǎn)并指示調(diào)試監(jiān)控器運(yùn)行程序到此處。所以你現(xiàn)在看到的就是main的C源代碼,一個(gè)光標(biāo)指示著嵌入式處

25、理器的指令指針正指向這個(gè)例程的入口點(diǎn)。</p><p>  使用標(biāo)準(zhǔn)的Turbo Debugger命令,你可以單步執(zhí)行程序、設(shè)置斷點(diǎn)、監(jiān)控變量和寄存器的值、做調(diào)試器允許的任何事?;蛘呖梢园聪翭9立即運(yùn)行程序的剩下部分、這樣做了以后,你就能看到板上的綠色LED開始閃爍了。確認(rèn)程序和調(diào)試器都正常工作之后,按下Arcom板上的復(fù)位開關(guān)來復(fù)位復(fù)位嵌入式處理器,然后LED會(huì)停止閃爍,Turbo Debugger又可以響應(yīng)你

26、指令了。</p><p><b>  4.3 仿真器</b></p><p>  遠(yuǎn)程調(diào)試器用來監(jiān)視和控制嵌入式軟件的狀態(tài)是很有用,不過只有用在線仿真器(In-Circuit Emulator,ICE)才能檢查運(yùn)行程序的處理器狀態(tài)。實(shí)際上,ICE取代了(或者仿真了)目標(biāo)板上的處理器。它自己就是一個(gè)嵌入式系統(tǒng),有它自己的目標(biāo)處理器、RAM、ROM和自己的嵌入式軟件,結(jié)果

27、在線仿真器一樣非常貴,往往要比目標(biāo)硬件還貴。但是這是一種強(qiáng)有力的工具,在某些嚴(yán)格的環(huán)境下可以幫你很大忙。</p><p>  同調(diào)試監(jiān)控器一樣,仿真器也有一個(gè)遠(yuǎn)程調(diào)試器作為用戶界面。某些情況下,甚至能使用相同的前端調(diào)試器。但是仿真器有自己的目標(biāo)處理器,所以就有可能實(shí)時(shí)的監(jiān)視和控制處理器的狀態(tài)。這就允許仿真器在調(diào)試監(jiān)控器提供的功能外支持一些高級(jí)的調(diào)試特性,如:硬件斷點(diǎn)額實(shí)時(shí)跟蹤。</p><p&

28、gt;  使用調(diào)試監(jiān)控器,你可以在你的程序里設(shè)置斷點(diǎn)。不過這些軟斷點(diǎn)只能到指令提取級(jí)別,也就是相當(dāng)于“在提取該指令前停止運(yùn)行”。相比之下,仿真器同時(shí)支持硬件斷點(diǎn)。硬件斷點(diǎn)允許響應(yīng)多種事件來停止運(yùn)行。這些事件不僅包括指令提取,還有內(nèi)存和I/O讀寫以及中斷。例如,你可以對事件“當(dāng)變量foo等于15同時(shí)AX寄存器等于0”設(shè)置一個(gè)硬件斷點(diǎn)。</p><p>  在線仿真器的另一種有用的特性是實(shí)時(shí)跟蹤,典型地仿真包含了大塊

29、的專用RAM,專門用來存儲(chǔ)執(zhí)行過的每一個(gè)指令周期的信息。這個(gè)功能使你可以得知事件發(fā)生的精確次序,這就嫩幫助你回答諸如計(jì)時(shí)器中斷是發(fā)生在變量bar變成94之前還是之后這類的問題。另外,通??梢韵拗拼鎯?chǔ)的信息或者在查看之前預(yù)處理數(shù)據(jù)以精簡要檢查的數(shù)據(jù)的數(shù)量。</p><p>  4.4 ROM仿真器</p><p>  另外一種仿真器也值得在這里提一下。ROM仿真器被用來仿真一個(gè)只讀存儲(chǔ)芯片。

30、和ICE一樣,它是一個(gè)獨(dú)立的嵌入式系統(tǒng)并和主機(jī)與目標(biāo)板相連。不過,這次是通過ROM芯片插座來和目標(biāo)板連接的。對于嵌入式處理器,它就像一個(gè)只讀存儲(chǔ)芯片,而對于遠(yuǎn)程調(diào)試器,它又像一個(gè)調(diào)試器。</p><p>  ROM仿真器相比調(diào)試監(jiān)控器有如下幾個(gè)優(yōu)點(diǎn)。首先,任何人都不需要為你的專有目標(biāo)硬件移植調(diào)試監(jiān)控器代碼。其次,ROM仿真器通常自帶了連接主機(jī)的串行或網(wǎng)絡(luò)連接,所以不必用主機(jī)自己的通常很有限的資源。最后,ROM仿真

31、器完全替代了原有的ROM,所以不會(huì)占用目標(biāo)板的存儲(chǔ)空間來容納調(diào)試監(jiān)控器代碼。</p><p>  4.5模擬器和其他工具</p><p>  當(dāng)然,還可以使用另外很多種調(diào)試工具,比如模擬器(simulator)、邏輯分析儀和示波器。模擬器是一個(gè)完全基于主機(jī)的程序,它模擬了目標(biāo)處理器的功能和指令集,它的用戶界面通常和遠(yuǎn)程調(diào)試器的一樣和比較類似。實(shí)際上,可以為后端模擬器使用一個(gè)調(diào)試器來做前端,

32、就像圖4-2顯示的那樣。盡管模擬器有很多不足,它在項(xiàng)目的早期特別是沒有任何實(shí)際的硬件可以用來試驗(yàn)程序的時(shí)候就相當(dāng)有用。</p><p>  注意:調(diào)試技巧#2:如果曾經(jīng)遇到目標(biāo)處理器從不同于你認(rèn)為應(yīng)該的數(shù)據(jù)手冊里讀取數(shù)據(jù),嘗試在模擬器上運(yùn)行相同的軟件。如果你的程序正常工作,那么你知道這是某種形式的硬件問題。但是,如果模擬器展示相同的問題像實(shí)際芯片一樣,你就知道你錯(cuò)誤的曲解了處理器的所有文件。到目前為止,一個(gè)模擬器

33、最大的缺點(diǎn)是它僅能模擬處理器,而且嵌入式系統(tǒng)經(jīng)常包含一個(gè)或多個(gè)其他重要設(shè)備。與這些設(shè)備相互作用有時(shí)會(huì)模仿與仿真腳本或其他變通辦法,但這種解決方法相比模擬本身的價(jià)值創(chuàng)造了更多的麻煩。所以,你可能不會(huì)做太多的模擬器,一旦你有實(shí)際嵌入式硬件提供給您。他們對處理器和其它芯片之間的相互作用非常有用。因?yàn)樗麄冎荒懿榭葱盘?hào)處理器以外的錯(cuò)誤,但是,他們無法控制你的像一個(gè)調(diào)試器或仿真器軟件可以執(zhí)行流程。這使得這些工具本身明顯用處不大。但是,再加上像一個(gè)遠(yuǎn)

34、程調(diào)試調(diào)試器或仿真器工具軟件,它們可以是非常寶貴。</p><p>  邏輯分析儀是專門用來調(diào)試數(shù)字電路硬件的一種實(shí)驗(yàn)室設(shè)備。它會(huì)有幾十個(gè)甚至上百個(gè)輸入,它們分別只用來做一件事:它所連接的電信號(hào)的邏輯電平是1還是0。你選擇的任何輸入子集都可以以時(shí)間坐標(biāo)顯示出來,如圖4-3所示。大多數(shù)邏輯分析儀也允許你以特定的模式捕捉數(shù)據(jù)或“觸發(fā)器”。例如,你可以發(fā)出如下請求:“顯示輸入信號(hào)1到10的值,但是直到輸入2和5同時(shí)變?yōu)?/p>

35、0時(shí)才開始記錄”。</p><p>  注意:調(diào)試技巧#3:有時(shí)可能需要同時(shí)觀察運(yùn)行著嵌入式軟件的目標(biāo)板上電信號(hào)的一個(gè)子集。例如:你可能想觀察處理器和它所連一個(gè)外設(shè)的總線交互信號(hào)。一個(gè)技巧是在你感興趣的交互的前面加上一個(gè)輸出語句。這個(gè)輸出語句會(huì)在處理器的一個(gè)或多個(gè)引腳上產(chǎn)生特定的邏輯電平。例如,你可以使一個(gè)空閑的I/O引腳從0到1,然后邏輯分析儀就可以設(shè)置成響應(yīng)這個(gè)使勁的觸發(fā)器并開始捕獲后續(xù)的所有情況。</

36、p><p>  示波器是用于硬件調(diào)試的另一種試驗(yàn)室設(shè)備,不過它可以在任何硬件上檢查任何電信號(hào),不管是模擬的還是數(shù)字的。在手頭沒有邏輯分析儀的情況下,示波器可以迅速觀察特定引腳上的電壓,也可以做一些更復(fù)雜的事情。不過,它的輸入很少(通常有四個(gè))而且通常沒有高級(jí)的觸發(fā)邏輯。結(jié)果,只有在沒有軟件調(diào)試工具的情況下它才會(huì)對你有用。</p><p>  附件2:外文原文(復(fù)印件)</p>&

37、lt;p>  RTX-51 Real-Time</p><p>  Operating System</p><p>  RTX51 is a multitasking real-time operating system for the 8051 family. RTX51simplifies system and software design of complex and ti

38、me-critical projects.RTX51 is a powerful tool to manage several jobs (tasks) on a single CPU. </p><p>  Thereare two distinct versions of RTX51:</p><p>  RTX51 Full which performs both round-rob

39、in and preemptive task switchingwith 4 task priorities and can be operated with interrupt functions in parallel.RTX51 supports signal passing; message passing with a mailbox system andsemaphores. The os_wait function of

40、RTX51 can wait for the following events:interrupt; timeout; signal from task or interrupt; message from task or interrupt;semaphore.</p><p>  RTX51 Tiny which is a subset of RTX51 Full. RTX51 Tiny easily run

41、s onsingle-chip systems without off-chip memory. However, program using RTX51Tiny can access off-chip memory. RTX51 Tiny allows round-robin taskswitching, supports signal passing and can be operated with interrupt functi

42、onsin parallel. The os_wait function of RTX51 Tiny can wait for the following</p><p>  events: timeout; interval; signal from task or interrupt.The rest of this section uses RTX-51 to refer to RTX-51 Full an

43、d RTX-51 Tiny.Differences between the two are stated where applicable.</p><p>  Introduction</p><p>  Many microcontroller applications require simultaneous execution of multiplejobs or tasks. F

44、or such applications, a real-time operating system (RTOS) allowsflexible scheduling of system resources (CPU, memory, etc.) to several tasks.RTX-51 implements a powerful RTOS that is easy to use. RTX-51 works withall 805

45、1 derivatives.</p><p>  You write and compile RTX-51 programs using standard C constructs andcompiling them with C51. Only a few deviations from standard C are requiredin order to specify the task ID and pri

46、ority. RTX-51 programs also require thatyou include the RTX51.H or RTX51TNY.H header file. When you select in theμVision2 dialog Options for Target - Target the operating system, the linker addsthe appropriate RTX-51 lib

47、rary file.</p><p>  Single Task Program</p><p>  A standard C program starts execution with the main function. In an embeddedapplication, main is usually coded as an endless loop and can be thou

48、ght of as asingle task that is executed continuously. For example:</p><p>  Round-Robin Task Switching</p><p>  RTX51 Tiny allows a quasi-parallel, simultaneous execution of several tasks.Each t

49、ask is executed for a predefined timeout period. A timeout suspends theexecution of a task and causes another task to be started. The following exampleuses this round-robin task switching technique.</p><p> 

50、 Simple C Program using RTX51</p><p>  RTX51 starts the program with task 0 (assigned to job0). The functionos_create_task marks task 1 (assigned to job1) as ready for execution. Thesetwo functions are simpl

51、e count loops. After the timeout period has beencompleted, RTX51 interrupts job0 and begins execution of job1. This functioneven reaches the timeout and the system continues with job0.</p><p>  The os_wait F

52、unction</p><p>  The os_wait function provides a more efficient way to allocate the availableprocessor time to several tasks. os_wait interrupts the execution of the currenttask and waits for the specified e

53、vent. During the time in which a task waits foran event, other tasks can be executed.</p><p>  Wait for Timeout</p><p>  RTX51 uses an 8051 timer in order to generate cyclic interrupts (timer ti

54、cks).The simplest event argument for os_wait is a timeout, where the currentlyexecuting task is interrupted for the specified number of timer ticks. Thefollowing uses timeouts for the time delay.</p><p>  Pr

55、ogram with os_wait Function</p><p>  This program is similar to the previous example with the exception that job0 isinterrupted with os_wait after counter0 has been incremented. RTX51 waitsthree timer ticks

56、until job0 is ready for execution again. During this time, job1 isexecuted. This function also calls os_wait with a timeout of 5 ticks. The result:counter0 is incremented every three ticks and counter1 is incremented eve

57、ry fivetimer ticks.</p><p>  Wait for Signal</p><p>  Another event for os_wait is a signal. Signals are used for task coordination: ifa task waits with os_wait until another task issues a signa

58、l. If a signal waspreviously sent, the task is immediately continued.</p><p>  Program with Wait for Signal.</p><p>  In this example, task 1 waits for a signal from task 0 and therefore process

59、es theoverflow from counter0.</p><p>  Preemptive Task Switching</p><p>  The full version of RTX51 provides preemptive task switching. This feature isnot included in RTX51 Tiny. It is explained

60、 here to provide a completeoverview of multitasking concepts.</p><p>  In the previous example, task 1 is not immediately started after a signal hasarrived, but only after a timeout occurs for task 0. If tas

61、k 1 is defined with ahigher priority than task 0, by means of preemptive task switching, task 1 isstarted immediately after the signal has arrived. The priority is specified in thetask definition (priority 0 is the defau

62、lt value).</p><p>  RTX51 Technical Data</p><p>  Overview of RTX51 Routines</p><p>  The following table lists some of the RTX-51 functions along with a briefdescription and execut

63、ion timing (for RTX-51 Full).</p><p>  Function Description These functions are available only in RTX-51 Full.</p><p>  Additional debug and support functions in RTX-51 Full include the followin

64、g:</p><p>  CAN Functions</p><p>  The CAN functions are available only with RTX-51 Full. CAN controllerssupported include the Philips 82C200 and 80C592 and the Intel 82526. MoreCAN controllers

65、are in preparation.on</p><p>  TRAFFIC: RTX-51 Tiny Example Program</p><p>  The TRAFFIC example is a pedestrian traffic light controller that shows theusage of multitasking RTX-51 Tiny Real-tim

66、e operating system. During a userdefinedtime interval, the traffic light is operating. Outside this time interval, theyellow light flashes. If a pedestrian pushes the request button, the traffic lightgoes immediately int

67、o walk state. Otherwise, the traffic light workscontinuously.</p><p>  Traffic Light Controller Commands</p><p>  The serial commands that TRAFFIC supports are listed in the following table.Thes

68、e commands are composed of ASCII text characters. All commands mustbe terminated with a carriage return.</p><p><b>  Software</b></p><p>  The TRAFFIC application is composed of thre

69、e files that can be found in the</p><p>  \KEIL\C51\EXAMPLES\TRAFFIC folder.</p><p>  TRAFFIC.C contains the traffic light controller program that is divided into the following tasks:</p>

70、<p>  Task 0 init: initializes the serial interface and starts all other tasks. Task 0deletes itself since initialization is needed only once.</p><p>  Task 1 command: is the command processor for the

71、traffic light controller.This task controls and processes serial commands received.</p><p>  Task 2 clock: controls the time clock.</p><p>  Task 3 blinking: flashes the yellow light when the cl

72、ock time is outside theactive time range.</p><p>  Task 4 lights: controls the traffic light phases while the clock time is in theactive time range (between the start and end times).</p><p>  Ta

73、sk 5 keyread: reads the pedestrian push button and sends a signal to thetask lights.</p><p>  Task 6 get_escape: If an ESC character is encountered in the serial streamthe command task gets a signal to termi

74、nate the display command.</p><p>  SERIAL.C implements an interrupt driven serial interface. This file contains thefunctions putchar and getkey. The high-level I/O functions printf and getlinecall these basi

75、c I/O routines. The traffic light application will also operatewithout using interrupt driven serial I/O. but will not perform as well.</p><p>  GETLINE.C is the command line editor for characters received f

76、rom the serial</p><p>  port. This source file is also used by the MEASURE application.</p><p>  TRAFFIC Project</p><p>  Open the TRAFFIC.UV2 project file that islocated in \KEIL\C

77、51\EXAMPLES\TRAFFIC folderwith μVision2. The source files for theTRAFFIC project will be shown in theProject Window – Files page.</p><p>  The RTX-51 Tiny Real-Time OS is selected under Options for Target.&l

78、t;/p><p>  Build the TRAFFIC program with Project - Build or the toolbar button.</p><p>  Run the TRAFFIC Program</p><p>  You can test TRAFFIC with theμVision2 simulator.</p>&

79、lt;p>  The watch variables shown on the rightallow you to view port status that drivesthe lights.</p><p>  The push_keysignal functionsimulates thepedestrianpush key thatswitches thelight system towalk st

80、ate.This functionis called withthe Push forUse Debug – Function Editor to open TRAFFIC.INC. This file is specified</p><p>  the Push forWalk toolbarbutton.</p><p>  under Options for Target – De

81、bug – Initialization File and defines thesignal function push_key, the port initialization and the toolbar button.</p><p>  Note: the VTREG symbol Clock is literalized with a back quote (`),since there is a

82、C function named clock in the TRAFFIC.C module.Refer to “Literal Symbols” on page 121 for more information.</p><p>  Now run the TRAFFIC application. Enable View – Periodic WindowUpdate to view the lights in

83、 the watch window during program execution.</p><p>  The Serial Window #1 displays the printf output and allows you to enterthe traffic light controller commands described in the table above.</p><

84、p>  Set the clocktime outside ofthe start/endtime intervalto flash theyellow light.</p><p>  RTX Kernel Aware Debugging</p><p>  A RTX application can be tested with the same methods and comm

85、ands asstandard 8051 applications. When you select an Operating System underOptions for Target – Target, μVision2 enables additional debugging features:a dialog lists the operating system status and with the _TaskRunning

86、_ debugfunction you may stop program execution when a specific task is active.</p><p>  The following section exemplifies RTX debugging with the TRAFFIC example.</p><p>  Stop program execution,

87、 reset the CPU and kill all breakpoints.</p><p>  An RTX-51 application can be tested in the same way as standardapplications. You may open source files, set break points and single stepthrough the code. The

88、 TRAFFIC application starts with task 0 init.</p><p>  μVision2 is completely kernel aware. You may display the task statuswith the menu command Peripherals – RTX Tiny Tasklist.</p><p>  The dia

89、log RTX51 Tiny Tasklist gives you the following information:</p><p>  RTX-51 Tiny contains an efficient stack management that is explained in the "RTX51 Tiny" User’sGuide, Chapter 5: RTX51 Tiny, St

90、ack Management.</p><p>  This manual provides detailed information about the Stack value.</p><p><b>  S</b></p><p>  The Debug – Breakpoints… dialog allows you to define

91、 breakpoints that stopthe program execution only when the task specified in the _TaskRunning_debug function argument is Running. Refer to “Predefined Functions” on page134 for a detailed description of the _TaskRunning_

溫馨提示

  • 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. 眾賞文庫僅提供信息存儲(chǔ)空間,僅對用戶上傳內(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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論