Interfacing with PS/2 controller: Shift or Serial?
Dlwigwam
Posts: 6
What is the difference between SHIFTIN/SHIFTOUT and SERIN/SEROUT? Which would be better for interfacing with a PS/2 mouse controller (e.g., the EM84510, link below)?
http://www.datasheetcatalog.org/datasheets/120/238986_DS.pdf
http://www.datasheetcatalog.org/datasheets/120/238986_DS.pdf
Comments
SHIFTIN / SHIFTOUT is a clocked (synchronous) serial I/O method using a clock line and either one bidirectional data line or an input and an output line. It looks like your PS/2 controller works with a clocked signal which otherwise looks similar to the format of asynchronous serial I/O. It looks like your PS/2 controller needs the clock, so you'd have to use the SHIFTIN / SHIFTOUT and maybe fiddle with the clock and data line at other times with INPUT / HIGH / LOW. Frankly, I'd look for some simpler mouse controller. You could even use a Propeller for this since there is already code in the Object Exchange for working with a PS/2 mouse (and keyboard for that matter) and the Propeller could easily talk to a Stamp.
The Wikipedia has good articles on both asynchronous serial I/O and clocked serial I/O (SPI for example).
It sounds like the CLK signal tends to originate from the PS2 IC, possibly waiting until there is a signal from the encoders or buttons (which I'll bypass). So I can use the onset of a LOW signal to initiate SHIFTIN. The referenced code has some interesting syntax that I might borrow:
FOR A = 1 to 8
loop1: IF clock = 1 then loop1
Key_data.0 = dataline
Key_data = Key_data *2 ; Shift once to left
loop2: IF clock = 0 then loop2
Next A
Link: http://www.picbasic.co.uk/forum/archive/index.php/t-2736.html
The hexcode result displayed by the DEBUG command is FF00, which looks to be a code for RESET. The chip is supposed to echo FA upon receiving most commands, but since I'm not sending any commands, I believe the FF00 is OK.
The next step is to set the EM84510 to remote mode, where it sends position and other data upon a signal from CLK.