#include <nitro/os.h>
void OS_StartTimer( OS_TimerId id, u16 count, OS_TimerPrescaler preScale );
void OS_StartTimer32( OS_Timer32Id id, u32 count, OS_TimerPrescaler preScale );
void OS_StartTimer48( OS_Timer48Id id, u64 count, OS_TimerPrescaler preScale );
void OS_StartTimer64( u64 count, OS_TimerPrescaler preScale );
id | Timer ID of the timer to use (differs according to number of timers used) |
count | Timer count |
preScale | Timer scale |
None.
Sets and starts the internal timer.
Nintendo DS has four 16-bit counter timers. Each can be used independently or two or more timers can be connected to create a count timer of greater than 16 bits.
The OS_StartTimer()
function uses 16-bit timers individually.
The OS_StartTimer32()
function uses two consecutive timers as a timer with a 32-bit count maximum.
The OS_StartTimer48()
function uses three consecutive timers as a timer with a 48-bit count maximum.
The OS_StartTimer64()
function uses four consecutive timers as a timer with a 64-bit count maximum.
id specifies the Timer ID of the timer to use, as shown below.
For 16-bit timers (id specification for OS_StartTimer()
, OS_StopTimer()
)
id | Timer to use |
---|---|
OS_TIMER_0 | Timer 0 |
OS_TIMER_1 | Timer 1 |
OS_TIMER_2 | Timer 2 |
OS_TIMER_3 | Timer 3 |
For 32-bit timers (id specification for OS_StartTimer32()
, OS_StopTimer32()
)
id | Timer to use |
---|---|
OS_TIMER32_01 | Timer 0, Timer 1 |
OS_TIMER32_12 | Timer 1, Timer 2 |
OS_TIMER32_23 | Timer 2, Timer 3 |
For 48-bit timers (id specification for OS_StartTimer48()
, OS_StopTimer48()
)
id | Timer to use |
---|---|
OS_TIMER48_012 | Timer 0, Timer 1, Timer 2 |
OS_TIMER48_123 | Timer 1, Timer 2, Timer 3 |
count is the count given to the timer. 16-bit timers take values from 0 to 0xFFFF; 32-bit timers take values from 0 to 0xFFFFFFFF; 48-bit timers take values from 0 to 0xFFFFFFFFFFFF; and 64-bit timers take values from 0 to 0xFFFFFFFFFFFFFFFF.
preScale is the parameter that sets the scale for the counting on the timer. See the table below.
Set Value | Prescaler (count interval) |
---|---|
OS_TIMER_PRESCALER_1 | System Clock |
OS_TIMER_PRESCALER_64 | 1/64th of the System Clock |
OS_TIMER_PRESCALER_256 | 1/256th of the System Clock |
OS_TIMER_PRESCALER_1024 | 1/1024th of the System Clock |
When the specified count is reached, a timer interrupt is generated. When using a timer that uses multiple timers, timer interrupts will be for the the timer that has the highest number.
Caution: Based on the hardware timer specifications, set timer interrupts occur repeatedly. However, the OS releases timer settings when the first interrupt occurs so only the first timer interrupt takes place. In order to generate repeated timer interrupts, processing to carry out settings needs to be done again in the interrupt handler.
03/08/2005 Standardized the Japanese term for "interrupt."
11/24/2004 Corrected mistake in timer ID.
06/03/2004 Added a caution about timer interrupts.
12/01/2003 Initial version.