XGATE和HCS12X.docx

上传人:b****3 文档编号:12650463 上传时间:2023-04-21 格式:DOCX 页数:17 大小:261.54KB
下载 相关 举报
XGATE和HCS12X.docx_第1页
第1页 / 共17页
XGATE和HCS12X.docx_第2页
第2页 / 共17页
XGATE和HCS12X.docx_第3页
第3页 / 共17页
XGATE和HCS12X.docx_第4页
第4页 / 共17页
XGATE和HCS12X.docx_第5页
第5页 / 共17页
点击查看更多>>
下载资源
资源描述

XGATE和HCS12X.docx

《XGATE和HCS12X.docx》由会员分享,可在线阅读,更多相关《XGATE和HCS12X.docx(17页珍藏版)》请在冰豆网上搜索。

XGATE和HCS12X.docx

XGATE和HCS12X

Introduction

TheHCS12XmicrocontrollerfamilyoffersmanyenhancementsovertheHCS12family;principalamongtheseistheXGateperipheralprocessor.

HCS12X微控制器系列提供了許多增強HCS12系列的,其中主要是XGATE週邊處理器。

TheXGATEisaprogrammablecorethatoperatesindependentlyofthemainCPU,hasaccesstoalloftheS12Xperipherals,andfeaturesaRISCinstructionset.

XGATE是一個可編程的核心,運行獨立於主CPU,具有存取所有S12X週邊設備,採用RISC指令集。

ThisapplicationnotedescribeshowtoconfigureandusetheXGATE.

本應用筆記介紹了如何配置和使用的XGATE。

Thedocumentbeginswithadiscussionoftheissuessurroundingdatacoherencyindualcoresystemsandhowthesecanbeaddressedbysoftware.

文件首先的討論的問題在雙核心系統中數據的一致性,以及如何將這些軟體可以解決。

Itgoeson,inthefollowingsection,toprovidesomegeneralinformationandadviceonhowtosetupandinitializetheXGATEmodule.

如此下去,在下面的章節中,如何設置和初始化XGATE模組提供一些一般資料和諮詢意見。

Finally,itdescribestheXGATE’svariouspowersavingmodes,andprovidesa

comparisonoftheircapabilitiesanddifferences

最後,它描述了XGATE的各種省電模式,提供了一個比較,他們的能力和差異。

DataCoherency

Datacoherencyisthestatewherebyasetofdataisseenasconsistentandcompletebyanyprocessthatwishestoexamineit.

數據一致性是一組數據被視為一致且完整的任何過程,想研究一下它的狀態。

Inpractice,thismeansthataccesstothesetisforbiddenifthedataiscurrentlybeingchangedandsoisnotinternallyconsistent.

在實踐中,這意味著設定的存取是被禁止的,如果數據正在被改變,所以內部沒有一致。

Example:

Oneprocessenterssomedataintoamemoryareaandincrementsavariableholdingthenumberofentries,whiletheotherprocesstakesthedataoutofthatmemoryareaanddecrementsthisentrycountvariable.

例如:

一個過程進入到記憶體區和遞增的變數保持的項目數的一些數據,而其它過程中取得數據該記憶體區域和遞減計數變數這個項目。

Atypicalcodesequencelookslikethefollowing:

一個典型的碼序列如下所示:

1。

讀取變數到內部處理器暫存器

2。

遞增或遞減變數

3。

寫變數回記憶體中

Inamulti-taskingsystem,aninterruptmightcauseataskswitchimmediatelyafterreadingthevariable.

在一個多任務系統中,可能會導致一個中斷任務切換後,立即讀取的變數。

Thevariablemightthenbereadintheothertask,decrementedandwrittenback,therebycausingthevariabletoendupinaninconsistentstate.

變數可能被讀取的其他任務,遞減寫回,從而導致變數處於不一致的狀態

Insingleprocessorsystems,suchcodesequencesaretypicallyprotectedbydisablingandenablingtheinterruptbeforeandafterthecriticalcodesequence.

