EmbeddedRelated.com
Forums

PS/2 mouse interface with 8052 microcontroller

Started by Ab Sah January 15, 2005
I am tring to interface  PS/2 mouse (optical) with a 8052 (AT89S52)
microcontroller. From what I get from the internet without adding any
extra hardware I cannot interface the mouse directly with the UART
(serial port) of the microcontroller (mouse has data and clock lines;
uC has RXD, TXD).
1. Are baud rates defined for asynchronous serial communication? What
are the common baud rates used for PS/2 mouse communnication?
2. Would transmitting at any one of these baud rates allow me to
communicate with the mouse or is the baud rate for the mouse fixed for
receiving data?
3. I am not using the inbuilt routines for serial communication, I'll
be using inbuilt timers for transmiting data. What values should I set
for the timers so that I could generate both clock and data on port
0(?) ?

Does the entire idea sound feasible?

Thanks
-Sahai
India
>Subject: PS/2 mouse interface with 8052 microcontroller
> >I am tring to interface PS/2 mouse (optical) with a 8052 (AT89S52) >microcontroller. From what I get from the internet without adding any >extra hardware I cannot interface the mouse directly with the UART >(serial port) of the microcontroller (mouse has data and clock lines;
The mouse generates the clock, the data is latched on one of the edges,I forget which, when it sends data to the pc and the other edge when the pc sends data to it, just like a keyboard. You need to connect the clock line to an interrupt input and the data to a bidirectional port bit. Then you need to write the software. You could just use an old mouse that sends ascii or buy a ps2-ascii converter.
yes, i figured that much, but when i have to send a reset signal (0xff)
and 0xf4, at what rate should i generate the clock (& data) from the uC
side?
i don't think it'll work without a timed delay because i'm using a
11.0592 mhz crystal and i read somewhere that the mouse works between
10 and 16 khz?

thanks

The device (mouse/keyboard) ALWAYS generates the clock. The clock is in 10 -
16.7 kHz range.

The device will start sending data when the line is at idle state (DATA and
CLOCK are held at logic high). To send data to the device, you must signal a
Request-to-send state, which is done by first pulling CLOCK to logic low.
Then pull DATA to logic low, and restore CLOCK to logic high, in this order.

After this, the device will start generating clock signals, and you can
start pushing data out when the interrupts arrive. In host-to-device
communication, data bit changes when the clock is low. When the clock goes
high, device will read the data bit.

For more specific information about the PS/2, read the following web page
through. It explains pretty much everything you need to know.

http://panda.cs.ndsu.nodak.edu/~achapwes/PICmicro/PS2/ps2.htm

-Antti Keskinen 


got it.. thanks :)


Ab Sah wrote:

> I am tring to interface PS/2 mouse (optical) with a 8052 (AT89S52) > microcontroller. From what I get from the internet without adding any > extra hardware I cannot interface the mouse directly with the UART > (serial port) of the microcontroller (mouse has data and clock lines; > uC has RXD, TXD). > 1. Are baud rates defined for asynchronous serial communication? What > are the common baud rates used for PS/2 mouse communnication? > 2. Would transmitting at any one of these baud rates allow me to > communicate with the mouse or is the baud rate for the mouse fixed for > receiving data? > 3. I am not using the inbuilt routines for serial communication, I'll > be using inbuilt timers for transmiting data. What values should I set > for the timers so that I could generate both clock and data on port > 0(?) ? > > Does the entire idea sound feasible? > > Thanks > -Sahai > India
It is very possible to do the original PS/2 receiver was another 8752 in the PC. You may need to bit bang it but it can be done.