HCS12ECTPWM增強型捕捉定時器模塊_第1頁
HCS12ECTPWM增強型捕捉定時器模塊_第2頁
HCS12ECTPWM增強型捕捉定時器模塊_第3頁
HCS12ECTPWM增強型捕捉定時器模塊_第4頁
HCS12ECTPWM增強型捕捉定時器模塊_第5頁
已閱讀5頁,還剩41頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、Freescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.TMFreescale HCS12 微控制器微控制器MC9S12DP2562

2、005年年8月月Freescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.TMEnhanced Capture Timer Modul

3、e增強型捕捉定時器模塊增強型捕捉定時器模塊TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 2ECT 模塊結構

4、模塊結構一個16位向上帶可編程預分頻的主計數(shù)器.一個16位的帶可編程預分頻的模數(shù)向下計數(shù)器8個獨立的定時器通道,每個通道具備輸入捕捉和輸出比較功能4個8位脈沖累加器,也可設置成2個16位脈沖累加器.通過對寄存器編程可以實現(xiàn)不同的功能TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names

5、are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 3定時器結構定時器結構預分頻選擇 PR2:0M Clock1 2 4 8 16 32 64 128TCNT15.0DATA BUSPINRRRR1 計數(shù)器使能0 計數(shù)器禁止TEN TSWAI TSFRZ TFFCATSCR1 -定時器控制寄存器定時器控制寄存器RST: 0 0 0 0 0 0 0 0TCNT CLK.TENB0.B7 B8.B15R = Reserved$0006Address Offset $0004, 0

6、5$FFFE$FFFF$0000*TOF模塊時鐘模塊時鐘計數(shù)器寄存器計數(shù)器寄存器脈沖累加器脈沖累加器計時器溢出時,對溢出標志位置位,如允許中斷,則向CPU發(fā)出中斷請求TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respect

7、ive owners. Freescale Semiconductor, Inc. 2005.Slide 4定時器,預分頻,計數(shù)器定時器,預分頻,計數(shù)器寄存器:1. TCNT 16 位自由運行/模計數(shù)器B15.B0RST: 0.0 Address Offset $0004, $00051 定時器溢出中斷使能0 定時器中斷禁止$000D3. TSCR2 RST: 0 0 0 0 0 0 0 0 1 定時器由OC7比較符合時復位0 定時器自由運行TCRE - 允許使用PWM功能B7.B0TOI 0 0 0 TCRE PR2 PR1 PR02. TFLG2定時器溢出標志位,寫 1 清零TOF 0 0

8、 0 0 0 0 0B7.B0RST: 0 0 0 0 0 0 0 0$000F標志寄存器標志寄存器除以1248163264128000011110101010100110011PR2 PR1 PR0 預分頻系數(shù)選擇預分頻系數(shù)選擇TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names a

9、re the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 5定時器編程步驟定時器編程步驟用途: 產(chǎn)生周期中斷初始化設定預分頻系數(shù)定時器溢出中斷使能定時器使能中斷函數(shù)清標志位1.用戶自己的代碼void ECT_Init(void) TSCR2_PR = 7; /prescale factor is 8, bus clock/128=8Mhz/8 TSCR2_TOI = 1; /timer overflow interrupt enable TSCR1_TEN = 1; /timer e

10、nable#pragma CODE_SEG NON_BANKED#pragma TRAP_PROCvoid Int_TimerOverFlow(void) TFLG2_TOF = 1; /clear timer overflow flag /用戶自己的代碼 .#pragma CODE_SEG DEFAULT在PRM文件中,加入VECTOR ADDRESS 0 xFFDE Int_TimerOverFlowTMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale

11、logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 6輸出比較功能輸出比較功能16位自由運行計數(shù)器16位輸出比較寄存器 比如:0 x5678 軟件可以修改引腳控制邏輯中斷請求OCxF狀態(tài)標志位置位,當比較發(fā)生時(值相等時)OCxI中斷屏蔽(通過軟件使能) 共有8個輸出比較通道 每個通道有自己的向量表和控

