PIC as a Keyboard replacement
Sorry for the delay, I have been working on trying different things. I am starting the PC with a regular keyboard and then swaping it with the PIC replacement.
I have tried a 16F627A and I have moved back to the 16F688
Below is the code I am testing, I am sending the data twice trying to send it both LSB and MSB first. Sometimes I get a beep from the PC when I change the PauseUS delay and other times I do not.
' PIC 16F688
' PortC.5 - Data
' PortC.4 - Clk
' PortA.2 - Switch in, normal low, active high
' PortA.4 - LED Out, high if switch pressed
' Circuit description
' 10K pull up on PortC.5 - Data
' 10K pull up on PortC.4 - Clk
' 10K pull up on /MCLR
' 10K pulling down on switch input, PortA.2
'Goal of program, to send a chracter to the PC keyboard port when switch is pressed
@ device INTRC_OSC_NOCLKOUT
INCLUDE "modedefs.bas"
DEFINE SHIFT_PAUSEUS 25
DEFINE OSC 8 ' 8 Mhz
TRISA = %00000100 ' Set PORTA.2 to input, all others are output
TRISC = %00000000 ' set PORTC to outputs
CMCON0 = 7 ' turn off comparitors
ANSEL = %00000000 ' set all as digital ports, analog off
WPUA = %00000000
char var word
breakcode var word
clkout var portc.4
switch1 var portA.2
ledout1 var portA.4
dataout var portc.5
'char = %10101101010 ' 'CR' mode 0
'breakcode = %11000011110 '/F0H mode 0
char = %01010110101
breakcode = %01111000011
'----- Main Loop --------------------------------
Start: ' loop start
low ledout1 ' turn off LED
if switch1 = 1 then ' check switch, if pushed then LED on and Char our
pause 50
if switch1 =1 then
high ledout1 ' LED on
shiftout dataout,clkout,4,[char\11]
shiftout dataout,clkout,4,[breakcode\11]
shiftout dataout,clkout,4,[char\11]
PAUSE 1
shiftout dataout,clkout,5,[char\11]
shiftout dataout,clkout,5,[breakcode\11]
shiftout dataout,clkout,5,[char\11]
endif
endif
goto start ' restart loop
'----- Main Loop --------------------------------
I have tried the character to send and the breakcode both ways, but they respond the same.
I see the characters and clock on the scope, all six characters come across but nothing on the PC.
I am driving the keyboard direct from the chip, no transistors. Do you think the open-collector could be an issue with the driving? Could the Clock and the timing be an issue?
I would think that something would appear with both combinations of send's but i seem to be going in circles.
USB would be great but it's not an option, I am not talking to a Windows OS. I have to use the PS/2 port to send data to the terminal.
Any thoughts would be great, my goal is to send about 24 pre-defined single characters on switches to the port. I have been
Thanks,
HH