I was just following this thread for some reason, had a mega4809 hooked up so just tried to make a freq divider. The main clock has a divider from 1 to 64 (1 2 4 6 8 10 12 16 24 32 48 64) of which the /10 is useful for lower freqs or if you just wanted 1MHz on clkout (and just a few lines of code).
The tca timer is 16bit, and has a freq mode, so made a simple little class to set tca to output all available integer frequencies from 1Hz to 5MHz (55 total choices out of 64k). Below 80Hz the timer prescale starts to get used and the cpu div will use /10 for some of them. Not much code, and half of it is a lookup table for the values I generated (cpudiv, tcadiv, tcacmp, freq).
FreqGenerate10Mhz fg;
while( true ){
Print( oled, "\tHz: %7lu", fg.freq ); //\t is my 'home' command
while( board.sw.isOff() ){}
fg.next(); //5Mhz ... 1Hz
}
The list of available choices-
5M,2.5M,1.25M,1M,625k,500k,312.5k,250k,200k,156.25k,125k,100k,
78.125k,62.5k,50k,40k,31.25k,25k,20k,15.625k,12.5k,10k,
8k,6.25k,5k,4k,3.125k,2.5k,2k,1.6k,1.25k,1k,
800,625,500,400,320,250,200,160,125,100,
80,50,40,32,25,20,16,10,8,5,4,2,1
My meter says it works, but I have no idea how this compares to using logic ic's, and have no idea when the difference starts to matter. It is the simpler option for those that are better at mcu's than dealing with logic ic's, or at least would be the first option to try. An 8 pin avr0/1 would probably do even if a display was wanted (and leaving updi pin for only programming)- pwr/gnd/updi, scl/sda, wo0, switch, extclk. These avr 0/1 need a logic signal to use an external clock, so may still end up using a logic ic to drive a crystal if that is your source.
Even if its not good enough (however defined), it took 15 minutes to get it working and test. If it turns out it does well, then you have a 50cent mcu solution and a square inch of board space needed. If not, you lost 15 minutes of time, plus whatever time it took to test.