12、制寄存器 在特定的時刻輸出一個信號在特定的時刻輸出一個信號當比較寄存器的值和計數(shù)器的值相等時,采取行動比如:當TCNT=0 x5678TCNTTOCxPinOCx比較比較比較器相等相等置位置位OROR清零清零翻轉翻轉TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the

13、property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 7輸出比較寄存器輸出比較寄存器 C7F C6F C5F C4F C3F C2F C1F C0FOM7OL7OM6OL6OM5OL5OM4OL41. TC7 TC02. TFLG13. TIE4. TCTL1 比較/捕捉標志位寫 1清除中斷狀態(tài)標志位 比較/捕捉屏蔽位 0 = 屏蔽中斷請求 1 = 中斷請求允許 OMXOLXAction on OCx00110101No Action OCxToggle OCxDrive OCx LODriv

14、e OCx HI輸出模式和輸出電平 (O7OC0)B6B5B4B3B7B2B1B05. TCTL2B6B5B4B3B7B2B1B0RST: 0 0 0 0 0 0 0 0$0008RST: 0 0 0 0 0 0 0 0RST: 0 0 0 0 0 0 0 0RST: 0 0 0 0 0 0 0 0$000C$000E$0009Address Offset$0010 - $0011 - -$001E - $001F16 位捕捉/比較寄存器 (TC7) 16 位捕捉/比較寄存器 (TC0) - C7F C6F C5F C4F C3F C2F C1F C0FB6B5B4B3B7B2B1B0OM3O

15、L3OM2OL2OM1OL1OM0OL0B6B5B4B3B7B2B1B0FOC7 FOC6 FOC5 FOC4 FOC3 FOC2 FOC1 FOC06. CFORCB7 B6 B5 B4 B3 B2 B1 B0RST: 0 0 0 0 0 0 0 0$0001TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or

16、 service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 8輸出比較輸出比較, OC7-OC0中斷: 清除中斷,對TFLG1 其中的OCxF寫1不要使用位操作使用OC7-OC0向量表復位條件: 自由運行計數(shù)器(TCNT)被初始化為$0000,并且被禁止 輸出比較寄存器被初始化為$0000捕捉/比較引腳與比較功能斷開中斷被禁止標志位被清零強制比較位被清零TMFreescale Semiconductor Confidential and Propriet

17、ary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 9輸出比較輸出比較, 通道通道7 OC7 (1 of 2)用途: 1、多個輸出比較引腳的控制2、通過2個輸出比較來控制1個引腳,可以輸出短脈沖在每個時鐘周期內,輸

18、出比較寄存器7和自由運行的計數(shù)器進行比較如果它們的值相等,則:1、中斷標志位被置12、輸出引腳OC7-OC0的狀態(tài)被改變 或/和 產(chǎn)生中斷OC7可以影響多個引腳(OC7-OC0)當OC7和OC7-OC0某個引腳的動作有沖突時,OC7的動作將被執(zhí)行 TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or servic

19、e names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 10輸出比較輸出比較 7 (2 of 2) C7I C6F C5F C4F C3F C2F C1F C0F OC7M7 OC7M6 OC7M5 OC7M4 OC7M3 OC7M2 OC7M1 OC7M04. TIE 定時器中斷允許使能5. OC7M - OC7MASKB7.B0 1 - TC7 -16 位比較寄存器7. RST: 0 0 0 0 0 0 0 0RST: 0 0 0 0 0 0 0 0$0002

20、$000C C7F C6F C5F C4F C3F C2F C1F C0FRST: 0 0 0 0 0 0 0 0$000EB7.B02. TCNT - 16-位計數(shù)器B15.B0RST: 0.0$0004, $05B7.B03. TFLG1 標志位 OC7D7 OC7D6 OC7D5 OC7D4 OC7D3 OC7D2 OC7D1 OC7D06. OC7D - OC7DATARST: 0 0 0 0 0 0 0 0$0003B7.B0OC7MASK 根據(jù)寄存器的設置,可以控制任意一路或全部輸出比較引腳 OC7DATA 當OC7比較事件發(fā)生時,引腳的邏輯電平TMFreescale Semico

