YM2610 timers: Difference between revisions

From NeoGeo Development Wiki
Jump to navigation Jump to search
(Created page with "The {{Chipname|YM2610}} provides 2 timers (called A and B), used to time music playback by triggering Z80 interrupts. The timer A is 10 bits wide, the timer B is only 8 b...")
 
mNo edit summary
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
The {{Chipname|YM2610}} provides 2 timers (called A and B), used to time music playback by triggering [[Z80 interrupts]].
The {{Chipname|YM2610}} provides 2 timers called A and B, used to time music playback by triggering [[Z80 interrupts]].


The timer A is 10 bits wide, the timer B is only 8 bits wide.
The timer A is 10 bits wide, the timer B is only 8 bits wide.
Line 5: Line 5:
=Ranges=
=Ranges=


* Timer A: 8M / 2 / 144 (prescaler) / (load value - 1): 27.18Hz ~ 27.8kHz ?
* Timer A interval: 72*(1024-value)/4M : 18µs to 18432µs (55.56kHz to 54.25Hz)
* Timer B: 8M / 16384 / (load value - 1): 1.922Hz ~ 448.3Hz
* Timer B interval: 1152*(256-value)/4M : 288µs to 73.728ms (3.47kHz to 13.56Hz)
* Smaller value = longer interval !


=Registers=
=Registers=
Line 24: Line 25:
|-
|-
|$27
|$27
|{{8BitRegister|CSM mode|1|3-slot mode|1|Flag reset TB|1|Flag reset TA|1|Enable TB IRQ|1|Enable TA IRQ|1|Load TB|1|Load TA|1}}
|{{8BitRegister|CSM mode|1|2CH mode|1|Flag reset TB|1|Flag reset TA|1|Enable TB IRQ|1|Enable TA IRQ|1|Load TB|1|Load TA|1}}
|}
|}


Line 39: Line 40:


* Flag reset refers to the same flags that are read from port $04
* Flag reset refers to the same flags that are read from port $04
* 2CH mode allows each of FM channel 2 operators to run at their own frequency.
* CSM mode is for automatic key-on for operators of the second FM channel when timer A expires ?
* CSM mode is for automatic key-on for operators of the second FM channel when timer A expires ?


[[Category:Audio system]]
[[Category:Audio system]]
[[Category:Code]]
[[Category:Code]]

Latest revision as of 00:37, 8 August 2021

The YM2610 provides 2 timers called A and B, used to time music playback by triggering Z80 interrupts.

The timer A is 10 bits wide, the timer B is only 8 bits wide.

Ranges

  • Timer A interval: 72*(1024-value)/4M : 18µs to 18432µs (55.56kHz to 54.25Hz)
  • Timer B interval: 1152*(256-value)/4M : 288µs to 73.728ms (3.47kHz to 13.56Hz)
  • Smaller value = longer interval !

Registers

Address (Z80 port 4) Data (Z80 port 5)
$24
Bit 7 6 5 4 3 2 1 0
Def TA counter load bits MSBs
$25
Bit 7 6 5 4 3 2 1 0
Def - TA counter load bits LSBs
$26
Bit 7 6 5 4 3 2 1 0
Def TB counter load
$27
Bit 7 6 5 4 3 2 1 0
Def CSM mode 2CH modeFlag reset TBFlag reset TAEnable TB IRQEnable TA IRQLoad TBLoad TA

Operation

The timers are decremented at regular intervals until they reach 0, at which point an interrupt will be generated (if enabled). The timer which caused the interrupt can be known by reading port $04.

When a timer expires, it is automatically reloaded. If interrupts are enabled, care must be taken to clear the appropriate flag(s) so that they can be triggered again.

The actual counters aren't accessible, only their load value can be written.

  • Writing 0 to the load bits in register $27 will reset the timer counters to zero.
  • Writing 1 to the load bits will copy the respective timer load value to the timer counter. This only works when the counter is at zero.
  • Flag reset refers to the same flags that are read from port $04
  • 2CH mode allows each of FM channel 2 operators to run at their own frequency.
  • CSM mode is for automatic key-on for operators of the second FM channel when timer A expires ?