15

As with most NMOS processors, the NMOS versions of the 6502 (and even earlier CMOS versions) do not have a static core. Thus, if you run the clock too slowly or stop the clock for too long while doing clock stretching, internal latches will lose their data and the 6502 won't work properly.

For how long could you stop the clock on a 6502 without running into problems?

22

Official figures vary, and are sometimes wrong. Evidence indicates that not exceeding to 5-6 microseconds is fine.

In Jim Sather's book Understanding the Apple II he has a rough transcript of an interview with Steve Wozniak. On page I-3 they discuss this exact issue.

W. I'll tell you about a timing problem that will interest you. My first design for the Apple II used a display method in which the 6502 was stopped for 40 microseconds. The Synertek data sheet said you could stop it for 40 microseconds, but I was having problems. The 6502s would work for a while, but the Apple would eventually stop working. I always had to have a new 6502 in my pocket in case it happened.

S. You mean the 6502 operated for 25 cycles, then the video display operated for 40 cycles?

W. That's right. When I designed the Apple II, dynamic RAM was just becoming available that could be accessed at two Megahertz. When it did become available, I changed the design of the Apple II to take advantage of it. I've told Synertek about the problem but they haven't changed their specification. New 6502s can be stopped for 40 microseconds, but they deteriorate. They are dynamic devices that store data in internal capacitive elements. As the 6502 wears in, its capacitive elements become less efficient.

S. I'm very glad you bought this up. Descriptions in my book are very vague about how long you could stop the 6502 during DMA. The data sheets are inconsistent. Synertek says 40 microseconds, Rockwell says 10 microseconds, and MOS Technology doesn't say at all.

W. Rockwell changed theirs to 10 microseconds? That's great.

S. Do you think 10 microseconds is a good number?

W. I'd stick with five or six. That's what Microsoft uses on their Z80 Softcard. It refreshes the 6502 every few cycles to keep it active. The 6502 is still used for things like disk I/O, even when the Z80 card is activated.