21、nductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 11定時器溢出時電平翻轉定時器溢出時電平翻轉TOV7 TOV6 TOV5 TOV4 TOV3 T

22、OV2 TOV1 TOV0 TOVx 定時器溢出時,電平翻轉只有當通道被配置成輸出比較時,才有效Address Offset $0007RST: 0.01. TTOV -定時器溢出時電平翻轉寄存器$000D2. TSCR2 定時器系統(tǒng)控制寄存器 RST: 0 0 0 0 0 0 0 0 B7.B0TOI 0 0 0 TCRE PR2 PR1 PR01 定時器由 OC7 比較事件發(fā)生來復位0 定時器自由運行TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale

23、logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 12輸入捕捉輸入捕捉, IC7-IC0 (1 of 3)用途用途:1、測量事件發(fā)生的間隔時間、測量事件發(fā)生的間隔時間2、對實時時間進行響應、對實時時間進行響應輸入捕捉能感應到引腳上的電平的變化輸入捕捉能感應到引腳上的電平的變化如果發(fā)現(xiàn)電平變化,則:如果

24、發(fā)現(xiàn)電平變化,則:1、計數(shù)器的值被保存到到輸入捕捉寄存器中,狀態(tài)、計數(shù)器的值被保存到到輸入捕捉寄存器中,狀態(tài)標志位被置標志位被置12、如果中斷允許,則向、如果中斷允許,則向CPU發(fā)出中斷請求發(fā)出中斷請求TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the propert

25、y of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 13輸入捕捉功能輸入捕捉功能比較/捕捉 單元16位自由運行計數(shù)器16位輸入捕捉鎖存器捕捉發(fā)生時,狀態(tài)位置1向CPU發(fā)出中斷請求Edge沿選擇檢測ICxICxFICxI上升/下降沿可選中斷屏蔽當外部事件發(fā)生時,或外部信號輸入發(fā)生變化時,記錄當前時間TCNTTICx延時計數(shù)器 0 0 0 0 0 0 DLY1 DLY0Bit 7 6 5 4 3 2 1 0DLYCT 延時計數(shù)器控制寄存器DLY1:0 - Delay Counter Values 00 = D

26、isabled 01 = 256 M Clocks 10 = 512 M Clocks 11 = 1024 M ClocksAddress Offset $0029注: 如果輸入信號電平和跳變之前的電平相反時,延時計數(shù)器在當前時鐘計數(shù)時刻產(chǎn)生一個脈沖,它用來去除噪聲OROR16位保持寄存器應用: ABS 剎車. 雷達測距,發(fā)動機引腳 共有8個輸入捕捉通道 每個通道有自己的向量表和控制寄存器TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are

27、 trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 14輸入捕捉輸入捕捉, IC7-IC0 (2 of 3)B2B1B0EDGxB 輸入捕捉沿控制(IC7IC0)EDGxAICx EDGE0101無邊沿 ICx 禁止上升沿下降沿任何沿4. TCTL3 C7F C6F C5F C4F C3F C2F C1F C0FC7I

28、 C6I C5I C4I C3I C2I C1I C0I2. TFLG13. TMSK11. TC7 TC0EDG7B EDG7A EDG6B EDG6A EDG5B EDG5A EDG4B EDG4A5. TCTL4EDG3B EDG3A EDG2B EDG2A EDG1B EDG1A EDG0B EDG0AB6B5B4B3B7B2B1B0RST: 0 0 0 0 0 0 0 0RST: 0 0 0 0 0 0 0 0RST: 0 0 0 0 0 0 0 0RST: 0 0 0 0 0 0 0 0B6B5B4B3B7B2B1B0B6B5B4B3B7B2B1B0B6B5B4B3B7B2B1B0

29、$000E$000C$000A$000BAddress Offset$0010 - $0011 - -$001E - $001F16 位捕捉/比較寄存器 (TC7) 16 位捕捉比較寄存器 (TC0) - 比較/捕捉標志位寫 1清除中斷狀態(tài)標志位 比較/捕捉屏蔽位 0 = 屏蔽中斷請求 1 = 中斷請求允許 0011TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconducto

