ATmega32 externer Interrupt 1

Dieses lauffähige Programm für den ATmega32 zeigt die Konfiguration des External Interrupt 1


Beschreibung

Der External Interrupt 1 reagiert auf eine fallende Flanke und toggelt daraufhin Port PA0.

Please visit: the four

ampel

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

int main(void)
{

    DDRA = 0x01;                       // Setup PA1 as output
    PORTD = 0x08;                      // Activate internal pullupressistor of PD3

    GICR |= (1<<INT1);                 // Enable INT1
    MCUCR |= (1<<ISC11);               // INT1 is executed on falling edge
    sei();                             // Set the I-bit in SREG

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

    return 0;                          // This line will never be executed

}

// Interrupt subroutine for external interrupt 1
ISR(INT1_vect)
{
    PORTA ^= 0x01;                     // Toggle PA0
}


Download lauffähiges C-File mit ASCII-Schema: Downloadlink

Signalplots

Externer Interrupt 1

Gelb: Digitaler Ausgang PA0
Blau: Interrupt 0 Eingang (PD3)