I was rummaging around in my parts cabinet and found not one, but two tubes full of 87C51 one-time programmable (OTP) microcontrollers, brand new, but now over 40years old!

The 87C51 was a CMOS variant of the popular 8051 microcontroller, originally released in the early 80’s and is still being sold today as a variety of variants, and even as a core if you want to roll your own. It normally had an internal program ROM (Read Only Memory), which was factory programmed for a custom application. The ‘7’ is this variant indicated that it had an EPROM (Erasable-Programmable Read Only Memory) instead of a factory ROM, which could be programmed in the field. The EPROM was erased using ultra-violet light, to facilitate this the part was packaged in a ceramic case with a glass window. The OTP part was packaged in a plastic case with no window, hence it could not be erased. Once programmed it was permanent. However, the clever folks at Intel designed a methodology into all the 8X51 parts so that they could use an external ROM instead, thus making the OTP part reusable, if it had an external ROM.

An 8051 Microcontroller circa 1980

Back in the early 1980’s I had a student working for me on a testing project, which had a microcontroller component. He used one of these with some software called ‘Tiny Basic’. This implemented a very simple Dartmouth Basic interpreter on the chip, enabling it to be programmed easily. Interestingly enough, it can still be found out there on the web, and several projects have been published, complete with schematic diagrams. This is a powerful educational tool to introduce the concept of embedded controllers, so I set about to build a single board computer (SBC) for this purpose.

The board needed to be able to supply an external ROM for the microcontroller so that the OTP issue could be avoided, some RAM for it to operate, and a flash memory for program storage. I found an interesting design online, by Ronald Dekker, so I captured the schematic and laid out a simple board using KiCAD. I used through-hole components to make it easy to build, all the components are still available from a variety of distributors.

The 87C51 SBC Layout

The board provides a power supply that can support any off available wall wart from 7 to 36V, or a bench supply if you have one available. There is an RS232 connector which supports a connection to a PC for programming, and two expansion connectors for the unused on-chip I/O port and memory spaces. It can be built it the space of a couple of hours.

The microcontroller is the large 40-pin device, to the right are a 32Kx8 SRAM, a ROM which can be either an 8Kx8 or 32Kx8, and a EEPROM (Electrically Erasable Programmable Read Only Memory) for program storage. These are currently hard to find, but the board will function without it. You can read and download the manual here.

The first board was turned up on Nov 24th. The hardware had a couple of challenges of its own:

  1. The Address latch MUST be a transparent, not edge-triggered latch. Also, when using a CMOS part, the HCT series of logic is recommended.
  2. The reset switch had no pull-down to drain the cap, and in a CMOS device that could take a long time. Adding a 1.2K resistor to ground helped it out.
  3. A connection to Pin 27 of the EPROM is missing, this is easily fixed with a small wire.
  4. An RS232 null modem is needed for the serial port.

The firmware itself was a challenge, as the board did not come alive right away. Some takeaways from that part of the project:

  1. Someone had hacked out the auto-baud from the startup routine, it was commented out, and so was some of the other important serial port initialization. I put it back, but fixed the speed at 9600bps.
  2. The maximum line length had to be fixed at 30 characters, due to the limited on-chip RAM and a requirement for stack space.
  3. The RAM initialization uses a clever technique to determine whether internal or external memory should be used for the variables. It writes a value to one location only and reads it back, if it finds the right value, it goes into external mode, if not, it uses internal memory. Due to memory space on the 8×51 parts being limited, it is preferable to always use external memory. So I disabled this and permanently implemented all 26 variables (A-Z), as there is plenty of room in the RAM.
  4. In its original form, all the firmware can do is run the basic interpreter. I added an Intel Hex downloader that adds the ability to download Basic programs to the RAM, and also Assembly language code can be run on the board. This is documented in version 1.1 of the online manual.

The software will be posted on Github when I have finished to make this an open source project.