timer-tutorial

Gast #2373268
Lesenswert?

hallo

ich lese mir gerade das timer tutorial auf avrfreaks durch 
(http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=50106)
und hab nur eine kurze frage zu folgendem Code: Dient das leere for(;;)
einfach nur dazu das der Controller irgendwas macht oder welchen sinn
hat es???


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

int main (void)
{
   DDRB |= (1 << 0); // Set LED as output

   TCCR1B |= (1 << WGM12); // Configure timer 1 for CTC mode

   TIMSK |= (1 << OCIE1A); // Enable CTC interrupt

   sei(); //  Enable global interrupts

   OCR1A   = 15624; // Set CTC compare value to 1Hz at 1MHz AVR clock, 
with a prescaler of 64

   TCCR1B |= ((1 << CS10) | (1 << CS11)); // Start timer at Fcpu/64

   for (;;)
   {

   }
}

ISR(TIMER1_COMPA_vect)
{
   PORTB ^= (1 << 0); // Toggle the LED
}

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren