6502 system schematics

July 18, 2020 ยท View on GitHub

This documentation provides all the information regarding my variant of BE6502 computer:

Deviations from Ben Eater's design

This section describes details of each deviation from original BE6502 design.

Automatic power-on reset

More of a cosmetic thing, but I liked the idea of computer running automatic reset on power-up. The added appeal was that the circuitry is actually copied from the original C64, which makes it instantly 1000x cooler :) You can read more on that here: Dirk Grappendorf's 6502 project - RESET

As a side note - I would strongly recommend anybody interested to read about Dirk's project, he has plenty of great insight there!

Address decoder change

This one was my first real change as in it was mine. As Ben explained in his video, there are many ways to handle address decoding logic and he opted for model with 16K RAM, 16K I/O shadow and 32K ROM. He does note that it's a bit of a waste, but given the simplicity of the project it should not be a problem - and he is absolutely right.

That being said, I wanted more for my build. I knew I wanted to be able to load programs into my computer and I wanted to ensure that I provide user with as much RAM as possible. At the same time, I wanted to save some space on more optimized I/O shadow segment. And, most importantly, I wanted to test my understanding of how address decoding works. As stated above, the best way to learn is to change and test your hypothesis. If you want to learn more, I posted thread on Reddit explaining what I did, how I did that and why I know it works. My build provides 32K RAM, 8K I/O shadow (for up to 11 devices), 24K ROM.

The key takeway here is that when porting Ben's programs you have to use this "mapping table":

SegmentBE6502DB6502Comment
RAM0x0000-0x3fff0x0000-0x7fff
VIA10x9000Connected to keyboard/LCD/blink LED in my build
VIA20x60000x8800Can be used to run Ben's programs
ACIA0x8400
ROM0x8000-0xffff0xa000-0xffffFirst 8K are not accessible, but need to be burned to the chip

Simplest possible example - Blink LED example from Ben's page:

#
# Please see this video for details:
# https://www.youtube.com/watch?v=yl8vPW5hydQ
#
code = bytearray([
  0xa9, 0xff,         # lda #$ff
  0x8d, 0x02, 0x60,   # sta \$6002

  0xa9, 0x55,         # lda #\$55
  0x8d, 0x00, 0x60,   # sta \$6000

  0xa9, 0xaa,         # lda #$aa
  0x8d, 0x00, 0x60,   # sta \$6000

  0x4c, 0x05, 0x80,   # jmp \$8005
  ])

rom = code + bytearray([0xea] * (32768 - len(code)))

rom[0x7ffc] = 0x00
rom[0x7ffd] = 0x80

with open("rom.bin", "wb") as out_file:
  out_file.write(rom)

The same program to run on my build:

#
# Please see this video for details:
# https://www.youtube.com/watch?v=yl8vPW5hydQ
#
code = bytearray([
  0xa9, 0xff,         # lda #$ff
  0x8d, 0x02, 0x88,   # sta \$8802 # MODIFIED HERE - use different VIA address

  0xa9, 0x55,         # lda #\$55
  0x8d, 0x00, 0x88,   # sta \$8800 # MODIFIED HERE - use different VIA address

  0xa9, 0xaa,         # lda #$aa
  0x8d, 0x00, 0x88,   # sta \$8800 # MODIFIED HERE - use different VIA address

  0x4c, 0x05, 0xa0,   # jmp $a005 # MODIFIED HERE - different code start address, so different jump target
  ])

# MODIFIED BELOW - first 8KB of ROM are not really used, but need to be filled out; actual ROM starts at address
# 0xa000 and is of 24KB length
rom = bytearray([0xea] * 8192) + code + bytearray([0xea] * (24576 - len(code)))

rom[0x7ffc] = 0x00
rom[0x7ffd] = 0xa0 # MODIFIED HERE - different code start address

with open("rom.bin", "wb") as out_file:
  out_file.write(rom)

LCD interface change

One of the silly things I decided to do, was to save pins on the first VIA chip and I decided on the following mapping:

PortPinsConnection
PORTACA1,CA2Keyboard controller read handshake - for IRQ based communication with keyboard controller
PORTAD0-D7Keyboard controller data line - for transferring ASCII scancodes of pressed characters
PORTBCB1,CB2Not used, disconnected
PORTBD0Blink LED - to be used as the Arduino onboard LED, for easy debugging
PORTBD1-D3LCD control signals (register select, R/W, enable)
PORTBD4-D7LCD data signals for 4-bit operation

