• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
  • slider image 488
  • slider image 491
:::


Browsing this Thread:   1 Anonymous Users






Re: 關於16FXX的外部中斷INT問題
#3
新會員
新會員


查看用戶資訊
Ryang兄
依照datasheet的資料,OPTION開機後的預設值應該全部為1,而當INTEDG是1的時候應該是rising edge不是嗎?

而且重點是現在不管INTEGD是0或1,都是在rising edge產生中斷
詭異的是有一個例外,我將ISR改寫為:
isr(void) // Here be interrupt function - the name is unimportant.
{

if(INTF){
INTF = 0;
RA3 = !RA3;

OPTION ^= 0x40;

}

}

也就是在INT中斷產生時,把INTEDG反相,那麼在falling edge就會產生中斷,用來debug用的IO port輸出波形就會變成跟信號產生器的波形變成一樣(也就是rising和falling都會中斷)
除此之外我就是沒辦法單獨讓他falling edge產生中斷

發表於: 2009/3/12 11:05
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於16FXX的外部中斷INT問題
#2
版主
版主


查看用戶資訊
OPTION_REG 的 Default 的設定就是 Falling Edge,利用 Watch Window 檢查一下 OPTION Register 的 INTEDG 位元狀態,或者就不要去設定它,使用Default 的設定值。

發表於: 2009/3/12 9:26
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


關於16FXX的外部中斷INT問題
#1
新會員
新會員


查看用戶資訊
我現在是用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
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------