版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、<p><b> 畢業(yè)設(shè)計(論文)</b></p><p><b> 外文翻譯</b></p><p> 學(xué)生姓名: </p><p> 院(系): </p><p> 專業(yè)班級:
2、 </p><p> 指導(dǎo)教師: </p><p> 完成日期: </p><p> ARM Cortex-M3脈寬調(diào)制器 (PWM)與通用定時器</p><p><b> 1.PWM</b></p>
3、<p> 脈寬調(diào)制(PWM)是一項(xiàng)功能強(qiáng)大的技術(shù),它是一種對模擬信號電平進(jìn)行數(shù)字化編碼的方法。在脈寬調(diào)制中使用高分辨率計數(shù)器來產(chǎn)生方波,并且可以通過調(diào)整方波的占空比來對模擬信號電平進(jìn)行編碼。PWM通常使用在開關(guān)電源(switching power)和電機(jī)控制中。</p><p> StellarisPWM模塊由 3個 PWM發(fā)生器模塊 1個控制模塊組成。每個 PWM發(fā)生器模塊包含1個定時器(16
4、位遞減或先遞增后遞減計數(shù)器),2個PWM比較器,PWM信號發(fā)生器,死區(qū)發(fā)生器和中斷/ADC-觸發(fā) 選擇器。而控制模塊決定了PWM信號的極性,以及將哪個信號傳遞到管腳。</p><p> 每個 PWM發(fā)生器模塊產(chǎn)生兩個PWM信號,這兩個PWM信號可以是獨(dú)立的信號(基于同一定時器因而頻率相同的獨(dú)立信號除外),也可以是一對插入了死區(qū)延遲的互補(bǔ)(complementary)信號。這些PWM發(fā)生模塊的輸出信號在傳遞到器件
5、管腳之前由輸出控制模塊管理。</p><p> StellarisPWM模塊具有極大的靈活性。它可以產(chǎn)生簡單的PWM信號,如簡易充電泵需要的信號;也可以產(chǎn)生帶死區(qū)延遲的成對PWM信號,如供半-H橋(half-H bridge)驅(qū)動電路使用的信號。3個發(fā)生器模塊也可產(chǎn)生3相反相器橋所需的完整6通道門控。</p><p><b> PWM定時器</b></p&g
6、t;<p> 每個PWM發(fā)生器的定時器都有兩種工作模式:遞減計數(shù)模式或先遞增后遞減計數(shù)模式。在遞減計數(shù)模式中,定時器從裝載值開始計數(shù),計數(shù)到零時又返回到裝載值并繼續(xù)遞減計數(shù)。在先遞增后遞減計數(shù)模式中,定時器從0開始往上計數(shù),一直計數(shù)到裝載值,然后從裝載值遞減到零,接著再遞增到裝載值,依此類推。通常,遞減計數(shù)模式是用來產(chǎn)生左對齊或右對齊的PWM信號,而先遞增后遞減計數(shù)模式是用來產(chǎn)生中心對齊的PWM信號。</p>
7、<p> PWM定時器輸出3個信號,這些信號在生成PWM信號的過程中使用:方向信號(在遞減計數(shù)模式中,該信號始終為低電平,在先遞增后遞減計數(shù)模式中,則是在低高電平之間切換);當(dāng)計數(shù)器計數(shù)值為0時,一個寬度等于時鐘周期的高電平脈沖;當(dāng)計數(shù)器計數(shù)值等于裝載值時,一個寬度等于時鐘周期的高電平脈沖。注:在遞減計數(shù)模式中,零脈沖之后緊跟著一個裝載脈沖。</p><p><b> PWM比較器&l
8、t;/b></p><p> 每個PWM發(fā)生器含兩個比較器,用于監(jiān)控計數(shù)器的值;當(dāng)比較器的值與計數(shù)器的值相等時,比較器輸出寬度為單時鐘周期的高電平脈沖。在先遞增后遞減計數(shù)模式中,比較器在遞增和遞減計數(shù)時都要進(jìn)行比較,因此必須通過計數(shù)器的方向信號來限定。這些限定脈沖在生成PWM信號的過程中使用。如果任一比較器的值大于計數(shù)器的裝載值,則該比較器永遠(yuǎn)不會輸出高電平脈沖。</p><p>
9、<b> PWM信號發(fā)生器</b></p><p> PWM發(fā)生器捕獲這些脈沖(由方向信號來限定),并產(chǎn)生兩個PWM信號。在遞減計數(shù)模式中,能夠影響PWM信號的事件有4個:零、裝載、匹配A遞減、匹配B遞減。在先遞增后遞減計數(shù)模式中,能夠影響PWM信號的事件有6個:零、裝載、匹配A遞減、匹配A遞增、匹配B遞減、匹配B遞增。當(dāng)匹配A或匹配B事件與零或裝載事件重合時,它們可以被忽略。如果匹配A
10、與匹配B事件重合,則第一個信號PWMA只根據(jù)匹配A事件生成,第二個信號PWMB只根據(jù)匹配B事件生成。</p><p><b> 死區(qū)發(fā)生器</b></p><p> PWM發(fā)生器產(chǎn)生的兩個PWM信號被傳遞到死區(qū)發(fā)生器。如果死區(qū)發(fā)生器禁能,則PWM信號只簡單地通過該模塊,而不會發(fā)生改變。如果死區(qū)發(fā)生器使能,則丟棄第二個PWM信號,并在第一個PWM信號基礎(chǔ)上產(chǎn)生兩個P
11、WM信號。第一個輸出PWM信號為帶上升沿延遲的輸入信號,延遲時間可編程。第二個輸出PWM信號為輸入信號的反相信號,在輸入信號的下降沿和這個新信號的上升沿之間增加了可編程的延遲時間。</p><p> 中斷/ADC-觸發(fā) 選擇器</p><p> PWM發(fā)生器還捕獲相同的4個(或6個)計數(shù)器事件,并使用它們來產(chǎn)生中斷或ADC觸發(fā)信號。用戶可以選擇這些事件中的任一個或一組作為中斷源;只要其
12、中一個所選事件發(fā)生就會產(chǎn)生中斷。此外,你也可以選擇相同事件、不同事件、同組事件、不同組事件作為ADC觸發(fā)源;只要其中一個所選事發(fā)生就會產(chǎn)生ADC觸發(fā)脈沖。選擇的事件不同,在PWM信號內(nèi)產(chǎn)生中斷 或ADC觸發(fā) 的位置也不同。注:中斷 和ADC 觸發(fā)都是基于原始(raw)事件的;而不考慮死區(qū)發(fā)生器在PWM信號邊沿上產(chǎn)生的延遲。</p><p><b> 同步方法</b></p>
13、<p> 具有全局復(fù)位功能,該功能可同時復(fù)位PWM發(fā)生器中的任何或全部計數(shù)器。如果多個PWM發(fā)生器使用相同的計數(shù)器裝載值來配置,那么可以保證PWM發(fā)生器也具有相同的計數(shù)值(這不表示PWM發(fā)生器必須在其同步之前被配置)。這樣,通過那些信號邊沿之間的已知關(guān)系可產(chǎn)生2個以上的PWM信號,因?yàn)橛嫈?shù)器總是具有相同的值。</p><p> 在PWM發(fā)生器中,要對計數(shù)器裝載值和比較器匹配值進(jìn)行更新有兩種方法。一種
14、是立即更新,計數(shù)器計數(shù)一到零就立即使用新值。由于要等計數(shù)器計數(shù)到零才能使用新值,因而在更新過程中定義了一個約定(guaranteed)行為,避免出現(xiàn)過短或過長的PWM輸出脈沖。</p><p> 另一種方法是同步更新,它要等全局同步更新信號有效才使用新值,同步更新信號有效時,計數(shù)器</p><p> 一到零就立即使用新值。第二種方法可以同時對多個PWM發(fā)生器中的多項(xiàng)進(jìn)行更新,而不會在更
15、新過程中出現(xiàn)意外的影響;所有邏輯在根據(jù)新值運(yùn)行之前都先在原來的值上運(yùn)行。 裝載和比較器匹配的更新方法可以在各個PWM發(fā)生器模塊中單獨(dú)配置。當(dāng)那些模塊中的定時器同步時,通??梢栽赑WM發(fā)生器模塊中使用同步更新機(jī)制,盡管該機(jī)制正常工作時不要求這個。</p><p><b> 故障狀態(tài)</b></p><p> 影響PWM模塊的外部條件有兩個;一個是故障管腳的信號輸入,
16、另一個是由調(diào)試器引發(fā)的控制器中止。我們可以采用兩種機(jī)制來處理這些情況,一是強(qiáng)制將輸出信號變?yōu)闊o效(inactive)狀態(tài),以及/或者讓PWM定時器停止運(yùn)行。</p><p> 每個輸出信號都帶有一個故障位。若故障位置位,則故障輸入信號將會使相應(yīng)的輸出信號變?yōu)闊o效狀態(tài)。如果無效狀態(tài)指的是信號能夠長期停留的安全狀態(tài),那么這樣可避免輸出信號在故障狀態(tài)下以危險的方式驅(qū)動外部電路。此外,故障條件還可以產(chǎn)生控制器中斷。&l
17、t;/p><p> 用戶可以將PWM發(fā)生器配置為在停止條件期間停止計數(shù)。T也可以選擇讓計數(shù)器一直運(yùn)行,直到計數(shù)值為零才停止,或計數(shù)值為零時繼續(xù)計數(shù)和重裝。停止?fàn)顟B(tài)不會產(chǎn)生控制器中斷。</p><p><b> 輸出控制模塊</b></p><p> 每個 PWM發(fā)生器模塊產(chǎn)生的是兩個原始PWM信號,輸出控制模塊在PWM信號進(jìn)入管腳之前要對其最
18、后的狀態(tài)進(jìn)行控制。通過一個寄存器就能夠?qū)?shí)際傳遞到管腳的PWM信號進(jìn)行修改。例如,通過對寄存器執(zhí)行寫操作來修改PWM信號(而無需通過修改反饋控制回路來修改各個PWM發(fā)生器),以實(shí)現(xiàn)無電刷直流電機(jī)通信。同樣地,故障控制也能夠禁能所有的PWM信號。能夠?qū)θ我籔WM信號執(zhí)行最終的反相操作,使得默認(rèn)高電平有效的信號變?yōu)榈碗娖接行А?lt;/p><p><b> 2.通用定時器</b></p>
19、;<p> 可編程定時器可對驅(qū)動定時器輸入管腳的外部事件進(jìn)行計數(shù)或定時。Stellaris? 通用定時器模塊(GPTM) 包含 3個 GPTM 模塊 (定時器0, 定時器1和定時器 2)。每個GPTM模塊包含兩個16位的定時器/計數(shù)器(稱作TimerA和TimerB),用戶可以將它們配置成獨(dú)立運(yùn)行的定時器 或事件計數(shù)器,或?qū)⑺鼈兣渲贸?個32位定時器 或一個32位實(shí)時時鐘 (RTC)。定時器也可用于觸發(fā)模數(shù)(ADC) 轉(zhuǎn)
20、換。由于所有通用定時器的觸發(fā)信號在到達(dá)ADC模塊前一起進(jìn)行或操作,因而只需使用一個定時器來觸發(fā)ADC事件。</p><p> 注意: 定時器2是一個內(nèi)部定時器,只能用來產(chǎn)生內(nèi)部中斷 或觸發(fā)ADC時間。</p><p> 通用定時器模塊是 Stellaris? 微控制器的一個定時資源。其它定時器資源還包括系統(tǒng)定時器 (SysTick)支持以下模式:</p><p>
21、; ■ 32-位定時器模式</p><p> – 可編程單次觸發(fā)(one-shot)定時器</p><p> – 可編程周期定時器</p><p> – 使用32.768-KHz 輸入時鐘的實(shí)時時鐘</p><p> – 事件的停止可由軟件來控制(RTC模式除外)</p><p> ■ 16-位定時器模式&
22、lt;/p><p> – 帶8位預(yù)分頻器的通用定時器功能模塊 (僅單次觸發(fā)模式和周期模式)</p><p> – 可編程單次觸發(fā)(one-shot)定時器</p><p> – 可編程周期定時器</p><p> – 事件的停止可由軟件來控制</p><p> ■ 16-位輸入捕獲模式</p>&l
23、t;p> – 輸入邊沿計數(shù)捕獲</p><p> – 輸入邊沿定時捕獲</p><p> ■ 16-位PWM模式</p><p> – 簡單的PWM模式,可通過軟件實(shí)現(xiàn)PWM信號的輸出反相。</p><p><b> 功能描述</b></p><p> 每個GPTM模塊的主要元件
24、包括兩個自由運(yùn)行的先遞增后遞減計數(shù)器(稱作TimerA和TimerB)、兩個16位匹配寄存器、兩個預(yù)分頻器匹配寄存器、兩個16位裝載/初始化寄存器和它們相關(guān)的控制功能。GPTM的準(zhǔn)確功能可由軟件來控制,并通過寄存器接口進(jìn)行配置。</p><p> 在通過軟件對GPTM進(jìn)行配置時需用到GPTM 配置 (GPTMCFG) 寄存器 、GPTM TimerA模式 (GPTMTAMR) 寄存器和 GPTM TimerB
25、模式 (GPTMTBMR) 寄存器。當(dāng)GPTM模塊處于其中一種32位模式時,該定時器只能作為32位定時器使用。但如果配置為16位模式,則GPTM的兩個16位定時器可配置為16位模式的任意組合。</p><p><b> GPTM 復(fù)位條件</b></p><p> GPTM模塊復(fù)位后處于未激活狀態(tài),所有控制寄存器均被清零,同時進(jìn)入默認(rèn)狀態(tài)。計數(shù)器TimerA和Ti
26、merB連同與它們對應(yīng)的裝載寄存器:GPTM TimerA 間隔裝載(GPTMTAILR) 寄存器和 GPTM TimerB 間隔裝載 (GPTMTBILR)寄存器一起初始化為0xFFFF。</p><p> 預(yù)分頻計數(shù)器:GPTM TimerA 預(yù)分頻(GPTMTAPR) 寄存器) 和GPTM TimerB 預(yù)分頻(GPTMTBPR) 寄存器初始化為0x00。</p><p><
27、b> 位定時器工作模式</b></p><p> 介紹GPTM的3種32位定時器模式(單次觸發(fā)、周期、RTC),并對其配置進(jìn)行描述。</p><p> 通過向GPTM 配置 (GPTMCFG)寄存器寫入0(單次觸發(fā)/32位周期定時器模式)或1(RTC模式),可將GPTM模塊配置為32位模式。在兩種配置中,都需將某些GPTM寄存器連在一起形成偽32位寄存器。這些寄存器
28、包括:</p><p> ■ GPTM TimerA 間隔裝載(GPTMTAILR) 寄存器 [15:0], </p><p> ■ GPTM TimerB 間隔裝載(GPTMTBILR) 寄存器 [15:0], </p><p> ■ GPTM TimerA(GPTMTAR) 寄存器 [15:0], </p><p> ■ GPTM
29、 TimerB (GPTMTBR) 寄存器 [15:0], </p><p> 在32位模式中,GPTM把對GPTMTAILR的32位寫訪問轉(zhuǎn)換為對GPTMTAILR和GPTMTBILR的寫訪問。這樣,寫操作最終的字順序?yàn)椋篏PTMTBILR[15:0]:GPTMTAILR[15:0]同樣,對GPTMTAR的讀操作返回的值為:GPTMTBR[15:0]:GPTMTAR[15:0]</p><
30、p> 32-位單次觸發(fā)/周期定時器模式</p><p> 在32位單次觸發(fā)和周期定時器模式中,TimerA和TimerB寄存器連在一起被配置為32位遞減計數(shù)器。</p><p> 然后根據(jù)寫入GPTM TimerA模式 (GPTMTAMR)寄存器 (見 167頁)的 TAMR 位域的值可確定選擇的是單次觸發(fā)模式還是周期模式,此時不需要寫GPTM TimerB 模式 (GPTMT
31、BMR) 寄存器。</p><p> 當(dāng)軟件對GPTM 控制 (GPTMCTL) 寄存器 (見 171頁)的TAEN位執(zhí)行寫操作時,定時器從其預(yù)加載的值開始遞減計數(shù)。當(dāng)?shù)竭_(dá)0x0000.0000狀態(tài)時,定時器會在下一個周期從相連的GPTMTAILR中重新裝載它的初值。如果配置為單次觸發(fā)模式,則定時器停止計數(shù)并將GPTMCTL寄存器的TAEN位清零。如果配置為周期定時器,它將繼續(xù)計數(shù)。</p>&l
32、t;p> 除了重裝計數(shù)值,GPTM還在到達(dá)0x00000000狀態(tài)時產(chǎn)生中斷并輸出觸發(fā)信號。GPTM將GPTM 原始中斷狀態(tài) (GPTMRIS)寄存器 中的TATORIS位置位,并保持該值直到向GPTM 中斷清零</p><p> (GPTMICR) 寄存器執(zhí)行寫操作將其清零。如果GPTM 中斷屏蔽 (GPTIMR) 寄存的超時(time-out)中斷使能,則GPTM還將GPTM 屏蔽后的中斷狀態(tài) (G
33、PTMMIS) 寄存器 的TATOMIS位置位。輸出觸發(fā)信號是一個單時鐘周期的脈沖,它在計數(shù)器剛好到達(dá)0x00000000狀態(tài)時生效,在緊接著的下一個周期失效。通過將GPTMCTL中的TAOTE位置位可將輸出觸發(fā)使能,并且可以觸發(fā)啟動轉(zhuǎn)換(SoC)事件,如ADC轉(zhuǎn)換。如果軟件在計數(shù)器運(yùn)行過程中重裝GPTMTAILR寄存器,則計數(shù)器在下一個時鐘周期裝載新值并從新值繼續(xù)計數(shù)。如果GPTMCTL寄存器的TASTALL 位有效,則定時器停止(f
34、reeze)計數(shù)直到該信號失效。</p><p> 32-位實(shí)時時鐘定時器模式</p><p> 在實(shí)時時鐘(RTC)模式中,TimerA和TimerB寄存器連在一起被配置為32位遞增計數(shù)器。在首次選擇RTC模式時,計數(shù)器裝載的值為0x0000.0001。后面裝載的值全都必須通過控制器寫入GPTMTimerA 匹配 (GPTMTAMATCHR) 寄存器。</p><
35、p> 在RTC模式中,要求CCP0, CCP2或CCP4管腳上的輸入時鐘為32.768KHz。然后將時鐘信號分頻為1Hz,將其傳送給32位計數(shù)器的輸入端。</p><p> 在軟件寫GPTMCTL中的TAEN位時,計數(shù)器從其預(yù)裝載的值0x0000.0001開始遞增計數(shù)。在當(dāng)前計數(shù)值與GPTMTAMATCHR中的預(yù)裝載值匹配時,計數(shù)器返回到0x0000.0000并繼續(xù)計數(shù),直到出現(xiàn)硬件復(fù)位或被軟件禁能(T
36、AEN位清零),計數(shù)停止。當(dāng)計數(shù)值與預(yù)裝載值匹配時,GPTM讓GPTMRIS中的RTCRIS位有效。如果GPTIMR中的RTC中斷使能,那么GPTM 也會將GPTMISR中的 RTCMIS位置位并產(chǎn)生一個控制器中斷。 通過寫 GPTMICR的RTCCINT位可將狀態(tài)標(biāo)志清零。如果GPTMCTL寄存器中的 TASTALL位和/或 TBSTALL 位置位,那么定時器在GPTMCTL的RTCEN位置位時不會停止計數(shù)。</p>&
37、lt;p> 16-位定時器的工作模式</p><p> 通過向GPTM配置 (GPTMCFG) 寄存器寫入0x04,可將GPTM配置為全局16位模式。本小節(jié)將描述每一個GPTM的16-位操作模式。TimerA和TimerB的模式相同,因此我們只介紹一次,并用字母n來表示這兩個定時器的寄存器。</p><p> 16-位單次觸發(fā)/周期定時器模式</p><p&
38、gt; 在16位單次觸發(fā)/周期定時器模式中,定時器被配置為帶可選的8位預(yù)分頻器的16位遞減計數(shù)器,預(yù)分頻器可有效地將定時器的計數(shù)范圍擴(kuò)大到24位。選擇單次觸發(fā)模式還是周期模式由寫入 GPTMTnMR寄存器中TnMR位域的值來決定。可選預(yù)分頻器中的值被加載到GPTM Timern 預(yù)分頻 (GPTMTnPR)寄存器中。</p><p> 在軟件對GPTMCTL寄存器的TnEN位執(zhí)行寫操作時,定時器從其預(yù)裝載的值
39、開始遞減計數(shù)。一旦到達(dá)0x0000狀態(tài),定時器便在下一個周期到來時將GPTMTnILR和GPTMTnPR的值重新載入。如果配置為單次觸發(fā)模式,則定時器停止計數(shù)并將GPTMCTL寄存器的TnEN位清零。如果配置為周期定時器,它將繼續(xù)計數(shù)。在到達(dá)0x0000狀態(tài)時,定時器除了重裝計數(shù)值,還產(chǎn)生中斷并輸出觸發(fā)信號。GPTM將GPTMRIS寄存器的TnTORIS位置位,并保持該值直到執(zhí)行GPTMICR寄存器寫操作將該位清零。如果GPTIMR的超
40、時中斷使能,則GPTM還將 GPTMISR寄存器的TnTOMIS位置位并產(chǎn)生控制器中斷。輸出觸發(fā)信號是一個單時鐘周期的脈沖,在計數(shù)器剛好到達(dá)0x0000狀態(tài)時生效,并在緊接著的下一個周期失效。它通過對GPTMCTL寄存器中的TnOTE位置位來使能,并且可以觸發(fā)啟動轉(zhuǎn)換(SoC)事件如ADC轉(zhuǎn)換。如果軟件在計數(shù)器運(yùn)行過程中重裝GPTMTAILR寄存器,則計數(shù)器在下一個時鐘周期裝載新值并從新值繼續(xù)計數(shù)。如果GPTMCTL寄存器中的 TnST
41、ALL 位被使能,那么定時器停止(freeze</p><p> 16-位輸入邊沿計數(shù)模式</p><p> 在邊沿計數(shù)模式中,定時器被配置為能夠捕獲3種事件類型的遞減計數(shù)器,這3種事件類型為上升沿、下降沿、或上升/下降沿。為了把定時器設(shè)置為邊沿計數(shù)模式,GPTMTnMR寄存器的TnCMR 位必須設(shè)為0。定時器計數(shù)時所采用的邊沿類型由GPTMCTL寄存器的TnEVENT位域決定。在初始
42、化過程中,需對GPTM Timern 匹配 (GPTMTnMATCHR)寄存器進(jìn)行配置,以便GPTMTnILR寄存器和GPTMTnMATCHR寄存器之間的差值等于必須計算的邊沿事件的數(shù)目。</p><p> 當(dāng)軟件寫GPTM控制(GPTMCTL)寄存器的TnEN位時,定時器使能并用于事件捕獲。CCP管腳上每輸入一個事件,計數(shù)器的值就減1,直到事件計數(shù)的值與GPTMTnMATCHR的值匹配。這時,GPTM讓GPT
43、MRIS寄存器的CnMRIS位有效(如果中斷沒有屏蔽,則也要讓CnMMIS位有效)。然后計數(shù)器使用GPTMTnILR中的值執(zhí)行重裝操作,并且由于GPTM自動將GPTMCTL寄存器的TnEN位清零,因此計數(shù)器停止計數(shù)。一旦事件計數(shù)值滿足要求,接下來的所有事件都將被忽略, 直到通過軟件重新將TnEN使能。</p><p> 在邊沿定時模式中,定時器被配置為自由運(yùn)行的遞減計數(shù)器,其初始值從GPTMTnILR寄存器中加
44、載(復(fù)位時初始化為0xFFFF)。該模式允許在上升沿或下降沿捕獲事件。通過置位GPTMTnMR寄存器的TnCMR位可將定時器置于邊沿定時模式,而定時器捕獲時采用的事件類型由GPTMCnTL寄存器的TnEVENT位域來決定。</p><p> 在軟件寫GPTMCTL寄存器的TnEN 位時,定時器使能并用于事件捕獲。在檢測到所選的輸入事件時,從GPTMTnR寄存器中捕獲Tn計數(shù)器的當(dāng)前值,且該值可通過控制器來讀取。
45、 然后GPTM讓CnERIS位有效(如果中斷沒有被屏蔽,則也讓CnEMIS位有效)。在捕獲到事件之后,定時器不會停止計數(shù)。它會繼續(xù)計數(shù),直至 TnEN 位清零。當(dāng)定時器到達(dá)0x0000狀態(tài)時,將GPTMnILR 寄存器中的值重新載入定時器。定時器配置為捕獲上升沿事件。每當(dāng)檢測到上升沿事件時,當(dāng)前計數(shù)值便裝載到GPTMTnR寄存器中,且該值一直保持在寄存器中直到檢測到下一個上升沿(在此上升沿處,新的計數(shù)值裝載到GPTMTnR中)。<
46、/p><p><b> 16-位PWM模式</b></p><p> GPTM支持簡單的PWM生成模式。在PWM模式中,定時器配置為遞減計數(shù)器,初值由GPTMTnILR定義。通過將GPTMTnMR寄存器的TnAMS位置為0x1、TnCMR位置為0x0、TnMR位域置為0x2來使能PWM模式。在軟件寫GPTMCTL寄存器的 TnEN 位時,計數(shù)器開始遞減計數(shù),直到計數(shù)值
47、到達(dá)0x0000。在下一個計數(shù)周期,計數(shù)器將GPTMTnILR寄存器中的值重新載入,作為它的初值(如果使用了預(yù)分頻器,則還要重新裝載GPTMTnPR中的值),并繼續(xù)計數(shù)直到計數(shù)器因軟件將GPTMCTL寄存器的TnEN位清零而被禁止。在PWM模式中,不產(chǎn)生中斷或狀態(tài)位。</p><p> 當(dāng)計數(shù)器的值與GPTMTnILR 寄存器的值(計數(shù)器的初始狀態(tài))相等時,輸出PWM信號生效,當(dāng)計數(shù)器的值與GPTM Timer
48、n 匹配 寄存器 (GPTMnMATCHR)的值相等時,輸出PWM信號失效。通過將GPTMCTL寄存器的TnPWML位置位,軟件可實(shí)現(xiàn)將輸出PWM信號反相的功能。</p><p> Pulse Width Modulator (PWM) General-Purpose Timers</p><p><b> 1.PWM</b></p><p&g
49、t; Pulse width modulation (PWM) is a powerful technique for digitally encoding analog signal levels.High-resolution counters are used to generate a square wave, and the duty cycle of the squarewave is modulated to encod
50、e an analog signal. Typical applications include switching power suppliesand motor control.</p><p> The Stellaris® PWM module consists of three PWM generator blocks and a control block. The controlbloc
51、k determines the polarity of the PWM signals, and which signals are passed through to the pins.</p><p> Each PWM generator block produces two PWM signals that can either be independent signals(other than be
52、ing based on the same timer and therefore having the same frequency) or a singlepair of complementary signals with dead-band delays inserted. The output of the PWM generationblocks are managed by the output control block
53、 before being passed to the device pins.</p><p> The Stellaris® PWM module provides a great deal of flexibility. It can generate simple PWM signals,such as those required by a simple charge pump. It ca
54、n also generate paired PWM signals withdead-band delays, such as those required by a half-H bridge driver. Three generator blocks canalso generate the full six channels of gate controls required by a 3-phase inverter bri
55、dge.</p><p><b> PWM Timer</b></p><p> The timer in each PWM generator runs in one of two modes: Count-Down mode or Count-Up/Downmode. In Count-Down mode, the timer counts from the
56、load value to zero, goes back to the loadvalue, and continues counting down. In Count-Up/Down mode, the timer counts from zero up to the load value, back down to zero, back up to the load value, and so on. Generally, Cou
57、nt-Down mode is used for generating left- or right-aligned PWM signals, while the Count-Up/Down mode is usedfor generating center-aligned </p><p> The timers output three signals that are used in the PWM ge
58、neration process: the direction signal(this is always Low in Count-Down mode, but alternates between Low and High in Count-Up/Down mode), a single-clock-cycle-width High pulse when the counter is zero, and a single-clock
59、-cycle-width High pulse when the counter is equal to the load value. Note that in Count-Down mode, the zeropulse is immediately followed by the load pulse.</p><p> PWM Comparators</p><p> Ther
60、e are two comparators in each PWM generator that monitor the value of the counter; when either match the counter, they output a single-clock-cycle-width High pulse. When in Count-Up/Down mode, these comparators match bot
61、h when counting up and when counting down; they are therefore qualified by the counter direction signal. These qualified pulses are used in the PWM generation process. If either comparator match value is greater than the
62、 counter load value, then that comparator never outputs </p><p> Figure 15-3 on page 493 shows the behavior of the counter and the relationship of these pulses when the counter is in Count-Down mode. Figure
63、 15-4 on page 493 shows the behavior of the counter and the relationship of these pulses when the counter is in Count-Up/Down mode.</p><p> PWM Signal Generator</p><p> The PWM generator takes
64、 these pulses (qualified by the direction signal), and generates two PWM signals. In Count-Down mode, there are four events that can affect the PWM signal: zero, load,match A down, and match B down. In Count-Up/Down mode
65、, there are six events that can affect the PWM signal: zero, load, match A down, match A up, match B down, and match B up. The match</p><p> A or match B events are ignored when they coincide with the zero
66、or load events. If the match A and match B events coincide, the first signal, PWMA, is generated based only on the match A event,and the second signal, PWMB, is generated based only on the match B event.</p><p
67、> Dead-Band Generator</p><p> The two PWM signals produced by the PWM generator are passed to the dead-band generator. If disabled, the PWM signals simply pass through unmodified. If enabled, the second
68、 PWM signal is lost and two PWM signals are generated based on the first PWM signal. The first output PWM signal is the input signal with the rising edge delayed by a programmable amount. The second output PWM signal is
69、the inversion of the input signal with a programmable delay added between the falling edge of the input sign</p><p> Interrupt/ADC-Trigger Selector</p><p> The PWM generator also takes the sam
70、e four (or six) counter events and uses them to generate an interrupt or an ADC trigger. Any of these events or a set of these events can be selected as a source for an interrupt; when any of the selected events occur, a
71、n interrupt is generated. Additionally, the same event, a different event, the same set of events, or a different set of events can be selected</p><p> as a source for an ADC trigger; when any of these sele
72、cted events occur, an ADC trigger pulse is generated. The selection of events allows the interrupt or ADC trigger to occur at a specific position within the PWM signal. Note that interrupts and ADC triggers are based on
73、the raw events; delays in the PWM signal edges caused by the dead-band generator are not taken into account.</p><p> Synchronization Methods</p><p> There is a global reset capability that can
74、 synchronously reset any or all of the counters in the PWM generators. If multiple PWM generators are configured with the same counter load value, this can be used to guarantee that they also have the same count value (t
75、his does imply that the PWM generators must be configured before they are synchronized). With this, more than two PWM signals can be produced with a known relationship between the edges of those signals since the counter
76、s always have the</p><p> The counter load values and comparator match values of the PWM generator can be updated in two ways. The first is immediate update mode, where a new value is used as soon as the co
77、unter reaches zero. By waiting for the counter to reach zero, a guaranteed behavior is defined, and overly short or overly long output PWM pulses are prevented.</p><p> The other update method is synchronou
78、s, where the new value is not used until a global synchronized update signal is asserted, at which point the new value is used as soon as the counter reaches zero. This second mode allows multiple items in multiple PWM g
79、enerators to be updated simultaneously without odd effects during the update; everything runs from the old values until a point at which they all run from the new values. The Update mode of the load and comparator match
80、values can be individua</p><p> Fault Conditions</p><p> There are two external conditions that affect the PWM block; the signal input on the Fault pin and the stalling of the controller by a
81、debugger. There are two mechanisms available to handle such conditions: the output signals can be forced into an inactive state and/or the PWM timers can be stopped.</p><p> Each output signal has a fault b
82、it. If set, a fault input signal causes the corresponding output signal to go into the inactive state. If the inactive state is a safe condition for the signal to be in for an extended period of time, this keeps the outp
83、ut signal from driving the outside world in a dangerous manner during the fault condition. A fault condition can also generate a controller interrupt.</p><p> Each PWM generator can also be configured to st
84、op counting during a stall condition. The user can select for the counters to run until they reach zero then stop, or to continue counting and reloading.</p><p> A stall condition does not generate a contro
85、ller interrupt.</p><p> Output Control Block</p><p> With each PWM generator block producing two raw PWM signals, the output control block takes care of the final conditioning of the PWM signa
86、ls before they go to the pins. Via a single register,the set of PWM signals that are actually enabled to the pins can be modified; this can be used, for example, to perform commutation of a brushless DC motor with a sing
87、le register write (and without modifying the individual PWM generators, which are modified by the feedback control loop). Similarly,fault con</p><p> General-Purpose Timers</p><p> Programmabl
88、e timers can be used to count or time external events that drive the Timer input pins.The Stellaris? General-Purpose Timer Module (GPTM) contains three GPTM blocks (Timer0, Timer1,and Timer 2). Each GPTM block provides t
89、wo 16-bit timers/counters (referred to as TimerA andTimerB) that can be configured to operate independently as timers or event counters, or configuredto operate as one 32-bit timer or one 32-bit Real-Time Clock (RTC).<
90、;/p><p> In addition, timers can be used to trigger analog-to-digital conversions (ADC). The ADC triggersignals from all of the general-purpose timers are ORed together before reaching the ADC module,so only o
91、ne timer should be used to trigger ADC events.</p><p> The GPT Module is one timing resource available on the Stellaris? microcontrollers. Other timerresources include the System Timer (SysTick) and the PWM
92、 timer in thePWM module.</p><p> The General-Purpose Timers provide the following features:</p><p> ■ Three General-Purpose Timer Modules (GPTM), each of which provides two 16-bittimers/counte
93、rs. Each GPTM can be configured to operate independently:</p><p> – As a single 32-bit timer</p><p> – As one 32-bit Real-Time Clock (RTC) to event capture</p><p> – For Pulse Wi
94、dth Modulation (PWM)</p><p> – To trigger analog-to-digital conversions</p><p> ■ 32-bit Timer modes</p><p> – Programmable one-shot timer</p><p> – Programmable pe
95、riodic timer</p><p> – Real-Time Clock when using an external 32.768-KHz clock as the input</p><p> – User-enabled stalling when the controller asserts CPU Halt flag during debug</p>&l
96、t;p> – ADC event trigger</p><p> ■ 16-bit Timer modes</p><p> – General-purpose timer function with an 8-bit prescaler (for one-shot and periodic modes only)</p><p> – Progra
97、mmable one-shot timer</p><p> – Programmable periodic timer</p><p> – User-enabled stalling when the controller asserts CPU Halt flag during debug</p><p> – ADC event trigger<
98、/p><p> ■ 16-bit Input Capture modes</p><p> – Input edge count capture</p><p> 270 September 04, 2010</p><p> Texas Instruments-Production Data</p><p>
99、General-Purpose Timers</p><p> – Input edge time capture</p><p> ■ 16-bit PWM mode</p><p> – Simple PWM mode with software-programmable output inversion of the PWM signa</p>
100、;<p> Functional Description</p><p> The main components of each GPTM block are two free-running 16-bit up/down counters (referredto as TimerA and TimerB), two 16-bit match registers, two prescaler
101、match registers, and two 16-bitload/initialization registers and their associated control functions. The exact functionality of eachGPTM is controlled by software and configured through the register interface.Software co
102、nfigures the GPTM using the GPTM Configuration (GPTMCFG) register,the GPTM TimerA Mode (GPTMTAMR) register and the GPTM</p><p> After reset has been applied to the GPTM module, the module is in an inactive
103、state, and all controlregisters are cleared and in their default states. Counters TimerA and TimerB are initialized to0xFFFF, along with their corresponding load registers: the GPTM TimerA Interval Load(GPTMTAILR) regist
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(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)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 外文翻譯--定時器運(yùn)行
- 基于ARM Cortex-M3的智能監(jiān)控器的設(shè)計.pdf
- 基于ARM Cortex-M3的通用數(shù)據(jù)終端的設(shè)計.pdf
- 基于ARM Cortex-M3內(nèi)核斷路器監(jiān)測組件的研究與實(shí)現(xiàn).pdf
- 電流型脈寬調(diào)制器的研究.pdf
- 三電平逆變器脈寬調(diào)制器研究.pdf
- 基于ARM Cortex-M3的迷宮電腦鼠設(shè)計與實(shí)現(xiàn).pdf
- 定時器設(shè)計畢業(yè)論文(含外文翻譯)
- 基于ARM Cortex-M3的無刷直流電機(jī)控制器設(shè)計.pdf
- 定時器85044
- js定時器
- 定時器84516
- 集成定時器
- 定時器85190
- 定時器84631
- vb定時器
- 定時器84659
- 定時器85010
- 定時器84358
- 定時器84772
評論
0/150
提交評論