Created
May 14, 2019 10:27
-
-
Save avr-programmierung/7fa14756e6bf1742df5c73274c50bc1c to your computer and use it in GitHub Desktop.
ATmega88 @ 1MHz interrupt 01
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* interrupt_01.c ATmega88 @ 1MHz */ | |
#include <avr/io.h> | |
#include <avr/interrupt.h> // Einbinden der Headerdatei für Interrupts | |
int main(void) | |
{ | |
DDRD &= ~(1<<PD2); // PD2 = Eingang (INT0) | |
DDRB |= (1<<PB1); // PB1 = Ausgang | |
PORTB = 0x00; // PORTB auf low | |
EICRA |= (1<<ISC01)|(1<<ISC00); // Int0 wird durch eine steigende Flanke ausgelöst | |
EIMSK |= (1<<INT0); // Ext. Int0 aktivieren | |
sei(); // Alle Interrupts aktivieren | |
while(1) | |
{ | |
} | |
return 0; | |
} | |
ISR (INT0_vect) // Hier beginnt die ISR für den ext. Int0 | |
{ | |
PORTB ^= (1 << PB1); // Toggle PB1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment