Skip to content

Instantly share code, notes, and snippets.

@avr-programmierung
Created May 14, 2019 10:00
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/6f27518fc4879ee08200cddd8e02fb6f to your computer and use it in GitHub Desktop.
Save avr-programmierung/6f27518fc4879ee08200cddd8e02fb6f to your computer and use it in GitHub Desktop.
ATmega88 @ 8MHz 16
/* code016.c ATmega88 @ 8MHz */
#include <avr/io.h>
#include <avr/interrupt.h> // Einbinden von interrupt.h (Interrupt Funktionen)
#include <avr/wdt.h> // Einbinden von wdt.h (Watchdog Funktionen)
uint8_t counter = 100;
int main(void)
{
DDRD = 0xFF;
PORTD = 0x00;
wdt_reset(); // watchdog timer reset
wdt_enable(WDTO_60MS); // watchdog enable, time-out 60ms
WDTCSR = (1<<WDIE);
sei(); // Interrupts aktivieren
asm ("NOP"); // no operation
while(1)
{
while (counter >= 0)
{
counter --;
PORTD = (1<<PD7); // LED D7 ON
}
wdt_reset(); // watchdog timer reset
}
}
ISR (WDT_vect) // ISR Watchdogtimer Overflow Interrupt
{
PORTD |= (1<<PD6); // LED D6 ON
WDTCSR = (1<<WDIE); // Watchdog Interrupt aktivieren
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment