Email: Password: Remember Me | Create Account (Free)
PS/2 Mouse for SBCMON
SBC Hardware: Main | SBC Schematic/Parts List | Technical Details | All pages in PDF format
SBC In-System Programming: Information | VisISP-52 ISP Application
SBCMON Monitor/Operating System: Main Page | Manual
SBCMON-based Software: SBCMON Monitor | Keypad Demo | LCD Echo Demo | Hardware Clock | Software Clock
SBCMON-based PS/2 Software: PS/2 Comm Monitor | PS/2 Keyboard | PS/2 Mouse
ORDER 8052.com SBC: PCB, KIT OR BUILT SBC AVAILABLE FOR PURCHASE

Download PS/2 Mouse for SBCMON

You may download either the source code or the ready-to-use Intel-Hex version of the mouse demonstration program. The Intel-Hex version may be loaded into SBCMON's memory using the L or Q commands. Download the source ASM program if you'd like to see the code that makes SBCMON work.

What Does this Program Do?

This program allows a standard PS/2-style mouse to be connected to the SBC. Movements of the mouse and mouse clicks are detected by the program and the information is displayed to the terminal.

You may press any key in the PC's terminal program in order to exit the program and return to SBCMON.

Concepts Demonstrated by Program

This program demonstrates the following concepts:

  1. Communicating with mouse using clock and bidirectional data line.
  2. Utilizing the mouse's communication protocol.
Additional Required Hardware

This program requires a PS/2 keyboard or mouse to be connected to the SBC. The keyboard requires a +5V power supply, ground, and the program assumes that the keyboard data line is attached to P1.3 and the clock line is attached to P1.2.

I would recommend using an external board to mount a DIN-6 keyboard connector (Digikey part #275-1043-ND). On this board, mount two 8-pin SIP headers. The first SIP header will allow you to attach a ribbon cable from port 1 (J7 on the SBC) and the second SIP header will allow you to attach a ribbon cable from the EX connector (J11). The J7 connector will expose P1.2 and P1.3 while the J11 connector will provide +5V and ground.

Connecting the PS/2 Connector

The PS/2 connector is a female DIN-6 connector. The pinout is pictured to the right. The top graphic shows the pinout when looking at the PS/2 female connector. The bottom portion of the graphic shows the normal pinout of the pins that are connected at a right angle to the PCB. The pins use 0.1" spacing so are very appropriate for a thru-hole circuit board.

Theory of Operation

The routines used in this example program can best be summarized as follows:

If these routines were used in a more significant, functional program, the program would be responsible for keeping track of the mouse pointer position on the screen, adjusting it positively and negatively as the mouse is moved, and keeping track of the button positions of the mouse buttons.

Credits

This example program was based on Gabriel Lour's "keyboard routine" code which was contributed to the 8052.com code library. Modifications were made to his code to make the example program more closely conform to the style of the other SBC example programs. Additionally, the routines were modified so as not to require any specific addresses in internal RAM. Rather, "R" registers are used for temporary variable storage.

Additionally, Gabriel's code deals with the keyboard's scan codes. This example program, on the other hand, takes the 1-3 byte keyboard scan codes and converts them to a a single-byte unique scan code. This makes it much easier to deal with the resulting data in an assembly language program.

Information on the PS/2 connector pin-out and the keyboard scan codes returned by the keyboard were obtained from Adam Chapweske's site.