在單處理器系統中,這樣的代碼序列通常是保護通過禁用和使能中斷之前和之後的關鍵碼序列。

Whendealingwithanydual-processorarchitecture,thismethoddoesnotwork.

當處理任何雙處理器架構,這種方法不起作用。

Strictlyspeaking,almosteverykindofperipheralhasthiskindofissue.

嚴格地說,幾乎每一種周邊有這種問題。

Forexample,anSCIreceiverfillsthereceivebufferwhenanewbyteisreceived;

atthesametime,theCPUmightreadthereceivebufferandgetconflictingdata.

例如,SCI接收器,當接收到一個新的字節填補接收緩衝區;

在同一時間,CPU可能會讀取接收緩衝器,並得到衝突數據。

Inthecaseofperipherals,inmostcasesspecialflagsindicatewhetherdataisavailableorcanbetransmitted.

在週邊設備的情況下,在大多數情況下,特殊標誌指示數據是否可用,或者可以被發送。

Inshort,eachtimetwoormoreprocessescanaccessthesameresourcesimultaneously,specialcarehastobetaken.

總之,每次兩個或多個進程可以同時存取相同的資源,必須採取特殊照顧。

XGATE和HCS12XCPU時間多路復用存取的RAM中的方式。

S12XCPU在一個週期(25ns)存取RAM,而XGATE可以在12.5ns內是CPU的兩倍,如果S12XCPU不處理的RAM;或時間中的至少一個,與一個接入專用的S12XCPU和其他XGATE。

這很好的功能增強的XGATE的通過,以及在CPU,但也增加了數據一致性問題的複雜性。

兩個處理器之間的數據交換,避免數據一致性問題的一個簡單方法是使用一個緩衝區。

Thetwoprocessorsmusthonouranunderlyingagreementthatonesidewritestothebufferonlyiftheothersidehasflaggedthebufferasempty,andtheothersidereadsfromthebufferonlyifithasreceivedthefullsignal.

兩個處理器必須履行相關協議,一方只有當對方有標記的緩衝區為空,是否已接收到完整的信號,另一側從緩衝區讀取寫入到緩衝區。

TransmitBuffer

典型的應用程序可以使用是LINtransmission及SPImasters這個簡單的方式。

一個發送緩衝區的流程將是如下:

1.CPUfillsthebuffer.

CPU填入緩衝區。

2.CPUsignalstheXGATEmodulethatthedataisreadyfortransmission.

(Thiscanbecaused,forinstance,byenablingthetransmitrequestinsidetheperipheral.)

CPUXGATE模塊,數據已準備好用於傳輸的信號。

(這可能是由於,例如,通過使內部的外圍設備的發送請求)。

3.TheXGATEmodulegetsatransmitservicerequest.

XGATE模塊得到一個發送服務請求。

4.TheXGATEmodulesendsoutthedatatotheperipheral.

XGATE模塊發送數據的外設。

5.Oncefinished,theXGATEdisablestransmitrequestoftheperipheral.

一旦完成後,XGATE禁止週邊的發送請求。

6.TheXGATEsignalstotheCPU(viaaninterrupt,forexample)thatthetransferiscompleted.

XGATE的信號到CPU(例如:

通過中斷),傳輸完成。

7.TheCPUcannowstartagainatstep1.

現在CPU可以重新開始在第1步

發送或接收緩衝區的數據結構

ReceiveBuffer

Theflowforreceivingdatafromaperipheraldeviceandstoringitintoabufferisverysimilar.

周邊裝置及並儲存到緩衝區中和接收數據的流程是非常相似的。

However,caremustbetakenthatnonewdataisreceivedbeforethebufferisread.

但是,必須小心讀緩衝區之前沒有接收到新數據。

ThisisnotanissueforaLINnode,orforSPIprotocols,forexample,asthesendingofdataisactuallycontrolledbyatransmitprocess,i.e.controlledbytheCPU,itself.

這不是LIN節點或SPI協議的問題,,例如作為數據發送實際上是由一個發送過程中控制,即由CPU自已本身控制。

