Tuesday, January 3, 2017

Building a 68000 Single Board Computer - It's Alive!



I spent some of my recent holidays wiring up the rest of the board. With about 30 chips and a similar number of discrete components, it was quite time consuming. I followed a wiring color coding convention to distinguish between power, ground, data, address, and control signals.

To minimize the chance of errors I also marked the schematic in red pen for every connection that was made, and "ohmed out" the connections using a multimeter. As work progressed I only made and noticed a few wiring errors. I noticed a couple of small errors in my schematic as well during this process.



Last night I completed the wiring except for some portions that were not yet needed - the second set of EPROMs and RAM chips (not used by the monitor software) and the second serial port.


Today I did a last check that all chips were correctly installed and then powered it up. There were a few good signs immediately: no smoke, no chips got hot, and the current drain was reasonable. The halt LED did not come on, and looking at the CPU signals indicated that it seemed to be executing instructions.

However, no data came out the serial port, which should be expected if the monitor program was running. Some investigation with an oscilloscope indicated that the UART was never being enabled, so I started tracing back the address decoding chain.

I studied the relevant circuitry and looked at the description in the Clements book. Only a few minutes of study led me to realize that there was an error in the textbook and accompanying schematic. The wrong output for decoding the UART address was being used. This was confirmed by seeing that what I believed was the correct output was being enabled.

I made a quick change of one wire wrap, and tried the system again, hooked up using an FTDI USB to serial adaptor to a terminal emulator on my laptop. Sure enough, now I was seeing the monitor prompt!



I was able to type monitor commands and they worked correctly. I did some simple checks of the EPROM and RAM, and they appear to be working correctly. The single step circuit also seems to be working.

I'm amazed that it basically worked the first time. A lot of things had to all come together - the circuit design had to be correct, it needed to be correctly wired, and all components needed to be working.

I updated the schematic on github to correct the error, and better documented the monitor commands .

The next steps are to wire up the second UART and second set of RAM and ROM chips.

After that I can experiment with some more software. I've already entered a small program and confirmed that I can run it from the monitor, including hitting a breakpoint.

In taking some pictures of the board I noticed that it has something in common with some versions of the Raspberry Pi - it is sensitive to the camera flash, and will reset if a flash picture is taken close to it. The culprits are the EPROM chips.

Wednesday, December 28, 2016

Building a 68000 Single Board Computer - Freerunning on Protoboard


I'm now at the stage with the wirewrap version where I was on the earlier breadboard -- I have the clock, power on and pushbutton reset circuits, and CPU wired up so that I can free run the CPU. The power switch and power LED work, as well as the reset pushbutton and reset/halt LED.




