I have two megas 2560 and one is with clock speed of 12 MHz crystal other with 16 MHz.
It seems my setup of timer 3 is not same for those two megas (Attachinterrupt have different counts )
I have this setup of timer 3 (Those timers setup are "dark India" for me...)
TIMSK3 &= ~(1 << TOIE3);
/* Configure timer3 in normal mode (pure counting, no PWM etc.) */
TCCR3A &= ~((1 << WGM31) | (1 << WGM30));
TCCR3B &= ~(1 << WGM32);
TCCR3A = TCCR3A | (1 << COM3A1) | (1 << COM3B1) | (1 << COM3C1);
/* Disable Compare Match A interrupt enable (only want overflow) */
TIMSK3 &= ~(1 << OCIE3A);
/* Now configure the prescaler to CPU clock divided by 128 */
TCCR3B |= (1 << CS32) | (1 << CS30); // Set bits
TCCR3B &= ~(1 << CS31); // Clear bit
sbi(TCCR3B, CS32); // CS31 set prescaler to 256 and start the timer
sbi(TCCR3A, WGM30); // put timer 3 in 8-bit phase correct pwm mode
sei();//allow interrupts
How to change the timer setting to be the same for both?
Or i have some other issue ... Mega2560 with 12MHz crystal works with breadboard and correct counting other with 16MHz and PCB board have a lower count of interrupts (Strangely slower).