【正文】
RTCMIS位置位并產(chǎn)生一個控制器中斷。可選預(yù)分頻器中的值被加載到 GPTM Timern 預(yù)分頻 (GPTMTnPR)寄存器中。輸出觸發(fā)信號是一個單時鐘周期的脈沖,在計數(shù)器剛好到達 0x0000 狀態(tài)時生效,并在緊接著的下一個周期失效。 當(dāng)軟件寫 GPTM 控制 (GPTMCTL)寄存器的 TnEN 位時,定時器使能并用于事件捕獲。 在軟件寫 GPTMCTL寄存器的 TnEN 位時,定時器使能并用于事件捕獲。 16位 PWM模式 GPTM 支持簡單的 PWM 生成模式。 Pulse Width Modulator (PWM) GeneralPurpose Timers Pulse width modulation (PWM) is a powerful technique for digitally encoding analog signal counters are used to generate a square wave, and the duty cycle of the squarewave is modulated to encode an analog signal. Typical applications include switching power suppliesand motor control. The Stellaris174。 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 parator match values can be individually configured in each PWM generator block. It typically makes sense to use the synchronous update mechanism across PWM generator blocks when the timers in those blocks are synchronized, though this is not required in order for this mechanism to function properly. Fault Conditions There are two external conditions that affect the PWM block。 they are therefore qualified by the counter direction signal. These qualified pulses are used in the PWM generation process. If either parator match value is greater than the counter load value, then that parator never outputs a High pulse. Figure 153 on page 493 shows the behavior of the counter and the relationship of these pulses when the counter is in CountDown mode. Figure 154 on page 493 shows the behavior of the counter and the relationship of these pulses when the counter is in CountUp/Down mode. PWM Signal Generator The PWM generator takes these pulses (qualified by the direction signal), and generates two PWM signals. In CountDown mode, there are four events that can affect the PWM signal: zero, load,match A down, and match B down. In CountUp/Down mode, 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 A or match B events are ignored when they coincide with the zero 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. DeadBand Generator The two PWM signals produced by the PWM generator are passed to the deadband generator. If disabled, the PWM signals simply pass through unmodified. If enabled, the second 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 the inversion of the input signal with a programmable delay added between the falling edge of the input signal and the rising edge of this new signal. Interrupt/ADCTrigger Selector The PWM generator also takes the same 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。在下一個計數(shù)周期,計數(shù)器將 GPTMTnILR寄存器中的值重新載入,作為 它的初值(如果使用了預(yù)分頻器,則還要重新裝載 GPTMTnPR中的值),并繼續(xù)計數(shù)直到計數(shù)器因軟件將 GPTMCTL寄存器的 TnEN位清零而被禁止。它會繼續(xù)計數(shù),直至 TnEN 位清零。一旦事件計數(shù)值滿足要求,接下來的所有事件都將被忽略 , 直 到通過軟件重新將 TnEN使能。 16位輸入邊沿計數(shù)模式 在邊沿計數(shù)模式中,定時器被配置為能夠捕獲 3種事件類型的遞減計數(shù)器,這3種事件類型為上升沿、下降沿、或上升 /下降沿。如果配置為周期定時器,它將 繼續(xù)計數(shù)。本小節(jié)將描述每一個 GPTM 的 16位操作模式。然后將時鐘信號分頻為 1Hz,將其傳送給 32位計數(shù)器的輸入端。輸出觸發(fā)信號是一個單時鐘周期的脈沖,它在計數(shù)器剛好到達 0x00000000狀態(tài)時生效,在緊接著的下一個周期失效。 然后根據(jù)寫入 GPTM TimerA模式 (GPTMTAMR)寄存器 (見 167頁 )的 TAMR 位域的值可確定選擇的是單次觸發(fā)模式還是周期模式,此時不需要寫 GPTM TimerB 模式 (GPTMTBMR) 寄存器。 GPTM 復(fù)位條件 GPTM模塊復(fù)位后處于未激活狀態(tài),所有控制寄存器均被清零,同時進入默認狀態(tài)。 注意 : 定時器 2是一個內(nèi)部定時器,只能用來產(chǎn)生內(nèi)部中斷 或觸發(fā) ADC時間。例如,通過對寄存器執(zhí)行寫操作來修改 PWM 信號(而無需通過修改反饋控制回路來修改各個 PWM發(fā)生器),以實現(xiàn)無電刷直流電機通信。 若故障位置位,則故障輸入信號將會使相應(yīng)的輸出信號變?yōu)闊o效狀態(tài)。由于要等計數(shù)器計數(shù)到零才能使用新值,因而在更新過程中定義了一個約定( guaranteed)行為,避免出現(xiàn)過短或過長的 PWM輸出脈沖。此外,你也可以選擇相同事件、不同事件、同組事件、不同組事件作為 ADC觸發(fā)源;只要其中一個所選事發(fā)生就會產(chǎn)生 ADC觸發(fā)脈沖。如果匹配 A與匹配 B事件重合,則第一個信號 PWMA 只根據(jù)匹配 A 事件生成,第二個信號 PWMB 只根據(jù)匹配 B 事件生成。 PWM比較器 每個 PWM 發(fā)生器含兩個比較器,用于監(jiān)控計數(shù)器的值;當(dāng)比較器的值與計數(shù)器的值相等時,比較器輸出寬度為單時鐘周期的高電平脈沖。它可以產(chǎn)生簡單的 PWM 信號,如簡易充電泵需要的信號;也可以產(chǎn)生帶死區(qū)延遲的成對 PWM信號,如供半 H橋( halfH bridge)驅(qū)動電路使用的信號。在脈寬調(diào)制中使用高分辨率計數(shù)器來產(chǎn)生方波 ,并且可以通過調(diào)整方波的占空比來對模擬信號電平進行編碼。 每個 PWM發(fā)生器模塊產(chǎn)生兩個 PWM信號,這兩個 PWM信號可以是獨立的信號(基于同一定時器因而頻率 相同的獨立信號除外),也可以是一對插入了死區(qū)延遲的互補( plementary)信號。通常,遞減計數(shù)模式是用來產(chǎn)生左對齊或右對齊的 PWM 信號,而先遞增后遞減計數(shù)模式是用來產(chǎn)生中心對齊的 PWM信號。在遞減計數(shù)模式中,能夠影響 PWM信號的事件有 4個:零、裝載、匹配 A遞減、匹配 B遞減。第二個輸出PWM 信號為輸入信號的反相信號,在輸入信號的下降沿和這個新信號的上升沿之間增加了可編程的延遲時間。這樣,通過那些信號邊沿之間的已知關(guān)系可產(chǎn)生 2 個以上的 PWM 信號,因為計數(shù)器總是具有相同的值。 故障狀態(tài) 影響 PWM 模塊的外部條件有兩個;一個是故障管腳的信號輸入,另一個是由調(diào)試器引發(fā)的控制器中止。停止?fàn)顟B(tài)不會產(chǎn)生控制器中斷。每個 GPTM 模塊包含兩個 16 位的定時器 /計數(shù)器(稱作 TimerA 和 TimerB),用戶可以將它們配置成獨立運行的定時器 或事件計數(shù)器,或?qū)⑺鼈兣渲贸?1個 32位定時器 或一個 32位實時時鐘 (RTC)。 在通過軟件對 GPTM 進行配置時需用到 GPTM 配置 (GPTMCFG) 寄存器 、 GPTM TimerA模式 (GPTMTAMR) 寄存器和 GPTM TimerB 模式 (GPTMTBMR) 寄存器。在兩種配置中,都需將某些 GPTM寄存器連在一起形成偽 32位寄存器。 除了重裝計數(shù)值, GPTM 還在到達 0x00000000 狀態(tài)時產(chǎn)生中斷并輸出觸發(fā)信號。在首次選擇 RTC 模式時,計數(shù)器裝載的值為 。 通過寫 GPTMICR的 RTCCINT位可將狀態(tài)標志清零。 在軟件對 GPTMCTL寄存器的 TnEN位執(zhí)行寫操作時,定時器從其預(yù)裝載的值開始遞減計數(shù)。它通過對GPTMCTL寄存器中的 TnOTE位置位來使能,并且可以觸發(fā)啟動轉(zhuǎn)換( SoC)事件如 ADC 轉(zhuǎn)換。 CCP 管腳上每輸入一個事件,計數(shù)器的值就減 1,直到事件計數(shù)的值與GPTMTnMATCHR的值匹配。在檢測到所選的輸入事件時,從 GPTMTnR 寄存器中捕獲 Tn 計數(shù)器的當(dāng)前值,且該值可通過控制器來讀取。在 PWM 模式中,定時器配置為遞減計數(shù)器,初值由 GPTMTnILR定義。 PWM module consists of three PWM generator blocks and a control block. The controlblock determines the polarity of the PWM signals, and which signals are passed through to the pins. Each PWM generator block produces two PWM signals that can either be independent signals(other than being based on the same timer and therefore having the same frequency) or a singlepair of plementary signals with deadband delays inserted. The output of the PWM generationblocks are managed by the output control block before being passed to the device