Presentation is loading. Please wait.

Presentation is loading. Please wait.

4-12 外部中斷 HT66F70A.

Similar presentations


Presentation on theme: "4-12 外部中斷 HT66F70A."— Presentation transcript:

1 4-12 外部中斷 HT66F70A

2 中斷來源 外部中斷 INT0-INT3、PINT 內部中斷 TM、LVD、SIM、A/D、SPIA

3 中斷控制位元 決定中斷是否啟動(enable bit) : ADE、INT0E、MF1E… 反應中斷是否發生(request flag) :
ADF、INT0F、MF1F…

4 HT66F70A 14種中斷來源 9個中斷源 (單一周邊) INT0 – 3 Comparator 0-1 A/D
Time Base 0-1 5個複功能中斷源 (18個周邊) Multi-function 0-4 TM0P-TM5P TM0A-TM5A TM1B SIM External Peripheral(PINT’) LVD EEPROM

5 INTEG (外部中斷觸發條件) Bit[7:6] : INT3S[1:0] 腳位觸發條件選擇位元
NAME INT3S1 INT3S0 INT2S1 INT2S0 INT1S1 INT1S0 INT0S1 INT0S0 RW R/W Bit 7 6 5 4 3 2 1 Bit[7:6] : INT3S[1:0] 腳位觸發條件選擇位元 =00 禁止 INT3 中斷 =01 選擇正緣觸發模式 =10 選擇負緣觸發 模式 =11 選擇雙緣觸發模式 Bit[5:4] : INT2S[1:0] 腳位觸發條件選擇位元 =00 禁止 INT2 中斷 =01 選擇正緣觸發模式 Bit[3:2] : INT2S[1:0] 腳位觸發條件選擇位元 =00 禁止 INT1 中斷 =01 選擇正緣觸發模式 Bit[1:0] : INT2S[1:0] 腳位觸發條件選擇位元 =00 禁止 INT0 中斷 =01 選擇正緣觸發模式

6 4-12 外部中斷 //按鍵外部中斷計數 #include <HT66F70A.h> #define SEG_Port _pc
#define SEG_PortC _pcc #define up _pa4 #define upC _pac4 #define upPU _papu4 typedef unsigned char u8; typedef unsigned short u16; const u8 SEG_TAB[] = { //七段顯示器顯示碼(共陰) 0x3F,0x06,0x5B,0x4F,0x66, 0x6D,0x7D,0x07,0x7F,0x67}; void Delay100us(u16); //函式原型宣告 u8 i=0;

7 void main() { _wdtc=0b ; //關閉看們狗計時器 SEG_PortC=0x00; //規劃SEG_Port為輸出模式 upC=0xFF; //規劃pu為輸入模式 _integ=0b ; //設定INT1觸發條件 _ifs0=0b ; //設定INT1輸入腳位 _emi=1; _int1e=1; //致能中斷致能位元 while(1) SEG_Port=SEG_TAB[i]; //查表並遞增索引值 Delay100us(40); //延遲4毫秒 }

8 void Delay100us(u16 del) //延遲del*200指令週期
{ u16 i,j; for(i=0;i<del;i++) for(j=0;j<=25;j++) GCC_NOP(); } DEFINE_ISR(ISR_INT1,0x08) { i++; if(i>9) i=0; _int1f=0;


Download ppt "4-12 外部中斷 HT66F70A."

Similar presentations


Ads by Google