Select Git revision
blink-07.c 601 B
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdint.h>
uint8_t flag = 0;
ISR (TIMER0_COMPB_vect)
{
static uint8_t counter = 0;
if (counter++ == 0)
flag = 1;
}
int main (void)
{
cli ();
TCCR0B = (1 << CS01) | (1 << CS00); /* Takt durch 64 dividieren */
TIMSK0 = 1 << OCIE0B; /* Interrupt einschalten */
sei ();
DDRB = 0xfe; // Bit Nr. 0 als Input nutzen
PORTB = 0x20; // Bit Nr. 5 auf 1 setzen, alle anderen auf 0 ("digitalWrite" für alle 8)
while (1)
{
if (flag)
{
PORTB ^= 0x20;
flag = 0;
}
}
return 0;
}