#include /*============================================================================= =============================================================================*/ unsigned char ex0_isr_counter = 0; void ex0_isr (void) interrupt 0 { ex0_isr_counter++; // Increment the count } /*============================================================================= =============================================================================*/ void main (void) { /*----------------------------------------------- Configure INT0 (external interrupt 0) to generate an interrupt on the falling-edge of /INT0 (P3.2). Enable the EX0 interrupt and then enable the global interrupt flag. -----------------------------------------------*/ IT0 = 1; // Configure interrupt 0 for falling edge on /INT0 (P3.2) EX0 = 1; // Enable EX0 Interrupt EA = 1; // Enable Global Interrupt Flag /*----------------------------------------------- Wait forever. -----------------------------------------------*/ while (1) { } } /*============================================================================= ============================================================================*/ Und hier das andere beispiel: #include void MyHighISR(void); #pragma config OSC = EC #pragma config PWRT = OFF #pragma config BOR = OFF #pragma config WDT = OFF #pragma config LVP = OFF // #pragma config CCP2MUX = OFF void main(void) { ADCON1=0x0F;// Alle AD-Eingänge als Digitale Eingänge Einstellen TRISA=0; //Port A: alles Ausgänge TRISB=1; //RB0 als Eingang definieren TRISC=0; //Port C: alles Ausgänge /*Interrupt einstellen*/ INTCON = 0x20; //disable global and enable TMR0 interrupt INTCON2 = 0x84; //TMR0 high priority RCONbits.IPEN = 0; //enable priority levels TMR0H = 255; //set timer TMR0L = 89; //set timer T0CON = 0x84; //set up timer0 - prescaler 1:32 INTCON2bits.INTEDG2 = 0; // falling endge INTCONbits.GIEH = 1; //Global enable interrupts while(1) { LATAbits.LATA0=!LATAbits.LATA0; // RA0 togglen } } /**************************************************************/ #pragma code highVector=0x08 void HighVector (void) { _asm goto MyHighISR _endasm } #pragma code /* return to default code section */ #pragma interrupt MyHighISR void MyHighISR(void) { if (INTCONbits.TMR0IF) { LATBbits.LATB0=!LATBbits.LATB0; // RB0 togglen } if (INTCONbits.INT0IF) { LATCbits.LATC0=!LATCbits.LATC0; // RC0 togglen } }