KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
Timer Unit

SH4 CPU peripheral providing timers and counters. More...

Modules

 Channels
 TMU channel constants.
 
 Direct-Access
 Low-level timer driver.
 
 Primary Timer
 Primary timer used by the kernel.
 
 Sleeping
 Low-level thread sleeping.
 
 Uptime
 Maintaining time since system boot.
 

Files

file  timer.h
 Low-level timer functionality.
 

Detailed Description

SH4 CPU peripheral providing timers and counters.

The Dreamcast's SH4 includes an on-chip Timer Unit (TMU) containing 3 independent 32-bit channels (TMU0-TMU2). Each channel provides a down-counter with automatic reload and can be configured to use 1 of 7 divider circuits for its input clock. By default, KOS uses the fastest input clock for each TMU channel, providing a maximum internal resolution of 80ns ticks.

Warning
Under normal circumstances, all 3 TMU channels are reserved by KOS for various OS-related purposes. If you need a free general-purpose interval timer, consider using the Watchdog Timer.
Note
90% of the time, you will never have a need to directly interact with this API, as it's mostly used as a kernel-level driver which backs other APIs. For example, querying for ticks, fetching the current timestamp, or putting a thread to sleep is typically done via the standard C, C++, or POSIX APIs.