4-13 etm 輸出 pwm
DESCRIPTION
4-13 ETM 輸出 PWM. HT66F50. ETM (Standard type TM) 提供 5 種模式. Compare match output Timer/Counter PWM output Input Capture Single pulse output. ETM. 10bit upcounter (TM1D[9:0]) 由 T1CK[2:0] 選擇不同時脈緣 與 TM1A[9:0], TM1B[9:0], T1RP[2:0] 比較. ETM 模式有 CCR 暫存器 (TM1A, TM1B) - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: 4-13 ETM 輸出 PWM](https://reader033.vdocuments.mx/reader033/viewer/2022050723/56815074550346895dbe7024/html5/thumbnails/1.jpg)
1
4-13 ETM 輸出 PWM
HT66F50
![Page 2: 4-13 ETM 輸出 PWM](https://reader033.vdocuments.mx/reader033/viewer/2022050723/56815074550346895dbe7024/html5/thumbnails/2.jpg)
2
ETM (Standard type TM) 提供 5 種模式
• Compare match output
• Timer/Counter
• PWM output
• Input Capture
• Single pulse output
![Page 3: 4-13 ETM 輸出 PWM](https://reader033.vdocuments.mx/reader033/viewer/2022050723/56815074550346895dbe7024/html5/thumbnails/3.jpg)
ETM
• 10bit upcounter (TM1D[9:0])由 T1CK[2:0] 選擇不同時脈緣與 TM1A[9:0], TM1B[9:0], T1RP[2:0] 比較
3
![Page 4: 4-13 ETM 輸出 PWM](https://reader033.vdocuments.mx/reader033/viewer/2022050723/56815074550346895dbe7024/html5/thumbnails/4.jpg)
4
![Page 5: 4-13 ETM 輸出 PWM](https://reader033.vdocuments.mx/reader033/viewer/2022050723/56815074550346895dbe7024/html5/thumbnails/5.jpg)
5
• ETM 模式有 CCR 暫存器 (TM1A, TM1B)
• TM1C1,TM1C2,TM1C0 三個特殊暫存器設定工作模式 , 計數時脈源
TM1C0 T1PAU T1CK2 T1CK1 T1CK0 T1ON T1RP2 T1RP1 T1RP0
TM1C1
TM1C2
![Page 6: 4-13 ETM 輸出 PWM](https://reader033.vdocuments.mx/reader033/viewer/2022050723/56815074550346895dbe7024/html5/thumbnails/6.jpg)
6
![Page 7: 4-13 ETM 輸出 PWM](https://reader033.vdocuments.mx/reader033/viewer/2022050723/56815074550346895dbe7024/html5/thumbnails/7.jpg)
7
![Page 8: 4-13 ETM 輸出 PWM](https://reader033.vdocuments.mx/reader033/viewer/2022050723/56815074550346895dbe7024/html5/thumbnails/8.jpg)
8
2-5-3
ETM 模式操作於 PWM output1. 當 T1CCLR=1,PWM 之 Duty cycle 由
TM1A 及 TM1B控制 , 波型由 TP1B腳位輸出 ,TP1A強制為一般 IO
2. 當 T1CCLR=0,支援雙通道 PWM輸出 ,由 TP1A,TP1B腳位輸出 , 週期由T1RP[2:0]決定 , TM1A 及 TM1B控制TP1A,TP1B, PWM之佔空比
![Page 9: 4-13 ETM 輸出 PWM](https://reader033.vdocuments.mx/reader033/viewer/2022050723/56815074550346895dbe7024/html5/thumbnails/9.jpg)
9
TM1C0 控制暫存器 T1PAU T1CK2 T1CK1 T1CK0 T1ON T1RP2 T1RP1 T1RP0
Bit 7 6 5 4 3 2 1 0
Bit [2 1 0 ] ; TnRP2 TnRP1 TnRP0
= 000 , 週期 = 1024x fINT-1 =100, 週期 = 512x fINT
-1
= 001 , 週期 = 128x fINT-1 =101 , 週期 = 640x fINT
-1
= 010 , 週期 = 256x fINT
-1 =110 , 週期 = 768x fINT
-1
= 011 , 週期 = 384x fINT-1 =111 , 週期 = 896x fINT
-1
![Page 10: 4-13 ETM 輸出 PWM](https://reader033.vdocuments.mx/reader033/viewer/2022050723/56815074550346895dbe7024/html5/thumbnails/10.jpg)
10
TM1C1 控制暫存器 ( 表 2-5-25)
T1AM1 T1AM0 T1AIO1 T1AIO0 T1AOC T1APOL T1CDN T1CCLR Bit 7 6 5 4 3 2 1 0Bit [7 6] ; T1AM[1 0] = 00, CCRA 為 compare match output mode = 01, CCRA 為 input capture mode = 10, CCRA 為 pwm/single pulse output mode = 11, CCRA 為 timer/counter modeBit [5 4] ; TP1A 功能選擇 CCRA 為 compare match output mode, T1AM[1 0]=00 , TP1A
為輸出 00: 比對吻合時 TP1A 不變 10: 比對吻合時 TP1A 輸出 1
01:比對吻合時 TP1A 輸出 0 11: 比對吻合時 TP1A 轉態 CCRA 為 input capture mode, T1AM[1 0]=01 , TP1A為輸入 00: 在 TP1A 正緣 , 記錄當前 TM1D之值 01: 在 TP1A 負緣 , 記錄當前 TM1D之值 10: 在 TP1A 負緣及正緣 , 記錄當前 TM1D之值 11: 停止 input capture mode
![Page 11: 4-13 ETM 輸出 PWM](https://reader033.vdocuments.mx/reader033/viewer/2022050723/56815074550346895dbe7024/html5/thumbnails/11.jpg)
11
TM1C1 控制暫存器 ( 表 2-5-25)
T1AM1 T1AM0 T1AIO1 T1AIO0 T1AOC T1APOL T1CDN T1CCLR Bit 7 6 5 4 3 2 1 0Bit [5 4] ; TP1A 功能選擇 CCRA 為 pwm/single pulse output mode, T1AM[1 0]=10 00: 強制 TP1A 為 inactive 10: PWM 輸出 01:強制 TP1A 為 active 11: 單脈衝輸出 CCRA 為 timer/counter mode, T1AM[1 0]=11 無作用
Bit [0] ; T1CCLR 1: 當 TM1A 比對吻合時清除計數器 0: 當 TM1RP 比對吻合或計數器溢位時清除計數器
![Page 12: 4-13 ETM 輸出 PWM](https://reader033.vdocuments.mx/reader033/viewer/2022050723/56815074550346895dbe7024/html5/thumbnails/12.jpg)
12
TM1C2 控制暫存器 ( 表 2-5-26)
T1BM1 T1BM0 T1BIO1 T1BIO0 T1BOC T1BPOL T1PWM1 T1PWM0 Bit 7 6 5 4 3 2 1 0Bit [7 6] ; TM1 CCRB 模式控 功能選擇 = 00, CCRB 為 compare match output mode = 01, CCRB 為 input capture mode = 10, CCRB 為 pwm/single pulse output mode = 11, CCRB 為 timer/counter modeBit [5 4] ; T1BIO 為 TP1B_0, TP1B_1, TP1B_2 功能選擇 CCRB 為 compare match output mode, T1BM[1 0]=00 00: 比對吻合時輸出不變 10: 比對吻合時 輸出 1 01:比對吻合時 輸出 0 11: 比對吻合時輸出 1 轉態 CCRB 為 input capture mode, T1BM[1 0]=01 ,為輸入 00: 在輸入信號為正緣 , 記錄當前 TM1D之值 01: 在輸入信號為負緣 , 記錄當前 TM1D之值 10: 在輸入信號為負緣及正緣 , 記錄當前 TM1D之值 11: 停止 input capture mode
![Page 13: 4-13 ETM 輸出 PWM](https://reader033.vdocuments.mx/reader033/viewer/2022050723/56815074550346895dbe7024/html5/thumbnails/13.jpg)
13
TM1C2 控制暫存器 ( 表 2-5-26)
T1BM1 T1BM0 T1BIO1 T1BIO0 T1BOC T1BPOL T1PWM1 T1PWM0 Bit 7 6 5 4 3 2 1 0Bit [5 4] ; T1BIO 為 TP1B_0, TP1B_1, TP1B_2 功能選擇 CCRB 為 pwm/single pulse output mode, T1BM[1 0]=10 00: 強制輸出 為 inactive 10: PWM 輸出 01:強制輸出 為 active 11: 單脈衝輸出 CCRA 為 timer/counter mode, T1AM[1 0]=11 無作用Bit [3] ; T1BOC 為 TP1B_0, TP1B_1, TP1B_2 輸出控制位元 CCRB 為 compare match output mode, T1BM[1 0]=00 ,輸出功能 1: 首次比對吻合前使輸出維持在 1 0: 首次比對吻合前使輸出維持在 0 CCRB 為 pwm/single pulse output mode, T1BM[1 0]=10 1:輸出 為 1 active high 0 :輸出 為 0 active low
![Page 14: 4-13 ETM 輸出 PWM](https://reader033.vdocuments.mx/reader033/viewer/2022050723/56815074550346895dbe7024/html5/thumbnails/14.jpg)
14
4-13 pwm;PROGRAM : 4-13.ASM ;FUNCTION: pwm by etm #INCLUDE HT66F50.INC#INCLUDE 4-13.INC;--------------------------------------------------------------------MY_DATA .SECTION 'DATA' ;== DATA SECTION ==DEL1 DB ?DEL2 DB ?DEL3 DB ? INDEX DB ?;--------------------------------------------------------------------MY_CODE .SECTION AT 0 'CODE' ;== PROGRAM SECTION
== ORG 00H ;HT-66XX RESET VECTOR
![Page 15: 4-13 ETM 輸出 PWM](https://reader033.vdocuments.mx/reader033/viewer/2022050723/56815074550346895dbe7024/html5/thumbnails/15.jpg)
15
MOV A,08h ;MOV CP0C,A ; Disable cp0 MOV CP1C,A ; Disable cp1
CLR ACERL ;Disable ADC inputSET SW_BRIGHTC ;set bright pull upSET SW_DARKC
SET SW_BRIGHTPUSET SW_DARKPUMOV A,01110000B ;set TP1B_[0:2] as TP1
fun.MOV TMPC0,A
MOV A,00000000B ;fint=fsys/4MOV TM1C0,A
![Page 16: 4-13 ETM 輸出 PWM](https://reader033.vdocuments.mx/reader033/viewer/2022050723/56815074550346895dbe7024/html5/thumbnails/16.jpg)
MOV A,10000001B ;TM1A in PWM o/p mode MOV TM1C1,A ;TM1D is cleared by TM1A compare match MOV A,10101000B ;TP1B is working in PWM o/p mode MOV TM1C2,A ;active high, non-invert, edge-aligned
MOV A,LOW 1024-1 ;SET DUTY 1024 us
MOV TM1AL,A
MOV A,HIGH 1024-1
MOV TM1AH,A MOV A,11011100B ; SET TP1B[012] as output mode ANDM A,PCC
ANDM A,PC ;select non-inverted
MOV A,5
MOV INDEX, A
SET T1ON ;start ETM
16
![Page 17: 4-13 ETM 輸出 PWM](https://reader033.vdocuments.mx/reader033/viewer/2022050723/56815074550346895dbe7024/html5/thumbnails/17.jpg)
MAIN:
MOV A,INDEX
ADD A,OFFSET TAB_PWM
MOV TBLP, A
TABRDL TM1BL ;load TM1CCRB indexed by index
MOV A,TBLH
MOV TM1BH,A
CALL DELAY ;delay 0.5sec
WAIT:
SNZ SW_BRIGHT ;SW_BRIGHT pressed?
JMP BRIGHTER ;yes
SNZ SW_DARK ;NO. SW_DARK pressed?
JMP WAIT ;NO
17
![Page 18: 4-13 ETM 輸出 PWM](https://reader033.vdocuments.mx/reader033/viewer/2022050723/56815074550346895dbe7024/html5/thumbnails/18.jpg)
DARKER:
DECA INDEX ;yes. Index-1
SZ ACC.7 ;less than 0?
JMP WAIT ;yes
MOV INDEX,A
JMP MAIN
BRIGHTER:
INCA INDEX ;yes. Index+1
SUB A,10
SZ C ;>=10
JMP WAIT ;yes
INC INEDX ;NO. INDEX+1
JMP MAIN
18
![Page 19: 4-13 ETM 輸出 PWM](https://reader033.vdocuments.mx/reader033/viewer/2022050723/56815074550346895dbe7024/html5/thumbnails/19.jpg)
50*10msDELAY PROC
MOV A,50 MOV DEL1,A ;SET DEL1 COUNTERDEL_1: MOV A,30
MOV DEL2,A ;SET DEL2 COUNTER DEL_2: MOV A,110
MOV DEL3,A ;SET DEL3 COUNTERDEL_3: SDZ DEL3 ;DEL3 DOWN COUNT
JMP DEL_3 SDZ DEL2 ;DEL2 DOWN COUNTJMP DEL_2 SDZ DEL1 ;DEL1 DOWN COUNTJMP DEL_1RET
DELAY ENDP
19
![Page 20: 4-13 ETM 輸出 PWM](https://reader033.vdocuments.mx/reader033/viewer/2022050723/56815074550346895dbe7024/html5/thumbnails/20.jpg)
ORG LASTPAGE
TAB_PWM:
DC 100
DC 200
DC 300
DC 400
DC 500
DC 600
DC 700
DC 800
DC 900
DC 1000
20
![Page 21: 4-13 ETM 輸出 PWM](https://reader033.vdocuments.mx/reader033/viewer/2022050723/56815074550346895dbe7024/html5/thumbnails/21.jpg)
• TMPC0T1ACP0 T1BCP2 T1BCP1 T1BCP0 - - T0CP1 T0CP0
21