timers
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
timers [2024/09/23 18:22] – arisotura | timers [2025/04/13 13:51] (current) – arisotura | ||
---|---|---|---|
Line 3: | Line 3: | ||
The gamepad has the following timer registers: (TODO word better) | The gamepad has the following timer registers: (TODO word better) | ||
^ Address | ^ Address | ||
- | | 0xF0000400 | ?? | | + | | 0xF0000400 | Prescaler for timer 0/1 | |
- | | 0xF0000404 | xx | | + | | 0xF0000404 | Prescaler for count-up timer | |
| 0xF0000408 | Count-up timer | | | 0xF0000408 | Count-up timer | | ||
| 0xF0000410 | Timer 0 control | | | 0xF0000410 | Timer 0 control | | ||
Line 13: | Line 13: | ||
| 0xF0000428 | Timer 1 target | | 0xF0000428 | Timer 1 target | ||
- | TODO: measure the rate at which the timers tick. It is dependent on the system clock settings, which are still not understood. | ||
- | Timer 0/1 count 8126 ticks per video frame. That is, 487560Hz. | + | ===== Prescalers ===== |
- | They count ~1237 ticks per frame at the default (slow) clock settings. That is, 74220Hz. | + | Registers 0xF0000400 and 0xF0000404 control the rate at which timers 0/1 and the count-up timer run, respectively. |
+ | They are simple prescaler counters. For example, setting them to 63 will divide the input clock by 64. | ||
+ | |||
+ | These registers are 8 bits wide. | ||
===== Count-up timer ===== | ===== Count-up timer ===== | ||
Line 24: | Line 26: | ||
This is a simple timer that is always counting up. When writing a value to 0xF0000408, it will begin counting from the new value. | This is a simple timer that is always counting up. When writing a value to 0xF0000408, it will begin counting from the new value. | ||
- | It counts at twice the speed of timers 0/1. | + | This register is 32 bits wide. |
Line 36: | Line 38: | ||
| 0 | ?? | | | 0 | ?? | | ||
| 1 | Timer enable | | | 1 | Timer enable | | ||
+ | | 2 | Count direction; 0=up, 1=down | | ||
| 4-6 | Prescaler | | | 4-6 | Prescaler | | ||
Line 44: | Line 47: | ||
The prescaler value has the following possible settings: | The prescaler value has the following possible settings: | ||
^ Value ^ Frequency ^ | ^ Value ^ Frequency ^ | ||
- | | 0 | + | | 0 |
- | | 1 | Divide by 2 | | + | | 1 | Divide by 4 | |
- | | 2 | Divide by 4 | | + | | 2 | Divide by 8 | |
- | | 3 | Divide by 8 | | + | | 3 | Divide by 16 | |
- | | 4 | Divide by 16 | | + | | 4 | Divide by 32 | |
- | | 5 | Divide by 32 | | + | | 5 | Divide by 64 | |
- | | 6 | Divide by 64 | | + | | 6 | Divide by 128 | |
- | | 7 | Divide by 128 | | + | | 7 | Divide by 256 | |
**0xF0000414** | **0xF0000414** | ||
- | Counter. Can be written to, the timer will count from the new value. | + | Counter. Can be written to, the timer will count from the new value. Writes are ignored when the timer isn't active. |
- | When the timer goes past the target, the timer is reloaded to 0 and IRQ 0x00 is triggered. | + | When the timer goes past the target |
Writing a new value greater than the target does not cause a reload. | Writing a new value greater than the target does not cause a reload. | ||
+ | |||
+ | This register is 32 bits wide. | ||
Line 67: | Line 72: | ||
Target. | Target. | ||
- | Before | + | In count-up mode, before |
+ | |||
+ | In count-down mode, before a reload, the last value the timer takes is 0. It is then reloaded to the target value. | ||
timers.1727115723.txt.gz · Last modified: 2024/09/23 18:22 by arisotura