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?