need help simulating PS/2 mouse
Hello Everybody. I'm trying to use a PIC to simulate a PS/2 mouse with no success at all. I've tried everything such as SHIFTOUT, PULSOUT and nothing. I found code that allows a BS2 to work. I substituted PBP commands for the BS2 commands and still nothing. Now, I rewrote the code using simple HIGH and LOW commands. As far as I can tell, I've followed the PS/2 mouse protocol exactly and still nothing. When I plug the connector into the PS/2 port, I am expecting the pointer to travel up/left. It doesn't budge. Can someone tell me what I'm missing here? I compared my circuit to a mouse on my scope. They look pretty much the same but the mouse works and the circuit doesn't. The only thing electrically different is the mouse uses optoisolators to bring the CLOCK and DATA lines low. I am simulating this by releasing the LOW command by turning these ports into inputs and let the pullup resistors bring the ports high after clocking in the data. Like I said, it looks good on the scope! Thank you.
'using 12F629
CMCON = 7 'comparators off
trisio = %11111111 'ALL INPUTS. HIGH & LOW COMMANDS WILL CONFIGURE TO OUTPUTS
DEFINE OSCCAL_1K 1 ' Set OSCCAL for 1K device
@ DEVICE MCLR_OFF, INTRC_OSC_NOCLKOUT, WDT_ON, BOD_ON, PWRT_ON, PROTECT_ON
START:
IF GPIO.1 = 0 Then START 'IF PC IS INHIBITING COMMUNICATION ON CLOCK LINE WAIT HERE
'FEED ALL BITS LSB (D0) FIRST AFTER START BIT
Low GPIO.0 'START BIT ALWAYS LOW
GoSub CLOCKPULSE 'CLOCK IN THE BIT
Low GPIO.0 'LEFT MOUSE BUTTON NOT PUSHED
GoSub CLOCKPULSE
Low GPIO.0 'RIGHT MOUSE BUTTON NOT PUSHED
GoSub CLOCKPULSE
Low GPIO.0 'ALWAYS A 0 ON A 2 BUTTON MOUSE
GoSub CLOCKPULSE
High GPIO.0 'ALWAYS A 1
GoSub CLOCKPULSE
High GPIO.0 'DIRECTION OF X MOVEMENT 1 = (+) = LEFT
GoSub CLOCKPULSE
High GPIO.0 'DIRECTION OF Y MOVEMENT 1 = (+) = UP
GoSub CLOCKPULSE
Low GPIO.0 'NO OVERFLOW ON X MOVEMENT
GoSub CLOCKPULSE
Low GPIO.0 'NO OVERFLOW ON Y MOVEMENT
GoSub CLOCKPULSE
Low GPIO.0 'PARITY BIT FOR ODD PARITY
GoSub CLOCKPULSE 'KEEP LOW AS DATA + PARITY IS AN ODD NUMBER
High GPIO.0 'STOP BIT ALWAYS A 1
GoSub CLOCKPULSE
Pause 1 'SEPARATE THE PACKETS BY 1MS
'PACKET 2 ADDS UP TO 127 FOR FULL LEFT
Low GPIO.0 'START BIT
GoSub CLOCKPULSE
High GPIO.0
GoSub CLOCKPULSE
High GPIO.0
GoSub CLOCKPULSE
High GPIO.0
GoSub CLOCKPULSE
High GPIO.0
GoSub CLOCKPULSE
High GPIO.0
GoSub CLOCKPULSE
High GPIO.0
GoSub CLOCKPULSE
High GPIO.0
GoSub CLOCKPULSE
Low GPIO.0
GoSub CLOCKPULSE
Low GPIO.0
GoSub CLOCKPULSE 'PARITY BIT
High GPIO.0
GoSub CLOCKPULSE 'STOP BIT
Pause 1
'PACKET 3 ADDS UP TO 127 FOR FULL UP
Low GPIO.0
GoSub CLOCKPULSE 'START BIT
High GPIO.0
GoSub CLOCKPULSE
High GPIO.0
GoSub CLOCKPULSE
High GPIO.0
GoSub CLOCKPULSE
High GPIO.0
GoSub CLOCKPULSE
High GPIO.0
GoSub CLOCKPULSE
High GPIO.0
GoSub CLOCKPULSE
High GPIO.0
GoSub CLOCKPULSE
Low GPIO.0
GoSub CLOCKPULSE
Low GPIO.0
GoSub CLOCKPULSE 'PARITY BIT
High GPIO.0
GoSub CLOCKPULSE 'STOP BIT
Pause 1
GoTo START
CLOCKPULSE:
Low GPIO.1 'BRING CLOCK LOW
PauseUs 50 'HOLD LOW FOR 50US TO ALLOW DATA BIT TRANSFER IN ON DATA LINE (GPIO.0)
Input GPIO.1 'RELEASE CLOCK. MAKE HIGH Z INPUT TO SIMULATE OPTOISOLATOR
PauseUs 50 'PULLUPS ON CLOCK LINE BRING IT HIGH
Input GPIO.0 'RELEASE DATA LINE MAKE HIGH Z INPUT TO SIMULATE OPTOISOLATOR
Return