Clock

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

Post Reply
evildragon
Very interested
Posts: 326
Joined: Mon Mar 12, 2007 1:53 am
Contact:

Clock

Post by evildragon » Thu Aug 02, 2007 5:11 pm

(I posted this on another forum, but that forum is a tad slow.. so hopefully someone here can help-----and for the record, im basing time from vertical blanks)

I made a clock a while ago for the Genesis, but I'm getting complaints that it looses times, like, within 10 minutes.. This didn't happen on my emulator (Genesis Plus for Macintosh)..

Can someone else test it for me on real hardware? I don't have a flash cart.. I wrote it on Basiegaxorz a while ago, I might have the source code still on my laptop...

http://blackevilweredragon.spymac.com/s ... index.html

Also, if this does have a problem, then that means my other application GenTimer would also have a problem, as it was based on the source of my clock..

Jorge Nuno
Very interested
Posts: 374
Joined: Mon Jun 11, 2007 3:09 am
Location: Azeitão, PT

Post by Jorge Nuno » Thu Aug 02, 2007 6:02 pm

It is possible to happen because the 60/50Hz Vints could be something like 59.9/49.9 or 60.1/50.1 Hertz, so, you need to get an external real time clock with a precision oscilator.

Or, If you know the averege time deviation, you can apply some "corrections", but it varies from console to console :?

8bitwizard
Very interested
Posts: 159
Joined: Sat Feb 24, 2007 11:35 pm
Location: San Antonio, TX

Post by 8bitwizard » Fri Aug 03, 2007 12:21 am

That's probably the problem, that it's not exactly 50 or 60 Hz. You either need to figure out what it really is, and hope that it doesn't vary much between consoles, or add a real-time clock chip.

But it's probably going to vary too much. I was looking at a bunch of the old Rex Sabio docs and noticed a tech note about the Xband modem. It said that any two average MD consoles can be expected to have their vertical sync counters go out of sync within two minutes.

Maybe if there was some way to configure it with a joypad to run faster or slower (add or remove one out of every few thousand vertical blanks), and display the tuning so you could re-enter it when you wanted to use it later.


It won't be useful here, but I know that you can get away with an inaccurate high-resolution counter if you have an accurate low-resolution counter like a real-time clock chip. I wrote a program on the Macintosh long ago which needed to have accurate timing for video subtitling, and I found out that setting up an interrupt handler for millisecond interrupts gave me somewhere between 1000 and 1100 interrupts per second. So I kept track of how long it was between real-time clock seconds changes and kept a running average over the last 10 seconds to get the scaling factor.

evildragon
Very interested
Posts: 326
Joined: Mon Mar 12, 2007 1:53 am
Contact:

Post by evildragon » Fri Aug 03, 2007 12:51 am

perhaps if i take one of those old Dallas RTC "blocks" from an old motherboard, I can use one of those? I'd have to figure out how they work though..

I think they contain a crystal, IC, memory, AND a battery.. not sure..

Shiru
Very interested
Posts: 786
Joined: Sat Apr 07, 2007 3:11 am
Location: Russia, Moscow
Contact:

Post by Shiru » Fri Aug 03, 2007 9:54 am

How about sync with Z80 or YM2612 timers? I don't think they clocking frequency can vary so much like VSYNC.

evildragon
Very interested
Posts: 326
Joined: Mon Mar 12, 2007 1:53 am
Contact:

Post by evildragon » Fri Aug 03, 2007 9:58 am

Shiru wrote:How about sync with Z80 or YM2612 timers? I don't think they clocking frequency can vary so much like VSYNC.
I don't think I can, with the language I used..

Jorge Nuno
Very interested
Posts: 374
Joined: Mon Jun 11, 2007 3:09 am
Location: Azeitão, PT

Post by Jorge Nuno » Fri Aug 03, 2007 11:11 am

evildragon wrote:perhaps if i take one of those old Dallas RTC "blocks" from an old motherboard, I can use one of those? I'd have to figure out how they work though..

I think they contain a crystal, IC, memory, AND a battery.. not sure..

