Compiled Mouse Application Notes

Basic Mouse Conecpt:

The concept for the mouse controller is to take the serial data clocked in by the mouse and verify the data received and when requested to send it internally to the next logic block. The mouse sends a serial data stream consisting of 3 packets each with 11 bits. Of the 11 bits there is a start bit, stop bit, parity and 8 bits of data.  The first packet contains the three mouse buttons, direction of x and y travel as well as if a value overflow has occurred.  The second packet contains the magnitude of the x value of travel, and the final packet contains the magnitude of the y value of travel.

The serial data is clocked into the FPGA with the Mouse clock sent with the data. This clock runs between 30 - 50us in length and can vary with each mouse used. To start mouse transmission we must send the correct command. The mouse clock line is held low for a period of 60 us which disables any mouse originating data, 60 us is used because this value is longer than the clock period and we can be sure that
there will be no transmission. Upon releasing the Clock line we apply a 0 to the data line. On the first rising edge the mouse receives this 0
and is ready for us to send a command. Immediately following the 0 we send F4 LSB first. This is the command to start Sending us packets at the default rate of 100 transmissions a second.

We can then prepare to accept data from the mouse. The first start bit occurs on the rising edge of the mouse clock. By using shift registers we receive each of the three packets. We then verify the data contained within the packet by checking the parity. It is then held until requested for by the system.

Data Packets:
 
 
Bit [0]
Bit [1]
Bit [2]
Bit [3]
Bit [4]
Bit [5]
Bit [6]
Bit [7]
Bit [8]
Bit [9]
Bit [10]
Packet [0]
Start Bit
Y Data
Overflow
X Data
Overflow
Y Data
Sign Bit
X Data
Sign Bit
1
Middle
Button Bit
Right
Button Bit
Left
Button Bit
Parity Bit
Stop Bit
Packet [1]
Start Bit
X Position
Bit [7]
MSB
X Position
Bit [6]
X Position
Bit [5]
X Position
Bit [4]
X Position
Bit [3]
X Position
Bit [2]
X Position
Bit [1]
X Position
Bit [0]
LSB
Parity Bit
Stop Bit
Packet [2]
Start Bit
 Y Position
Bit [7]
MSB
 Y Position
Bit [6]
 Y Position
Bit [5]
 Y Position
Bit [4]
 Y Position
Bit [3]
 Y Position
Bit [2]
 Y Position
Bit [1]
 Y Position
Bit [0]
LSB
Parity Bit
Stop Bit

Mouse Commands:
 
Command Hex Value
Reset Mouse
Mouse Returns AA, 00 after self-test
FF
Resend Message FE
Set to Default Values F6
Enable Mouse Streaming Mode
Mouse starts sending data packets at default rate
F4
Disable Streaming Mode F5
Set Sampling rate
XX is the number of packets per second
F3, XX
Read Device Type F2
Set Remote Mode EE
Set Wrap Mode
Mouse returns data sent by system
EC
Read Remote Data
Mouse sends 1 data packet
EB
Set Stream Mode EA
Status Request
Mouse returns 3-bytes with current settings
E9
Set Resolution
XX is 0, 1, 2, 3
E8, XX
Set Scaling 2 to 1 E7
Reset Scaling E6

Mouse Messages:
 
Message Sent Hex Value
Resend Message FE
2 Bad messages in a row FC
Mouse Acknowledge Command
Sent by mouse after each command byte
FA
Mouse passed self-test AA

Refernce Sources
 

   APPLICATION NOTE #4 Mouse implementation on Altera UP1 boards: McDermott, Ashley. Koziar, Kory. Stangeland,    Duane
   PS2 Mouse Interface to UP1 Board: Rob Chapman
    James Hamblen and Michael Furman, Rapid Prototyping of Digital Systems, Kluwer Academic Publishers, Boston, 2000, Ch.11
    Altera Corporation, University Program Design Laboratory Package User Guide, version 1, San Jose, CA, August 1997


If you have comments or suggestions, email the iAMP team at:

Todd Carter
Dan Ross
Stephen Tang
Any information on this page may be used as long as proper credit is given to the rightful parties.

Any user will include the following notice with any copies they make of the Copyrighted Materials, including any technical or educational publications that incorporate any portion of the Copyrighted Materials: "Altera is a trademark and service mark of Altera Corporation in the United States and other countries. Altera products are the intellectual property of Altera Corporation and are protected by copyright laws and one or more U.S. and foreign patents and patent applications."