Commodore 64 Keyboard-to-USB Converter for Use with VICE and MISTer

Pi Pico-powered converter: MISTer, VICE, and ASCII.

James Lewis
1 year ago β€’ Retro Tech

Software emulators like VICE and hardware re-implementation (FPGA) options like MISTer emulate the Commodore 64 computer. They both do a fantastic job of replicating the low-level hardware's behavior. However, one aspect neither solution has an ideal solution to emulate is the physical keyboard. The Commodore 64 did not use an ASCII-compatible keyboard. Also, it contains many Commodore-specific keys. (The special symbols are called "PETSCII.") So it is terrific to see YouTuber Rumbledethumps adapt a Commodore 64 keyboard to USB with a Pi Pico β€” and then support both emulation options!

The Commodore VIC-20 and C64 have the same keyboard layout and interface. Most of the keys are on a matrix. The only one that is separate is the RESTORE key, which is connected to a one-shot timer to provide a properly timed reset pulse. By scanning the keyboard matrix, you can see which keys are pressed and act accordingly.

Today keyboards contain a dedicated microcontroller and then talk to the computer via USB (or Bluetooth.) But back in the 8-bit computer era, the keyboard connected to some controller on the logic board. For example, a dedicated "keyboard encoder" scanned the matrix in the Apple II series. This encoder was a 6502 microprocessor with masked ROM! Alternatively, the C64 keyboard interfaces to a 6522 peripheral controller, relying on the CPU to scan the matrix.

Since the keyboard is "just" a matrix, it is relatively easy to interface with a modern microcontroller. In the case of the C64, the keyboard has a 2.54mm header-socket connector. So, it is easy to connect the standalone keyboard to the GPIO pins of a Pi Pico β€” which is what Rumbledethumps CBM2USB does!

The real trick of this project is what to do with the decoded keyboard signals. CBM2USB has three operation modes: ASCII, VICE, and MISTer. VICE and MISTer map a PC's USB keyboard slightly different from each other, so you need slightly different maps. Also, each has different "hotkey" combinations to perform actions within the emulator. The ASCII mode is useful for computers that accept ASCII inputs.

One such example is Rumbledethumps's Picocomputer. It is a 6502-based computer that uses Pi Picos for power, clocking, video, audio, WiFi, and USB. ASCII mode works with it. So, there is a Pi Pico to transform the C64 keyboard into a USB device. And then another Pi Pico to transfer the USB keyboard back into ASCII!

You can find 3D-printable STLs for keyboard stand-offs and code examples in the CBM2USB repository. Rumbledethumps also provided detailed Pi Pico C-code examples that build up to the final code.

James Lewis
Electronics enthusiast, Bald Engineer, and freelance content creator. AddOhms on YouTube. KN6FGY.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles