Falls es je,anden interessiert:
So sieht jetzt mein Timer aus:
So in der asuro.c
und im Hauptprogramm wird das folgendermaßen benutzt:Code:unsigned volatile char count72kHz; unsigned volatile int countkhz,countmsek,countsek; /* uses timer2 (36kHz for IR communication */ /* counts falling and rising edge => 36kHz*2 = 72kHz */ SIGNAL (SIG_OUTPUT_COMPARE2) { count72kHz ++; countkhz ++; if (countkhz == 72) { countmsek++; countkhz = 0; } if (countmsek == 1000) { countsek++; countmsek = 0; countkhz = 0; } }
Das bewirkt, dass die StatusLED 10 Sekunden lang schnell bilinkt und danach 5 Sekunden lang langsamer.Code:#include "asuro.h" #include "Funktionen.h" int main(void) { Init(); countsek=0; while (countsek<10) { StatusLED(RED); WaitM(100); StatusLED(GREEN); WaitM(100); } StatusLED(OFF); WaitS(1); countkhz=0; countmsek=0; countsek=0; while (countsek<5) { StatusLED(GREEN); WaitM(500); StatusLED(RED); WaitM(500); } StatusLED(OFF); while(1); return 0; }







Zitieren
Lesezeichen