There are four 16-bit hardware timers in the Nintendo DS. Each can be used independently, or they can be combined to make 32-bit, 48-bit, or 64-bit timers.
However, the user must abide by certain conditions when using these timers. When using a timer inside the NitroSDK OS, the user cannot directly use that timer.
Inside the NitroSDK, there are two features that use the timer: the tick system and the alarm system. By default, the tick system uses timer 0, while the alarm system uses timer 1. Also, the tick system is required when using the alarm system. These gives rise to the following restrictions:
When performing a DEBUG build with the NitroSDK, when trying to access the timer being used by the system by using the timer function, a warning appears and processing halts.
By setting a value in the timer count register and setting the enable flag of the timer control register, a regular-interval count begins. It is possible to configure and choose a multiple of the system clock (1x, 16x, 64x, or 1024x) for the increment interval.
A timer interrupt occurs when the counter ranges from 0xFFFF to 0x0000. If the timer interrupt handler is set in advance with OS_SetIrqFunction(), that handler will be called.
According to the hardware specifications, as long as the timer does not stop, the count up and interrupt will repeat any number of times. However, if the interrupt occurs inside the OS, the timer will be disabled. In other words, only one interrupt occurs per configuration.
The functions below set appropriate values to the timer count register and the timer control register, then start the timer.
OS_StartTimer()
OS_StartTimer32()
OS_StartTimer48()
OS_StartTimer64()
The functions below clear the enable flag of the timer control register and stop the timer.
OS_StopTimer()
OS_StopTimer32()
OS_StopTimer48()
OS_StopTimer64()
An Overview of OS Functions (Timer), An Overview of OS Functions (Time), An Overview of OS Functions (Alarm)
11/16/2004 Initial version