DIY ("Do-It-Yourself") 6502 computer

by Douglas Beattie Jr.

This is a hypertext version of my article which appeared in issue #78 of TCJ (The Computer Journal) -- you can order the hardcopy as a back issue from them.

There are many eight-bit processors, which have been around for a long time. One of these is the 6502, which has been used in a number of home computers. The 6502 is an ideal processor for a prototype. It is also quite affordable.

The 6502 prototype

A prototype is a basic model from which to build and expand upon. It allows us to evaluate and analyze a minimum system. With a prototype, we can study the operation of components functioning as a system.

This allows us to gain experience with the components, and better understand how they work. It would be difficult to study a component in detail without using it as part of a system.

As an example, perhaps there is a particular RS232 communications chip you wish to learn more about. It is not practical to use the chip all by itself. We connect it to other chips (components) and utilize its ability to communicate. If it is a chip we haven't used before, then we must learn to "speak its language," learn how it operates. One practical way to do this is with other computer chips, on a little circuit board, working together as a system. This type of system is often referred to as a prototype.

The 6502 prototype board is surprisingly easy to build, and if you build it on a bigger board than is needed, it can be expanded and enhanced later.

After you understand the minimum system (your prototype) you can add other things like a printer port, floppy drives, and even a hard disk, CD-ROM, plotter, or whatever.

At first, we want a real feeling for the capabilities of the 6502 prototype board, so at least let's have a keyboard, and a video screen to communicate with it. A computer terminal does both.

We can use the 6502 CPU to operate the communications chip. The communications chip already knows how to communicate with the RS232 modem port on our PC.

If you have a terminal, fine. Use that. If you have a TRS-80, you could use that as well. I also remember somebody mentioning once that a dumb terminal was a perfect application for a PC. All we do is run QMODEM or TELIX or PROCOMM or whatever... and instead of initializing a modem and dialing it, we fire up the little computer board and compute on it.

Overview

This is the computer board; you should build it. It's just a prototype, but the potential is here to expand and modify into many useful things. It consists of the following circuit chips.

6502 CPU -- the heart or "engine" of the system.

2K or 8K EEPROM (jumper selectable)
-- a special type of Read-Only Memory, also known as "E-2-prom," this is like EPROM but no dangerous ultraviolet rays are required to erase the chip. It is erased electronically.

32K Static RAM -- usually called "S-ram," static RAM is simple to interface.

