My head hurts.
I tried pre loading with 1 and subtracting 1 and a few other ideas, but the result just changes by one.
The issue comes & goes, it'll read 1,000,000 for a 1mhz input, and then every 20 results or so it'll go 1,065,535 sometimes just the once, sometimes a few times, then it'll go Ok again, so subtracting 65,535 obviously wont work.
I think the core is robbing processing time and the timer interrupts are not being serviced when requested and the count gets too high, a bit odd though its always 65,535 too high, I've tried a 1mc signal and a 3mc signal, both come up with the same 65,535 over read.
I find it odd the error is the same, plus if you divide 1mc by 16 bits it isnt close to an integer so the 16 bit timer will not be rolling over at the measurement interrupt anyway.
My sig gen square wave o/p goes to 240kc this counts fine every time.
It can be done as the freqcount lib works ok, it undereads on 3mc, and if I then measure 1mc the underead is 1/3 less so its a crystal accuracy error not a count error, the lib for this at first looks easy but after some messing you soon get bogged down.
Reading the 16 bit timer understandably could go wrong if there was an interrupt inbetween hi & lo byte reads, I've tried disabling interrupts during counting, but the issue is exactly the same.
So not sure what to do right now, maybe a hardware solution.