IfthereceiveprocessrunsasynchronoustotheCPUactivities,differentmethodsmustbeused,asshownbelow.

如果接收過程運行非同步於CPU,可以使用不同的方法如下所示。

對於接收處理,用於發送相同的結構都可以使用。

1。

XGATE服務是從周邊接收服務請求。

2。

XGATE模組填入緩衝區直到被填滿在預定義bytes或接收一個結束標誌。

3。

XGATE的傳輸完成時通知給CPU(例如,通過中斷)。

4。

CPU從緩衝區中提取數據然後可以進行進一步的處理。

另一種技術是不使用信號量並可以允許覆蓋的數據。

Thereadingsidemustseta“”beforereadingdata,andverifythatthisguardisstillsetafterthereadsequenceiscompleted.

讀方面必須讀取數據之前設置一個“警衛(guard)”,並確認這個守衛讀取序列完成後仍可設置。

這種技術的優點相較於一個信號技術(見下文),是讀取數據的過程中從來沒有被停止,甚至不需要阻止中斷。

這樣做的缺點是,可能必須重複進行數據的讀出。

一個程序開始之前要填補一個緩衝區,而變數Guard要遞增。

數據完全寫入到緩衝區中之後,變數Guard再次遞增。

Beforethereadprocessstartstoreadthedatabuffer,itcreatesacopyofthecurrentguard(OldG).

讀程序開始到讀取數據的緩衝區之前,它會建立一個復制的currentguard(OldG)。

AssumingthevariableGuardhasbeeninitializedto$0000,anoddnumberindicatesthatawriteisjustinprogress,sothereadprocesskeepspollingthevariableGuarduntilitbecomeseven,atwhichtimeitstartstoreadthedata.

假設變數guard已初始化到$0000,程序在寫以奇數表示,所以讀程序不斷輪詢變數guard,直到它變得偶數,此時它開始讀取數據。

Attheendofthereadprocess,thevariableGuardiscomparedtothesavedone,OldG.

在讀過程結束時,該變數Guard已存取與OldG相比。

Iftheyarenotequal,thenawritehasoccurredwhilereading,therebycorruptingthereaddata.

如果它們不相等,那麼在寫時發生讀,從而破壞讀出的數據。

Inthiscase,theprocessmustberepeated.Figure2showstheflow.

在這種情況下,該過程必須重複。

圖2表示出流程。

ThistechniquecanbeusedinXGATEtoS12XCPUorS12XtoXGATEdirection.

這種技術可以用在XGATE到S12XCPU或S12X到XGATE的方向。

互斥(互斥變量)或信號燈

Inmanycases,concurrentaccesstothesameresourceisavoidedbyusingamutex(mutuallyexclusiveRAMvariable)orasemaphore1.

在許多情況下,並發行存取相同的資源是為了避免使用互斥(互斥的RAM變量)或semaphore1的。

However,fortheS12XCPUandtheXGATEmoduleitisimpossibletousearead-modify-writemutexorsemaphoreinRAMtoindicateexclusiveaccesstoanyresources,becauseittakesseveralcyclestoreadaRAMvariable,testitscontents,andwritethemodifiedvariablebacktoRAM.Betweenthereadandthewrite,thevariableis“intransition”inaninternalregisterofeithertheCPUortheXGATEmodule

然而,對於S12XCPU和XGATE模組是不可能使用一個讀-修改-寫在RAM中的互斥或信號量去表示互斥存取的任何資源,因為它需要幾個週期來讀取的RAM變數,測試它的內容,並寫回RAM修改變數。

讀與寫之間變數是“轉換”在CPU或XGATE模組的內部暫存器。

If,now,theothermoduleaccessesthevariablewhilebeingintransition,awrite-backwillresultinaninconsistentstate

現在,如果存取其他模組的變數在轉型時,一個寫回將導致不一致的特質狀態。

XGATE可以提供專為此目的而設計的一組8個硬件信號燈。

