SX-clocks (another one)

From: silverdr_at_wfmh.org.pl
Date: Fri, 3 May 2013 18:38:42 +0200
Message-Id: <673A99CF-2F3D-4DC1-9329-3BAABA768A8A@wfmh.org.pl>
There are other interesting things in the SX.. the TOD clock, driven by either 50 or 60Hz in a regular 64. Of course when the frequency is taken from the power, whatever is supplied will affect the TOD accuracy. There is a bit in the CIA, which allows for selecting what frequency is used but to set it, the program must know what is the frequency supplied to TOD. So far I always assumed that when the machine is an NTSC one (which can be detected by software) it should be running at 60Hz. PAL OTOH has to be 50Hz. That was not a perfect solution (one can run NTSC machine on a 230/50 PSU in Europe) but in the lack of better method it worked in a way.

But in the SX that clock is no longer fed with the frequency from the power line. It has dedicated 60Hz crystal, meaning both PAL and NTSC will be always running at 60Hz, which in turn means that all the software, which use TODs in 50Hz mode (PAL detected) will again be off by a big margin.

Does anyone know a trick how to detect the frequency supplied to the TODs? I am thinking of something like:

int tod_frequency(void)
{
  pal = check_pal();
  set_tod_freq(50);
  all_interrupts_off();
  reset_tod(0);

  if(pal)
    wait_full_rasters(25);  // This can be done by simply polling the VIC
  else
    wait_full_rasters(30);

  if((tod_value = read_tod(0)) == 1.0)
    return 50;
  else
    return 60;
}

but if someone knows why this would not work (reliably) or knows a better method, I would be glad to hear!

-- 
SD!
       Message was sent through the cbm-hackers mailing list
Received on 2013-05-03 17:00:03

Archive generated by hypermail 2.2.0.