Hi, I have set up timer1 for input capture like so:
ISR(TIMER1_CAPT_vect) {
// make icr1 available outside ISR, not sure if this is needed at all, but who cares, figure out later
icr1 = ICR1
// timer 1 disable all IRQs
IMSK1 = 0;
// timer 1 no clock source --> full stop timer 1
TCCR1B = 0;
}
And I start the capture mode like so:
cli();
// stop timer 0 and timer 1 prescaler (and thus timer 0 and 1 as well)
GTCCR = (1 << TSM) | (1 << PSRSYNC);
// initialize all counters to 0
TCNT0 = 0;
TCNT1 = 0;
// no noise canceler, trigger on falling edge, no prescaler / use system clock
TCCR1B = (0 << ICNC1 | 0 << ICES1 | 0 << CS12 | 0 << CS11 | 1 << CS10);
// Timer/Counter1, Input Capture Interrupt Enable
TIMSK1 = (1 << ICIE1 );
// reset input capture flag
TIFR1 = ( 1 << ICF1 );
// go
GTCCR = 0;
sei();
Actually this is part of more code, but this is how I start it. In addition I configure PIN 8 (PORT B, 0) as input and enable the pullup.
Now what I would expect is that this starts timer 1 and a falling edge triggers the input capture. This does work.
However I would also expect that if I do not connect anything to PIN8, then it should not trigger the ISR. However it is triggered after 1.78 to 1.82 seconds and I have absolutely no clue why. I thought that it might be connected with other ISRs but I double checked and this is not the case.
It is definitely the capture ISR that starts to run even though the pin is pulled up.
Any ideas what could be the cause and how to fix it? Maybe some flag that I did not properly set? Something else?
Cheers, Udo