30、r, Inc. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 15輸入捕捉輸入捕捉/輸出比較選擇輸出比較選擇IOS7 IOS6 IOS5 IOS4 IOS3 IOS2 IOS1 IOS0TIOS 定時器輸入捕捉定時器輸入捕捉/輸出比較選擇寄存器輸出比較選擇寄存器 IOSx = 1 輸出比較功能 = 0 輸入捕捉功能RST: 0 0 0 0 0 0 0 0$0000B6B5B4B3B7B2B1B0TIM

31、ER 定時器使能1 計數(shù)器使能0 計數(shù)器禁止TSCR 定時器系統(tǒng)控制寄存器RST: 00$0006TEN TSWAI TSFRZ TFFCA Reserved TSWAI 在WAIT模式時,定時器停止 0 = 不停止 1 = 停止TSBCK 在DEBUG模式時, 定時器停止 0 = 不停止 1 = 停止TFFCA 定時器快速標志位清除使能 0 = 定時器標志位正常清零 1 = 輸入捕捉時讀取寄存器, 輸出比較時寫寄存器,可以對相應通道標志位清零TMFreescale Semiconductor Confidential and Proprietary Information. Freescal

32、e and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 16脈沖累加模式脈沖累加模式8 位計數(shù)器PA7/PAI 脈沖累加器輸入引腳 事件計數(shù)模式引腳作為計數(shù)器時鐘軟件選擇以什么沿來計數(shù)計數(shù)器溢出時,產(chǎn)生中斷(可選)在PAI引腳每個主動電平將產(chǎn)生中斷 8 位計數(shù)器PA7

33、/PAI 脈沖累加器輸入引腳 時間累加模式引腳作為計數(shù)器軟件選擇主動電平作為門的輸入當計數(shù)器溢出時產(chǎn)生中斷在使能的引腳上后面的邊緣時產(chǎn)生中斷 自由運行E/64時鐘對事件計數(shù)模式,PEDGE 選擇哪個PAI的沿用來增加 PACNT寄存器對門累加模式,PEDGE選擇哪個PAI 狀態(tài)用來禁止計數(shù)(比如. PEDGE = 1 - 禁止計數(shù) 當PAI = HI). TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Fr

34、eescale Semiconductor, Inc. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 17脈沖累加結構脈沖累加結構PINTCx PIN Logic DIV by 64Control Reg.+ 8/16 BIT CNTRHolding RegisterPOLARITYCONTROL PTxIRQDATABUS注 1: PTx 可以被用作脈沖累加,輸入捕捉或輸出比較這里 PTx = PT

35、0 - PT3SELECTED CLOCKDelayCounterEdgeDetector 0 0 0 0 0 0 DLY1 DLY0Bit 7 6 5 4 3 2 1 0DLYCT - Delay Counter Control RegisterDLY1:0 - Delay Counter Values 00 = Disabled 01 = 256 M Clocks 10 = 512 M Clocks 11 = 1024 M ClocksAddress Offset $0029注: 如果輸入信號電平和跳變之前的電平相反時,延時計數(shù)器在當前時鐘計數(shù)時刻產(chǎn)生一個脈沖,它用來去除噪聲TMFrees

36、cale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 18增強型捕捉增強型捕捉ECT比標準的比標準的TIM增強的特點增強的特點

37、4個輸入捕捉通道有16位緩沖寄存器 4個8位 / 2個16位脈沖累加器 16位帶4位預分頻的模數(shù)向下計數(shù)器 4個用戶選擇的延時計數(shù)器用來消除噪聲 主定時器預分頻擴展至7位 隊列和鎖定模式 主定時器輸入捕捉寄存器保持寄存器外部事件外部事件拷貝拷貝拷貝拷貝拷貝拷貝讀取數(shù)據(jù)讀取數(shù)據(jù)讀取數(shù)據(jù)讀取數(shù)據(jù)外部事件外部事件TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, In

