Re: 使用PIC18F2410,外部中斷INT0問題
|
||||
---|---|---|---|---|
中級會員
|
GIE有設定=1
PEIE沒設定=0 TMR0IE沒設定(目前沒用) TMR0IP沒設定(目前沒用) RCON:IPEN程式中已有設定 目前TMR0沒有使用,only使用int0
發表於: 2007/8/24 15:41
|
|||
|
Re: 使用PIC18F2410,外部中斷INT0問題
|
||||
---|---|---|---|---|
資深會員
|
INTCON:
GIE/GIEH: Global Interrupt Enable bit PEIE/GIEL: Peripheral Interrupt Enable bit TMR0IE: TMR0 Overflow Interrupt Enable bit INTCON2: TMR0IP: TMR0 Overflow Interrupt Priority bit RCON: IPEN: Interrupt Priority Enable bit T0CON: T0PS2:T0PS0: Timer0 Prescaler Select bits 以上都有設定了嗎??
發表於: 2007/8/24 15:28
|
|||
|
使用PIC18F2410,外部中斷INT0問題
|
||||
---|---|---|---|---|
中級會員
|
目前使用PIC18F2410,有用到外部中斷INT0,希望INT0中斷時,中斷服務程式會去執行中斷,目前INT0腳位輸入一個50HZ的輸入訊號,但中斷服務程式卻的不到相對輸出,中斷會遺失(不發生),我的程式如下,是否有設定的問題,希望個位大大幫幫忙提供意見, 謝謝
void initpic(void) { OSCCONbits.IRCF0=0; // 110=4Mhz INTOSC drives clock directly OSCCONbits.IRCF1=1; // MCU Default:100=1Mhz OSCCONbits.IRCF2=1; ADCON1=0b00001111; // Disable A/D Function CMCON =0b00000111 ; // Disable Comparator module !! TRISA=0xFF; // Set PortA for input PORTA=0xFF; // Switch input TRISB=0b10000011; // Set PortB LATB =0; PORTB=0b11110011; // TRISC=0x00; // Set Portc for Output PORTC=0xff; // Initila LED display = 0xFF (LED全滅) OpenRB0INT ( PORTB_CHANGE_INT_ON & FALLING_EDGE_INT & PORTB_PULLUPS_ON ); } void F_Enable_High_Interrupts (void) { RCONbits.IPEN = 1; INTCONbits.GIEH = 1; } #pragma code isrhighcode = 0x0000008 void isr_high_direct(void) { //***EXERCISE 2 CODE HERE*** _asm //begin in-line assembly goto isr_high //go to isr_high function _endasm //end in-line assembly } #pragma code void isr_high(void) { Freeled=0; if ( INTCONbits.INT0IF == 1 ) // 外部中斷'0' { INTCONbits.INT0IF=0; ISRled= 0; Nop( ) ; ISRled= 1; } Freeled=1; } void main(void) { initpic(); while ( 1 ) { Care_Test(); // self test } }
發表於: 2007/8/24 11:52
|
|||
|