MiSTer-devel / Minimig-AGA_MiSTer

142 stars 54 forks source link

RTC runs too fast in NTSC #178

Open rhester72 opened 1 month ago

rhester72 commented 1 month ago

When the system (not screen mode!) is set to NTSC, the real-time clock advances much too quickly (owing to the difference between 50Hz and 60Hz tick). When the system is set to PAL, the clock runs normally.

sorgelig commented 1 month ago

Noted. will check it.

rhester72 commented 1 month ago

Apologies, I think I worded this poorly.

RTC itself (the real RTC) is just fine. It appears to be CIAA (or CIAB or both? I don't remember which Kickstart 1.x uses vs. 2.x+) TOD that's the problem.

How to reproduce:

Hope this helps clarify :)

sorgelig commented 1 month ago

Are you talking about NTSC mode you can choose if you boot Amiga with both mouse keys held down, and choose in that boot menu? So you use PAL mode but temporary choose NTSC in boot settings?

rhester72 commented 1 month ago

No, the other way - selecting PAL in the core itself under video settings.

Working now to put together the smallest possible package with config, rom and adf to reproduce.

rhester72 commented 1 month ago

minimig_clock_test.zip

Attached are a minimig config (only change from defaults is "Audio & Video/TV Standard" is set to NTSC, which is key to triggering the problem), a Kickstart ROM of standard 3.1 for 68000, and a Workbench 3.1 ADF with NTSC and PAL monitor drivers (for convenience, screenmode does not affect the problem) and Clock set to start automatically.

Steps to reproduce:

Let it remain in that state for a while (hours, ideally) and you will observe it consistently losing time compared to wall clock. RTC is unaffected - if you wish, open a shell and execute "setclock load" and you will observe the time "snap" back to current.

This problem ONLY occurs if the core is set to NTSC video. If you repeat the above steps but first set the core to PAL, the problem will not occur.

Please let me know if there's anything else I can do to help.

sorgelig commented 1 month ago

Since Minimig includes RTC, do you think WB still gets time from CIA instead of RTC?

sorgelig commented 1 month ago

RTC in minimig core gets update every minute, so time must be not from RTC.

Looking as A1200 schematics, CIA gets clock from VSync which is obviously 20% faster in NTSC mode. It seems AmigaOS/WB should detect NTSC mode and program CIA accordingly. So it must be something inside Amiga software. I don't know why NTSC time running faster. Did you try additionally boot into Amiga boot config and choose NTSC mode there additionally?

rhester72 commented 1 month ago

It's definitely not a software bug, I've been running NTSC workbenches for almost 40 years. =)

CIA can get its clock either from vsync or from power, automatically detecting 50/60Hz from that. Is the latter updated? (I'd need to consult WinUAE to see which one the A1200 uses specifically, it varies by model.)

sorgelig commented 1 month ago

CIA-A gets tick from VSync, CIA-B from HSync. Same as in A1200 schematics.

sorgelig commented 1 month ago

Considering that A1200 can output wide range of frame rates i don't know how software can relay on such timer. A500 is less flexible in video output but still..

rhester72 commented 1 month ago

I confirmed only the A1000 and A3000 sync CIA TOD off of the power source, all others is indeed vertical sync.

I do not know the specifics of how it's done in Kickstart (or SetClock), but I know for sure there would have been a bug report or three if every American Amiga user couldn't depend on the time. laughs BBSes were quite big over here for a while...