Hello,
I have a problem with a timer and i really dont get what the problem is.
It is an arduino Mega1280 board and i am using timer3 which i believe is a 16bit timer.
So i thought, well if the prescaler is set to 128 the countintervall is:
1/(16 000 000/128) = 0,000008 seconds = 8µs
then if the timer is resetted to 0 after the overflow to the 16 bit (65536)
so it should take the timer 8µs *65536 = 524,288 ms to the Overflow.
this is how i set the timer up:
/* First disable the timer overflow interrupt while we're configuring */
TIMSK3 &= ~(1<<TOIE3);
/* Configure timer2 in normal mode (pure counting, no PWM etc.) */
TCCR3A &= ~((1<<WGM31) | (1<<WGM20));
TCCR3B &= ~(1<<WGM32);
/* Select clock source: internal I/O clock */
ASSR &= ~(1<<AS2);
/* Disable Compare Match A interrupt enable (only want overflow) */
TIMSK3 &= ~(1<<OCIE3A);
TCCR3B |= (1<<CS32) | (1<<CS20); // Set bits
TCCR3B &= ~(1<<CS31); // Clear bit
tcnt3 = 0;
TCNT3 = tcnt3;
ISR(TIMER3_OVF_vect) {
/* Reload the timer */
TCNT3 = tcnt3;
Serial.println(millis()-measure);
measure = millis();
}
Now i get 4194 mS on the serial monitor...
what is wrong with this?
is the Clock really 16Mhz or do i have to measure it first du get real times in seconds?
Is this timer connected to any pin ? i dont need any connection of the timer to any pins, because i use every pin on the board for something else.
can i use timers, just without anything happing with pins?
-Flo