USB keyboard communication

Started by Arun Venkataswamy August 9, 2006
Hi All,

I want to connect an USB keyboard to the RCM3720. I am using an
USB/PS2 convertor and the PS2KEYBOARD library (The PS2 connector
connects to the RCM). When I connect a PS2 Keyboard with the circuit,
the PS2KEYBOARD library works very well. When I connect the USB
keyboard with USB/PS2 convertor to the circuit, I am not able to read
the keys. When I set the debug option in the PS2KEYBOARD lib, I am
getting 0xff scancode continously. With a scope, I can see that the
USB keyboard is producing clocks at a fixed interval without pressing
any key. What could be the problem? Should the keyboard be initialized
(host to keyboard comm)?

Also, the same keyboard with the USB/PS2 connector works well when
connected to a PC.

With regards,
Arun Venkataswamy.
Hi Arun,
What kind of USB/PS2 converter R U using?
A passive adapter or an active converter?
POP

----- Original Message -----
From: "Arun Venkataswamy"
To:
Sent: Wednesday, August 09, 2006 10:43 AM
Subject: [rabbit-semi] USB keyboard communication
> Hi All,
>
> I want to connect an USB keyboard to the RCM3720. I am using an
> USB/PS2 convertor and the PS2KEYBOARD library (The PS2 connector
> connects to the RCM). When I connect a PS2 Keyboard with the circuit,
> the PS2KEYBOARD library works very well. When I connect the USB
> keyboard with USB/PS2 convertor to the circuit, I am not able to read
> the keys. When I set the debug option in the PS2KEYBOARD lib, I am
> getting 0xff scancode continously. With a scope, I can see that the
> USB keyboard is producing clocks at a fixed interval without pressing
> any key. What could be the problem? Should the keyboard be initialized
> (host to keyboard comm)?
>
> Also, the same keyboard with the USB/PS2 connector works well when
> connected to a PC.
>
> With regards,
> Arun Venkataswamy.
>
>
Glad you like the lib..:-)

As for your problem, It would be interesting to see if
The "converter" is doing this continious clocking when conected to
a "regular" PC. If so then there isn't much hope... You *could*
make a quick hack on the lib to ignore scan code FF (IIRC it's not a
scan code thats used) but that's just gonna hammer your Rabbit. If
you enable the "bit wiggler" in the lib and scope it while receiving
data you'll see that the ISR is chewing up about half your machine.
As I said when I posted the code I bet a good assembler rewrite
could get that down by at *LEAST* a factor of 2 probably more like 5.
--.- Dave
--- In r..., "Arun Venkataswamy"
wrote:
>
> Hi All,
>
> I want to connect an USB keyboard to the RCM3720. I am using an
> USB/PS2 convertor and the PS2KEYBOARD library (The PS2 connector
> connects to the RCM). When I connect a PS2 Keyboard with the
circuit,
> the PS2KEYBOARD library works very well. When I connect the USB
> keyboard with USB/PS2 convertor to the circuit, I am not able to
read
> the keys. When I set the debug option in the PS2KEYBOARD lib, I am
> getting 0xff scancode continously. With a scope, I can see that
the
> USB keyboard is producing clocks at a fixed interval without
pressing
> any key. What could be the problem? Should the keyboard be
initialized
> (host to keyboard comm)?
>
> Also, the same keyboard with the USB/PS2 connector works well when
> connected to a PC.
>
> With regards,
> Arun Venkataswamy.
>
--- In r..., "Pop4509hp" wrote:
>
> Hi Arun,
> What kind of USB/PS2 converter R U using?
> A passive adapter or an active converter?
> POP
>
Hi POP,

It is a small adapter with a female USB connector in one end (where
the USB keyboard connects) and a male PS/2 connector in the other end.
It was really low cost.

With regards,
Arun
Ok but...
May be (and only may be) your keyboard handles both protocols and your adapt
is just a cable. (my mouse works that way)
In that case its possible that you miss an initial handshake who changes the
way the KB starts the interface.
Just a thought
POP

----- Original Message -----
From: "Arun Venkataswamy"
To:
Sent: Wednesday, August 09, 2006 1:41 PM
Subject: [rabbit-semi] Re: USB keyboard communication
> --- In r..., "Pop4509hp" wrote:
> >
> > Hi Arun,
> > What kind of USB/PS2 converter R U using?
> > A passive adapter or an active converter?
> > POP
> >
> Hi POP,
>
> It is a small adapter with a female USB connector in one end (where
> the USB keyboard connects) and a male PS/2 connector in the other end.
> It was really low cost.
>
> With regards,
> Arun
--- In r..., "Dave August" wrote:
>
> Glad you like the lib..:-)
>
> As for your problem, It would be interesting to see if
> The "converter" is doing this continious clocking when conected to
> a "regular" PC. If so then there isn't much hope... You *could*
> make a quick hack on the lib to ignore scan code FF (IIRC it's not
a
> scan code thats used) but that's just gonna hammer your Rabbit. If
> you enable the "bit wiggler" in the lib and scope it while
receiving
> data you'll see that the ISR is chewing up about half your
machine.
> As I said when I posted the code I bet a good assembler rewrite
> could get that down by at *LEAST* a factor of 2 probably more like
5.
> --.- Dave

Hi Dave,

Thanks for the library. Great work!
Ignoring the oxFF is no use because the keyboard is producing only
that code. It has no reaction to key press. The same keyboard is
working well when connected to the PC.

regards,
Arun
--- In r..., "Pop4509hp"
wrote:
>
> Ok but...
> May be (and only may be) your keyboard handles both protocols and
your adapt
> is just a cable. (my mouse works that way)
> In that case its possible that you miss an initial handshake who
changes the
> way the KB starts the interface.
> Just a thought
> POP