38、c. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 19模向下計數(shù)器模向下計數(shù)器二進制向下計數(shù)器. 可以完全控制計數(shù)起始值 應用于精確事件計時-用于產(chǎn)生周期性的標志位和中斷主定時器單獨運行。時鐘來自總線時鐘,并經(jīng)過預分頻??梢员辉O置為定時中斷或產(chǎn)生標志位?;蜓b載初始值后向下計數(shù)到$0000。ParameterValueUnitsCrystal Frequency16MHzBus Frequency8M

39、HzBus Tick Time125.0000nSPeriodic Interrupt Time191uSBus Ticks Required1528.00TicksModulus Counter Prescaler4Modulus Counter Start Value382裝載向下計數(shù)至0執(zhí)行動作執(zhí)行動作TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, I

40、nc. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 20ABS 應用舉例應用舉例PT0PT1PT2SENSOR 1SENSOR 2SENSOR 3SENSOR 4PB1PB2PB3PB4BRAKEFLUIDPUMPSYSTEMSIGNALCONDITIONINGLOGIC IC/PASIGNALCONDITIONINGLOGICSIGNALCONDITIONINGLOGICSIGNALCONDITI

41、ONINGLOGICPT3左前輪左前輪 右前輪右前輪 左后輪左后輪右后輪右后輪HCS12TIMER 定時器輸入捕捉測量車輪轉速 發(fā)送命令到剎車壓力調節(jié)閥來調節(jié)壓力 IC/PA IC/PA IC/PA如果左右輪速脈沖周期不等則則調節(jié)電磁閥調節(jié)電磁閥TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service

42、 names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 21低功耗模式低功耗模式TSCR 定時器系統(tǒng)控制寄存器RST: 00$0006TEN TSWAI TSFRZ TFFCA Reserved TSWAI 在WAIT模式時,定時器停止 0 = 不停止 1 = 停止TSBCK 在DEBUG模式時, 定時器停止 0 = 不停止 1 = 停止TFFCA 定時器快速標志位清除使能 0 = 定時器標志位正常清零 1 = 輸入捕捉時讀取寄存器, 輸出比較時寫寄存器,可以對相應

43、通道標志位清零TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 22PULSE WIDTH MODULATIO

44、N(PWM)脈寬調制模塊脈寬調制模塊TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 23什么是什么是PWM?

45、periodonTTRatio Width PulseTonToffTperiodAverage0 %10 %50 %90 %99 %應用: D/A轉換 馬達控制 音調生成 正弦波生成占空比占空比=高電平時間高電平時間/周期周期 =Ton/TperiodTMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or ser

46、vice names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 24PWM信號的產(chǎn)生信號的產(chǎn)生(邊緣對齊邊緣對齊)開始周期 TPWMTPWM占空比 TDutyPWMDTYxPWMPERxPWMPERxfClock, TClock8-bit CounterPWMCNTx時鐘8-bit Compare =PWMDTYx8-bit Compare =PWMPERx0 x000 x00ResetPin當當8位計數(shù)器的值等于位計數(shù)器的值等于PWMDTY(duty cycle寄

47、存器寄存器)時,電平從有效跳到無效;時,電平從有效跳到無效;當當8位計數(shù)器的值等于位計數(shù)器的值等于PWMPER(周期寄存器)時,電平從無效跳到有效,然(周期寄存器)時,電平從無效跳到有效,然后計數(shù)器清后計數(shù)器清0,重新開始計數(shù),重新開始計數(shù)TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service na

48、mes are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 25PWM 模塊特點模塊特點 8個帶周期占空比可程控的PWM獨立通道 4個可程控選擇的時鐘源 每個PWM通道有專用的計數(shù)器 PWM每個通道脈沖極性可以選擇 每個PWM通道可使能/禁止 周期和占空比雙緩沖 每個通道有中心對齊和邊緣對齊方式 分辨率: 8位 (8通道), 16位 (4通道) 帶中斷功能的緊急切斷 工作模式TMFreescale Semiconductor Confidential and Propriet

49、ary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 26PWM 結構框圖結構框圖通道通道 7周期和占空比計數(shù)器通道通道 6周期和占空比計數(shù)器.通道通道 0周期和占空比計數(shù)器管腳使能選擇極性選擇對齊方式選擇管腳管腳T

