Skip to content

Instantly share code, notes, and snippets.

@avr-programmierung
Created May 14, 2019 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avr-programmierung/2952490a7b5093d6a0f60cfae4168ac4 to your computer and use it in GitHub Desktop.
Save avr-programmierung/2952490a7b5093d6a0f60cfae4168ac4 to your computer and use it in GitHub Desktop.
ATmega88 @ 1MHz interrupt 03
/* interrupt_03.c ATmega88 @ 1MHz */ #include <avr/io.h>
#include <avr/interrupt.h>
int main(void)
{
DDRB |= (1<<PB1); // PB1 = Ausgang
PORTB = 0x00; // PORTB auf low
PCICR |= (1<<PCIE0); // Aktiviere PCINT0 (PCINT0…7) als Interruptquelle
PCMSK0 |= (1<<PCINT0); // Aktiviere PCINT0 als Interrupt-Pin
sei(); // Alle Interrupts aktivieren
while(1)
{
}
return 0;
}
ISR (PCINT0_vect)
{
PORTB ^= (1 << PB1); // Toggle PB1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment