VOGONS


First post, by migry

User metadata
Rank Newbie
Rank
Newbie

I did check but no other threads seemed similar.

I have been working on a IBM PC-like 8088 PCB. I have modified the Tandy1000 BIOS to work on my board. My board has a 8255 PPI for keyboard but not the usual TTL circuitry. Consequently I was interested in how I might interface a keyboard (and mouse?) to my board. Given that in the AT system there is a chip specifically to perform this function, I bought a 40 pin device lacelled "AMIBIOS" to see if I could use this as a solution.

I have previous experience (back in the early 80's) of the Intel 8048 microcontroller, so was surprised to find out that the 8042 used the same architecture and instruction set. I was surprised to find out that on the 8042 the RD and WR lines are *inputs* rather than outputs as is much much more common, which allows this device to appear as a memory mapped peripherial in a system such as the 8088. The only other microcontroller which I have seen to implement this behaviour are some members of the PIC family (it's not a common feature/module and the last time I looked it was hard to locate parts with this feature).

I am aware that the ROM code of the 8042 has been dumped. I am pretty sure that it is documented how to "read" the ROM in the databook for the 8048. There is also a disassembly. This is likely to be for a very early clone of the AT 8042 keyboard controller chip. I would be interested to find out if the ROM code for any "newer" 8042 varients has been dumped. This might not be so easy for the custom clone 8042's.

So I found a seller of these parts on Ebay (UK) and bought one for £7. I decided to use a simple Arduino Nano (which has 5V I/O) as a test platform. I searched the net for all the information about this type of part, including datasheets of clone devices.

Here is my board.

AMBIOS low res.JPG
Filename
AMBIOS low res.JPG
File size
471.3 KiB
Views
881 views
File license
Fair use/fair dealing exception

I have wired up the databus, RESET, WR, RD, CS and A0 lines to the Nano. I have connected a PS2 keyboard as that was to hand.

I have spent a few days experimenting. I suspect that different 8042 devices/clones implement different firmware and so have different command sets.

Firstly I discovered that the device is unresponsive until the 0xAA (self test) c0mmand is issued. This is documented on some websites, but it's easy to forget.

I tried issuing all command varients, and the list of those which return values are given in the attached text file. I have no idea if this part works with AT keyboard only, or PS2 keyboard or PS2 keyboard and mouse.

Yesterday I did have the keyboard working, in that I could press a key and read the key value in the 8042 output register. Today the circuit is not playing ball and I'm unsure what is wrong.

Since other buyers have bought "AMIBIOS" devices from the same seller, perhaps if they read this thread they would share any knowledge?

I will return to this thread to add information as I have it.

Attachments

  • Filename
    AMIBIOS.txt
    File size
    2.58 KiB
    Downloads
    85 downloads
    File license
    Fair use/fair dealing exception

Reply 1 of 4, by migry

User metadata
Rank Newbie
Rank
Newbie

Firstly a possibly useful piece of advice (IOW don't make the same mistake as me!). If connecting a 5V USB powered arduino to some other circuity, measure the VCC voltage across this circuitry, and if this voltage less than around 4.7V, then power it from some other 5V supply. My circuit was sort of working yesterday and completely playing up today. The reason was way to low VCC on the AMIBIOS chip which also connected to the keyboard!

I simplified things a little, in that I changed the PS2 connector and keyboard for an AT (5 pin DIN) connector and keyboard.

Now the chip is operating in accordance with the IBM AT specification.

After the mandatory 0xAA Self-Test command you need a 0xAE Keyboard-Enable command. You can then press keys on the keyboard and read them from the lowest address (A2=0, i.e. the data register). The status register (A2=1) indicates whether there is data (i.e. keypresses) available to be read. I was also able to send commands to the keyboard. I tested "reset" and the command the set the 3 status LEDs.

There is a setting register, called (confusingly?) by IBM the "Keyboard Controller's Command Byte". I think of it as the configuration register. It is read using command 0x20 and set using command 0x60 plus a data value to the data register. I was able to confirm bit 6 would change the keyboard mapping from AT to XT values, and that bit 0 would enable port P24 (pin 35) as IRQ2 (it goes high when there is data in the internal buffer waiting to be read).

I confirmed on this particular 8042 AMIBIOS chip that command 0xD1 takes the parameter and uses it directly to update P20 to P27 (pins 21,21,23,24,35,36,37,38) although pins 38 and 38 are connected to the keyboard. Pin 35 (aka P24 / IRQ2) is set/reset when not enabled as the IRQ. In a PC, pin 21 is normally used for RESET and pin22 is used for gating address bit A20. But if using the chip like I am, these pins are general purpose and are set/reset by the 0xD1 command. Pins 27 to 34 are P10 to P17 and are inintialised as inputs. The full 8 bit value can be read using the 0xC0 command.

On various versions/clones of the 8042 some of the pins need to be tied to GND or VDD.
Pin 7 (EA on a real 8042) needed to be tied to GND. If tied to VDD I think it allows the use of an external ROM for code. Certainly the chip goes crazy if tied high (it's probably executing garbage).
Pin 26 (VDD on a real 8042) was tied to VDD.
Pin 5 (SS) could be left floating (perhaps I need to make further checks to be certain).
Pin 25 (PROG on a real 8042) didn't seem to matter and could be GND, VDD or left floating.

I hope this information helps other users of this chip.

I am interested now in re-visiting PS2 mode to try to find out if this AMIBIOS chip also supports a second PS2 channel or mouse.

Do I "rip off the plaster"? IOW do I remove the nice AMIBIOS sticker and find out what the real markings are?

Reply 3 of 4, by migry

User metadata
Rank Newbie
Rank
Newbie
maxtherabbit wrote on 2022-03-23, 14:13:

I'm pretty sure that is a AMI MEGAKEY rev F which does support PS/2 mode

OK thanks, that's a tantalising piece of information ! I do intend to re-try PS/2 mode now I have discovered the "power supply" issue, which likely affected the previous attempts to operate the chip in PS/2 mode.

I did a quick google (AMI MEGAKEY), and found postings by you in a different Vogons thread (Native PS/2 mouse implementation...). I'm surprised that I haven't found this thread previously. It's a wealth of knowledge!!!

In the thread mentioned above, an adapter board using the Holtek HT6542B (8042-like) is discussed together with driver support. A datasheet is readily available for this part, and confirms that it does support PS/2 keyboard and mouse. I did try a search on Ebay UK and I found this part for sale from "Little Rip-off" (not their real name) for £24.99 . Ouch!

Perhaps I am spending (wasting?) a lot of time trying to figure out how a random 8042 keyboard interface clone IC (bought on Ebay) works, when I could instead buy a new one with known datasheet ¯\_(ツ)_/¯ , nevertheless it's sort of a challenge.

Nevertheless I will be making a PCB for this chip, with an AT socket, to allow it to be connected to my 8088 PC-clone development board.