Mostek MK3870 with 14246 ROM Replacement

Me and my big mouth. After the more or less successful resurrection of my borked Cyrus tuner I bragged on the MFB Freaks forum that I could easily write replacement firmware for a dead Philips 22RH798 receiver. This is a TotL (Top of the Line) unit from 1979 and the first Philips receiver to sport digital readout and control. The controller is a Mostek MK3870 with 14246 ROM mask:

Now this chip is a very early MOS IC and as such not equipped with ESD protection. As a result these devices are prone to failure. Of course replacement controllers are not available anymore rendering the receiver (and its siblings 22RH799 receiver and 22RH106 tuner) inoperative.

So I set myself to the task of devving a replacement. My favorite PIC, the PIC16F628A, does not have enough ports to replace the Mostek. I could add a shift register to perform keyboard scanning but I decided that another PIC, the PIC18F2420, would be more appropriate and the resulting kludge simpler. As the code grew and grew and it looked to become the biggest project that I did to date I decided to dedicate it to my brother Warner, who tragically took his own life on 4 May 2021. He never got the help he needed due to the incessant budget cuts in Dutch health care. I blame Mark Rutte and his VVD party.

Back to the Mostek.

Looking at the schematic the controller has four tasks:

There actually is a fifth task which is handling the remote controller only available for the 22RH798 but I decided to leave that for later. If at all. It needs its own dedicated interrupt which is catered for. The preset memory IC6603 (HEF4720) is ignored because the PIC can handle that just fine. Once I had the receiver on my workbench I could start with the PIC adapter:

What a nightmare. I had to change the wiring a few times as I had to assign different ports to allow the firmware to work properly. The old socket had to go because the pins would not fit:

Luckily, the PCB allowed for in-line sockets. Note that the capacitor C2625 (next to "6602") has been changed for a red Wima film one. With the replacement PCB this capacitor should be removed altogether because it has moved onto the adapter board (C2).

Once the hardware was taken care of it was time to do the good old "hello world" routine:

This was version 0.00. Once I got going the firmware quickly ballooned into a huge spaghetti of code. Which is run from only two interrupts: the state machine timer0 interrupt which runs every 100 ms and the PORTB change interrupt caused by the tuning knob. But first the PIC needs to be initialized. This is what happens:

During the development of the init routine I discovered that it is limited by the boot area so I had to CALL the IF offsets. Once this is started and the first message is written to the display ("POLO") the state machine becomes active. This is the timer0 interrupt and it:

What then follows is a mix of RETFIEs and RETURNs. If nothing needs to be done (apart from the clock) the routine is exited. The other interrupt is the PORTB change interrupt. This interrupt is generated when the tuning knob is rotated. This is an optical rotary encoder, lovingly named "pulser" by the Philips engineers. The pulses it generates are run through a schmitt trigger (IC6604) removing the need of debouncing. Decoding the direction of rotation proved trickier than I thought but a bunch of tests work just fine. The knob performs the following functions:

Looks easier than it is because the tuning needs to be checked against the band (FM, MW, LW) and the band edge limits. Once a new frequency has been decided upon this is sent to the PLL (LOADPLL) and shown on the display (FREQDISPLAY). The PLL routine is simple, it shifts the data onto the data lines. This is the predecessor of the I2C interface (as used in the Cyrus). It lacks the handshaking (ACK) and addressing but otherwise is just shifting out data onto a serial line. The display chips proved troublesome to drive due to an error in the SAA1060 datasheet:

The load pulse is wrong and should be like this:

Once I fixed that in the code the display showed its data as intended. Note that the addressing is handled by the DLEN (Data Latch ENable). This is shared by the PLL but as the ICs check the number of data pulses clocked in by the CLB line this works well. This is why the display failed to load in the first place. The SAA1056 PLL needs 17 databits and the SAA1060 display driver 18 including the start bit. Devious! I then quickly got the PLL going after replacing the also borked PLL chip:

Still a bit shaky but that was due to some work that had been done in the PLL circuit. The revision list is a nice history of all the features added and bugs fixed. Even so, there were not even that many bugs...

Of course a big project like this warrants a proper PCB. The adapter socket nightmare above is just not very convenient. Using KiCAD I quicky put together the schematic and the resulting adapter board:

The pin strip headers are actually different (round) to allow insertion into the new socket. Note the two D1 LEDs: this is to allow EEPROM activity indication with a large Textool socket for the PIC. The MCLR reset is different from the original, C2625 needs to be removed. And as always, the last routed wire took the longest...

The PCB is available for purchase now together with the PIC as a kit. Contact me for details:

 

Back to the projects page

Date: 11 December 2021, updated 13 December 2021

CC-GNU GPL
This software is licensed under the CC-GNU GPL.