Hi POP,

You were right! I split open the adapter and saw only wires! So the
keyboard is a dual protocol one. But I am not able to figure out how
to switch the mode to PS/2. The PC running XP does it.

I connected a CRO (scope) to the clock line and found out that, when
connected to the PC, a single clock burst is made and then goes
silent till a key is pressed. I guess the PC is acknolowledging this
with some data and the keyboard switches to PS/2 mode after the
initial clock burst. I am not able to find out what acknowledgement
is done. When connected to the RCM, it produces this clock burst
every 0.5 seconds

Regards,
Arun
Hi Arun,
I hope this can help
http://www.computer-engineering.org/ps2keyboard/ Controller Commands>
http://www.computer-engineering.org/ps2protocol/
I guess the KBoard recognizes some 'standard' bios initialization and did
not check the USB until that fails. (my guessing is based in a backward
compatibility issue)
Let us know if you can solve the problem!
Regards
POP

----- Original Message -----
From: "Arun Venkataswamy"
To:
Sent: Thursday, August 10, 2006 8:24 AM
Subject: [rabbit-semi] Re: USB keyboard communication
> --- In r..., "Pop4509hp"
> wrote:
> >
> > Ok but...
> > May be (and only may be) your keyboard handles both protocols and
> your adapt
> > is just a cable. (my mouse works that way)
> > In that case its possible that you miss an initial handshake who
> changes the
> > way the KB starts the interface.
> > Just a thought
> > POP
>
> Hi POP,
>
> You were right! I split open the adapter and saw only wires! So the
> keyboard is a dual protocol one. But I am not able to figure out how
> to switch the mode to PS/2. The PC running XP does it.
>
> I connected a CRO (scope) to the clock line and found out that, when
> connected to the PC, a single clock burst is made and then goes
> silent till a key is pressed. I guess the PC is acknolowledging this
> with some data and the keyboard switches to PS/2 mode after the
> initial clock burst. I am not able to find out what acknowledgement
> is done. When connected to the RCM, it produces this clock burst
> every 0.5 seconds
>
> Regards,
> Arun
Ahh,

Based on this (and your outher 2 posts) I suspect that the keyboard
needs the 'Reset' command that the BIOS sends on power up (thats
when you see the keyboard LEDs flash and that the burst of clocks
you see going out..). And since I didn't impliment a write to
keyboard function yer kinda screwed...

It probably wouldn't be *that* hard to write one that just sends the
reset, you could try that.

Writing a fully functional bidirectional driver would be a bit of a
chore (that's why I didn't), but I bet you could hack out a quick
piece of code that just sent the reset command... If you google
around a bit you can find the KeyBoard protocol...

You could probably be real "rude and crude" about it and do it
BEFORE you call the init function in the PS2KEYBOARD lib...
--.- Dave

--- In r..., "Arun Venkataswamy"
wrote:
> --- In r..., "Dave August" wrote:
> >
> > Glad you like the lib..:-)
> >
> > As for your problem, It would be interesting to see if
> > The "converter" is doing this continious clocking when conected
to
> > a "regular" PC. If so then there isn't much hope... You *could*
> > make a quick hack on the lib to ignore scan code FF (IIRC it's
not
> a
> > scan code thats used) but that's just gonna hammer your Rabbit.
If
> > you enable the "bit wiggler" in the lib and scope it while
> receiving
> > data you'll see that the ISR is chewing up about half your
> machine.
> > As I said when I posted the code I bet a good assembler rewrite
> > could get that down by at *LEAST* a factor of 2 probably more
like
> 5.
> >
> >
> > --.- Dave
> >
> > Hi Dave,
>
> Thanks for the library. Great work!
> Ignoring the oxFF is no use because the keyboard is producing only
> that code. It has no reaction to key press. The same keyboard is
> working well when connected to the PC.
>
> regards,
> Arun
>
Hi,

Dave -- You were absolutely right! All it needed was (any) Host to
keyboard command to switch to the PS/2 mode. Yeah I tried the "rude
and crude" method to send an "Enable" command to the keyboard before
calling the PS2K init function. The keyboard acknowledged the command
and stopped the clock bursts and is working in PS/2 mode. Thanks for
the inputs given.

POP -- Your links were the eye-opener! The BIOS initialization held
the key to switching the USB keyboard to PS/2 mode while the keyboard
was connected to the PC. Thanks.

One small problem (electrical) exists - The USB keyboard data and
clock line are not switching to 0V. They are switching only to around
1.2V which I think the RCM is not accepting as "0". Will switching the
PortD pin 4 to open drain mode work?
Regards,
Arun

--- In r..., "Arun Venkataswamy"
wrote:
>
> Hi All,
>
> I want to connect an USB keyboard to the RCM3720. I am using an
> USB/PS2 convertor and the PS2KEYBOARD library (The PS2 connector
> connects to the RCM). When I connect a PS2 Keyboard with the circuit,
> the PS2KEYBOARD library works very well. When I connect the USB
> keyboard with USB/PS2 convertor to the circuit, I am not able to read
> the keys. When I set the debug option in the PS2KEYBOARD lib, I am
> getting 0xff scancode continously. With a scope, I can see that the
> USB keyboard is producing clocks at a fixed interval without pressing
> any key. What could be the problem? Should the keyboard be initialized
> (host to keyboard comm)?
>
> Also, the same keyboard with the USB/PS2 connector works well when
> connected to a PC.
>
> With regards,
> Arun Venkataswamy.
>