By tieing AS* to DTACK* and pulling the 16 data bus lines low, it will continuously execute the instruction $0000 (which corresponds to ORI.B #0,D0) and cycle through all of memory. If I pull some data lines high, it gets an odd address exception and halts with the RESET/HALT LED lit, as expected.



Only five chips are wired up, but the rest have power and ground and bypass caps.


The next step is to wire up most of the remaining circuitry and attempt to get it running out of ROM and RAM. This will take some time as it involves almost everything in the circuit except the two UARTs. I will also only need half of the RAM and ROM chips to run the Teesside monitor program.

Friday, December 23, 2016

Building a 68000 Single Board Computer - Wirewrap Prototype

I've started assembly on a protoboard.



I am using a phenolic board with 0.1 inch hole spacing. I actually glued two boards together using Crazy Glue and some additional pieces of circuit board material for reinforcement to make a board large enough.



I've determined the locations for the ICs and inserted the wirewrap sockets. Until they are wired up, the sockets will fall out if the board is inverted, so to hold them in place I put a small dab of Gorilla Glue on one pin of each socket to hold it in place.



I also mounted the front panel switches and LEDs and some connectors. Power will connect using two binding posts. Two 6-pin headers will connect to the FTDI USB to serial adaptors for the two serial ports. A few discrete parts will be mounted on the perfboard but most will be installed into wirewrap sockets.



I installed 5 nylon standoffs, one on each corner and one in the center, to act as feet and lift the board up above the sockets.



Each IC has a 0.1 uF bypass capacitor installed next to it. There is a single large 100 uF electrolytic filter capacitor installed near the power connections.



The next steps are to wire up power to the power switch and LEDs and some of the ICs, then assemble the clock oscillator, power and pushbutton reset circuits and the microprocessor so I can get it to the same state as I had earlier on the breadboard - being able to run in freerun mode.

Wednesday, December 7, 2016

Building a 68000 Single Board Computer - Programming the ROMs


The original TS2 computer design used 2764 8Kx8 EPROMs for read-only memory. There are four, providing a total of 32KB of ROM. The 2764 type were popular at the time the board was designed, providing a good tradeoff between cost and storage capacity.

These are EPROMs - Erasable Programmable Read Only Memory, programmed using a device programmer which provides the correct timing including a programming voltage (12.5V for these particular devices). They can be erased using an ultraviolet lamp. Erasing sets all bits to ones.

I'm also planning to support 28C64 EEPROMs which are electrically erasable. The device programmer can erase them electrically in a few seconds. You can also write to them in-circuit, but not typically at full speed (you need to wait a short time before subsequent writes).

Because the chips are 8 bits wide and the 68000 has a 16-bit address bus, pairs of ROMs are used -- one for even addresses (D0-D7) and one for odd addresses (D8-D15). There are four sockets on the board, but the TS2 monitor is less than 16KB in size and will fit in one pair of chips.

When you program them you need to split the data into even and odd data. You can either do that when creating the download files, or many ROM programmers can do it directly as an option when loading the files.

My monitor source code when assembled generates Motorola S record files. I added rules to the make file to generate odd and even download files.


My programmer is a low-cost Willem GQ-4X which can program various types of devices,including 2764 EPROMs and 28C64 EEPROMs. The software can perform splitting into even or odd data if desired.


I programmed a pair of 2764 EPROMs and also a pair of 28C64 EEPROMs in preparation for testing the board once it gets assembled.


To erase EPROMs, I have a low cost UV eraser which I bought on eBay. It will erase the devices in about 20 minutes.

Incidentally, the RAM on the system uses 6264 8x8K static RAM chips which have almost the same pinout as the EEPROMs. Four sockets are provided, supporting a total of 32KB of RAM.

Thursday, December 1, 2016

Building a 68000 Single Board Computer - BOM and Preliminary Layout



I spent some time updating the parts list on github, which is available as a spreadsheet and PDF file.


I started a rough layout of the prototype board by printing and cutting out small squares of paper corresponding to each IC and arranging them. I tried to minimize the distance between the chips that interconnect. This gave me the approximate board size needed. I will probably adjust it when I get the proto board as I'm not sure yet if I will put some of the discrete components like pullup resistors on wirewrap sockets or directly on the board.


A 64-pin wirewrap socket is hard to come by, and the lead spacing varies between the different versions of the 68000 chip (e.g. plastic versus ceramic packages). I made a 64-pin wirewrap socket by cutting two 40 pins units with a hack saw.


These are the controls that are planned go on the front of the board:

  • step pushbutton
  • single step/run toggle switch
  • reset button
  • reset/halt LED (red)
  • power LED (green)
  • power toggle switch

I may eventually put the board in a case. If so, I'll either find a commercial case large enough, or maybe 3D print it.

Friday, November 25, 2016

Building a 68000 Single Board Computer - Software

While waiting for the remaining parts, I spent some time getting the software for the board ready.

The Teeside TS2 used a monitor program which is listed in source code form in the book and on the included CD-ROM. The CD-ROM also includes a number of tools including a 68000 cross-assembler and simulator.

The programs are from the late 1980s and were written for MS-DOS (predating Windows). I was able to run the cross-assembler and the simulator under Windows 10 (it needs to be run as Administrator). I was able to run the small version of the monitor called minimon under the simulator. I was also able to run the programs under the Linux program dosbox (an MS-DOS emulator).


I normally use Linux and wanted a native cross-compiler for the 68000 that I could run there. The GNU assembler supports the Motorola 68K family. It is quite easy to build a 68000 cross-assembler under Linux. I followed some instructions I found here. These were the basic steps I followed:

  1. Get GNU binutils, which includes the assembler, by downloading it from http://ftp.gnu.org/gnu/binutils/
  2. Untar the source archive somewhere.
  3. Configure it using ./configure --target=m68k-elf
  4. Build it using make -j4
  5. Install it using sudo make install

The assembler binary is called m68-elf-as.

You can also build the GNU C compiler if you want to do high-level language programming. Quite a bit of code should fit in the RAM and ROM available. The basic steps I followed to do this are (based on http://daveho.github.io/2012/10/26/m68k-elf-cross-compiler.html):

  1. Get the code ftp://ftp.gnu.org/pub/gnu/gcc/gcc-5.4.0/gcc-5.4.0.tar.gz
  2. Untar it.
  3. You will need some development tool packages which vary depending on your Linux distribution.
  4. Configure, build, and install it using:

mkdir objdir
cd objdir
../gcc-5.4.0/configure --target=m68k-elf --enable-languages=c --disable-libssp
make -j4
sudo make install

The C compiler binary is m68k-elf-gcc. Many other tools also get built.

I was able to port the TS2 monitor to assemble under the GNU assembler and was able to generate binaries that match the original from the Teesside assembler. The port can be found here on github.

I also wrote some simple code that plan to use when I start to bring up the board - a simple ROM that will do only a little more than freerun mode, like a simple loop or writing to the serial port. This can be found here, but is still a work in progress and untested.

Future projects, if and when the board is up and running, could include trying to get the TUTOR software from Motorola's ECB board running (the TS2 should be compatible with it). It is a little more advanced than the TS2 monitor and includes an assembler than runs on the board, for example.

There are some free implementations of BASIC for the 68000 that could possibly be ported including http://members.shaw.ca/gbrandly/68ktinyb.html and http://www.easy68k.com/applications.htm

Thursday, November 24, 2016

Building a 68000 Single Board Computer - CPU Freerun on Breadboard


Phase 2 of the project is to breadboard a minimal circuit and get the CPU to run in freerun mode. This also allows testing the power on and pushbutton reset circuits.

The idea of freerun is to get the CPU to execute instructions before the RAM, ROM, and other circuitry is present, by hard wiring the data lines so it continuously reads and executes an instruction. It should then walk through all memory addresses. Often this is done with a NOP (no operation) instruction. Getting the CPU to execute in freerun mode requires minimal circuitry and is a good first step towards getting the system working.

What signals are needed to freerun a 68000? We need:

  • +5V power and ground
  • a clock (CLK) signal
  • proper timing of RESET* and HALT* signals
  • data on the data lines D0 through D15 corresponding to a valid instruction
  • DTACK* pulled low to acknowledge read cycles

The sequence of events in more detail is

  1. RESET* and HALT* need to be asserted and then deasserted to reset the CPU.
  2. The 68000 will do word-size reads from addresses $000000 and $000002 and store the value in the the Supervisor State Pointer (SSP) .
  3. The 68000 will do word-size fetches of the reset vector from addresses $000003 and $000004 and load the program counter (PC).
  4. Execution then starts at the reset vector address read above.
  5. The CPU will fetch instruction words (of varying length) and execute the instruction.
  6. Then it will fetch and execute the next instruction, continuously cycling through memory.

For the 68000, a NOP instruction is $4E71. We can't actually use this because the CPU will read this value as the SSP and RESET vectors, and they need to be even addresses or the CPU will take an odd address exception. If the exception vector address read is also odd, it will then halt the CPU. A convenient value that does work is all zeroes, which corresponds to the instruction ORI.B #0,D0.

Our minimal freerun circuit is basically page 2 of the schematic. In addition we need to pull the 16 data lines low through pulldown resistors to force $0000 on the data bus, and in order to complete the bus cycles we can connect the 68000 AS* output to the DTACK* input.


I built this circuit on a solderless breadboard as in the picture above.

To start, I wired up the clock oscillator. I used a 1 MHz clock oscillator rather than 8 MHz because solderless breadboards don't tend to work well at higher frequencies. I verified it was working with my oscilloscope (which also has a frequency counter).

Then I built the power on reset circuit that uses a 555 timer to generate a suitable RESET pulse on power up. I confirmed that it generated the correct pulse on power on.

Next was the reset pusbutton circuit which uses some cross-coupled NAND gates to generate a clean reset pulse when the button is pressed. This was also working.

Next I wired up the 68000 CPU with the required pullup and pulldown resistors.

A problem I noticed initially with the full circuit was that the 5 volt power supply was dropping too low in voltage. It turned out that the jumper wires and alligator clips I was using were dropping too much voltage. I wired the power supply to the protoboard directly using heavier wires and the voltage then read close to 5.00 volts at the board.

Initial testing shows that the CPU was not executing instructions and was halted, as indicated the HALT* line being asserted (low). I eventually realized that this was because I had omitted the pullup resistors on the RESET* and HALT* lines. They are driven by open collector chips which require pullups to go high. I added the resistors and the CPU started executing in freerun mode. The address lines were toggling correctly at binary rates depending on the address line.


I tried changing the clock oscillator to an 8 MHz unit, and was surprised to find that it still ran. The clock signal was a little rough but this is impressive for a breadboard.

The current draw was 215 mA at 1 MHz and 256 mA at 8 MHz.

I observed the signals on the CPU, which were as follows:

CLK    8 MHz
E      800 kHz, not 50/50 duty cycle (which is normal)
A1     1 MHz
A2     500 kHz
A3     250 kHz
A4     125 kHz
A10    1.95 kHz
A20    2 Hz
AS*    2 MHz pulses
UDS*   "
LDS*   "
R/W*   high (indicating read cycles)
FC0    low  \
FC1    high  > indicating supervisor program
FC2    high /
RESET* high
HALT*  high
BERR*  high

As a test, I pulled data line D0 up. On reset the CPU should then fetch a stack pointer of $00010001 and reset vector of $00010001, causing an odd address exception, double bus fault, and drive HALT* low. This happened as expected.

The power on reset circuit is working correctly, with the CPU starting reliably on powerup. It also reset whenever the switch was pressed.

Connecting AS* to DTACK* was the method suggested in the textbook to get the bus cycles to be completed. An alternate method, which also works, is simply to ground DTACK* (trivia: One of the early manufacturers of 68000-based computers was a company called Dtack Grounded).

An alternate freerun instruction that was suggested in a magazine article I found is $2040, MOVE D0,A0. This requires pulling D6 (pin 63) and D13 (pin 56) high, and the other data lines low. This also worked.

With freerun mode working, I'm ready to move on to the next phase, building more of the circuit on a wirewrapped prototype board. I'm still waiting for my protoboards to arrive before I can start that.