打印

INT1 不进中断!

[复制链接]
2770|5
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
457878|  楼主 | 2012-3-20 14:13 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
不进中断,头大了!!

 
#pragma config WDTEN = OFF          //WDT disabled (enabled by SWDTEN bit)
#pragma config PLLDIV = 2           //Divide by 3 (12 MHz oscillator input)
#pragma config STVREN = ON          //stack overflow/underflow reset enabled
#pragma config XINST = OFF          //Extended instruction set disabled
#pragma config CPUDIV = OSC1        //No CPU system clock divide
#pragma config CP0 = OFF            //Program memory is not code-protected
#pragma config OSC = INTOSCPLL
#pragma config T1DIG = OFF           //Sec Osc clock source may be selected
#pragma config LPT1OSC = OFF        //high power Timer1 mode

#pragma config FCMEN = OFF          //Fail-Safe Clock Monitor disabled
#pragma config IESO = OFF           //Two-Speed Start-up disabled
#pragma config WDTPS = 32768        //1:32768
#pragma config RTCOSC = INTOSCREF    //RTCC uses INTRC as clock

#pragma config DSBOREN = OFF        //Zero-Power BOR disabled in Deep Sleep
#pragma config DSWDTOSC = INTOSCREF //DSWDT uses INTOSC/INTRC as clock
#pragma config DSWDTEN = OFF        //Disabled
#pragma config DSWDTPS = 2048       //1:8,192 (8.5 seconds)

#pragma config IOL1WAY = OFF        //IOLOCK bit can be set and cleared
#pragma config MSSP7B_EN = MSK7     //7 Bit address masking
#pragma config WPFP = PAGE_0        //Write Protect Program Flash Page 0
#pragma config WPEND = PAGE_0       //Start protection at page 0
#pragma config WPCFG = OFF          //Write/Erase last page protect Disabled
#pragma config WPDIS = OFF          //WPFP[5:0], WPEND, and WPCFG bits ignored

#include <p18cxxx.h>
void drv_CPUIO_INT1_Init_Falling(void)
{
INTCON3bits.INT1IF = 0;
INTCON2bits.INTEDG1=0;  //No, falling edge is used
INTCON2bits.RBPU=1; //disable pullups
INTCON2bits.RBIP=1;
INTCONbits.RBIE=1;
INTCONbits.RBIF=0;
INTCON3bits.INT1IP=1;
INTCON3bits.INT1IE=1;
PORTB = PORTB;

}
void main(void)
{
TRISA = 0x25;
PORTA = 0x27;
LATA = 0x27;
TRISB = 0x1;
PORTB = 0xF;
LATB = 0xF;
TRISC = 0x33;
PORTC = 0x73;
LATC = 0x73;
RPINR1 = 0; //INT1 = RP0(RA0外接按键,按下为低电平)
drv_CPUIO_INT1_Init_Falling();
while(1)
{
  Nop();
  Nop();
  PORTB = PORTB;
}
}
void high_isr (void);
void low_isr (void);
#pragma code high_vector=0x08
void high_vector (void)
{
  _asm goto high_isr _endasm
}
#pragma code low_vector=0x18
void low_vector (void)
{
  _asm goto low_isr _endasm
}

#pragma code
#pragma interrupt high_isr
void high_isr (void)
{
if(INTCON3bits.INT1IF)
{
  Nop();
  INTCON3bits.INT1IF = 0;
}
if(INTCONbits.RBIF)
{
  Nop();
  INTCONbits.RBIF=0;
}
}
#pragma interruptlow low_isr
void low_isr (void)
{
Nop();
Nop();
Nop();
}

沙发
yewuyi| | 2012-3-20 14:27 | 只看该作者
优先级对不对?

是不是出现了更高优先级中断屏蔽了低优先级中断?

使用特权

评论回复
板凳
asspeed| | 2012-3-20 14:41 | 只看该作者
全局都没开,能响应才怪...

使用特权

评论回复
地板
457878|  楼主 | 2012-3-21 06:34 | 只看该作者
上面问题都有,而且,眼睛看花了,看错了引脚。

使用特权

评论回复
5
457878|  楼主 | 2012-3-21 06:34 | 只看该作者
:)

使用特权

评论回复
6
zxx6176| | 2012-4-5 16:28 | 只看该作者
楼主 现在一切恢复正常了么 1# 457878

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

270

主题

885

帖子

3

粉丝