PDA

View Full Version : PS2 Keyboard not funny !!



Jųan
- 20th December 2007, 12:14
Greetings chaps,

Yes I have read previous threads on this subject, yes I have tried numerous codes. However, Im really missing something coz the code below only seems to work on laptops. As far as I can see, there aint any difference between PC and laptop PS2. I am using a PIC16F876A @ 20MHZ and 10k pullups connected to SCL SDA lines to PS2. Ultiblade has been kind enough to share his code with me, however, only seems to work on a laptop. Gaaah, this is really bugging me. If anyone can provide some pointers, would be much appreciated.

Ive tried sending the packet in different ways, as suggested by

http://www.picbasic.co.uk/forum/showthread.php?t=7071&highlight=keyboard+question
http://www.picbasic.co.uk/forum/showthread.php?t=81

I have spent waaay too many days on this project without success, now I would really like somebody to give me a bit of a steer. Many thanks in advance.

Regards

Juan (what am I doing wrong ??)

------------------------------------------------------------


@ DEVICE HS_OSC,LVP_OFF,BOD_OFF,WDT_OFF 'Sets fuse values on PIC

INCLUDE "modedefs.bas"
DEFINE SHIFT_PAUSEUS 50

DEFINE OSC 20

ADCON1 = 7
CMCON = 7


char var word
breakcode var word

clkout1 var portc.3
dataout1 var portc.4

a_key con %00001110001 '$1C = 'a'
h_key con %00011001111 '
space_key con %00010100101
esc_key con %00111011001
F3_key con %00000010001

redLed var portb.4
relay1 var portb.5

breakcode = %01111000011 '$F0



'a_key con %10001110000 ' $1C = 'a' reverse order
'breakcode = %11000011110 '$F0 reverse order



char = a_key
high relay1
high redled

miniLoop:

high clkout1
high dataout1


high redled
pause 500

shiftout dataout1,clkout1,4,[char\11]
pauseus 100
shiftout dataout1,clkout1,4,[breakcode\11,char\11]
' pauseus 100
' shiftout dataout1,clkout1,5,[char\11]


low redled
pause 500

goto miniloop

--------------------------------------------------------------------------------

mister_e
- 20th December 2007, 22:13
What i'll suggest you
measure your clock frequency and make sure it met the PS2 requirement
record what's happening when you boot your PC and a regular PS2 Keyboard is attached
make sure you timing is right... and... erm... make the sure than PAUSEUS really needed between your data
go back to step 2 and compare a real PS2 data against what you're sending
carefully read the PS2 protocol and see if you're allowed to use SHIFTOUT AS-IS

It really looks easier than it is actually... trust me...