Are you sure you are sampling your data on (actually after) the correct edge of the clock? Are you grabbing the data too late (or possibly too soon)? Good luck! Bob Ammerman RAm Systems (high function, high performance, low level software) ----- Original Message ----- From: John Hansen To: Sent: Tuesday, May 30, 2000 11:08 PM Subject: Re: Anybody interfaced an AT Keyboard with a PIC > One other item. I seem to be transmitting commands to the keyboard just > fine. For example, I can command it to turn on it's LED's by sending it an > 0xED, waiting for an acknowledgment and then sending a 0x03. The > acknowledgment, however is supposed to be an FA but I get an F0 > instead. I've noticed that it is sometimes interpreting ones as zeros, but > it is never interpreting zeros as ones. So the data line isn't high when > it's supposed to be. I'm pretty sure I'm not missing bits because I am > seeing exactly 33 clock cycles. I've tried an external pull-up on the data > line and I've also tried enabling the internal Port B pull-ups. I'm > getting consistent data out of the keyboard... that is, what is supposed to > be FA is always F0, for example. I've checked the power supply to make > sure it is a solid 5 volts. Anybody think of anything else worth trying? > ... it seems like I'm so close on this. > > John > > > > > >Here are some more symptoms. Any help would be appreciated. I created a > >program on a F84 that reads the data coming off the keyboard and displays > >it on an LCD. When I press a key on the keyboard (the keyboard that > >works) I get 33 bits clocked in. This is as expected since it should give > >me a 1C when the key is pressed followed by an F0 and a 1C when the key > >is released. Since there is a start bit, a parity bit and a stop bit, > >this should produce 33 bits. So far so good. However, the bits that are > >clocked in are not what are expected. Instead of a 1C (which is supposed > >to be the scan code for "a"), I get an 0x18. I have the data line hooked > >to pin B0 and the clock hooked to B1. When I switched the data line to A4 > >(as Steve Lowthar has in his on-line code and schematic) the keyboard > >gives me a 0x10. Now you might be saying that the A4 pin needs a pull-up > >resistor, but according to the keyboard documentation, pc keyboards > >contain pull-ups on both the data and clock lines. However, in any case, > >adding a pull-up still produces a 0x10. Interesting that the value read > >on this pin changes depending upon whether it is read from pin B0 or pin A4. > > > >I decide to try Steve Lowther's code and schematic for a 16C84 hooked to a > >keyboard and an LCD display. When in doubt, start with something you know > >works, I figured. I wired it up on a protoboard and burned the chip. He > >uses B0 for clock (using it as an interrupt) and A4 for data. It produces > >the same 0x10 that I was getting from my code. Also, the other two > >keyboards don't work on his code either, leading me to believe that Mark > >is right, no reset is required (Steve's source code doesn't show > >any). Well, the bottom line is that my code seems to be producing the > >same results as his. I conclude that there must be a problem with the > >hardware somewhere, yet I've followed his schematic. I wonder if the fact > >that I get a different value from pin B0 and A4 provide any clues. There > >is no variability in the results produced: I always get 0x10 on A4 and > >0x18 on B0. > > > >Once again any thoughts would be appreciated. > > > >John Hansen