【正文】
the signal input on the Fault pin and the stalling of the controller by a debugger. There are two mecha nisms available to handle such conditions: the output signals can be forced into an inactive state and/or the PWM timers can be stopped. Each output signal has a fault bit. 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 output signal from driving the outside world in a dangerous manner during the fault condition. A fault condition can also generate a controller interrupt. Each PWM generator can also be configured to stop 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. A stall condition does not generate a controller interrupt. Output Control Block With each PWM generator block producing two raw PWM signals, the output control block takes care of the final conditioning of the PWM signals 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。 delays in the PWM signal edges caused by the deadband generator are not taken into account. Synchronization Methods There is a global reset capability that can 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 (this 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 counters always have the same values. The counter load values and parator 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 counter 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. The other update method is synchronous, 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 generators to be updated simultaneously without odd effects during the update。 when any of the selected events occur, an interrupt is generated. Additionally, the same event, a different event, the same set of events, or a different set of events can be selected as a source for an ADC trigger。 when either match the counter, they output a singleclockcyclewidth High pulse. When in CountUp/Down mode, these parators match both when counting up and when counting down。 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 pins. The Stellaris174。通過將 GPTMCTL寄存器的 TnPWML位置位,軟件可實現(xiàn)將輸出 PWM信號反相的功能。在 PWM模式中,不產(chǎn)生中斷或狀態(tài)位。在軟件寫 GPTMCTL寄存器的 TnEN 位時,計數(shù)器開始遞減計數(shù),直到計數(shù)值到達 0x0000。在 PWM 模式中,定時器配置為遞減計數(shù)器,初值由 GPTMTnILR定義。每當(dāng)檢測到上升沿事件時,當(dāng)前計數(shù)值便裝載到 GPTMTnR寄存器 中,且該值一直保持在寄存器中直到檢測到下一個上升沿(在此上升沿處,新的計數(shù)值裝載到 GPTMTnR中)。當(dāng)定時器到達 0x0000 狀態(tài)時,將 GPTMnILR 寄存器中的值重新載入定時器。在捕獲到事件之后,定時器不會停止計數(shù)。在檢測到所選的輸入事件時,從 GPTMTnR 寄存器中捕獲 Tn 計數(shù)器的當(dāng)前值,且該值可通過控制器來讀取。通過置位 GPTMTnMR 寄存器的 TnCMR 位可將定時器置于邊沿定時模式,而定時器捕獲時采用的事件類型由 GPTMCnTL 寄存器的 TnEVENT 位域來決定。 在邊沿定時模式中,定時器被配置為自由運行的遞減計數(shù)器,其初始值從GPTMTnILR 寄存器中加載(復(fù)位時初始化為 0xFFFF)。然后計數(shù)器使用 GPTMTnILR中的值執(zhí)行重裝操作,并且由于 GPTM自動將 GPTMCTL寄存器的 TnEN位清零,因此計數(shù) 器停止計數(shù)。 CCP 管腳上每輸入一個事件,計數(shù)器的值就減 1,直到事件計數(shù)的值與GPTMTnMATCHR的值匹配。在初始化過程中,需對 GPTM Timern 匹配 (GPTMTnMATCHR) 寄存器進行配置,以便 GPTMTnILR 寄存器和GPTMTnMATCHR寄存器之間的差值等于必須計算的邊沿事件的數(shù)目。為了把定時器設(shè)置為邊沿計數(shù)模式, GPTMTnMR 寄存器的 TnCMR 位必須設(shè)為 0。如果 GPTMCTL 寄存器中的 TnSTALL 位被使能,那么定時器停止( freeze)計數(shù),直到該信號失效后再繼續(xù)計數(shù)。它通過對GPTMCTL寄存器中的 TnOTE位置位來使能,并且可以觸發(fā)啟動轉(zhuǎn)換( SoC)事件如 ADC 轉(zhuǎn)換。如果 GPTIMR 的超時中斷使能,則 GPTM 還將 GPTMISR 寄存器的 TnTOMIS 位置位并產(chǎn)生控制器中斷。在到達 0x0000狀態(tài)時,定時器除了重裝計數(shù)值,還產(chǎn)生中斷并輸出觸發(fā)信號。如果配置為單次觸發(fā)模式,則定時器停止計數(shù)并將GPTMCTL寄存器的 TnEN 位清零。 在軟件對 GPTMCTL寄存器的 TnEN位執(zhí)行寫操作時,定時器從其預(yù)裝載的值開始遞減計數(shù)。選擇單次觸發(fā)模式還是周期模式由寫入 GPTMTnMR寄存器中 TnMR位域的值來決定。 TimerA 和 TimerB 的模式 相同,因此我們只介紹一次,并用字母 n來表示這兩個定時器的寄存器。 16位定時器的工作模式 通過向 GPTM配置 (GPTMCFG) 寄存器寫入 0x04,可將 GPTM配置為全局 16位模式。 通過寫 GPTMICR的 RTCCINT位可將狀態(tài)標(biāo)志清零。當(dāng)計數(shù)值與預(yù)裝載值匹配時, GPTM讓 GPTMRIS中的 RTCRIS位有效。 在軟件寫 GPTMCTL中的 TAEN位時,計數(shù)器從其預(yù)裝載的值 始遞增計數(shù)。 在 RTC模式中,要求 CCP0, CCP2或 CCP4管腳上的輸入時鐘為 。在首次選擇 RTC 模式時,計數(shù)器裝載的值為 。如果 GPTMCTL寄存器的 TASTALL 位有效 ,則定時器停止( freeze)計數(shù)直到該信號失效。通過將 GPTMCTL中的 TAOTE 位置位可將輸出觸發(fā)使能,并且可以觸發(fā)啟動轉(zhuǎn)換( SoC)事件,如ADC轉(zhuǎn)換。如果 GPTM 中斷屏蔽 (GPTIMR) 寄存的超時 (timeout)中斷使能,則 GPTM還將 GPTM 屏蔽后的中斷狀態(tài) (GPTMMIS) 寄存器 的 TATOMIS位置位。 除了重裝計數(shù)值, GPTM 還在到達 0x00000000 狀態(tài)時產(chǎn)生中斷并輸出觸發(fā)信號。如果配置為單次觸發(fā)模式,則定時器停止計數(shù)并將 GPTMCTL寄存器的 TAEN位清零。 當(dāng)軟件對 GPTM 控制 (GPTMCTL) 寄存器 (見 171頁 )的 TAEN位執(zhí)行寫操作時,定時器從其預(yù)加載的值開始遞減計數(shù) 。 這 樣 , 寫 操 作 最 終 的 字 順 序 為 :GPTMTBILR[15:0]:GPTMTAILR[15:0]同樣,對 GPTMTAR 的讀操作返回的值為:GPTMTBR[15:0]:GPTMTAR[15:0] 32位單次觸發(fā) /周期定時器模式 在 32位單次觸發(fā)和周期定時器模式中, TimerA和 TimerB寄存器連在一起被配置為 32位遞減計數(shù)器。在兩種配置中,都需將某些 GPTM寄存器連在一起形成偽 32位寄存器。 位定時器工作模式 介紹 GPTM的 3種 32位定時器模式(單次觸發(fā)、周期、 RTC),并對其配置進行描述。計數(shù)器 TimerA和 TimerB連同與它們對應(yīng)的裝載寄存器: GPTM TimerA 間隔裝載( GPTMTAILR) 寄存器和 GPTM TimerB 間隔裝載 ( GPTMTBILR)寄存器一起初始化為 0xFFFF。但如果配置為 16 位模式,則 GPTM 的兩個 16 位定時器可配置為 16 位模式的任意組合。 在通過軟件對 GPTM 進行配置時需用到 GPTM 配置 (GPTMCFG) 寄存器 、 GPTM TimerA模式 (GPTMTAM