You are currently viewing How to Interface PS/2 with 8051 Advanced Development Board

How to Interface PS/2 with 8051 Advanced Development Board

Spread the love

8051 Advanced Development board

The 8051 Advanced Development board is specifically designed to help students to master the required skills in the area of embedded systems. The kit is designed in such way that all the possible features of the microcontroller will be easily used by the students. The kit supports in system programming (ISP) which is done through serial port.

NXP’s 8051 (AT89V51RD2), 8051 Advanced Development Kit is proposed to smooth the progress of developing and debugging of various designs encompassing of speed 8-bit Microcontrollers.

PS/2 (Play Station 2)

The PS/2 connector is a round shape of 6-pin Mini-DIN connector used for connecting some keyboards and mice to a PC compatible compute r system.

Interface PS/2 with 8051
Interfacing PS/2

Fig. 1 shows how to interface PS/2 port to microcontroller. The PS/2 bus includes both clock and data. Both a mouse and keyboard drive the bus with identical signal timings and both use 11-bit words that include a start, stop and odd parity bit. However, the data packets are organized differently for a mouse and keyboard. Furthermore, the keyboard interface allows bidirectional data transfers so the host device can illuminate state LEDs on the Keyboard.

Interface PS/2 with 8051 Advanced Development Board
Fig. 1 Interfacing PS/2 to Microcontroller

Interfacing PS/2 with 8051

The 8051 Advanced Development Kit includes a PS/2 port and the standard 6-pin mini-DIN connector, labeled U11 on the board. User can connect PS/2 Devices like keyboard, mouse to the 8051 kit. PS/2’s DATA (P8) and CLK (P10) lines connected to 8051 I/O Lines.

Pin Assignment with 8051

Both a PC mouse and keyboard use the two-wire PS/2 serial bus to communicate with a host device, the 8051 in this case.

Circuit Diagram to Interface PS/2 with 8051

Source Code

The Interfacing PS/2 with 8051 program is very simple and straight forward, which controls keyboard and display the keys position into PC through serial port. The C programs are written in Keil software. Some time delay occurring for a single data transmitted into PC. The baud rate used in microcontroller is 9600.

C Program to interface PS/2 using 8051

***************************************************************************************

Title : Program to control PC through PS/2

***************************************************************************************

#include

#include

//PS/2- Keyboard Pin sbit PS2_DATA = P2^0;

//PS2 Data sbit PS2_CLK = P2^1;

//PS2 Clock code unsigned char Key[]={"0F FFFFF FFFFt` as cQ1 ZSAW2 CXDE43 VFTR5 NBHGY6 MJU78 ,KIO09 ./L;P- ' [=\\"};

unsigned char KeyVal,KeyVal2,i=0;

void Serial_init();

//serial initialization unsigned char Scan_Data();

//scan data void putch(unsigned char);

void DelayMs(unsigned int);

/***************************/ /*Main Program Starts Here /***************************/

void main()

{

P2=0xff; Serial_init();

//serial init DelayMs(50);

while(1)

{

while(PS2_CLK==1);

KeyVal=Scan_Data();

if(KeyVal>85 || KeyVal0)

{

del--;

for(j=0;j<306;j++);

}

}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.