不进中断,头大了!!
#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();
}
|