I am trying to interface a PS/2 keyboard to a MSP430 for a toy. The PS/2 keyboard runs off 5V, but the MSP430 microcontroller runs off 3.3V. So I have a 74LVC245 level shifter to convert between the two.

Now I have this, however, I have discovered that the PS/2 keyboard interface uses open collector signals, so that they can be driven from either end, and apparently using a 74LVC245 with these is complicated. This is the first time I've met such a thing; I'm mostly a software guy.

I'm not interested in sending commands TO the keyboard, only in receiving commands FROM the keyboard, so I never need to drive the data and clock lines from the microcontroller end. Is it sufficient simply to tie the keyboard signals to Vcc via a (large) pullup resistor, so that they stay high when the keyboard's not driving them (this is required by the protocol; if they're not high, the keyboard won't send). But this means that when the keyboard tries to bring the lines low, it's driving against the resistor, and I don't know what the implications of this are. And I don't know whether the 74LVC245 itself has its own pullup/pulldown resistors in the inputs.

Is this a good idea? If not, why, and is there any way I can make this work without having to build a proper driver circuit with resistors?

The 74LVC245 datasheet is here, for reference: http://www.adafruit.com/datasheets/sn74lvc245a.pdf

  • \$\begingroup\$ If you're only interested in the outputs of the keyboard and they're open-collector, then you can use pull-up resistor tied to the 3.3 V rail and wire the keyboard's outputs directly to the microcontroller's inputs. You won't need the 74LVC245. \$\endgroup\$
    – m.Alin
    Feb 24, 2013 at 16:28
  • \$\begingroup\$ Off-topic, but do you have a link to good information on how to work with the PS/2 protocol with a micro? Wasted lots of weekends on it already... \$\endgroup\$
    – user17592
    Feb 24, 2013 at 16:41
  • 1
    \$\begingroup\$ @Camil: tonnes. Right now I'm looking at kbdbabel.org, which even has some protocol converter source for the 8051. There's also the PC keyboard FAQ at ilkerf.tripod.com/c64tower/F_Keyboard_FAQ.html. \$\endgroup\$ Feb 24, 2013 at 16:52
  • \$\begingroup\$ @m.Alin Bah, wish I'd known that earlier. Just to double check: is that completely safe, given that I'm not allowed to drive a microcontroller input above 3.6V and the keyboard runs at 5V? \$\endgroup\$ Feb 24, 2013 at 16:53
  • \$\begingroup\$ I don't want to discourage you, but all my experiences with PS/2 keyboards and mice required bidirectional traffic to get the devices initialized properly. I hope you will prove me wrong. \$\endgroup\$
    – jippie
    Feb 24, 2013 at 16:59

1 Answer 1


This is just an $0.02 thought, and not necessarily an answer.

Level shifting of a bi-direction open-collector signal sometimes is done in I2C bus. There are specialized level shifter ICs for I2C, such as PCA9306, which you could try to adopt for PS/2. There's another method, where level shifting is done with a MOSFET connected like this

enter image description here

This picture shows level shifting of 2 separate lines (obviously). More details in this app note by Philips (now NXP).

  • \$\begingroup\$ Yes, and I wish I'd bought one! Given that I appear to have decided to work with 3.3V microcontrollers in a world where homebrew's designed around 5V (coughArduinocough) it would be a wise investment. \$\endgroup\$ Feb 24, 2013 at 23:08
  • \$\begingroup\$ @DavidGiven There are lots of good but 5V-intolerant peripherals. You would have had to deal with leve-shifting too, should you have chose a 5V controller. \$\endgroup\$ Feb 24, 2013 at 23:22
  • \$\begingroup\$ @DavidGiven By the way, which development environment are you using for MSP430? \$\endgroup\$ Feb 24, 2013 at 23:24
  • \$\begingroup\$ mspgcc and mspdebug, although the current project is in assembly. MSP430 assembly is a joy to work in (although it has its usual selection of weirdnesses). \$\endgroup\$ Feb 25, 2013 at 0:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.