reducing shiftout clock freq and PS2/PC interfacing ....
I'm working on a wireless optical keyboard using the PS2 caple and I'm working on it with my friends step by step and we start to try sending a single character. And through our searching we found that we need to satisfy some conditions :
11 bit outputs , sycronous comm. with host should be done , and clock frequency with range 10KHz and 16.7KHz and the data recivied to the host ( PC ) should be read on the falling edge of the clock signal.
ok we wrote a simple prog. using shiftout to make an " A " appears on the screen but when we make so the computer get frozen and we have to restart it from the power switch.
and what we think is the clock freq ia the problem and we use a 4MHz osc and we don't know if we should make a pause after using the shiftout ! and how "DEFINE SHIFT_PAUSEUS 100" exactlly works !!and how it can hepl us to reduce the freq of clock and 4M => 50KHz
and in the documents they say 50kHz depend on the osc how ??!!
and why the computer get frozen ? and if any one worked on the connecting the Pic with the computer throgh PS2 caple please tell me if there are some point that we should take on our consideration or if there is some steps ore configrations that we might missed
Thanks and I really nead your help to make this project !! and I'm still in the 1st step !!
what is wrong with those computers !!
ok actually I tried your code with little midifications :
as follow:
device 16f877a
INPUT portb.1 ' when you are done with sending a byte,
INPUT portb.0 'assign the pins as input pins.
input portd.2
StopBit var bit
StartBit var bit
Parity var bit
Temp var byte
DatTime var byte
ClkTime var byte
stopbit = 1
startbit = 0
Parity = 0 'for q parity=0
Temp = $15 ' Send "q" as an example.
DatTime = 10 ' Data Pause Time.
ClkTime = 50 ' Clock Pause time.
main:
if portd.2=1 then sendQ
goto main
end
sendQ:
OUTPUT portb.1 ' Before you send anything, assign the pins as output pins.
OUTPUT portb.0
portb.1 = 1
PAUSEUS DatTime
portb.0 = STARTBit ' Start bit is always zero.
PAUSEUS DatTime
portb.1 = 0
PAUSEUS ClkTime
portb.1 = 1
PAUSEUS DatTime
portb.0 = Temp.0 ' Bit 0.
PAUSEUS DatTime
portb.1 = 0
PAUSEUS ClkTime
portb.1 = 1
PAUSEUS DatTime
portb.0 = Temp.1 ' Bit 1.
PAUSEUS DatTime
portb.1 = 0
PAUSEUS ClkTime
portb.1 = 1
PAUSEUS DatTime
portb.0 = Temp.2 ' Bit 2.
PAUSEUS DatTime
portb.1 = 0
PAUSEUS ClkTime
portb.1 = 1
PAUSEUS DatTime
portb.0 = Temp.3 ' Bit 3.
PAUSEUS DatTime
portb.1 = 0
PAUSEUS ClkTime
portb.1 = 1
PAUSEUS DatTime
portb.0 = Temp.4 ' Bit 4.
PAUSEUS DatTime
portb.1 = 0
PAUSEUS ClkTime
portb.1 = 1
PAUSEUS DatTime
portb.0 = Temp.5 ' Bit 5.
PAUSEUS DatTime
portb.1 = 0
PAUSEUS ClkTime
portb.1 = 1
PAUSEUS DatTime
portb.0 = Temp.6 ' Bit 6.
PAUSEUS DatTime
portb.1 = 0
PAUSEUS ClkTime
portb.1 = 1
PAUSEUS DatTime
portb.0 = Temp.7 ' Bit 7.
PAUSEUS DatTime
portb.1 = 0
PAUSEUS ClkTime
portb.1 = 1
PAUSEUS DatTime
portb.0 = Parity ' Parity Bit.
PAUSEUS DatTime ' You must calculate Parity bit_
portb.1 = 0 'in somewhere before putting it here.
PAUSEUS ClkTime
portb.1 = 1
PAUSEUS DatTime
portb.0 = StopBit ' Stop bit is always 1.
PAUSEUS DatTime ' Have a variable named StopBit and make it 1.
portb.1 = 0
PAUSEUS ClkTime
INPUT portb.1 ' when you are done with sending a byte,
INPUT portb.0 'assign the pins as input pins.
goto main
______________________________
and it still not working ,nothing appears on the screan and if I used the 5V supply from the PC , the PC became freezing and nothing will work , if I used an auxiliarysupply the character " q " will not appear also as in the first case but the computer will not freezing !
now:
1) I thought it might be the DataTime and ClkTime values so I think to chnge them to dataTime = 18 , ClkTime=37 by using those values the period of logic one = 37us and logic zero period = 37us ( for the clock ) !! then the T=74us -> f=1/T =13.513KHz in the required range. but I didn't try it yet
2) the second reason I was thinking about (it may look crazy - but I get missed of reasons)
ok what I think:
in all the cases ever the PS/2 cable that we are use was goten from a mouse " a mouse
PS/2 cable - green - " was conntected to our Pic microcontroller !!
so do you think that one of those might be the reason of making the PC freezing and the character not appears.
AMAZING THAT AN ENGINEERES CAN'T MAKE A HARDWARE TO SHOW A SINGLE CHARACTER ON THE COMPUTER NOTEPAD
and this is still the first step on my project .
by the way thanks sayzer for your tring and for your help !! waitting to see your replay and what Ideas do you have in your mind !