Converting the IC Station PS/2 Keyboard Interface to ASCII

IC Station PS/2 to Serial/Parallel/IIC/TWI
IC Station PS/2 to Serial/Parallel/IIC/TWI

At VCFMW this fall,  this small board was passed to me to see what I could do with it.  The silkscreen on the back indicates that it is from IC Station.  It is designed to allow a user to connect a PS/2 keyboard to a computing device without having to poll the keyboard signals directly.  It provides an 8-bit parallel output, a 5v serial output, and either I2C/TWI output.

Our original thought was that the adapter would allow us to connect a PS/2 keyboard to a vintage computer that required a parallel input.  However, upon connecting a keyboard, and monitoring the signaling, I discovered that it was only mirroring the values provided by the keyboard to the parallel, serial, and IIC/TWI outputs.

I set it aside, until I had a chance to look at it further, which I did a short time later.

Examining the system closely, I realized that it uses an STM8S003F3 processor.  This is a small 8-bit MCU with 8Kbytes Flash, 1Kbytes of SRAM, and 128 bytes of EEPROM.  It has an internal clock, capable of running at 16Mhz, three timers, and 16 I/O pins.  It uses a single wire interface module (SWIM) for development and programming.

With that knowledge, I ordered an ST-Link programmer and waited for it to arrive.

Upon arrival, I soldered a wire to the reset pin  to the board and connected the programmer to read the contents of the embedded Flash.  Unfortunately, this processor has a read out protection bit, and it was set.  As a result, I was unable to read the existing program.  However, I could reset it, and clear the Flash, which I did.

I was then able to program it with my own program, which reads the values from the PS/2 keyboard and then uses a table to convert them to the correct ASCII values.  These values are presented on the parallel data lines, and the KEY pin is toggled as a strobe.

The Apple 1 requires a reset and clear screen option, which I mapped to F1 and F2.  I use the SCL to act as the clear screen output and the SDA pin to act as a reset.

The board will need a protection diode on the clear screen line, much like I discussed when  attaching a Texas Instruments Keyboard.  Mike Willegal uses this same technique for his PS/2 Keyboard adapter.

The Flash memory contains plenty of room for additional features and this could be used with a mouse, keypad, or the two PS/2 pins could be used as generic I/O pins.

Here is information regarding the connections between the pins available on the board and the STM8S:

PS/2
Clock:  Port D, Pin 4
Data:   Port A, Pin 1
Serial
TX:     Port D, Pin 5
RX:     Port D, Pin 6
Parallel
D0:     Port C, Pin 3
D1:     Port C, Pin 4
D2:     Port C, Pin 5
D3:     Port C, Pin 6
D4:     Port C, Pin 7
D5:     Port D, Pin 1
D6:     Port D, Pin 2
D7:     Port D, Pin 3
I2C/TWI
SDA:    Port B, Pin 5
SCL:    Port B, Pin 4
Enable: Port A, Pin 3
Other:
Key:    Port A, Pin 2

2 thoughts on “Converting the IC Station PS/2 Keyboard Interface to ASCII”

  1. did you test the parallel data if they are present or not. In my case the data is not present.

    Regards

    1. I took a look at the output of one of these this morning. The pin marked key outputs a high while a key is pressed on the keyboard. On the parallel side, the ps/2 key code is output until a new key is pressed. The parallel side appears to be delayed by around 5.5usec from the key output.

      If the led blinks when you press a key, then the serial output is working, as the led is connected to the TX output.

Comments are closed.