• 0

Anvyl board HID/PS2Keyboard interface


Question

I have an Anvyl board and I want to design logic to use the HID PS2/Keyboard interface on the board.  Is there any additional specification for the Keyboard interface beyond what is in the reference manual?  The reference manual data is incomplete and inconsistent with PS2 interface specifications that I have found (specifically most PS2 interface docs specify that the Keyboard drives the CLK line when the Host sends data to the Keyboard. The Anvyl reference manual implies that the Host sends data to the Keyboard by driving both the CLK and DAT lines).  Since the PS2 interface is implemented in code on the PIC uController there should be some documentation (worst case the uController code itself). If you do not have documentation beyond the reference manual, would you provide the source code for the uController?

It looks like the uControllers can be programmed using connectors J15 and J16.  Will you provide information about how I could (re)program the uControllers (what programmer do I need to purchase to write my own code and download to the uController)?

  Thanks,
     Peter Baran

Link to post
Share on other sites

10 answers to this question

Recommended Posts

  • 0

Hi @pbaran,

The reference does say that the "The keyboard can send data to the host only when both the data and clock lines are high (or idle). Since the host is
the bus master, the keyboard must check to see whether the host is sending data before driving the bus". The reference manual does not describe the process for sending data to the keyboard specifically. We have implemented basic ps2 controllers on multiple boards but they did not handle sending data to the keyboard. I have reached out to verify how we implemented the PS2 for when sending data to the keyboard along with your source code and programming information request for the PIC24.

thank you,

Jon 

Link to post
Share on other sites
  • 0

Hi

You can use the AXI PS/2 IP core that you can find here

There is also a demo project for it here (made for the Nexys Video). The demo basically writes to a terminal opened on the PC whatever you type on the keyboard connected to the board's USB HID port.

I am working on the wiki page for the demo project but for now you can use the IP's documentation to understand how it works.

Sergiu

Link to post
Share on other sites
  • 0


Sergiu :

Thanks for the link to the PS/2 IP core!
The comments in the code described the protocol to send and receive data from the keyboard.  The protocol described is consistent with other documents I have found on the PS/2 protocol - the Keyboard controls the clock when the Host sends data to the Keyboard and the Keyboard acknowledges the transfer.


I am still interested in being able to modify the PIC uController code, I’d like to add a feature that allows the Keyboard to send ASCII characters instead of Key presses.
Even better would be a PMOD with the uController and USB circuitry with 4 signals that allowed many different protocols (PS/2, I2C, SPI, custom, . . .) that would allow any FPGA board to interface to USB devices like Keyboards and Mice.

Thanks again,
   Peter Baran

Edited by pbaran
hit send before I was done
Link to post
Share on other sites
  • 0

I have found this to be a detailed description of the PS/2 protocol: http://www.burtonsys.com/ps2_chapweske.htm

It describes the full bi-directional protocol.

I do have one question in exchange: what kind of keyboard do you use to plug into the Anvyl?  I tried a USB keyboard (and mouse, for good measure), but no go.  The keyboard does nothing, and the mouse sends two transactions when it is plugged in, and then nothing more.  Do I need one of those keyboards that supports both USB *and* PS/2 protocols?

Link to post
Share on other sites
  • 0

I have not tried a Keyboard yet.  I assumed that a standard USB keyboard was going to work.  Other FPGA boards (like the Spartan3E starter board) require a true PS/2 Keyboard with a PS/2 Mini-DIN connector, but the Anvyl board should only work with USB HID(Human Interface Device) Devices like Keyboards and Mice. The PIC uController has a USB interface and the firmware should act as an OTG Host that can access a USB HID device.  The firmware should then take the USB data from the Keyboard or Mouse and send it to the FPGA using the PS/2 protocol (or read data from the FPGA using the PS/2 protocol and send the data to the USB Keyboard).

I did notice that there is a footnote in the Anvyl Reference manual that warns that not all USB Keyboards conform to the PS/2 specifications :

 "Not all keyboard manufacturers strictly adhere to the PS/2 specifications; some keyboards may not produce the
proper signaling voltages or use the standard communication protocols. Compatibility with the USB host may vary
between different keyboards"

I guess I need to get some keyboards and look at the PS/2 signals going to the FPGA.

Thanks for the link to the PS/2 doc.

 

Link to post
Share on other sites
  • 0

Thanks, I did a bit more research.

Apparently a really old Apple USB keyboard does not work (that's what I used initially).  However, a more recent run-of-the-mill USB keyboard worked just fine.  So... for once not a problem with my Verilog!  I suspect that my Apple keyboard was *so* old that the PIC on the Anvil board did not recognize it as a HID keyboard, and thus refused to generate *any* PS/2 signals on the other end (into the FPGA).

All of which makes me think that the note on the Anvil Reference (re. not all keyboards complying with PS/2 protocol) is most likely erroneous (and probably a leftover from older boards where they had physical PS/2 connectors).  I am guessing *any* HID-compliant USB keyboard will work, and the on-board PICs will just generate PS/2 signals in response to ordinary USB interactions with the keyboard. 

On a separate note, I also tried out a USB mouse, and found out that you have to do a little additional work.  When you plug the mouse in, it immediately reports "AA,00", but nothing else.  Turns out that that is the code for, essentially, "hi, I am a mouse" (AA is not a valid keyboard scan code), and the host is supposed to send a "F4" command back to the mouse ("enable reporting").  Haven't done that yet, but found the info at https://wiki.osdev.org/PS/2_Mouse.

That page in turn has a link to a Linux PS/2 mouse driver (http://lxr.linux.no/linux+v3.5.4/drivers/input/mouse/psmouse-base.c) which, if you are so inclined, will let you see the true horror of what manufacturers have done with mice.   I did not know.   :-/

 

Link to post
Share on other sites
  • 0

It's an older ergonomic "split" keyboard, a GoldTouch KeyOvation "model SKR-4200U (PS-2)" / "US model GTN0077".  I suspect it's not possible to get that exact model any more.

One thing that's intriguing, studying the product label, is that "PS-2" in the model number.  It most definitely has a USB connector, not a PS/2 one...

Link to post
Share on other sites
  • 0

@pbaran,

I did some edits to the relevant sections of the Anvyl Reference Manual. To summarize:

The microcontrollers are USB embedded hosts supporting keyboards and mice implementing the USB HID boot protocol. The rule of thumb is if it works in a BIOS setting, it should work with our boards too. Devices with USB/PS/2 dual functionality are still used in USB mode.

The whole set of PS/2 commands are implemented, even keyboard output commands. I could not find the contradictions you mentioned with respect to PS/2 specs. The device (microcontroller) always drives the clock pulses, but the host can pull the line low in certain conditions.

There is a programming header, so you can write your own firmware and program it with Microchip tools. The firmware source code is not public. State your case in an e-mail to support and we might give it to you provided certain legal requirements are met.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now