MAX3421 as a host withy PICAXE

Status
Not open for further replies.

DrWhoF

Advanced Member level 1
Joined
May 6, 2005
Messages
402
Helped
24
Reputation
48
Reaction score
11
Trophy points
1,298
Activity points
4,388
I need to read USB keyboard codes.
I have MAX3421 ev-kit and I'd like to write a code that will allow to detect and configure keyboard and then read codes for pressed keys.
So far I can read registers and write data to registers using half-duplex bit banging SPI.
Does anyone have experience with the MAX3421 working as a host?
 

On the 3421 ev-kit card I can see the bus-power-switch.
It is controlled by GPOUT7.
Start with setting the GPOUT7 = 1.
That should switch the power to the USB connector and set the FLAG on GPIN0 low.

:wink:
IanP
 
Reactions: DrWhoF

    DrWhoF

    Points: 2
    Helpful Answer Positive Rating
I write extensively about max3421e programming here -> Circuits@Home . Look for USB Host Shield. There is a lot of sample code, too.
 
I write extensively about max3421e programming here -> Circuits@Home . Look for USB Host Shield. There is a lot of sample code, too.
Unfortumatelly all that stuff is in C and I am not "C-MAN"

---------- Post added at 07:35 ---------- Previous post was at 07:34 ----------

On the 3421 ev-kit card I can see the bus-power-switch.
It is controlled by GPOUT7.
Start with setting the GPOUT7 = 1.
That should switch the power to the USB connector and set the FLAG on GPIN0 low.

:wink:
IanP
Yes, I can do that.
What would be next?
 
Reactions: IanP

    IanP

    Points: 2
    Helpful Answer Positive Rating
Try to set the MAX3421 as a low-speed host
Which registers have to be set-up?
 
Reactions: IanP

    IanP

    Points: 2
    Helpful Answer Positive Rating
Which registers have to be set-up?

Set the following bits in the R27 register:

DPPULLDN - R27, b7
DMPULLDN - R27, b6
LOWSPEED - R27, b1
HOST - R27, b0

In other words, try to send 0xC3 to R27

Then issue a USB bus reset by setting BUSRST - R29, b0 --> wait something like 100ms and turn on frame markers by sending 0xCB to R27 ..
Now, clear bit FRAMEIRQ and at this stage MAX3421 should generate one SOF packet.

:wink:
IanP
 
Reactions: DrWhoF

    DrWhoF

    Points: 2
    Helpful Answer Positive Rating
Ok, the issue with the MAX3421 is solved, and I can set/read/reset all registers.
So I set it up into the low-speed-host mode, then I set the device address using SUDFIFO. **Next I sent to PERADDR 0x01 – device=keyboard, and so on ..

In an endless loop I send an IN token to EP1, read bits HRSLT0-4, if=0x00 success, and so on, ...., and so on ..
I could read USB keyboard’s press and release codes ..
Fine.

I tried another keyboard.
The same as above.

I tried another keyboard = nothing works.
Keyboard is OK when plugged to a PC.
When I try to send address to it (step **) it returns 0x0D, that is J-state, should be 0x00 => ACK.
So, I’m stuck here and at this moment have no clue what to do next.

Q: keyboards suppose to be low-speed devices. Is it possible that not all are?
 
Reactions: IanP

    IanP

    Points: 2
    Helpful Answer Positive Rating
It doesn’t look like you have performed full enumeration and the USB Enumeration is the process of detecting, identifying and loading drivers for a USB device ..
Some keyboards may respond without full enumeration, some may not .. it's difficult to predict a device's behaviour when you try to make a short-cut ..
Have you tried more keyboards and is that one that didn’t work somehow different from the others?

:wink:
IanP
 
Reactions: DrWhoF

    DrWhoF

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…