50、MFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 27PWM 初始化步驟初始化步驟禁止PWM Disable P

51、WMPWME選擇時鐘 Select clock (prescaler and scale) for the PWM PWMPRCLK, PWMSCLA, PWMSCLB, PWMCLK選擇極性 Select polarityPWMPOL選擇對齊模式 Select center or left aligned modePWMCAE對占空比和周期編程Program duty cycle and periodPWMDTYx, PWMPERx使能PWM通道 Enable used PWM channelsPWMETMFreescale Semiconductor Confidential and Pr

52、oprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 28PWM 時鐘選擇時鐘選擇 (1 of 4)Clock A (Ch 0, Ch 1, Ch 4, Ch 5)Clock SA (scaled A;

53、Ch 0, Ch 1, Ch 4, Ch 5)Clock B (Ch 2, Ch 3, Ch 6, Ch 7)Clock SB (scaled B; Ch 2, Ch 3, Ch 6, Ch 7)4個時鐘源:Bus ClockDivide by Prescaler Taps:248163264128預分頻PWMPRCLK $_03Clock SAClock SBClock AFurther Division of the clock:2468.512Clock BFurther Division of the clock:2468.512PWMSCLA $_08PWMSCLB $_09分頻TM

54、Freescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 29PWM 時鐘選擇時鐘選擇 預分頻寄存器預分頻寄存器 (2 o

55、f 4)0PCKB2 PCKB1 PCKB00PCKA2 PCKA1 PCKA0RWReset: 00000000= Unimplemented or ReservedPWMPRCLK $_03PCKx2PCKx1PCKx0Value of Clock x000Bus Clock001Bus Clock / 2010Bus Clock / 4011Bus Clock / 8100Bus Clock / 16101Bus Clock / 32110Bus Clock / 64111Bus Clock / 128可在任意時刻讀寫!x = A or B設置 PRESCALE 寄存器:PWMPRCLK

56、 = 0 x22;/ B= Bus/4, A = Bus/4PWMPRCLK = 0 x07;/ B = Bus, A = Bus/128Software ExamplesBit 0Bit 1Bit 2Bit 3Bit 4Bit 5Bit 6Bit 0TMFreescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or serv

57、ice names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 30PWM 時鐘選擇時鐘選擇 分頻寄存器分頻寄存器(3 of 4)總線時鐘fBusDivide by Prescaler Taps:2481632641288-Bit Down CounterBit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0PWMSCLx分頻值SxClockxClockPWMSCLxPWMSCLxxClockSxClock_2_2_PWMSCL

58、x = $00 PWMSCLx value is 256可在任意時刻讀寫!x = A or B/ 2Clock SxClock xClock x = fBus / PWMPRCLKCount = 1PWMPRCLK $_03PWMSCLB $_09PWMSCLA $_08例如:要求: Clock Sx = 1 kHz總線時鐘 = 16 MHzPrescaler = 128 Prescaler = 64Clock x = 125 kHzClock x = 250 kHzPWMSCLx = 63 PWMSCLx = 125 Clock Sx = 992 HzClock Sx = 1000 HzTM

59、Freescale Semiconductor Confidential and Proprietary Information. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2005.Slide 31PWM 時鐘選擇寄存器時鐘選擇寄存器 (4 of 4)PCL

60、K6 PCLK5 PCLK4 PCLK3 PCLK2 PCLK1 PCLK0RWReset: 00000000PWMCLK $_02PCLK7選擇時鐘源:PCLK0 = 1;/ SA is source of ch 0PCLK6 = 0;/ B is source of ch 6PWMCLK = 0 x11; / all channels軟件示例軟件示例Bit 0Bit 1Bit 2Bit 3Bit 4Bit 5Bit 6Bit 0PCLK5 通道 5時鐘選擇 1 =時鐘源為SA 0 =時鐘源為APCLK4 通道 4時鐘選擇 1 =時鐘源為SA 0 =時鐘源為APCLK3 通道 3時鐘選擇 1

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論