[time-nuts] 32768Hz using DDS
chris.cheney at tesco.net
Thu Jul 24 04:36:07 EDT 2008
On 24 Jul 2008 at 8:27, Murray Greenman wrote:
> and second that the time around the loop is
> changed by the instructions involved in loading.
Well, the timing can be kept constant by always adding in a value.
For the AVR, using a branch to test for overflow is not necessary: ROL
followed by ANDI will get carry (instead of overflow as we are performing
unsigned arithmetic) into the bottom bit of a register from where it can
be used to index for the appropriate value (0 or 52,947) to be added.
So the relevant calculation can be done with straight-through code,
without any branches, giving a constant instruction count.
Regards from Cambridge
More information about the time-nuts