Atari STE video & DMA sound frequencies


Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

Atari User
Atari User
Posts: 43
Joined: Sat Mar 15, 2014 11:23 pm

Atari STE video & DMA sound frequencies

Postby fenarinarsa » Sun Dec 24, 2017 10:05 am

Christmas topic :)

When I developped Bad Apple I found out that the STE DMA frequencies may not exactly be the ones that are in every documentation.
This also applies to vertical video frequencies.

Atari ST video frequencies are often described as:
50Hz (PAL)
60Hz (NTSC)
71Hz (hig-res)

However it seems high-res is actually 71.2Hz and not 71Hz.

The same goes with STE DMA audio:

6258 Hz
12517 Hz
25033 Hz
50066 Hz

I read somewhere (maybe here) that the frequencies are actually derived from a main frequency and the values above are rounded.

For Bad Apple I needed to know all exact frequencies because the audio is multiplexed with the video. If audio frames are too small or too large, there is a sync drift that ends up with audio frames being played twice or skipped.
To be precise, the demo runs at 60Hz and plays a 50066 Hz sound in stereo, so the average audio frame should be 1668,87 bytes. I round it to 1668 and my generator adds a pair of bytes from time to time to stick to 1668,87 globally.

The audio DMA is then set to loop mode and the next audio frame addresses are loaded into the DMA register while an audio frame is already playing. This was to avoid using Timer A which may fire too late because of blitter transfers... and honestly it would make some things more complicated.

But... it doesn't work as expected.

When I fire a Timer A to see where the DMA loop point occurs, I can see a big drift in time. Also I noted that the drift is different on real hardware and on emulators.
I had to change the data used for my calculation and found out that the best result I could get was with (2* 50035)/60 = 1667,83 bytes/vbl.

It works, but I wondered why 50035? Or maybe this is the video frequency that's not 60 but something else?
Or maybe I'm completely wrong and my code is crap :roll:

Now I'm doing a high-res version and I have the exact same issue, except that the audio drift is really huge. Currently the best shot I could get to make it work on emulators is (2*50005)/71.2 = 1404,63 bytes/vbl. And various emulators behave really differently in monochrome. I couldn't test it on real hardware yet.

To be honest I had the exact same kind of issues back in the 1990's when I worked on an Amiga TFMX conversion.
Last edited by fenarinarsa on Sun Dec 24, 2017 11:18 am, edited 1 time in total.

User avatar
Atari God
Atari God
Posts: 1364
Joined: Mon Apr 30, 2012 6:20 pm
Location: Sweden

Re: Atari STE video & DMA sound frequencies

Postby troed » Sun Dec 24, 2017 11:09 am

PAL ST VBL is always 160256 cycles. However, there are different clock speeds used (8.007, 8.01, 8.02 and 8.05MHz). For the STE, only 8.02 ("PAL") and 8.05 ("NTSC") are relevant*.

You can back-calculate everything from this I believe, together with the info that "NTSC" (60Hz) scanlines are 508 cycles long, "PAL" (50Hz) are 512, mono are 224 and the number of lines per frame for the different screenmodes are 263, 313 and 501 respectively.

(I have 71.4Hz in my notes for mono for some reason, but 71.2Hz is also commonly stated)

I have no info on how the STE DMA replay frequencies are calculated.


*) Exact clocks are found by taking the circuit on the motherboard's frequency and dividing by four:

32.0424 MHz
- early STF, also NTSC
32.04245 MHz
- Mega ST
32.084988 MHz
32.215905 MHz

Additionally, there exists some, very few, 8.007MHz STs. Paulo Simoes has one, it might be Atari having been cheap or a simple mis-order where 32.0242 was bought instead of 32.0424 (although that would be 8.006MHz .. )

User avatar
Atari God
Atari God
Posts: 1475
Joined: Fri Oct 04, 2002 11:23 am
Location: Warsaw, Poland

Re: Atari STE video & DMA sound frequencies

Postby Cyprian » Sun Dec 24, 2017 11:23 am

In ST/STe Video frequecies are calculated from formula:
- VBL = Mainclock / 4 / CPU clocks per line / Lines per VBLANK
- HBL = Mainclock / 4 / CPU clocks per line

And now some contants:
1) STE Main clock: 32 084 988 HZ

2) Color mode "50Hz":
- CPU clocks per line: 512
- lines per VBLANK 313

3) Color mode "60Hz":
- CPU clocks per line: 508
- lines per VBLANK 263

4) Mono "71Hz":
- CPU clocks per line: 224
- lines per VBLANK 500 or 501 (I'm not sure)

"VBL = Mainclock / 4 / CPU clocks per line / Lines per VBLANK"
- Color mode "50Hz": 32084988 / 4 / 512 / 313 = 50,05270941 Hz
- Color mode "60Hz": 32084988 / 4 / 508 / 263 = 60,03747642 Hz
- Mono "71Hz"
32084988 / 4 / 224 / 500 = 71,61827679 Hz
32084988 / 4 / 224 / 501 = 71,47532613 Hz

Btw, check this topic Test your CPU speed (and Sound DMA speed)

Troed was faster :)
Jaugar / TT030 / Mega STe / 800 XL / 1040 STe / Falcon030 / 65 XE / 520 STm / SM124 / SC1435
SDrive / PAK68/3 / CosmosEx / SatanDisk / UltraSatan / USB Floppy Drive Emulator / Eiffel / SIO2PC / Crazy Dots / PAM Net
Hatari / Aranym / Steem / Saint

Atari User
Atari User
Posts: 43
Joined: Sat Mar 15, 2014 11:23 pm

Re: Atari STE video & DMA sound frequencies

Postby fenarinarsa » Sun Dec 24, 2017 11:39 am


No matter how hard I searched, I couldn't find those numbers (even here, I didn't find that thread Cyprian). And the Atari wiki has been down for years :(

So if I compare the result I found by trial & error
(2*50035)/60 = 1667,83 bytes/vbl

to the actual numbers
(2*50066)/60.03747642 = 1667,82 bytes/vbl

Aaaaaaaaand that's it. I knew the numbers we can read everywhere were surely rounded.

That's why I was looking for the correct info. Again thank you so much both of you \o/

Social Media


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 1 guest