AnsweredAssumed Answered

Why USB keeps attach/reset/detach in _usb_khci_task()?

Question asked by Kai Liu on May 23, 2013
Latest reply on May 30, 2013 by Kai Liu

I have tried HID (mouse/keyboard+mouse) demos on FRDM-KL25Z with hyper terminal. It works in most cases with some exceptions.

 

If I plug K/B and run HID project, it keeps on attach/reset/detach in khci_kinetis.c::_usb_khci_task(). And it will not goes to usb_host_hid_keyboard_event().

 

Even I run HID project before connecting K/B, it runs to usb_host_hid_keyboard_event(), only after quite a long attach/reset/detach loops. The time is at least longer than a normal debounce time of connecting USB device.

 

Here is a complete debug log to show that case.

USB HID Keyboard + Mouse
Waiting for USB Keyboard or mouse to be attached...
events:01
khci_event:01,event_attach
khci_event:02,event_reset
khci_event:10,event_detach
events:01
khci_event:01,event_attach
khci_event:02,event_reset
khci_event:10,event_detach
events:01
khci_event:01,event_attach
khci_event:02,event_reset
khci_event:10,event_detach
events:01
khci_event:01,event_attach
khci_event:02,event_reset
khci_event:10,event_detach
events:01
khci_event:01,event_attach
khci_event:02,event_reset
khci_event:10,event_detach
events:01
khci_event:01,event_attach
khci_event:02,event_reset
khci_event:10,event_detach
events:01
khci_event:01,event_attach
khci_event:02,event_reset
khci_event:10,event_detach
events:01
khci_event:01,event_attach
khci_event:02,event_reset
khci_event:10,event_detach
events:01
khci_event:01,event_attach
khci_event:02,event_reset
khci_event:10,event_detach
events:01
khci_event:01,event_attach
khci_event:02,event_reset
khci_event:10,event_detach
events:01
khci_event:01,event_attach
khci_event:02,event_reset
khci_event:10,event_detach
events:01
khci_event:01,event_attach
khci_event:02,event_reset
----- Attach Event -----
State = 0  Class = 3  SubClass = 1  Protocol = 1
----- Interfaced Event -----
Keyboard device interfaced, setting protocol...
Keyboard device ready, try to press the keyboard
abcdeffghijklmnopqrstuvwxyz

 

The khci_event value is set in USB_ISR_HOST() by calling _usb_event_set(). But I don't understand why there are so many KHCI_EVENT_RESET event? And what is different between executing order of connection USB devices and running code?

Outcomes