這樣的信號量,可以在以下三種狀態之一

1。

未發布

2。

指定給S12XCPU過程

3。

指定給XGATE過程

這三種狀態之間的轉換處理過程如下

1。

設置信號燈。

XGATEprovidesadedicatedinstructioncalledSSEMwitheithera3-bitimmediatevalueoraregisterasoperand.

XGATE提供專用指令稱為SSEM,一個3位立即值或其暫存器作為操作數。

ThecarryflagissetiftheXGATEcouldsuccessfullylockthesemaphore,andisclearedifthesemaphoreisalreadylocked.

如果XGATE可以成功鎖定信號,進位標誌被設置,如果信號已被鎖定,進位標誌被被清除。

TheS12CPUaccessesthesemaphoreviatheXGSEMperipheralregisterandrequiresatwostepapproachtosetandcheckthesemaphore,usingtheC-Macrosshownbelow.

S12CPU存取的信號量通過週邊暫存器XGSEM和需要兩個步驟的方法來設置,並檢查信號量,使用如下所示的C宏

2。

釋放信號量。

XGATEprovidesadedicatedinstructioncalledCSEMwitheithera3-bitimmediatevalueoraregisterasoperandtoreleasethesemaphore.

XGATE提供了一個專用的指令稱為CSEM,3位立即數或暫存器作為操作數來釋放信號。

Again,theS12CPUaccessesthesemaphoreviatheXGSEMperipheralregister.

同樣,S12的CPU存取通過信號燈的XGSEM周邊寄存器。

Thehardwareassuresaclearpriority,incasethetwo“get”commandsare

issuedatthesametime.

硬體確保明確的優先級,此情況下兩個“get”命令在同一時間發出。

The“release”commandshouldbeissuedonlybytheprocessassociatedwiththesemaphore

應只與信號相關的程序發出“釋放”命令

2.Whydoesthisnothappeninanormalmultitaskingoperationsystemusingsemaphoresoraliketoguaranteeexclusiveaccessofonetasktoasharedresource?

2。

為什麼這不是發生在一個正常的多任務操作系統使用信號燈或類似以確保一項任務獨占存取共享資源?

MostCPUshaveannoninterruptible“read,test,modify,write”instructionsothevariableisnever“intransition”.

大多數CPU有一個不可中斷的“讀,測試,修改,寫”的指令,因此變數是從來沒有的“轉型”。

TheHCS12mustemulatethisbyusingdisableandenableinterrupts,aroundtheread-modify-writesequence,whiletheHCS12XCPUhasadedicatedinstruction(BTAS).

HCS12必須模擬這種使用禁用和啟用中斷,周圍的讀-修改-寫序列,HCS12XCPU專用指令(BTAS)。

SemaphoreStates

FIFO

Awellknowntechniqueforde-couplingtwoasynchronousdatastreamsisaFirst-In-First-Out(FIFO)datastructure.

一位知名去耦兩個非同步數據流技術是一種先入先出(FIFO)的數據結構。

AFIFOismostusefulifastreamofdatahastobereceived,wheretheindividualbytes(orwholemessages)arereceivedinbursts,toofastfortheCPUtohandle,eventhoughtheoverallperformanceoftheCPUismorethansufficienttosustaintheaveragedatarate.

如果數據流的形式被接收,FIFO是最有用的,其中的各別bytes(或整個訊息)中接收到脈衝串,速度太快由CPU來處理,即使在CPU的整體性能是綽綽有餘維持的平均數據速率。

通過使用一個FIFO,在CPU的等待時間要求,可以顯著減少。

Atypicalexampleisthe16550UARTfoundinalmosteverypersonalcomputer,whichusesa16-bytedeepFIFOtobuffertheincomingandoutgoingdata.

一個典型的例子是16550UART發現幾乎每一台個人電腦,它使用一個16字節的深FIFO緩衝傳入和傳出的數據。

ThemainissuewithanyFIFOisthatatleastonecommonbitofinformationisre

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 法律文书 > 调解书

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1