6502 CPU Stepper - Page 1
Forum section: electronics / beginners

author: Bigmalc40
author_rank: Newbie
timestamp: September 24, 2022, 12:20:34 pm
content: Hi Guy's,Just come across to this site while researching an old 7 segment LED, unfortunately I didn't find the information.However maybe there is someone who may be able to suggest some advice to my new question.I want to debug an Old 6502 computer which is no longer working and think a single step circuit for the 6502 chip would be of some use to me.Does anyone have Experience with the 6502 CPU and could provide a Single Step Circuit.ThanksBigmalc40

author: Ed.Kloonk
author_rank: Super Contributor
timestamp: September 24, 2022, 12:36:00 pm
content: Quote from: Bigmalc40 on September 24, 2022, 12:20:34 pmA youtuber, Ben Eater has a whole channel dedicated to building 6502 kits. I remember he made a clock circuit which would allow advancement of the program counter via a push button.https://www.youtube.com/c/BenEater/featured

author: CountChocula
author_rank: Unknown
timestamp: September 24, 2022, 01:09:28 pm
content: Quote from: Ed.Kloonk on September 24, 2022, 12:36:00 pmBen's videos are great, but please do keep in mind that he's using a modern CMOS version of the 6502, which has a completely static core. Old-timey chips from the 80s cannot be stopped and single-stepped by supplying individual clock pulses—they need a minimum frequency to operate correctly.It might help to hear a bit more about what kind of debugging you're thinking about… perhaps you could achieve your goal without single-stepping, but that's hard to say without more specifics.You could also ask on6502.org. Lots of friendly advice from people who have done all sorts of things with (and to) the 6502.Cheers!

author: Bigmalc40
author_rank: Newbie
timestamp: September 25, 2022, 05:52:56 pm
content: Thanks Ed, there's so much stuff there, I shall have many happy hours reading though them though I can't see any mention of a 6501 stepper.

author: Bigmalc40
author_rank: Newbie
timestamp: September 25, 2022, 05:57:05 pm
content: Hi Count, Thanks for responding to my post, I don't know what you mean by "a modern CMOS version of the 6502, which has a completely static core", What is this?RegardsBigmalc40

author: CountChocula
author_rank: Unknown
timestamp: September 25, 2022, 07:24:22 pm
content: Quote from: Bigmalc40 on September 25, 2022, 05:57:05 pmHi! If your device is really old, it probably uses an older 6502 made in the 80s or 90s. These chips are quite different from the modern 65C02 that is still made and sold by WDC today, like the one that Ben Eater uses in his videos.The modern 65C02 has what's called a “static” core that can be stopped and held in its current state for an indefinite period of time (as long as you supply the appropriate voltage and meet a few other conditions). This allows you to single-step the processor by supplying clock pulses that come at arbitrary intervals; you can quite literally pulse the clock by hand (though you need to be cautious of bounces), and the CPU will happily follow along, once cycle at a time. This is actually pretty cool, because you get to see a lot of what the processor does as it works its way through executing each operation.The old 6502s, like, say, the stock ones you might find in an Apple II or a Commodore 64, cannot do this; they must be supplied a clock of a minimum frequency, or they will misbehave and exhibit unpredictable behaviour. I can't remember the exact minimum frequency, but IIRC it's at least several kHz. If you try to single-step them using Ben's approach, you will get all kinds of confusing weirdness.There is, however, a trick that you can use even with the old CPUs. IIRC, it was something that Woz came up with and takes advantage of the CPU's ability to suspend execution using the RDY signal. I've attached the circuit below, but never tried it myself, as I typically use modern CPUs. I hope this helps!—CC

author: coppice
author_rank: Super Contributor
timestamp: September 25, 2022, 09:21:22 pm
content: Quote from: CountChocula on September 25, 2022, 07:24:22 pmThe original 6502 core used registers that were a lot like DRAM, and required regular refresh, just like DRAM. However, these cores had to be refreshed a lot more often than DRAM. I think the 6502 was similar to the 6800, and the 6800 needed a clock of at least 100kHz.

author: Benta
author_rank: Super Contributor
timestamp: September 25, 2022, 09:40:00 pm
content: The normal 6502 way to do single-stepping would be to have the program to be debugged loaded in RAM.Setting a breakpoint would invoke the Monitor (no, not a CRT/LCD screen, but the resident ROM program) to insert a "BRK" instruction at the relevant location, which would then allow the user to examine the CPU registers and data involved. ("BRK" is a non-maskable software interrupt that should invoke an interrupt handler to display the data).

author: coppice
author_rank: Super Contributor
timestamp: September 25, 2022, 09:43:03 pm
content: Quote from: Benta on September 25, 2022, 09:40:00 pmThat is the approach a lot of early MPU evaluation boards used. Most instruction sets have some kind of software interrupt instruction which can be used in that way.

author: Benta
author_rank: Super Contributor
timestamp: September 25, 2022, 09:49:08 pm
content: Yep, and the only way you can do it with NMOS (and early CMOS) processors.

author: coppice
author_rank: Super Contributor
timestamp: September 25, 2022, 09:52:36 pm
content: Quote from: Benta on September 25, 2022, 09:49:08 pmThere were some dynamic MPUs with specific single step hardware features. You had to keep the clock running with all dynamic MPUs, but that didn't mean instruction processing had to continuously proceed.

author: brucehoult
author_rank: Super Contributor
timestamp: September 25, 2022, 11:17:32 pm
content: Quote from: CountChocula on September 25, 2022, 07:24:22 pmC64, yes. I don't think the 6510 was ever updated.I'm sure there were more Apple II made with CMOS processors than with NMOS 6502.I found the following data, which the author admits is questionable:Code:Apple II 64,700Apple II Plus 545,500Apple //e 4,250,000Apple //c 450,000Apple //c Plus 200,000Apple IIGS 979,000Total 6,489,200Apple //e made between January 1983 and February 1985 (just over two years) used the NMOS 6502, but those made between March 1985 and November 1993 (more than 8 1/2 years) used the CMOS 65C02. As of course did the //c models, and the IIGS (65C816).It's hard to find sales for individual models or years of the //e. I've found one source that says there were 400k //es in 1983 and 1 million in 1984 (the peak). The same source says 300k total Apple II in 1990.By elimination, 4,250,000 //e in total, minus 1.4 million NMOS ones in 1983/84, would mean 2.85 million CMOS ones. Added to //c and IIGS that makes 4.48 million CMOS vs 2.01 million with NMOS.I'll bet its even more skewed if you find a working Apple II in an attic.

author: lapm
author_rank: Frequent Contributor
timestamp: October 02, 2022, 12:12:37 pm
content: Quote from: Bigmalc40 on September 24, 2022, 12:20:34 pmHave you verified there actually clock signal present and for example reset/irq/nmi lines are not stuck in wrong state?