VOGONS


First post, by Electronic Genets

User metadata
Rank Newbie
Rank
Newbie

This interrupt is named ninetenth seconds interrupt (1/18 s). Part of sources states the interval is 55 ms. Part of sources states the interval is 65536/1193180 s = 54.925493 ms and part states the interval is 65536/1193184 s = 54.925309 ms.

Where is the truth?...

I need correct frequency to correctly play HSC files (they uses 08h / 1Ch interrupt as timer).

Author of the DINO-2e OPL2-like emulator.
DINO-2e is not OPL2 emulator.

Reply 2 of 8, by Electronic Genets

User metadata
Rank Newbie
Rank
Newbie

Thank you ripsaw8080. It means the crystal frequency is 1193182 Hz and the "8254" timer counts to 65536 (interrupt at overflow)?

It also means that OPL2/OPL3 frequency isn't 49716 Hz but 49715,91(6) Hz.

Author of the DINO-2e OPL2-like emulator.
DINO-2e is not OPL2 emulator.

Reply 3 of 8, by ripsaw8080

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Well, the linked article makes a point about (in)accuracy: https://wiki.osdev.org/Programmable_Interval_ … _Timer_Accuracy
It doesn't seem very clear at what points in calculation, and in which units, it is "acceptable" to round off, but the point about variation in hardware implementations remains.

DOSBox uses a PIT clock rate of 1193182 Hz, and 49716 Hz for the OPL and mixer rate are just rounding to integer value.

Reply 4 of 8, by mkarcher

User metadata
Rank l33t
Rank
l33t
Electronic Genets wrote on 2022-06-01, 12:58:

Thank you ripsaw8080. It means the crystal frequency is 1193182 Hz and the "8254" timer counts to 65536 (interrupt at overflow)?

Morally yes, technically no.

The crystal frequency is 14.31818MHz, not 1.193182MHz, but the crystal frequency is divided by 12 before it is sent into the 8254 timer. Thus, if the crystal frequency were infinitely precise (which it isn't, of course), the timer would be clocked at exactly 1193181.6 MHz, with boldface indicating infinite repetition of that 6, which is pretty close to 1193182MHz. It makes no sense to argue whether the frequency is intended to be 1'193'182 Hz or 1'193'184 Hz, as crystals are not that precise. But it might make sense to lock the OPL2/OPL3 rate to the 8254 rate, as they might be derived from the same crystal (depending on the sound card). So locking in the OPL3 to be "ticked" exactly every 24 timer ticks makes sense. If you run the OPL3 at a nominal rate of 49'716Hz, it would make sense to run the PIT at a nominal rate of 1'193'184Hz just to keep the ratio. If you don't care about the PIT clock, but just about the IRQ0 clock: The OPL3 is intended to run at a 8192/3 times the IRQ0 clock.

Reply 5 of 8, by Electronic Genets

User metadata
Rank Newbie
Rank
Newbie

The 1193182 Hz and 1193184 Hz and 1193181.666 Hz makes no difference because crystals have error about +/-20ppm at standard temperature.
Thank you mkarcher and ripsaw8080 for your answers. It is about 54.9254 ms. It is not 55 ms.

Author of the DINO-2e OPL2-like emulator.
DINO-2e is not OPL2 emulator.

Reply 6 of 8, by reenigne

User metadata
Rank Oldbie
Rank
Oldbie

While it doesn't really matter for practical purposes due to the tolerance of the crystal, there is actually an exact nominal answer here based on the derivation of the frequencies in the NTSC color TV standard: it's 13.125MHz/11 = 1193181.818... Hz. Although the exact value doesn't make much difference, it is important that emulators use the same value consistently - there have been cases where not doing so has caused emulator bugs that make games run incorrectly.

Reply 7 of 8, by kdr

User metadata
Rank Member
Rank
Member
mkarcher wrote on 2022-06-01, 15:16:

It makes no sense to argue whether the frequency is intended to be 1'193'182 Hz or 1'193'184 Hz, as crystals are not that precise. But it might make sense to lock the OPL2/OPL3 rate to the 8254 rate, as they might be derived from the same crystal (depending on the sound card). So locking in the OPL3 to be "ticked" exactly every 24 timer ticks makes sense.

The actual precise frequency of the 14.318mhz clock varies from machine to machine. Some motherboards, such as the original IBM PC and XT motherboards, even allow the user to fine tune the frequency. (Which controls the tint/hue of the CGA's composite video signal!) Since the OPL in early sound cards (e.g. Adlib and Sound Blaster) is hooked directly to the 14.318mhz OSC signal, it's possible to use the frequency adjustment trimmer on a PC/XT motherboard so that the OPL plays a perfectly tuned 440.0hz A-4 note. Not sure how badly this would mess up the NTSC composite video's hue.

Reply 8 of 8, by Jo22

User metadata
Rank l33t++
Rank
l33t++
kdr wrote on 2022-06-02, 09:34:
mkarcher wrote on 2022-06-01, 15:16:

It makes no sense to argue whether the frequency is intended to be 1'193'182 Hz or 1'193'184 Hz, as crystals are not that precise. But it might make sense to lock the OPL2/OPL3 rate to the 8254 rate, as they might be derived from the same crystal (depending on the sound card). So locking in the OPL3 to be "ticked" exactly every 24 timer ticks makes sense.

The actual precise frequency of the 14.318mhz clock varies from machine to machine. Some motherboards, such as the original IBM PC and XT motherboards, even allow the user to fine tune the frequency. (Which controls the tint/hue of the CGA's composite video signal!) Since the OPL in early sound cards (e.g. Adlib and Sound Blaster) is hooked directly to the 14.318mhz OSC signal, it's possible to use the frequency adjustment trimmer on a PC/XT motherboard so that the OPL plays a perfectly tuned 440.0hz A-4 note. Not sure how badly this would mess up the NTSC composite video's hue.

Guys, you miss something very crucial, maybe because you're into digital technology, dunno. 🙂
But oscillators, crystals especially, are temperature sensitive.
They work correctly only once they reach operating temperature.
That's why 'quartz oven' existed. Heating is easier than cooling, when it comes to stabilized temperature.

"Time, it seems, doesn't flow. For some it's fast, for some it's slow.
In what to one race is no time at all, another race can rise and fall..." - The Minstrel

//My video channel//