Afterwards it turned out that 4-bit operation is actually bit more complicated that 8-bit, and it breaks compatibility with Ben's programs. My best advice, if you want to run Ben's LCD programs on this build, is to use the second VIA port and 8-bit interface.

If you want to use onboard LCD conector and 4-bit interface it is suggested to use the code I supplied in this repo. It has all the data communication routines for LCD 4-bit operation tested and ready to go.

Extra VIA chip

This one increases cost of the build, but in the end you have the whole chip to yourself, so you can hack whatever contraptions you can think of :)

This extra VIA chip can be also used to run Ben's programs, but you have to remember to update addressing mode.

Extra ACIA chip for serial communication

This one is really important - thanks to ACIA chip you can actually forget about LCD and keyboard altogether, and all the input/output can be handled by the serial port. This also allows you to run programs that are loaded in runtime, over the serial line, making the ROM flashing no longer necessary. Obviously, there is a bootloader program required in ROM and one will be provided in this repo for your use shortly.

Currently my software supports only Rockwell R6551P chips and it uses fully asynchronous, buffered and IRQ driven send/receive operations. In future I plan to add support for WDC65C51 chips, but this requires change in source code to blocking send operation. Not a biggie, just not at the top of my priorities now. More on the ACIA chips below, in the PCB BOM section.

Extra USB->UART interface chip

When I designed PCB for DB6502, I had one goal in mind: it must be possible to solder it with THT-only components. So, if you don't want to play with SMD soldering (which, admittably, is much easier that it seems), you can completely skip this component and connect serial over one of many UART->USB adapters. The same goes for the Micro-USB port - you can skip it, and use only USB-B port for power. Your call.

If you do decide to use FT230X chip onboard, you will have a 6502 computer that requires only USB cable - simply plug it in your PC, connect using serial terminal and you are good to go, nothing else needed. Power consumption is well below USB limits, even with LCD and external keyboard connected.

PS/2 Keyboard interface and ATtiny4313 based controller

This was a bit of an overkill with the serial port addition, but I wanted DB6502 to be versatile and enable operation without PC connected.

Software to be uploaded to ATtiny is also provided in this repo and discussed in detail in dedicated section. You can either program the chip away from the board or use the included AVR ISP interface. I have successfully used USBASP programmer onboard, and since the reset lines between ATtiny and CPU/VIA/ACIA/FT230X are all connected, upload operation simply resets the whole computer without any risk for running programs. Pretty neat, that one :)

Expansion port

The main purpose is to enable easy connection of Arduino-based debugger as used in Ben's videos. Everyone who managed to build the 6502 kit on breadboard knows how difficult it is to manage these connections and prevent them from unplugging system bus wires. In my build there is dedicated connector with several other options.

Beside address bus, data bus, clock and R/W signals, you will also find reset line (can be pulled low for external reset), IRQ input line (can be pulled low to signal interrupt, but can't be used to intercept system IRQs) and IOCS signal from address decoder indicating that CPU is now using address in I/O shadow range.

IOCS line can be used to add additional chips like ACIA or VIA via expansion port. VIA1 is selected using IOCS and A12 line (address 0b1001xxxxxxxxxxxx), VIA2 is selected using IOCS and A11 line (address 0b100x1xxxxxxxxxx), ACIA using IOCS and A10 line (address 0b100xx1xxxxxxxxxx), and you can access external I/O chips using addresses like IOCS and A9 for example (address 0b100xxx1xxxxxxxx). As you can see, it enables up to 8 external I/O chips (last two lines A0/A1 for register select) :)

Modified clock module

I have also modified Ben's design of clock module used in both 8-bit breadboard computer and in 6502 computer. The reason here was pretty similar - modification introduced to validate own understanding of the original design. There was another thing, though - contents of my kit were not aligned with Ben's design (wrong kind of switch) and the design itself had serious flaw. Details of both of these things have been explained in detail here and here.

Migration from VASM to CC65

As much as I liked VASM for small, simple projects, it became quite cumbersome to use when I wanted to introduce different addressing models. CC65 is basically much better compiler for anything 65(C)02 :)

If time allows, I will also provide special versions of Ben's programs written for VASM, but targeted for my own build.