Yeah you can, Just look at the datasheet, it explains how to use it, and they don't contain batteries or crystals, but they are nearby on the motherboard, but forget about emulation.

evildragon
Very interested
Posts: 326
Joined: Mon Mar 12, 2007 1:53 am
Contact:

Post by evildragon » Fri Aug 03, 2007 11:16 am

Jorge Nuno wrote:
evildragon wrote:perhaps if i take one of those old Dallas RTC "blocks" from an old motherboard, I can use one of those? I'd have to figure out how they work though..

I think they contain a crystal, IC, memory, AND a battery.. not sure..

Yeah you can, Just look at the datasheet, it explains how to use it, and they don't contain batteries or crystals, but they are nearby on the motherboard, but forget about emulation.
actually, the old Dalas RTC do have a battery, check the datasheet ;)

http://www.mcamafia.de/mcapage0/dsrework.htm

Jorge Nuno
Very interested
Posts: 374
Joined: Mon Jun 11, 2007 3:09 am
Location: Azeitão, PT

Post by Jorge Nuno » Fri Aug 03, 2007 12:05 pm

LOL but the internal battery probably it is dead by now, so you need extra work to preserve the time/date when you shut down the megadrive. 8)

8bitwizard
Very interested
Posts: 159
Joined: Sat Feb 24, 2007 11:35 pm
Location: San Antonio, TX

Post by 8bitwizard » Fri Aug 03, 2007 2:23 pm

Shiru wrote:How about sync with Z80 or YM2612 timers? I don't think they clocking frequency can vary so much like VSYNC.
Those come from the same master timing source and will be exactly as incorrect as the vsync.

Shiru
Very interested
Posts: 786
Joined: Sat Apr 07, 2007 3:11 am
Location: Russia, Moscow
Contact:

Post by Shiru » Fri Aug 03, 2007 2:38 pm

8bitwizard, you said that master clock frequency can vary on different SMD units? How that can be possible, with master clock which driven by quartz generator with very exactly known frequency?
Last edited by Shiru on Fri Aug 03, 2007 3:08 pm, edited 1 time in total.

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Fri Aug 03, 2007 2:51 pm

Hmm, my 20year old Dallas RTC brick that I got from a 286 still works, never had to set the time again... but these have these stupid Address+Data lines which will make getting data out from them little more difficult...

Use of YM2612 timers give very stable results... but I want to know what results NTSC machines give... they have slightly different master clock... PAL machine has 53.203424(or 242)MHz OSC...
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

evildragon
Very interested
Posts: 326
Joined: Mon Mar 12, 2007 1:53 am
Contact:

Post by evildragon » Fri Aug 03, 2007 9:44 pm

Jorge Nuno wrote:LOL but the internal battery probably it is dead by now, so you need extra work to preserve the time/date when you shut down the megadrive. 8)
Read the link I posted, shows how to hack an external battery for it.... ;)

But mine still work anyway.......luckily...

Jorge Nuno
Very interested
Posts: 374
Joined: Mon Jun 11, 2007 3:09 am
Location: Azeitão, PT

Post by Jorge Nuno » Fri Aug 03, 2007 11:22 pm

evildragon wrote:Read the link I posted, shows how to hack an external battery for it.... ;)

But mine still work anyway.......luckily...
I saw it, but it's kinda risky, at the first glance, well you are ripping/drilling/cutting the chip's package, if your hand shakes or slippers->probably RTC dead...

still works? then learn how to read the time from it, and you're set.

evildragon
Very interested
Posts: 326
Joined: Mon Mar 12, 2007 1:53 am
Contact:

Post by evildragon » Sat Aug 04, 2007 12:35 am

Jorge Nuno wrote:
evildragon wrote:Read the link I posted, shows how to hack an external battery for it.... ;)

But mine still work anyway.......luckily...
I saw it, but it's kinda risky, at the first glance, well you are ripping/drilling/cutting the chip's package, if your hand shakes or slippers->probably RTC dead...

still works? then learn how to read the time from it, and you're set.
the block isn't a chip.. there's a chip IN the block.. the block is a chunk of potted plastic..

Post Reply