Note that your millis() clock will run at the wrong rate unless the system clock is 16MHz or 8MHz, EVEN IF YOU SPECIFY THE NEW CLOCK FREQUENCY.
Are you sure of that?
Nearly. To work correctly, the
millis code requires F_CPU to be an even power of two (16, 8, 4, ...). So, a few more frequencies are supported.
I thought the core libraries utilized the f_cpu=xxxxxxxL variable in the boards.txt file to setup the timer used for millis() and micros() ?
They do. However...
The Arduino folks wanted an efficient millisecond clock and as many PWM pins as possible. Those three goals drive the structure of the code and limit the clock speed choices.
The simple fact is that the code in wiring.c requires the processor clock to be a power of 2 (1 MHz, 2 MHz, ... 8 MHz, 16 MHz). To support arbitrary clock speeds requires code that is more complicated (less efficient) and, in some cases, giving up PWM on timer 0.
So wouldn't he just have to modify the boards.txt entry to whatever clock speed he setup his external clock generator for?
For non-power of two frequencies, the code in
wiring.c has to be modified.
I suspect the
millis code could be modified to support a wider range of frequencies (like 20 MHz) but I don't think it can be written to support an arbitrary frequency. The problem is fourth grade math: fractions. Some fractions are easy to determine at compile time like the one currently used in
millis (1/1024). Some fractions are not so easy to determine even by a human (what fractions are appropriate for a 14.7456 MHz frequency).