AnsweredAssumed Answered

USB host HID demo times out on FRDM-KL25Z with reproduced USB host

Question asked by Kai Liu on Apr 7, 2013
Latest reply on Apr 12, 2013 by Kai Liu



I am trying to design a USB OTG board with KL24/25. I want to reuse FRDM-KL25Z for firmware development before making my own board. It is surprised to find out TWR-KL25Z has OTG port with 64KB ROM, while FRDM-KL25Z HAS NOT OTG port with 128KB ROM. So I have to reproduce an additional USB OTG port with FRDM. Check out the following images:



Fig 1: USB device for FRDM-KL25Z


Fig 2: USB OTG for TWR-KL25Z



Fig 3: My add-on OTG port for FRDM-KL25Z, with a DELL mouse attached


Description of re-produced OTG port

Basically, I made a mini USB cable connecting D-/D+/GND from USB KL25Z port to a USB standard A socket, and a separate wire connecting P5V_SDA to VBUS of USB std A socket. I know VBUS power supply should be controlled by a dedicated USB pwr switch with enable pin to GPIO of KL25Z. But I think it is enough for simple hardware. Once plug in SDA USB, the VBUS from PC should supply to VBUS of reproduced USB port.


Regarding pull-up/pull-down, it should be implemented by USB internal PU/PD resistors controlled by firmware.


The code is usb-host demo, with small modification on preprocessor in EWARM for FRDM. The terminal reports as following:


External Pin Reset
KL2580pin      100pin      
Low Power Line with Cortex M0+
SRAM Size:  16 KB
Silicon rev 15
Flash size:  128 KB program flash, 4 KB protection region     Main OK

Timer Init OK

Waiting for USB Mouse to be attached...


USB host can not detect mouse at all. So I traced the code.


hidmouse.c::main() Mouse_Task(main_buffer,&main_hid_com); // hid_device.DEV_STATE is always USB_DEVICE_IDLE _usb_khci_task(); // times out and keep reset bus khci.c::_usb_khci_task() switch (msg.type){    case TR_MSG_SETUP:        _usb_khci_atom_tr(...) // always timeout

...... }

...... if ((khci_event.VALUE & KHCI_EVENT_MASK)){

......    /* bus reset */    USB0_CTL |= USB_CTL_RESET_MASK; // mouse laser is turned off    time_delay(10);    USB0_CTL &= ~USB_CTL_RESET_MASK; // mouse laser is turned on




The result is: when mouse is plugged-in, USB host can detect and find out its speed (LS). However the following transaction always timeout. And it keeps reset the bus, I can find it from laser LED toggling. I am pretty sure VBUS/D-/D+/GND is connected correctly between USB mini B and USB std A. I assume the code should have been verified on TWR board.Can anyone tell me why its transaction times out? Any suggestions are highly appreciated.


I found the desired device should be populated into a table, but its PID/VID are all zero. Should I touched the const table with my DELL mouse? (HID\VID_0461&PID_4D15\7&A65A7C4&0&0000 for my mouse)