Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
raga_2618521
Level 1
Level 1
Code Expert

We have to develop PS/2 keyboard using PSOC 4 controller. In that can we use SPI or UART block to communicate to PC PS/2 port.

0 Likes
1 Solution
Alakananda_BG
Moderator
Moderator
Moderator
50 likes received 250 sign-ins 250 replies posted

Hi,

Since this is the data frame format of PS/2,

A data frame is made of 11 or 12 bits (depending on data direction):

  • a start bit (always low)
  • 8 data bits, LSB first
  • a odd parity bit
  • a stop bit (always high)
  • an acknowledge bit (the device pulls the data line low when transmitting from host to device)

Using SPI or UART would not be compatible.

The easiest way to read data sent from a PS/2 keyboard is to use external interrupts. All microcontrollers allow to trigger an interrupt when a specific event occurs on an external pin and most of them have a dedicated external interrupt controller. During device to host communication the host samples the data line when the clock is low, so it’s easy to set up a trigger when the pin connected to the clock line goes low and read the scan code from the keyboard.

Regards

Alakananda

Alakananda

View solution in original post

0 Likes
1 Reply
Alakananda_BG
Moderator
Moderator
Moderator
50 likes received 250 sign-ins 250 replies posted

Hi,

Since this is the data frame format of PS/2,

A data frame is made of 11 or 12 bits (depending on data direction):

  • a start bit (always low)
  • 8 data bits, LSB first
  • a odd parity bit
  • a stop bit (always high)
  • an acknowledge bit (the device pulls the data line low when transmitting from host to device)

Using SPI or UART would not be compatible.

The easiest way to read data sent from a PS/2 keyboard is to use external interrupts. All microcontrollers allow to trigger an interrupt when a specific event occurs on an external pin and most of them have a dedicated external interrupt controller. During device to host communication the host samples the data line when the clock is low, so it’s easy to set up a trigger when the pin connected to the clock line goes low and read the scan code from the keyboard.

Regards

Alakananda

Alakananda
0 Likes