Close

RetroChallenge 2023/10 Log Entry #1

A project log for PicoRAM 2090

A Raspberry Pi Pico (RP2040)-based 2114 SRAM Emulator & Multi-Expansion for the Microtronic Computer System * RetroChallenge 2023/10 *

michael-wesselMichael Wessel 10/11/2023 at 14:400 Comments

I have signed up for the RetroChallenge 2023/10 - my goal is to turn this into the multi-functional Microtronic extension I've been dreaming of. As described on the RetroChallenge page:

My goal is to create a multi-purpose expansion for the Busch Microtronic Computer (1981, 4bit). I already have a Raspberry Pico set up to emulate the Microtronic's 2114 SRAM. The Pico enables me to store and restore Microtronic memory dumps as files to resp. from SDcard, in milliseconds (the cassette interface takes minutes for a decent program!) By "snooping" the address bus and SRAM (which the Pico emulates), the Pico also knows the instruction currently being executed by the Microtronic. I can hence turn the Pico into a co-processor, adding new op-codes to the original Microtronic. I plan to add op-codes for OLED display output, sound, speech synthesis, a Real Time Clock, as well as bank switching. The goal is to have a working prototype at the end of the Challenge month that can then be turned into a PCB (consisting of a Pico, OLED display, loudspeaker and op-amp, SDcard, speech chip, and a few buttons for the user interface).

As much as I liked the clean look of the Pico Freenove breakout board, the scope of the project now calls for a proper breadboard with some real estate for the different components. This is my current kitchen sink prototype:

You can see it's lots of voltage dividers. In addition to the SRAM cables, there is one new jumper cable that grabs R12 from the board, as described in my previous log entry: https://hackaday.io/project/192655-picoram-2090/log/223457-i-know-what-you-are-doing Unfortunately, it requires a hardware mod to the Microtronic, but it is relatively clean as the single pin header is mounted to an existing via on the PCB.

By now, I have the following components on board:

The OLED display is controlled over I2C, and SPI is used for the TTS and SDCard. I was nervous if the SDcard and TTS would co-exist on the same SPI0 port, but luckily that turned out to be the case. Not sure about the RTC yet.

The biggest challenge was porting the TTS firmware to the Pico VSCode C SDK - my previous projects with the MikroE TextToSpeech were written in WinAVR (e.g., https://hackaday.io/project/165677-lambdaspeak-3 and https://hackaday.io/project/171035-talker80-for-the-trs-80-model-1-3-and-4

Thanks to the excellent Programming The Raspberry Pi Pico/W In C, Second Edition book I managed to port the firmware to the Pico. The Epson firmware image has to be loaded over SPI into the S1V30120 first, and that's not entirely trivial. So, I have a working DECtalk for the Pico now!

Next, for the SDcard, I used the excellent https://github.com/carlk3/no-OS-FatFS-SD-SPI-RPi-Pico library. Worked like a charm.

The OLED driver is supplied with the Pico SDK Examples.

Obviously, a number of user interface buttons are required - since I am running out of pins, I decided to hook up a 5-button resistor ladder to one of the Pico's analog inputs. So it's only 1 pin instead of 5. The circuit (and following schematics) is from the well-known Arduino LCD & Key Shield (3.3V is used for the Pico though):

For sound output, I first looked at https://github.com/martinkooij/pi-pico-tone but had problems getting this to work. So I am simply using hardware PWM to generate sound. This is not as fancy as using the PIO (in pi-pico-tone), but works without bugging down the 2nd core as well.

I am already short on GPIOs - I have exhausted all of the Pico's IOs. For that reason, I cannot use sound and TTS simultaneously. I had to find a compromise, and choosing between either sound or TTS during start-up seemed like a reasonable compromise. A physical double pole 6pin toggle switch is used to toggle between TTS and sound.  

This is the allocation of the Pico pins:

// I2C OLED DISPLAY: 
#define PICO_DEFAULT_I2C_SDA_PIN 20
#define PICO_DEFAULT_I2C_SCL_PIN 21

// SRAM ADDRESS BUS: 2 - 11 
#define ADR_INPUTS_START 2
#define DATA_GPIO_START (ADR_INPUTS_START + 10)
// SRAM DATA BUS: 12 - 16 
#define DATA_GPIO_END (DATA_GPIO_START + 4) 

// R12 DISPLAY MULTIPLEX LINE 
#define DISP_INPUT 0
// SRAM WRITE ENABLE INPUT 
#define WE_INPUT 1

// 5 PUSH BUTTONS VIA RESISTOR LADDER 
#define ADC_KEYS_INPUT 27

// PWM SOUND 
#define SOUND_OUTPUT 28

// EPSON TEXT2SPEECH 
#define EPS_RESET 28
#define EPS_READY 26
#define EPS_CS 22

As you can tell, I can either use GPIO 28 for resetting the TTS, or use it for sound output. I am using the double throw switch for routing; if the switch is in SOUND position, then the EPS_READY pin 26 is pulled high by the switch. The Pico firmware can determine the switch position during boot, and csn act accordingly (i.e., configure itself for TTS or sound). A few more GPIOs would have made this easier.

So, with the hardware and driver software fully operational, I am now in a position where I just need to grind away at the firmware!

I am now using the 2nd core of the Pico to drive the display, user interface, and implement the op-code extensions (as explained previously, extra op-codes for sound, speech, display, and memory bank switching), while the 1st core is constantly emulating the SRAM.

I have 5 buttons for controlling the expansion; from left to right: 

UP, DOWN, BACK, OK, CANCEL

This should be enough to, for example, select files from SDcard, create file names, and control some other functions.

There is a main menu in which the buttons have to following functions: 

By now, I have 8 Microtronic programs in the first 8 banks, and I can toggle through them with the "BACK" button. So banked memory works! 
Next, I am going to implement the SDcard interface (storing the current SRAM bank to SDcard, and loading a memory dump back into the current bank from SDCard). 
And then there is some work to be done for implementing the extended op-codes. Here is the table of the extended op-codes that I am planning to implement: 
0xx ENTER DATA x

500 HEX DATA ENTRY MODE
501 DEC DATA ENTRY MODE
502 DISP CLEAR SCREEN
503 DISP CLEAR LINE <X> 
504 DISP SHOW CHAR <LOW><HIGH>
505 DISP CURSOR AT LINE <X>
506 DISP CURSOR <X> <Y>
507 DISP PLOT <X> <Y> 
508 DISP LINE <X1> <Y1> <X2> <Y2> 
509 SOUND OFF 
50A SOUND PLAY NOTE <NOTE> 
50B SOUND PLAY FREQ <LOW><HIGH> 
50C SPEAK OFF   
50D SPEAK BYTE <LOW><HIGH> 
50E SPECIFY REG <REG> 
50F LOAD VALUE FROM REG <REG>

70x SWITCH MEMORY BANK x
Video soon!

Discussions