6522 Versatile Interface Adapter -- combination of two parallel I/O ports (each with eight synchronized lines, like for a printer device), and timers. Timers are useful for one-shots or counting duration, or alarms for overtime, etc.

  • one-shots:
    something happens for a precise timed duration. It might be a length of a tone, squirt of fuel or a douse of water, or a shot of air.

  • duration:
    how long something happens .. perhaps how long after dawn your street light finally decides to go off. How long it takes your little heater to heat the backyard pool up to comfy.

  • alarms (time-out): been in the freezer room for too long? an alarm sounds.

  • 6551 ACIA
    -- the Asynchronous Communications Interface Adapter. Don't let the long technical name fool you. It's fairly simple. Basically, it provides the interface to a modem or to another computer.

    The ACIA connects your terminal to the computer board, so you can interact with your computer board, update information, set parameters of operation, duration of timing, error correction factors, etc.

    Basically, that's it... CPU, RAM, ROM, VIA and ACIA

    Other Chips

    The 7404 (chip U2) is an inverter. It produces a high level from a low input, and a low level from a high input.

    The 74LS139 (chip U3) is similar to the popular 74LS138, but instead of producing eight signals from three lines, it produces four signals from two lines. The 74LS139 also includes two identical decoders within one package.

    The MAX233 (chip U7) is a single-chip solution for RS232 line drivers/receivers, producing the proper voltage transitions between 5-volt TTL level and 12-volt RS232 level. It is an ideal chip for serial communication when only 2 input and 2 output lines at most are needed. No external capacitors are required, and it draws very little power.

    Theory of operation

    System ROM is jumper-selectable. The jumper option allows either 2K ROM or 8K ROM, addressing the 2K option at $F800, or the 8K option at $E000. The schematic references an 8K (28-pin) socket, but no distinction is made between the two -- either ROM will work effectively if the jumper is set correctly.

    Address decoding for upper memory is accomplished using 1/2 of a 74LS139 (chip U3A).

    The 6522 VIA is decoded at location $C000..C00F. Chip selects come from chip U3A and address line A12 (inverted).

    The 6551 ACIA is decoded at location $D000..D003. Chip selects come from chip U3A and address line A12 (true).

    The CPU clock comes from a 1_MHz crystal oscillator. VIA and ACIA clocks are driven from the buffered CPU clock PH2 (for greek letter "phi", and 2). The ACIA also utilizes a separate 1.8432_MHz crystal oscillator for baud rate generation.

    A full 32K of RAM is located at $0000..7FFF. Chip select for this RAM is provided by CPU address line A15; when A15 is low, the 32K RAM is selected. Read and write signals are provided by U3B, another 1/2 of a 74LS139.

    Construction

    It seems that wire-wrap is the way to go. Now, if you have tried to wire wrap before, and were not successful, this time you should be:

    1. because there is a wirewrap list.

    2. I drew the schematic to represent the component layout.

    You don't have to build it this way, but I tried to make it easy for you. With a few sockets and a perfboard, you can build the prototype.

    There is a drawing of where the sockets should go.
    - try to position the sockets on the perfboard according to the diagram.

    There is a schematic which closely resembles the actual layout.
    - follow the schematic as you build it; refer to it throughout.

    There is a systematic wire-wrap list.
    - not much more difficult than a dot-to-dot.

    There is also a parts list.
    - I picked all parts that are available from Jameco Electronics. Jameco has been around for many years and has competetive prices.

    Be sure to use Wrap ID tags. These are worth the extra cost. The task of wire wrapping becomes a smoother process.

    Parts

    The toughest part of this whole project will probably be filling out an order.

    Filling in an order form, and punching in all those part numbers is not exactly my idea of fun. Any spreadsheet program makes light of the job. I used a really old version of Lotus 1-2-3 (the one that runs on a PC-XT) -- it worked just fine. And evidently Jameco didn't mind. Their service was fast.

    Call Jameco for their latest catalog at (800) 831-4242, or e-mail them at info@jameco.com, or request a catalog through their computer bulletin board at (415) 637-9025.

    ((( see parts list )))

    Software

    If you do decide to build this prototype, and then expect it to do something, it will need two things:

    An application -- what the computer will be applied to do. Applications can be simple or complex, depending...

    A program in ROM. That would be software, but we call it firmware when it is programmed into an EPROM or EEPROM. Program development usually requires a cross-assembler. You can also "hand-assemble" without an assembler program.

    I wrote a short test program to verify that the board is working. BB0010A.AS transmits a sequence of "01234567" repeatedly to the serial channel, while at the same time receiving keys through interrupt. Whenever a key is received, it is also re-transmitted to the serial port. While all this is happening, parallel port B is turning LEDS on and off. This assumes that you have put eight LEDS on the parallel port.

    You might wire a 20-pin socket to port B of the VIA (as I have done). By using a ribbon cable with IDC socket plugs on each end, you can do all further experimenting on a breadboard. Use port B, because it can sink more current (handle a bigger load). The test program BB0010A.AS is only to prove that the board is working. I might provide a follow-up article which will give some more software examples.

    ((( see BB0010A.AS source code )))

    If you already have a 6502 assembler, then cool. Otherwise, scour the internet; I have found 6502 cross assemblers in any one of six different locations. I also wrote one for IBM-compatibles. This is MAS65.EXE and can be found at my web site, URL
    http://www.hytherion.com/beattidp/

    If you don't have access to the internet, my advice is GET IT. You have no excuse not to. It is affordable, easy to learn, and readily available. It can be accessed through an x86 PC or a CP/M machine or even a dumb terminal. You probably would use the x86 PC since more cross assemblers are available for the PC. I also saw a CP/M cross-assembler for the 6502 somewhere.

    Applications

    You tell me! What would you use a small computer board for? (Note one example above for the deep freezer time-out alarm.) Feel free to send some suggestions via E-mail or Mail. The 6502 prototype is rather powerful; plenty can be done with it.

    More To Come

    In the future, we will look at ways to enhance the 6502 CPU, expanding its ability. I will provide functionally equivalent TTL and PLD examples, along with a diagram of the state machine.

    Further Reading

    David L. Wagner, Digital Logic, Harcourt Brace Jovanovich Inc., pp 265..275, 1988

    Ronald A. Reis, Electronic Project Design and Fabrication, Merrill Publishing Company, pp80..83, 1989

    Rodney Zaks, 6502 Applications, Sybex Inc., 1979

    Rodney Zaks, Programming the 6502, Sybex Inc., 1980

    References and Data

    Rockwell International, R650X and R651X Microprocessors (CPU), Document No. 29000D39; Rev 8; June 1987

    Rockwell International, R6522 Versatile Interface Adapter (VIA), Document No. 29000D47; Rev 9; June 1987

    Rockwell International, R6551 Asynchronous Communications Interface Adapter (ACIA), Document No. 29651N90; Rev 4; June 1987

    Rockwell International, R6500 Microcomputer System Programming Manual, Document No. 29650N30A; Rev 3; April 1984

    NEC Electronics Inc., Memory Products Data Book, Volume 2 of 2, Document No. 60105-1-V2, 1993

    Xicor Inc., X28C64 8K x 8 bit 5-Volt Byte-Alterable E2PROM, document 3583-2.4; 7/24/95

    National Semiconductor, LS/S/TTL Logic Databook, 1989

    Maxim Integrated Products, +5V-Powered, Multi-Channel RS-232 Drivers/Receivers, document 19-4323; Rev 3; 5/94

    Contacts

    (contact information was accurate in 1995, but phone numbers and URLs may be outdated or gone.)

    Rockwell International
    (714) 833-4600
    http://www.rockwell.com/

    NEC Electronics Inc.
    (415) 960-6000
    http://www.nec.com/

    Xicor Inc.
    (408) 432-8888
    http://www.xicor.com/

    National Semiconductor
    (800) 272-9959
    http://www.national.com/

    Maxim Integrated Products
    (408) 737-7600
    http://www.maxim.com/

    About the Author

    Douglas Beattie Jr. is an independant consultant for electronic design and development. He left school early, as he was much too busy studying the minutiae of state machines and combinatorial logic to be sitting in a classroom, learning at a standardized rate. He enjoys reading databooks and scrutinizing waveforms; designing prototypes; preparing technical reports, and documenting his work for future reference. His personal library consists of over 450 books and technical manuals, with not one work of fiction.

    Write to Doug at his office:
    This address is current.

    Douglas Beattie Jr.
    ICONIX Research
    5875 S. Adams Ave., Ste. 222
    Ogden UT, 84405-6961


    email: beattidp@ieee.org


    EOF