Re: 關於16FXX的外部中斷INT問題
|
||||
---|---|---|---|---|
版主
|
OPTION_REG 的 Default 的設定就是 Falling Edge,利用 Watch Window 檢查一下 OPTION Register 的 INTEDG 位元狀態,或者就不要去設定它,使用Default 的設定值。
發表於: 2009/3/12 9:26
|
|||
|
關於16FXX的外部中斷INT問題
|
||||
---|---|---|---|---|
新會員
|
我現在是用16F73且使用PICC compiler
要用INT功能,且需要falling edge中斷 不過奇怪的是不管我INTEDG這個bit怎麼設定,或是直接設定OPTION,都是在上升緣產生中斷 我的試驗方法是用信號產生器給INT一個clock,在ISR中將另一隻IO腳反相,然後用示波器同時觀察兩個信號,結果發現那隻IO腳只有在當信號產生器的clock上升緣變化 不知道有沒有人欲過這種情形! 程式如下: #include <htc.h> #include <stdio.h> void init(void); void main(void) { init(); RA3 = 0; while(1); } void init(void) { OPTION = 0x03; INTCON = 0x00; PIR1 = 0x00; PIE1 = 0x00; /*setting I/O port direction 0:output 1:input*/ TRISB = 0x01; TRISA = 0x00; TRISC = 0xbf; PORTA = 0xff; PORTC = 0xff; PORTB = 0x01; ADCON1 = 0x07; /*setting INT*/ INTE = 1; INTF = 0; /*enable all interrupt*/ PEIE = 1; GIE = 1; } static void interrupt isr(void) // Here be interrupt function - the name is unimportant. { if(INTF){ INTF = 0; RA3 = !RA3; } }
發表於: 2009/3/11 16:17
|
|||
|