ATmega8 Externer Interrupt 1 rising/falling edge

In diesem Codebeispiel reagiert der Externe Interrupt des ATmega8 auf Flanken beider Richtungen.


Beschreibung

Bei einer Flanke am Eingang des External Interrupt1 wird ein Digitalport getoggelt.

Please visit: the four

ampel

C Sourcecode

#include <avr/io.h>
#include <avr/interrupt.h>

int main(void)
{

     DDRB = 0x01;                        // Setup P0 as output
     PORTD |= 0x08;                      // Activate Apullupressistor of PD3
     GICR |= (1 << INT1);                // Enable INT1
     MCUCR |= (1 << ISC10);              // INT1 is executed on any edge

     sei();                              // Set the I-bit in SREG

     for(;;);                            // The main loop stays empty and
                                         // could contain some code you want.

     return 0;                           // This line will never be executed
}


// Interrupt subroutine for external interrupt 1
 ISR(INT1_vect)                            
{
     PORTB ^= 0x01;                      // Toggle PB0

}

Download C-Sourcefile mit ASCII-Schema: C-Sourcefile mit ACII-Schema

Signalplots

ATmega8 External Interrupt1 Plot

Gelb: Ausgang Digitalport PB0

Blau: Eingang Externer Interrupt 1