Hello,
This is just to avoid long investigations for people working with Timers/Counters and frequencies experiencing time mismatch in their applications:
The AT4809 doc says it is factory preset at 20MHz (chapter 7.8.2.3), but the Arduino preset is at 16Mhz.
Chip doc also says the factory preset of the prescaler is 6, and one deduces enabled by default (chapter 10.3.3), but the prescaler is actually disabled.
You can check with:
Serial.begin(9600);
Serial.print("Freq main clk: ");Serial.println(FUSE.OSCCFG & 3 , BIN) ; //0x01 for 16M, 0x02 for 20M
Serial.print("Prescaler main clk: ");Serial.println(CLKCTRL.MCLKCTRLB , BIN) ; // bit 0 is at 1 if enabled, bits [4:1] define the prescaler division.
}
I get:
Freq main clk: 1
Prescaler main clk: 0
which means frequency preconfig 0x01 (16Mhz), and no bit enabled in MCLKCTRLB register, then prescaler disabled.