Not surprisingly, if you put five 8-channel logic level converters together, you'll get a 40-channel level converter. You can use it to interface a retro computer, typically operating at 5V, with a fast microcontroller that usually works at 3.3V.
Why is this useful?Suppose you have an old 8-bit computer with only 16 Kbytes of RAM (such as the ZX Spectrum 16k) or even just 1 Kbyte of RAM (such as the UT-88 in its basic configuration), and you want to give it more RAM. Or perhaps you wish to add a micro SD slot to your 1980s computer in place of a cassette tape recorder. Or maybe the computer only has a few 7-segment displays as its 'screen' and a few keys as its keyboard, and you've decided it's time to upgrade it with a more modern screen and keyboard. Often, designs of such extensions are available, typically involving similarly vintage electronic parts.
However, this path is not for me. As a software engineer, not an electronics engineer, I prefer programming a microcontroller (also known as a microcontroller unit or simply MCU) to achieve the same result. So, what are my options? I need a well-known MCU operating at 5V with enough GPIO (general-purpose input/output) pins and, ideally, sufficient RAM. I know only one such MCU: the Arduino Mega 2560.
Can we use the Arduino Mega 2560?Unfortunately, the Arduino Mega 2560 not only has limited RAM (8 kB) but, more importantly, its 16 MHz CPU is simply too slow for this project. For comparison, the Zilog Z80 CPU of the ZX Spectrum works at 3.5 MHz in normal mode and 7 MHz in turbo mode.
The best Z80 performance I could achieve with the Arduino Mega 2560 is roughly 0.5 to 0.6 MHz, and this is with a 16x2 LCD screen instead of a more typical computer display. Printing on the LCD (that is, using the LCD library) significantly slows things down.
Which MCUs can we use without slowing down the retro computer?I know that the following more or less common MCUs with the Arduino Mega 2560 form factor are faster than Arduino Mega 2560:
- Diligent Max32 (80 MHz, PIC32 family), which is retired and is no longer for sale in the manufacturer's store.
- Arduino Due (84 MHz), which has some user-friendly documentation available.
- Adafruit Grand Central M4 Express (120 MHz), which has a micro SD slot right on the board.
- Arduino Giga R1 WiFi (two cores - 480 MHz and 240 MHz), which has a dedicated 4" display 'shield'.
You could also try a Raspberry Pi Pico or a Teensy MCU.
What's common about all these relatively fast MCUs? Their operating voltage is 3.3V! So, you can't directly connect your retro CPU pins with MCU GPIO pins - even if they are 5V tolerant, they only output a maximum of 3.3V, which may make your CPU memory read operations unpredictable.
That's where a logic level converter is handy.We need 16 channels for the address bus, 8 channels for the data bus, and additional channels for control signals such as memory read, memory write, input/output (I/O) port input, I/O port output etc. (Note that some CPUs, like the Intel 8085, share half of their 16-bit address bus with the 8-bit data bus.) For slower operations, like using a micro SD card, you may need additional channels to signal the retro CPU to wait. If you plan to perform direct-memory access (DMA), for example to render the screen based on the contents of a certain region of RAM, you'll need extra channels to temporarily disable the CPU as well (unless that region of RAM is in the MCU).
To actually come up with a 40-channel logic level converter, Adafruit's long Perma-Proto PCB can come quite handy. First, five 8-channel logic level converters take the whole width of the board. Secondly, you'll need to add pin headers parallel to the converters, to connect the whole thing to your CPU and MCU. You would do it on a custom PCB anyway, so the extra room on the breadboard is not lost. You can also have headers on the 8-channel converters (like on the photo), which can be handy to connect something else to your computer - at the 5V side and/or the 3.3V one.
If you're sure that you're not going to need direct memory access (which means the CPU will be the only one driving the address bus), you can use two 74LVC245 8-bit logic level shifters for your address bus, instead of the more expensive TXB0108 8-channel bi-directional logic level converters. (In the photo above, I actually used three 74LVC245 chips - two for the address bus and one for half of the control bus.) Just keep in mind that this cheaper substitute is not automatically bi-directional (it has a direction-control pin) and that it can only lower a 5V signal level to the 3.3V level, but it can't elevate a 3.3V signal up to 5V. You can also use just four converters instead of five if you only need a maximum of eight control signals.
UPDATE: Existing implementationHalf a year after writing this article, I realized that most of what I discussed had already been implemented in the Teensy Adapter for RetroShield by 8-Bit-Force.
Comments
Please log in or sign up to comment.