Nano Every: main clock freq and prescaler

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.

The frequency can be changed between 16MHz and 20MHz by modifying the boards.txt file.
By default Arduino IDE will set the fuse bits and set the operating frequency to 16MHz. This is done with the two lines:

nona4809.build.f_cpu=16000000L
nona4809.bootloader.OSCCFG=0x01

To run at 20MHz, change them to:

nona4809.build.f_cpu=20000000L
nona4809.bootloader.OSCCFG=0x02

Note that not all library functions correctly support this change. If you keep it at 16MHz there won't be any issues.