4

In my quest to build my first CPU, I am trying to hook up a PS/2 keyboard to my FPGA. The keyboard is a Perixx PERIBOARD-409P.

After a bit of reading, I hooked up the keyboard to a scope to verify its correct behaviour.

Unfortunately, what I get is a flow of continuous 0xAA codes. I am not able to see any other code, no matter what key I press.

This is happening immediately after the LEDs flash. I read here that the LEDs flash during the POST routine. If everything goes well, the keyboard should send a single 0xAA code to indicate a successful POST operation.

What I don't understand is why I keep getting this code and if there is a way to avoid it.

Does someone have any idea about this?

EDIT

I am using the FPGA's 5 V pins only to power up the keyboard. I connect data and clock directly to the scope. I also tried an Arduino, but the result was similar. The following picture shows my current setup:

enter image description here

From what I have understood about the protocol, what should happen is:

  1. The keyboard is powered-up.
  2. LEDs flash and the keyboard transmits 0xAA (BAT)
  3. When I press a key, the keyboard will drive CLOCK low 11 times, and the DATA is an 11-bit serial word: data = [start, d0,..d7, parity, stop]

The problem I have is that the keyboard gets stuck at step 2. It keeps sending 0xAA and it does not send any other code when I press a key.

I also tried to hook up the keyboard to a normal PC, and it works correctly.

What am I doing wrong?

EDIT - 2

After a lot of browsing, I found this post where they explain that the keyboard I am using implements a different protocol from the standard PS/2.

Basically the PERIPERI keyboard sends the 0xAA and waits for the host to reply back. This is the protocol implemented.

So, I ordered a new (very old) keyboard and I will try to see what happens.

  • 1
    Does the keyboard get enough voltage and current so it does not reset? Does your FPGA try to communicate with the keyboard, keeping data, clock, or both low for long periods of time, to make it reset? How did you connect the 5V bus to a 3.3V FPGA? I am just assuming here that you give 5V to keyboard and the FPGA has 3.3V IO, but you really don't give much information to work with. Maybe you have a loose wire somewhere. What have you checked and what have you not checked? – Justme Jun 30 '22 at 04:47
  • You're also trying to "build a CPU" ? – TonyM Jun 30 '22 at 07:22
  • @Justme, I edited the question to clarify. – Giuseppe Rossini Jun 30 '22 at 08:48
  • @TonyM, I am trying to implement the nand2tetris CPU: https://www.nand2tetris.org/ – Giuseppe Rossini Jun 30 '22 at 08:48
  • 1
    It was unrelated to your question...I was wondering if you really meant 'build a CPU'. But, from looking at the course, that's exactly what you're doing. Question upvoted, always great to see people here that are putting the work into their learning :-) – TonyM Jun 30 '22 at 09:01
  • But what is giving power to the system? Is the supply voltage really 5V? What is the scale on the scope waveform? If I'd have to guess it's 2V per div and the communication is not at 5V level like it should be. – Justme Jun 30 '22 at 09:20
  • @Justme, I measured the power supply (of the FPGA) with a voltmeter yesterday and I did get 5.1 V. Off the top of my head, I don't remember to what I did setup the vertical scale on the scope, I will double check tonight and let you know. Thanks! – Giuseppe Rossini Jun 30 '22 at 10:31
  • @TonyM, Thanks! I honestly didn't think it would have been that hard :) – Giuseppe Rossini Jun 30 '22 at 10:31
  • @Justme, I had a look and is it possible that I have 20 volt / div? This is what the scope says (and I double checked , it is not 2.0). Anyway, I might have found the issue: apparently it's the keyboard that is problematic. I will re-edit the question – Giuseppe Rossini Jun 30 '22 at 22:16
  • It can't be 20V/div, as the waveforms are nearly 2 div high and it is unlikely that a keyboard powered with 5V would output nearly 40V signals on a 5V bus. – Justme Jun 30 '22 at 22:50
  • @TonyM DIY electronics has come a long way from a cats whisker wireless set! – Ian Bland Jul 01 '22 at 00:46
  • 1
    @IanBland, yes, hasn't it :-) I first thought the OP might have meant 'build an MCU' using an existing CPU and had just got their terminology wrong. I designed a simple interface CPU in an HDL for a positioning control FPGA some years back and wrote its assembler, used soft CPUs in a few other FPGAs, so it's familiar ground. – TonyM Jul 01 '22 at 08:21

1 Answers1

1

I finally sorted out the mystery. As I pointed out in the comments, it was the keyboards fault.

From the discussion in this thread the keyboard I was using (the PERIBOARD 409P) was following a different protocol from the standard PS/2.

I bought an old PS/2 keyboard from e-bay and the problem was sorted. Now I can finally see the proper scan code for A: enter image description here

Thank you to all commenters for the help!

  • Giuseppe Rossini - Hi, Thanks for coming back with the answer to your question. In order to effectively mark the topic as solved, and since there are no other answers, please consider "[accepting](https://meta.stackexchange.com/q/5234)" your answer (click the "tick mark" next to your answer, to turn it green). That shows that you don't need more help and future readers can quickly see that this was the confirmed solution. Thanks. – SamGibson Jul 05 '22 at 13:00