Clock input

Clock signal can be provided in one of three ways:

  1. Use onboard 1MHz oscillator - simply put jumper on J1 connector two leftmost pins,
  2. Use external clock module - remove the jumper from J1 connector, and connect clock signal to middle pin,
  3. Use expansion port - remove jumper from J1 connector and provide clock signal via CLK pin of the expansion port.

Last option will be used in (planned currently) custom debugger board.

Ordering PCB

First revision of PCBs have been released (one for modified clock module and one for the computer itself). PCBs can be ordered here (please note: I get small commission in coupons from PCBWay when ordering using these links. If you don't want that to happen, please download gerbers from the GitHub rulease page and order directly via PCBWay home page):

PCBWay Shared Projects - 65C02 Hobby Computer

PCBWay Shared Projects - Clock Module

65C02 Computer Bill Of Materials

The following components are required for DB65C02 Computer

ReferenceTypeValueDescriptionJamecoDigiKey
C1Unpolarized Capacitor100 nFDisk, 2.5mm raster151116399-4151-ND
C2Unpolarized Capacitor100 nFDisk, 2.5mm raster151116399-4151-ND
C3Unpolarized Capacitor100 nFDisk, 2.5mm raster151116399-4151-ND
C4Unpolarized Capacitor100 nFDisk, 2.5mm raster151116399-4151-ND
C5Unpolarized Capacitor100 nFDisk, 2.5mm raster151116399-4151-ND
C6Polarized Capacitor10 uFTube, 2.5mm raster, 5mm diameter3306921189-2322-ND
C7Unpolarized Capacitor100 nFDisk, 2.5mm raster151116399-4151-ND
C8Unpolarized Capacitor10 nFDisk, 2.5mm raster399-4150-ND
C9Unpolarized Capacitor47 pFDisk, 2.5mm raster2300831399-9737-ND
C10Unpolarized Capacitor47 pFDisk, 2.5mm raster2300831399-9737-ND
C11Polarized Capacitor1000 uFTube, 5mm raster, 10mm diameter3307221189-1745-ND
C12Unpolarized Capacitor100 nFDisk, 2.5mm raster151116399-4151-ND
C13Unpolarized Capacitor100 nFDisk, 2.5mm raster151116399-4151-ND
C14Unpolarized Capacitor100 nFDisk, 2.5mm raster151116399-4151-ND
C15Unpolarized Capacitor100 nFDisk, 2.5mm raster151116399-4151-ND
C16Unpolarized Capacitor100 nFDisk, 2.5mm raster151116399-4151-ND
C17Unpolarized Capacitor100 nFDisk, 2.5mm raster151116399-4151-ND
D1LEDGreen5mm diameter (PWR)2279199754-1263-ND
D2LEDRed5mm diameter (TX)333973754-1264-ND
D3LEDGreen5mm diameter (RX)2279199754-1263-ND
D4LEDRed5mm diameter (BLINK)333973754-1264-ND
FB1Ferrite bead small1844580490-10997-ND
J1Pin header 3x12.54mm raster2057-PH1-03-UA-ND
J2Female pin header 6x12.54mm rasterS7004-ND
J3USB B MicroMolex 105017-0001WM1399CT-ND
J4USB BStandard THT horizontal USB B port20962452057-USB-B-S-RA-ND
J5Barrel JackStandard power input 2.1/5.5101178
J6Mini-Din-6Standard THT PS/2 Keyboard port119475CP-2260-ND
J7Female pin header 16x22.54mm rasterS7119-ND
J8Pin header 3x2AVR ISP 2.54mm raster609-3234-ND
J9Pin header 12x12.54mm raster2057-PH1-12-UA-ND
J10Pin header 12x12.54mm raster2057-PH1-12-UA-ND
J11Female pin header 16x12.54mm rasterS7049-ND
R1Resistor1M1/4 watt691585
R2Resistor47K1/4 watt691260
R3Resistor10K1/4 watt691104
R4Resistor271/4 watt690486
R5Resistor271/4 watt690486
R6Resistor4K71/4 watt691024
R7Resistor4K71/4 watt691024
R8Resistor4K71/4 watt691024
R9Resistor2201/4 watt690700
R10Resistor2201/4 watt690700
R11Resistor2201/4 watt690700
R12Resistor2201/4 watt690700
R13Resistor4K71/4 watt691260
RV1Potentiometer10KPiher PT10-LV10-1031993-1116-ND
SW1PushbuttonStandard 6mm THT pushbutton149948
U1IC74HC212285255296-8266-5-ND
U1Socket14-pin37197ED3314-ND
U2IC74HC0045161296-1563-5-ND
U2Socket14-pin37197ED3314-ND
U3IC74HC0245188296-1564-5-ND
U3Socket14-pin37197ED3314-ND
U4ICNE55527422296-NE555P-ND
U4Socket8-pin51626ED90048-ND
U5IC6551ACIA chip, see notes below43318
U6ICFT230XS768-1135-1-ND
U7IC65C02S2143638
U7Socket40-pin41136ED90059-ND
U8IC28C25674843AT28C256-15PU-ND
U8Socket28-pinOrder two2289583ED90520-ND
U9IC62256824721450-1480-ND
U9Socket28-pin2289583ED90520-ND
U10ICATtiny4313-PUAdd socketATTINY4313-PU-ND
U10Socket20-pin38623ED90036-ND
U11IC65C22S2143591
U11Socket40-pin41136ED90059-ND
U12IC65C22S2143591
U12Socket40-pin41136ED90059-ND
X1Crystal Oscillator1MHz27861X937-ND
X2Crystal Oscillator1.8432MHz27879X939-ND

[ Important note about the ACIA chip: There are basically two types of chips that can be used. Modern, rated to higher frequencies WDC65C51 and older, Rockwell 6551P chips, rated only for 1MHz. The problem with former is that there is a bug with interrupt handling on transmit operation - both IRQ and status flag polling fail, you have to implement dead loop to wait long enough for the byte to be transmitted. Latter chip is probably no longer manufactured, but can be purchased online from Chinese sellers - these are cheap, but not all of them work correctly, so get more than one to be safe. For me the second chip worked correctly and both polling and IRQ-based transmit work as expected.

Notes about the resistors: Jameco sells a resistor assortment that includes all the 1/4 watt resistors required for this project except for 27 ohm and will stock you with resistors for many electronics projects going forward.

Clock Module Bill Of Materials

The following components are required for building Clock Module

ReferenceTypeValueDescriptionJamecoDigiKey
C1Polarized capacitor1 uF2.5mm raster, 5mm diameter3304311189-1401-ND
C2Polarized capacitor1 uF2.5mm raster, 5mm diameter3304311189-1401-ND
C3Unpolarized capacitor10 nF2.5mm raster399-4150-ND
C4Unpolarized capacitor100 nF2.5mm raster151116399-4151-ND
C5Unpolarized capacitor100 nF2.5mm raster151116399-4151-ND
C6Unpolarized capacitor100 nF2.5mm raster151116399-4151-ND
C7Unpolarized capacitor100 nF2.5mm raster151116399-4151-ND
C8Unpolarized capacitor100 nF2.5mm raster151116399-4151-ND
C9Polarized capacitor1 uF2.5mm raster, 5mm diameter3304311189-1401-ND
D1LEDYellow5mm diameter (Automatic tick)34825754-1284-ND
D2LEDRed5mm diameter (Manual mode)333973754-1264-ND
D3LEDGreen5mm diameter (Automatic mode)2279199754-1263-ND
D4LEDYellow5mm diameter (Manual tick)34825754-1284-ND
D5LEDBlue5mm diameter (Output tick)2234071754-1489-ND
J1Female pin header 6x12.54mm rasterS7004-ND
J2Barrel JackStandard power input 2.1/5.5101178
R1Resistor1K1/4 watt690865
R2Resistor1K1/4 watt690865
R3Resistor1K1/4 watt690865
R4Resistor100K1/4 watt691340
R5Resistor10K1/4 watt691260
R6Resistor1K1/4 watt690865
R7Resistor10K1/4 watt691104
R8Resistor1K1/4 watt690865
R9Resistor1M1/4 watt691585
R10Resistor2201/4 watt690700
R11Resistor2201/4 watt690700
R12Resistor2201/4 watt690700
R13Resistor2201/4 watt690700
R14Resistor2201/4 watt690700
R15Resistor1K1/4 watt690865
RV1Potentiometer1MPiher PT10-LV10-1051993-1117-ND
SW1PushbuttonStandard 6mm THT pushbutton149948
SW2PushbuttonStandard 6mm THT pushbutton149948
U1ICNE55527422296-NE555P-ND
U1Socket8-pin51626ED90048-ND
U2ICNE55527422296-NE555P-ND
U2Socket8-pin51626ED90048-ND
U3ICNE55527422296-NE555P-ND
U3Socket8-pin51626ED90048-ND
U4IC74LS0446316296-1629-5-ND
U4Socket14-pin37197ED90049-ND
U5IC74LS3247466296-1658-5-ND
U5Socket14-pin37197ED90049-ND
U6IC74LS0846375296-1633-5-ND
U6Socket14-pin37197ED90049-ND

Building PCB

So, let's assume you got the PCBs and all the components, listed in the Bill of Materials. First thing is to solder the components on. At this stage you have to decide if you want to try soldering on the SMD components - there are two, each of them being totally optional. FT230X chip is required if you want to have onboard serial USB->UART converter. MicroUSB connector if you want to use this connector standard. You can replace MicroUSB with standard USB B port (and you can also solder both, as I did, but only use one at a time).

Other optional components are:

  • UART Port (J2) - it was placed on the board if you decide to skip the FT230X chip, but you still want to use serial connection. You can use this port to connect to one of external USB->UART converters. Please note: if your USB->UART converter doesn't expose CTS/RTS lines, you have to connect CTS and RTS lines permanently to ground,
  • USB-B Port (J4) - if you prefer to use Micro-USB port,
  • Power-In Port (J5) - you can power the computer using any of the USB ports, so this one is optional,
  • PS/2 Connector (J6) - you can skip this one, if you don't intend to connect keyboard. Please note - ATtiny must be connected and programmed even if you don't plan to use keyboard - otherwise the lines would be left floating and could cause strange behavior. You can try grounding them using ATtiny socket, but this has not been tested,
  • AVR-ISP Port (J9) - required only if you plan to program the ATtiny onboard, otherwise you can program the chip externally, but it requires chip removal each time,
  • Expansion Port (J7) - this one can be skipped, if you don't plan to use Arduino Mega bus analyzer nor any extensions, but it's not recommended.

For the soldering, I would suggest to start with the most difficult components - you will probably get more than one board, so use the first one to brave the SMD components. Important step after soldering is to verify if there are any bridges/shorts between adjacent chip/port pins. Since checking the pins itself might be difficult (they are pretty small), it's easier to check on the connected THT pads, and these are:

FT230X PinConnected THT pad on PCB
1RxD pad of UART Port (J2)
2CTS pad of UART Port (J2)
3Bottom pads of resistor R10, R11
4TxD pad of UART Port (J2)
5Left pad of capacitor C8
6RTS pad of UART Port (J2)
7Disconnected
8Left pad of resistor R5
9Left pad of resistor R4
10Bottom pads of resistors R10,R11
11Pad 4 of the ACIA chip (U5)
12Right pad of capacitor C8
13Left pad of capacitor C8
14Left pad of LED D3
15Left pad of LED D2
16Disconnected
MicroUSB PinConnected THT pad on PCB
1Top pad of ferrite bead FB1
2Right pad of capacitor C10
3Right pad of capacitor C9
4Disconnected
5Left pad of capacitors C9, C10

So, to verify that there is no bridge between pins 5 and 6 of FT230X, connect your multimeter in circuit continuity mode between left pad of capacitor C8 and RTS pad of UART Port (J2). If it beeps, you have bridge between these two pins and you need to check your soldering again.

Repeat for each pair of adjacent pins. You want to have zero beeps :) Please note: this only means that there are no bridges, it doesn't guarantee that your chip is soldered correctly, that will be verified later.

After SMD components are in place (or if you skipped them), solder on all the THT components, starting from the smallest ones and going up the size. There is plenty of redundant space on the board, so this should be pretty easy. Make sure to observe polarity of capacitors and LEDs and be careful when mounting ACIA chip - it's actually oriented differently than the rest of horizontal chips on the board.

After all the components are soldered in place, put the chips in sockets (I recommend using two tooled sockets for ROM - one will be soldered to the board, the other one will be used for easy ROM replacement for programming) and check everything once again - orientation of the chips, visible solder bridges, etc. If it looks good, connect power and you expect the power LED to light up. If this works, go to next step, would be building, installing and running sample programs. This is all covered in Software documentation