#91176 - xyierz - Wed Jul 05, 2006 1:36 am
I'm working on a program which requires very accurate timing. The problem is that I have a base-unit of time in seconds stored as a rational number (eg. 1/24 which means 24 ticks per second) and I want to use the DS's built in timers to tick at that rate, as accurately as possible.
One way I've tried to tackle this problem is using cascade timing: I calculate the equivalent time interval in system clock ticks, then find a value for the first timer that evenly divides this value (as much as possible), and use count-up timing in the next system timer to generate an interrupt whenever the preceding timer has overflowed the appropriate number of times. Unfortunately this doesn't work -- apparently you can't have the second timer generate an interrupt when using cascade timing, or else I'm doing something wrong.
Does anyone have any ideas on the best way to solve this problem that preferably doesn't take a lot of extra CPU time?
One way I've tried to tackle this problem is using cascade timing: I calculate the equivalent time interval in system clock ticks, then find a value for the first timer that evenly divides this value (as much as possible), and use count-up timing in the next system timer to generate an interrupt whenever the preceding timer has overflowed the appropriate number of times. Unfortunately this doesn't work -- apparently you can't have the second timer generate an interrupt when using cascade timing, or else I'm doing something wrong.
Does anyone have any ideas on the best way to solve this problem that preferably doesn't take a lot of extra CPU time?