Hello all
we have a periodic signal and want to meter it's Duration and Frequency by atmega8 Ic
by following codes :
ISR (INT1_vect){ static unsigned char flag_start=0,state=1; if(state==1){ TCNT1_old=TCNT1; overflow=0; state=0; }else if(state==0){ diff_time=TCNT1-TCNT1_old+(overflow*1000); state=1; } }
ISR(TIMER1_OVF_vect){ overflow++; TCNT1=-1000; }
the diff_time is Duration.
Why this code is wrong and doesn't work?