| improve this answer | |
  • 3
    Conversely, the Acorn Electron stops its 6502 clock for up to 40 microseconds without issue, though it’s a 2Mhz-rated part, so a different revision even though still NMOS. – Tommy Apr 12 at 12:43
  • 6
    "I always had to have a new 6502 in my pocket in case it happened." Hold a moment! Does this mean that you can destroy a 6502 if the clock is stopped for too long? – mcleod_ideafix Apr 12 at 15:28
  • @mcleod_ideafix: I think the issue is that parts of the chip that are supposed to behave as insulators have impurities that cause current leakage. During normal usage, charges will slowly distribute themselves through these bits of impurities in a way that facilitates (unwanted) current flow, increasing leakage. Charges might redistribute themselves in a way that would reduce leakage when the part is idle, but not necessarily on a meaningful timescale (e.g. if one had a 6502 that wasn't used in ten years, its leakage might drop to the point where it would tolerate 40us idle periods... – supercat Apr 12 at 16:35
  • ...until it had been used for 30 minutes, whereupon one would have to wait another decade for the part's leakage properties to go back down). By analogy, imagine a battery-powered device that doesn't draw much current, but will only work if a battery outputs at least 1.52 volts per cell. A battery wouldn't be able to power the device for very long, but even after the battery deteriorated enough that it couldn't operate the device, it would still be fine for most other purposes. – supercat Apr 12 at 16:36
  • 3
    @mcleod_ideafix Based on the deterioration thing, I don't think the Z80 is destroyed, but I think they are saying that as the Z80 gets used, it "wears out", and the amount of time you can stop it for goes down, and eventually you can only stop it for 35us and it won't work when you stop it for 40. – user253751 Apr 12 at 23:33
1

As with most NMOS processors, the NMOS versions of the 6502 (and even earlier CMOS versions) do not have a static core.

Neither is true. Being static or not is not a feature of NMOS vs. CMOS design, but the way individual chips are designed. In case of the NMOS 6502 it's non static nature is due the way line precharge is used to generate constant values used for certain operations. See this answer for more details.

This never applied to CMOS version, as there a precharge can not be used the same way. After all, switching both ways instant, without running much current, is the primary idea here. All CMOS versions feature full fledged constant value generators active during the whole cycle.

Thus, if you run the clock too slowly or stop the clock for too long while doing clock stretching, internal latches will lose their data and the 6502 won't work properly.

It's not about latches, but precharged lines, as the NMOS 6502 design simply spares dedicated latches wherever possible.

For how long could you stop the clock on a 6502 without running into problems?

This depends on internal bus design as well as manufacturing process, its improvement over time - plus a rather wide variety per unit - as the main influence is the quality of the charging resistors (*1).

Basically each data sheets value for clock duration can be used as guideline (*2).

enter image description here

(Taken from the MOS May 1976 data sheet)

For the NMOS 6500 the cycle duration is specified as 1 µs minimum and 10 µs maximum. At first sight this could mean that it can be held for 10 µs (*3). But since the critical stretch is the PHI2 high section (Rising edge to falling of PHI2), and no further qualifier is given for that, it may depend on the signal assumed. While the manual refers multiple times to a symmetric clock, the datasheet doesn't give a direct description it- But all NMOS data sheets define PHI1 high and PHI2 high is of the same Length as PHI0 high, with only a small variation allowed. Together this would allow either interpretation, whereas staying on the safe side means the clock is only within spec if held in either state for a maximum 5 µs (half the cycle time).

And this is were Woz went wrong about timing and Synertek's 40 µs. Here the April 1979 data sheet states:

enter image description here

The sheet doesn't say it can be stopped for 40 µs, but the maximum cycle time to be 40 µs. Like with the MOS manuals Synertek ones assume a symmetric 50/50 duty cycle for the clock. But unlike the MOS data sheet, the Synertek one links PHI1 and PHI2 pulse width directly to PHI0 puls length, thus requiring a symmetric clock. Woz' clock circuit, as used in the Apple II does not hold up to this. Based on these values, the maximum guaranteed duration to stop the clock in either state is 20 µs, not 40 as Woz assumed. There was no reason for Synertek to change the date sheet values, as his application was out of spec.

Next, Rockwell didn't change the data sheet as implied, but the 10 µs are stated already in the very first Rockwell data sheets (although I say this part is more of a misunderstanding how the interview went).

Lastly, the Z80 Softcard does not let the 6502 go for a cycle every few (5-6) cycles, but every M1 cycle, which can be anywhere between four Z80 (two 6502 (*4)) cycles in case of a NOP or 19 cycles for EX (SP),HL (*5). The 6502 thus will therefore be stopped at a varying rate between 2 and and 10 cycles.

While this is technically already outside the spec, it makes the Z80 card a great empirical evidence that any NMOS 6502 can be held for 9 µs (*6), as it did work quite well in millions of Apple II or clones.


Lessons to learn here:

  • Simple numbers often so not convey the whole information
  • Datasheets are called religious documents for a reason
  • And like any religious script, interpretation can create schism
  • Secondary literature may add to confusion
  • Otherwise good books (as well as conclusions from great engineers) do need to be fact checked.
  • Empiric research has a hard time when trying to overwrite the scripture

*1 - Nicely shown due the fact that the minimum clock period is the same for 1, 2 or 3 MHz parts.

*2 - Interestingly the very first data sheet and manuals don't give a maximum clock duration, only a minimum, which could lead to the false assumption of a static CPU. Likewise Rockwell's papers.

*3 - Which for all practical use can be done without problems.

*4 - The Softcard runs at double the 6502 clock speed, so two Z80 cycles will make a 6502 cycle, with them being synchronized at every memory cycle (including refresh), so effective speed varies.

*5 - For Z80 specialists: Yes, the EX (SP),IX takes 23 cycles, but there also 'only' 19 cycles between M1, as its prefix is its own M1 cycle, letting the 6502 go for a cycle. In fakt, the rather weird double prefix instructions with offset like RRC (IX+d) feature three M1 cycles, thus turning off the 6502 only for a maximum of 6 cycles.

*6 - Followed by a full 1 µs cycle. It effectively creating a a 1:19 (0,5µs:19,5µs) signal form at 100 kHz, which does work reliable.

| improve this answer | |
  • 1
    Rockwell disagrees with you that their CPU had a static core: "[I]f the input clock is held in the low state for for longer than 5 microseconds, internal register and data status can be lost" (p. 1-16). As for your assertion that most NMOS processors do have a static core, the only worthwhile response I can come up with is, "whatever." – cjs Apr 12 at 14:51
  • The data sheet specifications for phi1 and phi2 are saying what those outputs will do in response to the inputs, and so one would almost certainly depend upon the low period of phi0 and the other would depend upon the high period. Any datasheet implication to the contrary would seem an error. It's certainly possible for NMOS parts to use static logic or CMOS parts to use dynamic logic, but NMOS designs receive some unique advantages from dynamic logic that CMOS designs don't. – supercat Apr 12 at 14:52
  • @supercat Righ, the statement is about the output signals. But it since they are directly derivated from the input, it is only true for an assumed symmetric input. otherwise either of the signals will be out of spec. As a result, the whole document is made under the assumption of a 50/50 duty timing - which can be found in other places as well - don'T you agree? – Raffzahn Apr 12 at 15:14
  • 2
    You misread. I said that "most NMOS processors...do not have a static core." You said that statement is not true. Case closed, as far as I am concerned. – cjs Apr 12 at 15:55
  • 3
    @Raffzahn: Given that the data sheet specifies maximum clock period, and minimum clock high and low times, and has space for maximum high and low times but leaves them blank, I do not think it would have been at all unreasonable for an engineer to infer that the maximum clock high time is the maximum clock period minus the actual low time, and the maximum clock low time is the maximum clock period minus the actual high time. If the actual safe maximum high and low times had been shorter, the data sheet vendor should have specified that. – supercat Apr 12 at 16:29
0

The answer to this is unknown. Test your particular part under a variety of conditions (over all possible temperature, voltage, duty cycle, IO loading ranges, etc.) to get a better guess. But who knows how representative your sample is?

Back then, the tools and NMOS processes were not characterized well enough for the total leakage of a circuit the size of a 6502 to be more than an educated wild guess at some point on a statistical distribution based on some crude (by todays standards) models. Chip tester time back then was likely too valuable to specifically test this parameter. So any timing derived from the data sheet for this parameter was probably just a good guess that turned out to be successful enough to not to require the data sheet(s) to be revised.

| improve this answer | |
  • You don't think that constant testing on the most popular CP/M system in the world was enough to get a reasonable idea that five or six cycles was safe? – cjs Apr 16 at 17:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.