10

I have a trouble understanding how the MOS 6502 clock works. Possibly due to my extremely low knowledge regarding electronics in general.

According to the Wikipedia:

MOS would introduce two microprocessors based on the same underlying design: the 6501 would plug into the same socket as the Motorola 6800, while the 6502 re-arranged the pinout to support an on-chip clock oscillator (https://en.wikipedia.org/wiki/MOS_Technology_6502)

Later in the article:

The 6512 is a 6502 with a 2-phase clock input for an external clock oscillator, instead of an on-board clock oscillator.

However, 6502 has also a clock-input pin

The 6502 receives an external square-wave clock input signal on pin 37, which is usually labeled PHI0. (https://lateblt.livejournal.com/88105.html)

I don't understand why we need an external clock signal if it has a builtin oscillator? What is the role of the oscillator (I though the oscillator generates a clock signal)? 6501 doesn't have one, so it requires two clock input signals, why is that? Isn't one enough?

EDIT:

I attach also a quote from the official MOS Hardware Manual: http://archive.6502.org/books/mcs6500_family_hardware_manual.pdf

The [6502] is a 40-pin device which provides all the features of the MCS6501, along with an "on-the-chip" oscillator and clock drivers. This device should be used in all new designs which require the capability of the 40-pin processors. The clock drivers can be driven with a single TTL level square wave or with the internal Oscillator. The frequency of operation of the internal oscillator can be set by attaching an R-C combination to the chip and, if the clock stability is required, by attaching a crystal between the oscillator and ground. This feature totally eliminates the problems encountered in generating MC6800 type clock signals.

0

5 Answers 5

16

I have a trouble understanding how the MOS 6502 clock works.

Erm, reading through the question it seems you're actually asking why different 6500 CPU variants each need a different clock setup.

Possibly due to my extremely low knowledge regarding electronics in general.

This isn't about 'electronics knowledge' (*1) but simply designated use case for each 6500 variant.

The 6501 ...

... is a straight drop in replacement for the 6800. That means it can be plugged directly into a computer built for a 6800.

The 6800 has no internal clock generator, but needs to be fed two non-overlapping clock signals, such as those created by the Motorola 687x family of integrated clock generators (*2). To make a 6501 work in a computer designed for the 6800 it has to the same pinout and behave exactly like a 6800 regarding their operation, i.e. all signals, which of course includes taking the Phi1/2 clock signals and using them like a 6800 would.

The 6502...

... is a new design, based on the 6800 design, but radically simplified and improved. As such, it relies on the same non-overlapping two-phase clock signal to manage its workings. It has a different pinout than the 6501 and cannot be used with 6800 boards.

One improvement over the 6800 was that it includes an on-board clock generator. Thus all it needs is an external oscillator - which can be as simple as a RC-circuit - this saves quite some money. Motorola priced the 6870 in 1976 at 20-30 USD, depending on volume. That the 6502 cost less than that for the CPU including clock generator does make a point (*3).

The 6512 ...

... in turn is a 6502 regarding the signalling exactly like the 6502, except it needs to be fed a two-phase signal exactly like the 6501(6800). The internal clock generator is disabled.

While many standard applications work quite fine with a simple symmetric single-speed clock, there are cases where it is of advantage to have fine control over how the CPU is clocked in general and at times. For example, working with an asymmetric clock structure with varying clock speed: for synchronisation with external devices, or more generally to fit with external timing of whatever structure.

The eventually most well-known example of a 6512 may be the BBC Micro B+ using it instead of the 6502 the Model A had.(*4)

Conclusion:

6501, 6502 and 6512 are three variants of the same CPU for different use cases each requiring a different approach to clock generation


P.S.: That cited site about 6500 clock is not entirely correct when saying

The two clocks are basically inverted versions of each other.

No, they are complementary non overlapping. That means they are not simply inverted, but delayed in a way that no two transitions occur at the same time. This is due to the fact that the two clock signals are needed to produce 4 distinct clock signals used to crank all internal workings.

The 6502 receives an external square-wave clock input signal on pin 37

Again no, it need not be a square wave, only a wave form that stays long enough above and below a certain threshold. It can be a square wave, but does not have to be.

Or in other words, that page is well ... let's say 'oversimplified' without understanding what it tells.


*1 - Maybe a bit, as to the difference between an oscillator and a clock generator:

  • An oscillator is some device that delivers a periodic signal, for example a crystal or a RC-circuit, while
  • a clock generator takes the periodic signal and turns it into one (or more) clock signal(s) as needed by the CPU.

*2 - A very interesting circuit, as what looks like a strange crystal is in fact a hybrid circuit combining a crystal, clock circuit and drivers in one package.

*3 - So maybe better qualified as clock generator with CPU included for free?

*4 - Often the Apple II is cited as already doing this with a 6502, as Woz created a rather complex clock circuit that fed the 6502 as well. But doing so with Phi0 on a 6502 only allows changing the basic clock frequency and symmetry, not not handling Phi1 and Phi2 separately as the 6512 does.

2
  • Thanks for the detailed answer. I think the most important sentence is: > One improvement over the 6800 was that it includes an on-board clock generator. Thus all it needs is an external oscillator - which can be as simple as a RC-circuit I couldn't get why we need an external clock source if we have a builtin mechanism for it, but now everything is clear!
    – Andy
    Oct 21, 2022 at 2:08
  • @tgdavies and then there was the B+64 and B+128 both using the 12 ... and the 102 for the master ... so what was you point again?
    – Raffzahn
    Oct 23, 2022 at 4:00
14

I think there's one point that needs to be sorted first: Your Wikipedia quote suggests that there's an on-chip oscillator in the 6502. There isn't. [1] What there is is a clock generator, which takes one clock signal, and uses it to generate others. Which is what the clock inputs and outputs are for.

[1] At least not in the way the term is used today: A circuit that generates a clock signal out of nothing but some DC. I don't know whether the meaning has changed over time, like it has, say, for "real time clock", or whether there was a misunderstanding.

2
  • 1
    Indeed, I think there is a lot of confusion regarding the terminology, even the official 65XX Hardware Manual says: « [6502] provides [...] an "on-the-chip" oscillator and clock drivers. [...] The clock drivers can be driven with a single TTL level square wave or with the internal Oscillator. The frequency of operation of the internal oscillator can be set by attaching an R-C combination to the chip and, if the clock stability is required, by attaching a crystal between the oscillator and ground. [...]» I guess they just meant a clock generator (despite saying the internal Oscillator)?
    – Andy
    Oct 21, 2022 at 2:29
11

All 6502-family processors subdivide each cycle into two active periods, controlled by wires called phi1 and phi2. For each cycle, it's necessary that phi1 goes high and low for a certain period of time, and then phi2 goes high and low for a certain period of time. If both clock wires were ever high simultaneously, bad things would happen likely rendering the chip unusable until the next time it is reset.

The 6502 includes internal circuitry which, given a single square-wave clock input, will produce phi1 and phi2 signals which meet the specified requirements. Some members of the family, however, allow separate phi1 and phi2 signals to be supplied instead. This offers two major advantages:

  1. The clock oscillator for the 6502 has minimum high and low time requirements. If the chip were to receive a "runt pulse", that would may cause bad things to happen. This can complicate some designs that require the ability to have external hardware take over the bus without warning (the chip has a READY line, but it only operates during reads). The 6502 won't care if it receives runt or redundant phi2 pulses without a phi1 pulse or vice versa, provided that between every pair of phi1 pulses there are either no phi2 pulses at all, or else at least one full length phi1 pulse, and likewise if it receives runt or redundant phi1 pulses. If an external device takes over during phi2, it can end the phi2 pulse immediately, provided the 6502 receives at least one full-length phi2 pulse before the next phi1 pulse. When using the built-in clock generator, however, there would be no way to end a phi2 pulse without automatically starting the next phi1.

  2. The minimum lengths for the four parts of the 65xx clock cycle are all different, and the circuitry that converts a square wave into the two-phase clock isn't terribly precise. Circuitry which generates phi1 and phi2 clocks that precisely satisfy the minimum length requirements can thus operate the chip faster than circuitry which simply drives a single-phase clock.

4

The 6502 does not really have an oscillator. Confusing terminology is being used.

It requires an external clock signal to be fed into Phi0.

However it has an internal clock generator which takes the externally fed clock signal on Phi0 input pin, and converts it to the required two phase non-overlapping clock signals, and it outputs them on the Phi1 and Phi2 output pins.

The 6512 does not have internal clock generator to genetate the required two phase non-overlapping clock signals, so it has two input clock pins Phi1 and Phi2 for externally feeding it the two phase non-overlapping clock signals into it. So they have to be externally generated.

2
  • Indeed, I think there is a lot of confusion regarding the terminology, even the official 65XX Hardware Manual says: « [6502] provides [...] an "on-the-chip" oscillator and clock drivers. [...] The clock drivers can be driven with a single TTL level square wave or with the internal Oscillator. The frequency of operation of the internal oscillator can be set by attaching an R-C combination to the chip and, if the clock stability is required, by attaching a crystal between the oscillator and ground. [...]» I guess they just meant a clock generator (despite saying the internal Oscillator)?
    – Andy
    Oct 21, 2022 at 2:30
2

Without going into detail on the 6502 family, there's a more general principle here. Many devices with internal oscillators are often run with an external crystal.

Internal oscillators only run at relatively low clock rates. In the 1990s and 2000s when I was working with the lower-end 8-bit microcontrollers of the day, typically the internal oscillator would only run at a few hundred kilohertz, whilst the device was perfectly able to run at 10MHz or more. Higher-end devices today will often give you a clock-multiplier PLL to step this up, but lower-end microcontrollers still generally don't - that's why they're lower-end, after all. And back in the day of the 6502, those kind of features weren't on the cards. So if you want more reasonable processing power, you want an external crystal.

Internal oscillators are also very inaccurate. +/-20% tolerance on the frequency is entirely normal. And to make matters worse, they can vary substantially with temperature, meaning that they won't even keep a consistent frequency whilst your device is running. If your application needs reasonably accurate timings or frequencies, you simply can't use an internal oscillator.

Why would we even use an internal oscillator then? Well, for all the low-power, low-cost, slow applications where you don't really care. Lower clock rates save power, and fewer components saves money. If you're making a burglar alarm, it doesn't really matter whether you check the window contacts every 0.8s or 1.2s. If you're making a greetings card that plays Axel F, or one of those cheap sound-effects toys that makes sounds like a laser or a bomb dropping, it doesn't really matter whether the sound is pitched somewhat higher or lower than it officially should be.

2
  • So this answer, along with this quote from the Hardware Manual: « [6502] provides [...] an "on-the-chip" oscillator and clock drivers. [...] The clock drivers can be driven with a single TTL level square wave or with the internal Oscillator. The frequency of operation of the internal oscillator can be set by attaching an R-C combination to the chip and, if the clock stability is required, by attaching a crystal between the oscillator and ground. [...]»
    – Andy
    Oct 21, 2022 at 14:31
  • It means 6502 does have both clock generator (to produce two phase outputs from one input) AND an internal oscillator, however you are allowed to plug your own oscillator, for more stability and/or higher clocks. (And all known computers using 6502 were just providing their clock) Do I understand it correctly?
    – Andy
    Oct 21, 2022 at 14:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .