Adding ROM to the BE6502

It is nice to have a microprocessor that executes hard-wired NOPs, but if you want to do something more complicated then it is useful to have some kind of memory, for example a ROM. This is what also Ben Eater’s second video introduces for his breadboard computer. I already had an 32kByte EEPROM chip, just needed a programmer. And if you are building a breadboard computer and your wife understands what an EEPROM programmer is, then you can call yourself lucky. And if she buys you one then even luckier. :-*

Connecting the EEPROM to the W65C02S is straightforward, you just have to look at the pinout carefully. The 6502 has the address bits on the “left” side top-down from A0 to A11, and on the “right” side bottom-up A12-15, and then the data bits from D7 down to D0. The AT28C256 on the “left” side starts on the top with A14, then A12 and then A7 down to A0. Then it has tree data bits D0 (aka I/O0) to D2 (I/O2). On the “right” side from the bottom D3 (I/O3) to D7 (I/O7), then chip enable, A10, output enable, A11, A9, A8 and A13. You can see in the picture below that the wires are a bit messy.

BE6502 with ROM

By the way, I have decided to use a different layout than Ben Eater: I plan to put the ROM and RAM chips to a breadboard above the CPU board, and later on the Versatile Interface Adapter (VIA) beside the CPU.

After putting in the wires, I have connected the arduino in place of the EEPROM to see if the wiring was correct. Afterwards I created the ROM image used by Ben Eater flashed on the EEPROM, inserted into its place. AAaaaand…. it almost worked. You can see the first 10 clock cycles below, 7 steps for reset, 2 for the read of the starting address and the last one is reading the first instruction.

Faulty output

Reading the start address (reset vector) always happens from addresses 0xfffc and 0xfffd, so that’s where you can identify if something is wrong. As you see, somehow address bit nr. 11 was 0 instead of 1. But somehow the data has been read, although some bits were flipped there too. Anyway, first I looked at pin A11, it is easy to find, at the lower left corner of the CPU. I used colored jumper wires, they are in the sequence of red, orange, yellow, green, blue, purple, grey and white. A0 is red, A1 is orange, etc, and then A8 is red again, A9 is orange and so on. On the Arduino I used one row of the extra digital pins (22, 24, 26, … 52). Then the data pins are again D0 is red, D2 is orange, etc and on the Arduino they are in the other row of the additional pins, but only the upper eight (39, 41, 43, … 53).

And as it turned out, I mixed up two green wires! 44 went to D3 and 45 went to A12. This swap is best visible on these two lines, when fffc/00 is expected but f7fc/08 is shown. But, the good thing is that the board itself was ok, just the arduino was connected on the wrong way. After swapping back these two wires, everything was working as expected.

Small remark regarding minicom: if you use Debian, just download the source from git, build, create a .deb package and install. And it works.

Building the BE6502 computer – the microprocessor

As the very first step to build up the actual Ben Eater 6502 breadboard computer is to connect and power the 6502 microprocessor. Just like Ben Eater, we also got the modern variant of the 6502, the 65C02S from Western Design Center (WDC). This time it was my son who came to my help: he took a new breadboard, and following the video he attached the microprocessor and connected all the pins that needed to be connected, including +5V (VDD), GND (VSS) and the clock (PHI2). This is not a complicated setup, but of course one cannot really see what the processor is doing.

Connected 65C02S

To see what’s going on, I took the Arduino and connected all the address pins (A0-A15) and data pins (D0-D7) of the 65C02S to the extra digital IO ports of the Arduino.

Checking address and data lines with Arduino

With a small piece of SW as show in the video I could quickly see what was happening on the address and data buses. I mean almost… somehow the result didn’t match the one that Ben Eater got, but I quickly realized the root cause: he connected A15 through A0 to the even Ardunio ports 22-52, while I connected A0 thought A15. That is in the opposite order. But a quick change in the code fixed it. The final step was to add some resistors to connect the data pins and to hardcode the value 0xAE, so the output on the serial line was then just as expected:

Serial output of the address and data line monitoring

To hardcode the value, you take the binary value 10101110, and connect D7 through D0 with 1k resistors to +5V (1) or to GND (0). You can really read it off from the legs of the resistors as you can see the picture below. My daughter liked it so much that together we calculated how to change the configuration so that it shows 0x2A, because she is in class 2A 🙂

Resistors to hardcode data 0xAE, binary 11101010

New project: learning about electronics

Recently I have stumbled upon some videos from Ben Eater showing and explaining some interesting projects on breadboards. For example building a computer based on the 6502 CPU: https://www.youtube.com/watch?v=LnzuMJLZRdU

I have never heard about breadboards before, unfortunately. As a child I was interested in electronics, but I was not very keen on soldering stuff, and I didn’t have tools or knowledge. So it’s my second chance to start experimenting, so I decided to follow Ben Eater’s videos and build stuff. I have even found a partner for it: my son.

I have ordered some stuff yesterday afternoon. I have found the breadboards suggested by Ben Eater in a dutch online shop, eleshop.eu, much cheaper than on amazon. They are now on the way, expected to arrive on Thursday. The rest I have ordered on reichelt.de, but there you cannot pay with credit card, so I had to transfer the money from our bank account. And as today was a public holiday in Germany, I expect the transfer and the delivery taking a bit more time.