hello i am working on atmega16 micro-controller, i am trying to interface the color sensor whos output is the pulse, i am want to connect it to the ICP1 pin (input capture) mode, here is my timer 1 configuration but i am not able to get any sort of results, please look into it and correct the code
void TIMER_1(void)
{
// Set up input capture, no prescaler
TCCR1B |= (1<<ICES1); // get rising edge first
TCCR1B |= (1<<CS10); // no prescaler
TIMSK |= (1<<TICIE1); // enable ICP interrupt
sei(); // enable global interrupts
}
ISR (TIMER1_CAPT_vect)
{
// Read ICR1
// Flip edge trigger
// Clear ICR1
localICR=ICR1;
TCCR1B ^= (1<<ICES1);
TCNT1=0;
pulse++;
}