PS/2 Keyboard not working on the 6502 but is working on a Desktop Computer
Hi everyone,
I am using a micro terminal (found here) with my 6502 computer, and it works perfectly so far. But, the keyboard does not work. I am using a Perixx PERIBOARD-409P Mini PS/2 Keyboard. However, it does work on a normal desktop PC. Evidence that it is working that way - I am typing with it right now.
Anyone know what could be wrong?
P.S: I suspect that new keyboards are somehow not compatible, but I need conformation on that because I don't have an old one and they are kind of expensive.
Posted Mar 18, 2021, 11:01 PM UTC
I looked at the reviews for that keyboard on Amazon and one said " IF YOU ARE TRYING TO BUY A NATIVE PS/2 KEYBOARD, STAY AWAY FROM THIS. THIS IS A USB KEYBOARD WITH A PS/2 CONNECTOR AND AS A RESULT DOES NOT WORK WITH A TRUE NATIVE PS/2 INPUT. "
So that might be your answer. Whatever they did to give it a PS/2 connector might not match the actual PS/2 standard.
I saw that review when I bought the keyboard. I paused a bit on reading it, but since the keyboard didn't cost that much and it's size was just what I wanted I figured I'd give it a try. While I haven't connected it to my 6502 build yet I have confirmed with an oscilloscope that it's sending out PS/2 type data.
When powered up, the keyboard is sending a string of $AA with even parity (Edit: I likely misinterpreted my scan and the keyboard is sending this with odd parity; see comment by u/pjdennis below). Per this link (towards the bottom) this indicates the keyboard is trying to determine the interface to use. The link says you need to send a resend command ($FE) back to the keyboard (note that PS/2 uses odd parity, so typically an $AA with even parity would indicate an error).
I'm not sure what keyboard program u/AndrewCoja is using but a simple version here sends a reset ($FF) when receiving $AA instead of a resend command. It's possible a slight modification of the code is all that's needed (though I didn't trace it fully to see what it does when receiving a byte with even parity). If so, it would appear that the Amazon reviewer either got a usb version of the keyboard or they didn't dive into this as far as needed. Anyway, that's the path I intend to take when I get to hooking up the keyboard.
I also recently purchased the Perixx Periboard-309P PS2 keyboard to experiment with connecting to my BE6502. On the scope I’m also seeing it repeatedly send $AA when powered up—however—I’m seeing the correct (odd) parity.
While sending the repeated $AA codes, the keyboard ignores key presses; it does not send scan codes.
I built a simple circuit to send commands to the keyboard and observed that once the keyboard receives a command, it stops sending the $AA codes and begins behaving ‘normally’, sending scan codes for key presses. It doesn’t seem to matter which command is sent; I tried $FF (reset,) $F4 (enable,) $F2 (read ID,) and $EE (echo.) Each of these commands resulted in the keyboard sending the appropriate command response, after which it began sending scan codes for key presses.
$AA is the code sent by the keyboard to indicate successful completion of self test–see this reference.
My guess is that the repeated ‘successful self test’ $AA codes until receipt of a command, is intended to solve the potential problem of the connected host device failing to receive the $AA. This would be much more likely if sent only once per the published protocol and could result in the host failing to detect the keyboard. This ‘enhancement’ is unlikely to be a problem since any host would likely send commands to initialize the keyboard with repeat rate, indicator light status, etc.
Unfortunately this behavior of the 309P complicates things for those of us who are experimenting, but once it has been sent a command this device does appear to behave just as you would expect for a PS2 keyboard.
Perixx Periboard-309P PS2 keyboard sending repeated hex AA with odd parity after power up
Thanks, that is a lot of helpful information for when I get to adding the keyboard to my build. Yes, I probably misinterpreted my scan. As I recall mine was the same as yours. I've noted it in my comment above.
I'm not sure what program the OP was using, but one of the ones he linked to sent a $FF after receiving an $AA. Per your tests that should have activated the keyboard. So it's still a mystery why he couldn't get the keyboard working.
Yes, non-standard devices do trip up many folks who don't have the tools or patience to troubleshoot. I like the challenge though.
That makes sense.
I can’t really change the code for the keyboard decoder chip because I don’t know how to program in C yet.
I do not have an oscilloscope, but I did make a PS/2 decoder like Ben did in his newest video. The keyboard was acting pretty strangely. It was sending the correct clock pulse, but it kept sending all ones on the all the 12 bits. What this possibly it asking if it was going to use the PS2 standard or the USB standard? Also where would I find a keyboard that has a genuine PS/2 standard? I stumbled across the Periboard-107, but it is by the same manufacturer so I am unsure. The reviews look good though. Even if this works, I still need it to be small like this one because I am making a laptop computer and it can’t be too big. Ideally without the number pad.
[removed]
You are better off trying to make it work with a modern keyboard chip that works on both USB and PS/2. There is some USB handshaking and then the keyboard will give up and assume PS/2 mode. You might need to wait for a few cycles of the keyboard clock before it acts like PS/2.
I tried that as my first option, not wanting to buy some more stuff for this hobby.
But none of my USB keyboards supported this dual mode, thus I opted for an inexpensive, PS/2 keyboard. I also wanted a small keyboard, something uncommon in old PS/2 keyboards.