Oh that explains it thanks. I was under the impression that it counted up to 2^20 every real second and that by 'microsecond' we were reffering to one 1048576th of a second. I would have thought this would be more logical but I guess the canon engineers thought differently.
So this won't be a problem, still I don't look forward to writing a wraparound though. Has anyone else written one yet by any chance?
For the record, there is a logical, but possibly not very interesting reason for this (which you may already be aware of, in which case my apologies for butting in
).
Typically this sort of timer is driven by an oscillator that runs at a precise frequency, rarely is that frequency an exact binary fraction of a second.
The exception being things like real time clock chips, and digital watch crystals who's purpose is to generate human readable time, and which typically run using a precision 32768 Hz crystal. This frequency is chosen because if we divide 32768 by 2^15 we get a precise 1Hz signal (i.e. if we count to 2^15 using a 32768 Hz oscillator it will take us exactly 1 second (+/- the accuracy of the crystal) see
here for more details).
The CPUs and other logic in a modern camera and other computing devices tend to run at many MHz or even tens or hundreds of MHz, and thus their frequencies are often, not easily divided by a power of 2 to give exactly 1Hz.
A 1MHz clock for example will give you precise timings in binary multiples of 1/1000,000 second but is not *exactly* related by a power of 2 to give precisely 1 second timings.
In practice, this is usually not a problem , so long as we know how many "ticks" of our clock will give us one second, we can use the counter part of the timer to count to this number, or down from this number to zero, then generate our interrupt (depending on the type of timer we are dealing with, some count from zero to the chosen number, some count down from the number to zero, some can be programmed to do either).
If we require interrupts at precise (for example one second) intervals, and if we are dealing with a counter/timer , and if we know how to set up the counter and interrupt functions of this timer, and if we are able to handle the resultant interrupt(s), everything can be done in software.
I am not sure if all of these "ifs" are known in the case of the Digic timers.
The timers we are looking at in the Digic processors are probably broadly similar in operation to
this or
this, however since the Digic family are Canon specific hardware, their exact functional nature would have to be reverse engineered by comparing with similar devices, and by reading the code in the firmware to discern their operation. Some of this work has been done on the Magic Lantern site, and some has been done in this forum.