Clock sources - Kyuchumimo/Micro-Joy-Home-Video-Computer GitHub Wiki

Most sound chips need a clock signal to operate. Here is a list of common operating frequencies:

  • 4 Mhz
  • 3.579545 MHz
  • 2 Mhz
  • 1.79 Mhz

The TMS9918 can supply a frequency of 3.579545 MHz on the CPUCLK pin internally by dividing its internal clock by 3. Now if you want to obtain a frequency of 1.79 MHz, it is possible by dividing by 2 the CPUCLK signal with the help of some flip-flops or counters.

Now if you want to obtain a specific frequency, you will need to get a Full Can Crystal Oscillator at the desired frequency or a quartz crystal at the desired frequency plus build an oscillator circuit.
The pierce oscillator is one of the simplest oscillator circuits you can build. Below is a diagram of it:

cmos_clock_oscillator

⚠️ NOTE: This circuit is not universal for all frequencies. It is necessary to tune the resistor Rs according to the resonance frequency of the quartz crystal, otherwise, the circuit will oscillate at a different frequency which may affect the pitch of the melodies or in the worst case, it will not oscillate at all.

The duty cycle of clock generators is not necessarily 50%. Applications requiring perfect square wave symmetry are easily satisfied by feeding the oscillator to a tilting flip-flop. The latter then produces a square wave with D(%) = 50%, but with half the frequency of the oscillator. To achieve the desired frequency, a crystal with twice the frequency is simply used.

3579-oscilloscope

Another solution is to use a PWM signal from e.g. a microcontroller as clock signal, but keep in mind that the higher the desired frequency, the lower its accuracy.