I am using CodeWarrior 6.3 C Compiler for Coldfire MCF52223 on the Freescale M52223EVB Development board. I need to use the processor USB interface in Host mode. My software is based on the CMX routines (Host Demo) downloaded from Freescale Web Site.
I modified the software and it works correctly with mouse and keyboard to send to the RS232 i/f their data.
This software has in the file “host_hid_kbd.c” the “void hid_kbd_set_leds (.......)” routine that use the “hid_set_report(.....)” routine to turn on/off the keyboard leds.
I use “hid_set_report(0, &leds, 1)” in the main loop when change my status_leds, but this did not work, so I found an error of the toggle DATA0/1 in usb_host_start_transaction(..)routine during a setup transaction (see link http://forums.freescale.com/freescale/board/message?board.id=CWCFCOMM&thread.id=2133 ).
Now all work correctly with a old usb keyboard, in fact I change the status led and read the press key without problems, but with a lot of new usb keyboards when I change the status led often they hang up and it is necessary to disconnect it.
I have investigated and I have found :
1. an error in the loop “/* wait till frame is due */” (see link http://forums.freescale.com/freescale/board/message?board.id=CWCFCOMM&thread.id=2133 ) not yet fully resolved because with keyboards that don’t work correctly, reading the frame register returns strange values. Now I have added a delay in this loop to read less times the Frame Number Register and it seems to work better.
2. when turning on/off the keyboard leds work correctly, the transaction is:
---------------------------------------
CF: Setup + Data0
KBD: Ack
CF: Out + Data1
KBD: Ack
CF: In + Data1
KBD: Ack
---------------------------------------
when it doesn’t work correctly the transactions is:
---------------------------------------
CF: Setup + Data0
KBD: Ack
CF: Out + Data1
MCF_USB_ERR_STAT & ~MCF_USB_ERR_STAT_CRC5_EOF=1
and the loop retry for a new Out token:
CF: Out + Data1
KBD: Nack
CF: Out + Data1
KBD: Not respond
---------------------------------------
I don’t understand well the function of the SOF threshold and frame registers; I think that this problem is due on the usb bus to a misaligned SOF token and “setup transaction” on the control endpoint.
Any suggestion?
Hi,
If you get really desperate, I actually wrote a from-scratch host driver for the 52221 which you might have better luck with... I tried to simplify it as much as possible. I talked successfully to USB mass storage devices as well as a PIMA camera and proprietary Canon camera... I since abandoned my host project and have been running in device mode, but I just tested this code and it still works :smileyhappy:, if it might help you. I had found the same data-toggle bug with the CMX stack, and probably others, so I decided to try it this way.
Anyway, if it helps, good luck!
-- Rich
Thank you very much for your help, but your code seems to me not suitable to solve my problem.
Francesco
To see better my bug I have done the acquisition (see link figure errledsr2.gif ) of the set_report routine transaction.
http://img143.imageshack.us/my.php?image=errledsr2.gif
At the first setup_transaction (setup+data0) the MCF52223 give no answer, at the second setup_transaction answer with an ACK,.