Building a 6502 computer: Episode 2, the pins of the 6502 and connecting for a basic system.

Intro
Here is the venerable 6502 processor,

in this series of articles we are going to build a full computer system based around this 8 bit brain. Today we are going to look at the various pins and how we need to connect them to create a basic system.

A supporting video is available.

Affiliate and other links for parts

Here is a list of parts shown in this video.

United States

Breadboards : https://amzn.to/33w1NYp (Limited Stock!)

Board wire (red, black, white, green, blue, yellow): https://amzn.to/3LIvWVx

United Kingdom
Breadboards : https://amzn.to/3oTBJOo

Note: These are not the ones I’m using in the videos, I’m using BusBoard ones not Elegoo. Busboard are much more expensive but are highly rated. The Elegoo are probably fine, I’ve used other cheap breadboards lots of times and been fine but for full disclosure I cannot vouch for these particular ones. If you can, order from US Amazon, which does Busboard. That’s where I get mine from. The process is just like ordering from UK.

Board wire (red, black, white, green, blue, yellow): https://amzn.to/34IBeA5

Purple board wire : https://amzn.to/3rX3OGn

Other none affiliate links:

W65C02 CPU from Mouser

UK : https://www.mouser.co.uk/ProductDetail/Western-Design-Center-WDC/W65C02S6TPG-14?qs=opBjA1TV903lvWo9AEKH5w%3D%3D

US : https://www.mouser.com/ProductDetail/Western-Design-Center-WDC/W65C02S6TPG-14?qs=opBjA1TV903lvWo9AEKH5w%3D%3D

The 6502

Most of you watching this video will already know that along with the Z80 the 6502 dominated the home computer market in the late 70’s and early to mid eighties. It was an 8 bit processor that could address 64K’s worth of memory, more on this later. 

They had a small instruction set which made them kinda RISC like and had a low interrupt latency because of this. However they did lack in other ways, in particular it was harder to interface them to other chips that might want to access the memory directly and to support a type of ram called dynamic ram. These limitations could be worked around but it was not as straightforward as other comparable processors. If you’re not too sure what these terms mean, don’t worry we will be going through them in more detail as the episodes progress.

Note that I’m going to go through the more modern version of the 6502 from Western Design Centre, called the W ,6,5,C,0,2,. It is mostly pin and fully instruction compatible with the original 6502 but in addition can run at up to 14Mhz compared to the originals 1Mhz and later CMOS 2Mhz version. It also has some extra instructions and addressing modes. 

Wherever differences occur between the various versions I will endeavour to point them out but I would recommend if you are planning to build your own system, that you buy a new Western 65c02 rather than re-use an old one as I will take advantage of new instructions and addressing modes when I see fit. Even in the 80’s Rockwell produced a 6502 that had some additional instructions compared to the original 6502 so this is nothing new and in fact some games and software did come a cropper because of this. I’ll probably do a short no frills video about this for those that are interested, somewhere in between this series of videos.

The 6502 pins

W65C02 with suggested connections for basic system

Pin 1

But, where is pin 1? How do you know? Every chip has a top notch to indicate the top of the chip, the first pin on the left is pin 1. You then count down to the bottom, in this case down to 20 and then count up from the bottom right for the rest, in this case going up to 40.

OK, safety warning, this is really important if you ever want to replace a 6502 in an older system with this new modern replacement. It is virtually hardware compatible but not quite. Pin 1 is the sticking point, that if you don’t make changes then more than likely you’re going to fry your spanking new chip. To explain, this pin on the old 6502 was one of two ground pins. On the newer chips it’s called Vector Pull and is an output set by the processor to indicate that the processor has been interrupted and is about to go to an interrupt address vector, more on this in a later episode.

So as an output it will want to drive this pin high or low. If it drives it high and this is a ground connection on an old system then…. Well…. It’s going to  spoil your day and probably fry your new 6502 – at the least. In this scenario you simply need to cut off or bend this pin up out of the way so it does not connect with pin 1 in the old system. 

With that safety advice out of the way and with the fact we are creating a new system……… let’s talk about this VP pin. 

So it’s labelled VPB, which stands for Vector Pull Bar. The bar part literally means that the VP should have a line above those letters – a bar line – Bar lines above letters on pin out diagrams indicate that this pin is active low, that is, whatever function it does occurs when it is goes low to ground rather than when raised high. 

So in this case if it goes low then the processor is accessing an interrupt vector, again, don’t worry if you’re not following, this is more advanced stuff that I’ll cover in later episodes.

Pin 2

