Beebthernet

Introduction

My Beebthernet project is an attempt to add ethernet networking to a BBC Microcomputer. Briefly the BBC Micro or "Beeb" is an 8 bit computer from the early 1980s that uses a 2MHz 6502 micro-processor, has 32KB of RAM and 32KB of ROM. It does have a respectable number of IO ports including serial, 8bit parallel, parallel printer, ADC and proprietary.

I've thought about adding networking for many years. At first I looked at a Crystal part that would interface to an 8 bit bus. This would have required me to write a TCP/IP stack. It was at the initial planning of the software design I realised just how much buffer memory would be required to build the TCP packets. I did start coding a stack that would use SLIP as a method of talking to another computer but it was a lot of work so I put the project on hold for a while. Then I discovered the WizNet W5100 chip which has a built in TCP/IP stack in its micro-controller and it was obvious this was the way to go. Things are made easier by the WIZ810x modules which combine the chip, support components, connector and LEDs in a single cheap module. There are curently three versions of the module. The WIZ810MJ which has most of the pins of the W5100 accessable on its connectors however it uses 2mm pitch connectors which are awkward to use and hard to get sockets for. The other two modules are the WIZ811MJ and the WIZ812MJ. These both use 0.1" pitch connectors but differ slightly in how the link, RX and TX LEDs are handled.

Beebthernet Mk 1

BBC Micro Ethernet Schematic V1.1

My first attempt at Beebthernet used the Tube interface on the BBC Micro. The Tube is basically a 2MHz parallel port provided by giving access to the control lines, data lines and some of the address lines of the 6502 micro-processor. The WIZ modules can be addressed three ways. Either as via SPI, as a fully memory mapped part, or using four memory mapped registers. The latter seemed ideal and using the Tube seemed to provide the quickest data transfer between the module and the 6502. However it had a problem! I could read registers but I writing didn't work.

TUBE based interface

The problem is timing. Once upon a time I/O was slower than the processor so you would have to wait or slow the processor to give time for the IO interfaces to respond or react. As time has gone on this has remained true but both processors and IO components have gotten faster. So if you use modern IO parts with older processors (and the 6502 is a 30 year old processor design) it is the processor that is too slow for the IO. When writing to the W5100 the data bus has to stabilise in a shorter time than the 6502 can comply with.

The timing specification for a 2MHz 6502 says that the data bus will be stable ay a minimum of 110ns after the clock E2 goes high. Since reads and writes are made when E2 is high the /RD and /WR lines, which are generated from E2 and the R/W line, will go low sooner than that. The specification for the W5100 says that the maximum time take for the data lines to stabilize is 18ns. I.e. the data bus doesn't stabilize in time. I need to work out a way of delaying the write line signal change by 100ns.

A possible solution is to have some kind of delay on the write line so that it gives time for the data lines to stabilise. I will look at this but I decided to put this version on hold and use SPI interfacing instead.

Beebthernet Mk 2

Description

SPI is a synchronous serial bus for communicating with peripheral chips. It is usually used internally between silicon in a product rather than an user level external interface. It allows the controlling micro-processor to speed up or slow down communications as appropriate. Using the "User Port" on the BBC micro you can generate the appropriate protocol in software. So I prototyped up an interface using breadboard and modules I used for my Vivarium Temperature Monitor and it worked. I could set an IP address and ping the device.

The board uses a WIZ810MJ module in combination with an NKC WIZ810MJ module to breadboard SPI adapter. This small adapter board has LEDs for power, link, speed, RX, TX, collision and FDX; it has a reset switch; and it breaks out the power, SPI bus, interrupt, reset and select lines suitable for a breadboard. A boarduino is used to provide 5V from a power adapter. An LM33V and a couple of capacitors provides the 3.3Vs required by the WIZ module. The module has 5V tolerant signal lines. Which means its can be interfaced directly with 5V logic but needs a 3.3V supply. GND, MOSI, MISO, SCLK and /SCS (Select) are connected to data lines on the BBC parallel port.

SPI based interface

Schematic

Once the prototype was working I set about drawing the schematic for the PCB version of Beebthernet. The circuit comprises a power regulator circuit for 5V and 3.3V rails. There is a diode on the input to protect the board if the unregulated supply is connected reversed and it has an LED indicating the board is powered. There are a couple of sockets that connect to the WIZ module and the Link, RX and TX LEDs are broken out. Finally since an SPI bus can drive more than one device a 74x138 part provides /SCS lines for the WIZ module and a Microchip EEPROM part (which you can use to store network settings in when the power is off). Also the SPI lines, power lines and a couple of select lines are broken out to a connector for a possible daughter board. It was only after the PCBs were fabricated I realised I'd omitted the IRQ line.

Beebthernet Mk 2 Circuit Diagram

PCB

The PCB layout, like the schematic, was created in Eagle CAD. This was the first time I had drawn a schematic and laid out a PCB using software and sent it off to be professionally manufacturered. Due to the urgency (I was preparing for Makerfaire Newcastle-upon-Tyne) I used Olimex. The board doesn't have a ground plane but since the signal frequencies a relatively low it isn't an issue.

Beebthernet

Beebthernet Mk3

I am currently experimenting with an RTC clock chip that has built in EEPROM. This is also an SPI part and will replace the EEPROM in the Mk2 board. I'm also working with SD cards which also have a legacy mode based on the SPI protocol. So the Mk3 board will probably have an on board RTC and an SD card slot.