ich habe eine frage: untenstehendes programm zum timer 2 funktioniert
nicht. ersetze ich jedoch die Register durch ihre gegenstücke von timer
0 dann funktionierts (mit timer0).
Weiß jemand rat, was beim timer 2 schiefgeht?
Programm mit TImer 2 // geht nicht
#include <io.h>
#include <interrupt.h>
#include <sig-avr.h>
unsigned char i=0;
SIGNAL(SIG_OVERFLOW2) /* signal handler for tcnt2 overflow
interrupt */
{
if (i==10)
{outp(~PORTF,PORTF);
i=0;}
else
{i++;}
}
int main( void )
{
outp(0xff,DDRF);
utp(0xff,PORTF);
outp((1<<TOIE2),TIMSK);
outp(0,TCNT2);
outp(7,TCCR2);
sei();
for(;;){}
}
Programm mit TImer 0 // funktioniert
#include <io.h>
#include <interrupt.h>
#include <sig-avr.h>
unsigned char i=0;
SIGNAL(SIG_OVERFLOW0)
{
if (i==10)
{outp(~PORTF,PORTF);
i=0;}
else
{i++;}
}
int main( void )
{
outp(0xff,DDRF);
utp(0xff,PORTF);
outp((1<<TOIE0),TIMSK);
outp(0,TCNT0);
outp(7,TCCR0);
sei();
for(;;){}
}
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.