68hc11 as ps/2 keyboard controller: how is it possible? - Page 1
Forum section: electronics / general

author: DiTBho
author_rank: Super Contributor
timestamp: January 13, 2023, 12:52:02 pm
content: Yesterday I got shocked when I opened a QWERTY ps/2 scan-2 keyboard and found an HC11 chip as controller.So, key scan, key debounce, key decode, and PS/2 protocol all done by a HC11!!!I don't know yet how much it uses, but I know it does not operate in "single-chip mode" but rather in "expanded mode". That's amazing!!! Even because the PS/2 keyboard implement abidirectional synchronous serial protocol.ps/2 lines areopen-collector type; the bus is "idle" when both lines are high: this is the only state where the keyboard (hc11 as kb controller) is allowed begin transmitting data, but the host has ultimate control over the bus and may inhibit communication at any time by pulling the clock line low, so hc11 has to monitor the line, and stop transmitting if the host requires the bus.The ps/2 keyboard has also to generate the clock signal. If the host wants to send data, it must first inhibit communication from the device by pulling clock low. The host then pulls Data low and releases Clock. This is the "Request-to-Send" (RTS) state and signals the device to start generating clock pulses.Code:bus states, ps/2 bus========================state data clockidle high highinhibited high lowhost_RTS low highSo, looking at the communication "hc11-to-host", when the hc11-keyboard wants to send information, it first checks the Clock line to make sure it's at a high logic level. If it's not, the host is inhibiting communication and the device must buffer any to-be-sent data until the host releases Clock.hc11 needs an internal buffer!Also, following the ps/2 protocol spec, the Clock line must be continuously high for at least 50 microseconds before the device can begin to transmit its data.hc11 has internal timers for this.Then it needs to use a 11-bit frames to transmit1 start bit (always 0)8 data bits (least significant bit first)1 parity bit (odd parity)1 stop bit (always 1)and the clock frequency must be { 10 ... 16 } kHz.That's all amazing because hc11 doesn't have any ps/2 hardware.SPI, synchronous serial protocolSCI, asynchronous serial protocol, what we usually call "uart"looking at the wiring configuration, i found that the hc11 used in my keyboard is not using SPI at all but rather this setup:Code:ps/2 clock <------- HC11.uart_rx (crazy? hc11 has to generate the clock!!!)ps/2 data_out <------- HC11.uart_txps/2_data_in -------> HC11.???I still have to figure out how it can generate the 10Khz ps/2 clock, and how it can use the SCI synchronouslyAnyone?

author: pcprogrammer
author_rank: Super Contributor
timestamp: January 13, 2023, 01:24:34 pm
content: Why so surprised that it is using a simple 8 bit micro to do this. PC keyboards have been made with various 8 bit micro's like 8051 derivatives.10KHz is not that much even for these older micro's. Have never used or looked at a HC11, but guess it will have similar performance as 8051 or 6511 micro's. Have used these in multiple projects and managed to do much more then scanning a keyboard and sending out some data.

author: DiTBho
author_rank: Super Contributor
timestamp: January 13, 2023, 01:43:56 pm
content: Quote from: pcprogrammer on January 13, 2023, 01:24:34 pmwell, it's an uncommon and more expensive choice which even takes more space on the PCB in its "expanded mode", since in this configuration hc11 uses external ram, rom, and mux, while a single Intel {8048, 8049} chip with internal ram and rom is usually better, cheaper, therefore the common choice I have ever seen used in a ps/2 keyboard.But I don't know, oh, Saint eBay ... I found it there, the seller has no idea and there's no label on the back of the keyboard, and it is really a weird keyboard with macro keys (you can register a keystroke) and a 4x40 LCD (looks like HD44780-ish)...so who knows ? probably only a few units were custom-made for someone in a super secret department of the CIA or FBI, or something to film x-filesQuote from: pcprogrammer on January 13, 2023, 01:24:34 pmwell, HC11 has internal timers and dedicated circuits for timing, I myself wrote a PWM generator for an ESC (brush-less motor) controller, but... what seems strange and interesting is that the ps/2 lines are not connected to the pins of the timer but rather to the SCI pins.What? Why? How?So, is this some kind of bit-banging to *mimic" the ps/2 protocol? Or is there some trick to advance the internal shift register used by the SCI module? But in this case how is the clock generated?Perplexed

author: DiTBho
author_rank: Super Contributor
timestamp: January 13, 2023, 02:08:23 pm
content: "So how does a PS/2 keyboard interface work?" - Ben EaterThis video on Youtube is as nice as interesting

author: pcprogrammer
author_rank: Super Contributor
timestamp: January 13, 2023, 02:43:30 pm
content: How about some pictures of this special keyboardQuoteYeah with additional ic's it becomes more expensive, but with the external rom it will be easier to extract and reverse engineer the firmware, to satisfy your curiosity.

author: SiliconWizard
author_rank: Super Contributor
timestamp: January 13, 2023, 08:09:15 pm
content: Quote from: pcprogrammer on January 13, 2023, 01:24:34 pmI don't get the surprise factor either. You can use very slow processors to handle a keyboard. All you need is enough GPIOs to scan the keyboard matrix. The scan itself, even including debouncing and whatnot, can be done at a few kHz only, so there's ample processing power in any 8-bit CPU running at a couple MHz. You could do that with an 8-bit PIC running at 100 kHz probably, or even at lower clock rate if you program cleverly.

author: DiTBho
author_rank: Super Contributor
timestamp: January 13, 2023, 08:30:21 pm
content: Quote from: SiliconWizard on January 13, 2023, 08:09:15 pmQuote

author: DiTBho
author_rank: Super Contributor
timestamp: January 13, 2023, 08:32:52 pm
content: Quote from: pcprogrammer on January 13, 2023, 02:43:30 pmreverse engineer the firmware? of course, I will