RDY – The ready pin. An input. If high then the processor can run, if pulled low then it halts the processor from executing instructions. This can be handy if we are talking to slower devices in our system or if we want other parts of our system to access the memory, for example video. We’ll cover this in a later episode. 

For now we want our processor to run so we’ll pull it high.

Pin 3, 37 and 39

Pin 37 is our main clock input to the processor. More on clocks in the next episode but basically they are like a heartbeat to the system keeping all operations within the processor and the system as a whole in step with one another. It needs to be a nice clean square wave. Pin 3, PHI1O – Phase 1 clock output. This is an output of the clock you supply on pin 37 but inverse. So if the main clock going into a processor on pin 37 is high this would be low and vice versa. 

Pin 39 is just a copy of the clock you send in on pin 37 and we won’t need that in any of our designs so we’ll leave it unconnected. Why is it there at all when we have our clock going into pin 37 already? Well I think its intended purpose was for clock circuits that could not supply a lot of power or “umph” as we call it in the trade. So this gives a nice higher current copy of your clock for sending out around your design. Our clock circuits will have enough umph so we won’t need this pin I’ve left unconnected.

Pin 4
Pin 4 IRQB – Interrupt ReQuest Bar. If this pin is pulled low then the processor will be interrupted, stop what it’s doing and go and run some code to service whatever interrupt is happening. This interrupt is seen as low priority and can be ignored by the processor by setting a flag, a flag is a bit like a preference setting, sort of. More in a later episode. We have connected it to high so that it’s never interrupted – for now.

Pin 5
Pin 5, MLB – Memory Lock Bar. An output that indicates that the 6502 must have exclusive access to the memory and cannot be blocked. This can help in the design of multiprocessor systems and is beyond the scope of this series of videos at the moment. I may cover it in the future, who knows. For now we’ll leave it unconnected. On the original 6502 this did not exist and this pin was electrically unconnected to any parts of the processor.

Pin 6
Pin 6, NMIB – Non Maskable Interrupt Bar. Another interrupt, this one is used for more timing critical tasks where you want the processor to act quickly, for example disk drives needing attention or perhaps full serial buffers. Unlike Interrupt ReQuest it cannot be turned off in code. For now we’ll tie it high.

Pin 7
Pin 7, SYNC. This output goes high when the processor is fetching an opcode, OK this is all a bit beyond this introduction, so we’ll look at it in later episodes. In short when used with the Ready pin it can enable single step instructions. 


Pin 8
Pin 8, VDD, this is where you shove your 5 volts, although on this newer processor it’ll work with anything from 1.8 volts to 5. However as I envisage connecting up chips that are only 5 volt compliant then we will be using 5 volts.

Pins 9 to 20 and pins 22 to 25
We then come to the address bus which starts with bit 0 of the 16 bit address on pin 9 going to pin 20 for Bit 11, continuing on pin 22 for bit 12 and finishing on pin 25 for bit 15. This is where the processor sends out an address to the system – perhaps memory or a peripheral and either writes data to that location or reads from it. There will be more on this in Episode 3 when we look at busses and binary.

Pin 21
Pin 21 VSS – This is where you connect your 0 volts, the ground pin, nuff said.

Pins 27 to 33
Pins 27 to 33 are the databus connections, eight in all as it’s an eight bit processor, they run  from pin 33 for bit 0 to Bit 7 on pin 27. Again more on this in the next episode.

Pin 34.
Pin 34, RWB, Read Write bar, or as it used to be called Read NOT write. So this is high if the processor wants to read from memory and low if it wants to write. In your system you will then know whether to enable your memory for read or write.

Pin 35.
Pin 35, NC. Is not connected.

Pin 36.
Pin 36, BE – Bus Enable. This is a new input not available on the 6502 that helps with systems where you have more than one device that needs to access the memory directly itself. The most common one being video or graphics operations. We will cover this in later episodes. It needs to be high to allow the 6502’s busses to operate, so we’ve tied it high here and again we also send the signal to our debugger interface.

Pin 37, 38
We’ve talked about pin 37 earlier so we’ll move onto pin 38 SOB, Set Overflow. This is an input pin and setting this low can set the overflow flag in the processor. From all accounts very few systems ever used this. I may cover it’s designers intended use in the future – perhaps, but for now we’ll move on and just tie it high.

Pin 39, 40
Pin 39 has been already covered as well so we’ll move to the last pin, top of the ship, pin 40. RES, Reset Bar. You pull this low for at least two full clock cycles and then high to reset the processor. And for now we’ve connected it to our debugger to perform this task. We’ll look at simple reset circuitry later.

Next Episode
So in the next episode we’ll connect up our clock hardware, power up the system and do some diagnostics.