C64 clock generation
Posted: Fri Nov 03, 2017 9:20 am
For supporting the C74 project, I felt a need to post something about how clock generation in the C64 works.
;---
First, a picture of the clock generation circuitry taken from a C64 schematic (1982 ?).
Before 1984, a PLL like in the picture was used for generating the dot_clock.
(Looks like this circuitry was replaced by a 8701 clock generator chip in 1984.)
A block diagram of the PLL clock generator:
How it works:
U31 (74LS629) contains two VCOs (voltage controlled oscillators).
One VCO of U31 works as a crystal oscillator, generating the color_clock.
U30 (74LS193) works as an up_counter and divides down the color_clock by 9 (PAL) or 7 (NTSC).
A D_flipflop from U29 (74LS74) divides the U30 output by 2 for getting a neat symmetrical square wave.
The result is the _reference_ for PHI0.
The other VCO from U31 (74LS629) generates the dot_clock, which is divided down by 8 in the VIC-II for generating PHI0.
U32 (MC4044, now out of production) compares the PHI0 _reference_ (generated from the color_clock)
with PHI0 (generated by that VCO and the VIC-II), and is supposed to change the input voltage of that VCO
until PHI0 and the PHI0 _reference_ match.
BTW: the other D_flipflop in U29 (74LS74) is abused to work as an inverter for generating the constant of that U30 (74LS193) divider.
74LS\HC\HCT\AC\ACT74 datasheets don't explicitly state whether the /PRE or the /CLR input of the flipflop has higher priority,
better don't try such tricks at home, kids.
;--
Some background info about what a chrominance subcarrier is and why it has this odd frequency can be found on Wikipedia.
For the C64, I think the calculations look like this:
PAL:
chrominance_subcarrier = 4.43361875MHz
color_clock = chrominance_subcarrier *4
dot_clock = color_clock *2 /4.5
phi0 = dot_clock /8
NTSC:
chrominance_subcarrier = 3.57954545MHz
color_clock = chrominance_subcarrier *4
dot_clock = color_clock *2 /3.5
phi0 = dot_clock /8
Would like to mention, that the crystal might have a 50ppm tolerance or such.
I guess that quite some hobbyists wanted to measure the frequencies in a C64 by using a frequency counter,
and if the last digits of the frequencies are a bit different in the one or other text found in the internet,
please just ignore it and blame those tolerances...
;---
Some more info on the 8701:
ftp://www.zimmers.net/pub/cbm/documents ... a/8701.txt
ftp://www.zimmers.net/pub/cbm/documents ... a/8701.zip
http://visual6502.org/images/pages/MOS_8701.html
Different revsions of the C64 PCB, looks like the 8701 showed up in 1984, third version, ASSY 250425.
There is a replacement for the 8701 which seems to be based on a 74HC7046 PLL chip.
Edit: 8701R2 dissection is here.
;---
Another interesting PLL chip in the 5..133MHz range might be the CY2302.
Works at 3.3V and 5V.
When trying to generate odd frequencies from a standard crystal (let's say 12MHz), the ICS525-02 might be a good choice.
Works at 3.3V and 5V, Fin = 2..50MHz (5..27MHz crystal), Fout=5..250MHz (at 5V).
There are other chips that might (or might be not) useful, like the SI5351.
But reading the description of how to set those registers in the Si5351 might hurt your brain...
and it's hard to tell something about the phase relation between the chip outputs without throughly testing that chip.
;---
First, a picture of the clock generation circuitry taken from a C64 schematic (1982 ?).
Before 1984, a PLL like in the picture was used for generating the dot_clock.
(Looks like this circuitry was replaced by a 8701 clock generator chip in 1984.)
A block diagram of the PLL clock generator:
How it works:
U31 (74LS629) contains two VCOs (voltage controlled oscillators).
One VCO of U31 works as a crystal oscillator, generating the color_clock.
U30 (74LS193) works as an up_counter and divides down the color_clock by 9 (PAL) or 7 (NTSC).
A D_flipflop from U29 (74LS74) divides the U30 output by 2 for getting a neat symmetrical square wave.
The result is the _reference_ for PHI0.
The other VCO from U31 (74LS629) generates the dot_clock, which is divided down by 8 in the VIC-II for generating PHI0.
U32 (MC4044, now out of production) compares the PHI0 _reference_ (generated from the color_clock)
with PHI0 (generated by that VCO and the VIC-II), and is supposed to change the input voltage of that VCO
until PHI0 and the PHI0 _reference_ match.
BTW: the other D_flipflop in U29 (74LS74) is abused to work as an inverter for generating the constant of that U30 (74LS193) divider.
74LS\HC\HCT\AC\ACT74 datasheets don't explicitly state whether the /PRE or the /CLR input of the flipflop has higher priority,
better don't try such tricks at home, kids.
;--
Some background info about what a chrominance subcarrier is and why it has this odd frequency can be found on Wikipedia.
For the C64, I think the calculations look like this:
PAL:
chrominance_subcarrier = 4.43361875MHz
color_clock = chrominance_subcarrier *4
dot_clock = color_clock *2 /4.5
phi0 = dot_clock /8
NTSC:
chrominance_subcarrier = 3.57954545MHz
color_clock = chrominance_subcarrier *4
dot_clock = color_clock *2 /3.5
phi0 = dot_clock /8
Would like to mention, that the crystal might have a 50ppm tolerance or such.
I guess that quite some hobbyists wanted to measure the frequencies in a C64 by using a frequency counter,
and if the last digits of the frequencies are a bit different in the one or other text found in the internet,
please just ignore it and blame those tolerances...
;---
Some more info on the 8701:
ftp://www.zimmers.net/pub/cbm/documents ... a/8701.txt
ftp://www.zimmers.net/pub/cbm/documents ... a/8701.zip
http://visual6502.org/images/pages/MOS_8701.html
Different revsions of the C64 PCB, looks like the 8701 showed up in 1984, third version, ASSY 250425.
There is a replacement for the 8701 which seems to be based on a 74HC7046 PLL chip.
Edit: 8701R2 dissection is here.
;---
Another interesting PLL chip in the 5..133MHz range might be the CY2302.
Works at 3.3V and 5V.
When trying to generate odd frequencies from a standard crystal (let's say 12MHz), the ICS525-02 might be a good choice.
Works at 3.3V and 5V, Fin = 2..50MHz (5..27MHz crystal), Fout=5..250MHz (at 5V).
There are other chips that might (or might be not) useful, like the SI5351.
But reading the description of how to set those registers in the Si5351 might hurt your brain...
and it's hard to tell something about the phase relation between the chip outputs without throughly testing that chip.