We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi I have made a simple program for LPC4337 Device, this is my code for initiating the HID mouse that I have connected to my board. The problem is that I got this error usbDeviceError
and my USB function initialize Ok
int main(void) { osKernelInitialize (); // initialize RTOS kernel osKernelStart (); // start kernel with job2 execution usbStatus usbst; usbst=USBH_Initialize(0); // USB Host 0 Initialize while(1) { usbst=USBH_HID_GetDeviceStatus (0U); // Get HID device status } }
I suspect the mouse you want to connect does not support boot protocol and has special HID descriptor that is not standard simple mouse in that case it will not be mounted by USB Host as it does not support complex HID descriptor, you would have to write your own handling of that mouse with using of custom class implementation on the USB Host.
Do you have Configuration Descriptor of that mouse?
Thanks for your time, I do not know how to extract that info or use as custom implementation. if you direct me to where I could find the info It would help me a lot.
Thanks
You can use extended HID functionality, check functions USBH_HID_ParseReportDescriptor and USBH_HID_Read and USBH_HID_Write here: www.keil.com/.../group__usbh__hid_functions__api.html or you can use custom class functionality explained and documented here: www.keil.com/.../group__usbh__custom_functions.html
Thanks for the info
In the documentation it said that
The application starts the USB Host by calling USBH_Initialize. The USB Host Core will wait until an USB HID device is attached to the system. As soon as this happens it will enumerate the device and it will be ready to be used by the application. The handling of the HID class events is implemented in USBH_HID_Thread.
The problem is that the USBH_HID_Thread is not in the task list in the OS.
And I have increased the tasks in RTX configuration. Do you have any Idea?
Try with a standard USB keyboard first and see if it works as expected.
Thanks for your time, I have tried every thing including several mouses and keyboards.I will get always the same answer, it's usbDeviceError. Also I have probed the D+ and D- lines of the USB with an oscilloscope, It seems there is no activity on the lines!
What should I do? Please help me
Well, last mentioned was that you are working on LPC1768 if you are using MCB1700 evaluation board from Keil then you have an example c:\Keil\ARM\PACK\Keil\LPC1700_DFP\2.3.0\Boards\Keil\MCB1700\Middleware\USB\Host\Keyboard\ which should work out-of-the-box. If you have your custom board or any other board, then you have to find the differences towards MCB1700 (http://www.keil.com/mcb1700/mcb1700-schematics.pdf) usually clocking and layout of USB pins (VBUS), and address these differences in software by changing setup of the USB drivers (RTE_Device.h file) or if necessary drivers themselves (USBH_LPC17xx.c file), main code and USB library needs no changes.
Then you need to get that keyboard example to work on your LPC1768 board with standard keyboard.
BTW, USB analyser would be a big help here.
Thanks for your response, I have my costume board. I have already tried the keyboard example from the MBC1700 files. The only difference with the MBC1700 is that I have only routed the D+ and D- pins and I did not use any auxiliary pins like the VBUS. Also my PCB routing is very good, I don't think the PCB traces would cause any issue. why I do not have any activity on the USB lines?
And this is the settings in the RTE device files
https://ibb.co/d5OUMF
Also what is USB analyser? where Can I find it?
Only things that I can suggest on theoretical level are: - do you have same crystal for the CPU - do you have same pins used for D+ (P0.29) and D- (P0.30) as Keil MCB1700 board - do you have 5V on VBUS pin of USB connector - check just in case that overcurrent pin is not in active state
If none of previous things work, can you make prototype routing same as on MCB1700, and try the original Keil example. At this point if it does not work then you need to fix your hardware, after this you should know what is the reason and what you need to do.
USB analyzer is this for example www.totalphase.com/.../
Thanks,The only difference is that I left the VBUS pin and overcurrent connected to something else and disabled them in the RTE device, I will hack the board and connect the VBUS pin to VCC to see it it tries to do something.
Finally It decided to work, The problem was nothing except the 10 different mouses and keyboards that I have used, none of them Seems to be HID!!! and the Last mouse That I have connected to the system it's being detected and working properly.
I have tried the custom Class for detecting other keyboard and mouses, It seems that the USB host would not find anything, and my custom class code detect the mouse that is HID compatible!
Here is my Code for the custom class Testing to see if I could detect the other mouse and keypads. It seems there is something wrong with the USB LIB.
static int whatCallback=0; usbStatus USBH_CustomClass_Initialize (uint8_t instance) { whatCallback=1; } uint8_t USBH_CustomClass_Configure ( const USBH_DEV * ptr_dev,const USB_DEVICE_DESCRIPTOR * ptr_dev_desc,const USB_CONFIGURATION_DESCRIPTOR * ptr_cfg_desc ) { whatCallback=2; } usbStatus USBH_CustomClass_Uninitialize (uint8_t instance) { whatCallback=3; } usbStatus USBH_CustomClass_Unconfigure ( uint8_t instance ) { whatCallback=4; } int main(void) { USBH_Initialize (0); /* Initialize USB Host 0 */ while(1) { USBH_CustomClass_GetDeviceStatus(0); } }
Hi Ali,
it would be very helpful if you could see USB bus traffic, as a lot could be concluded from that.
There is however a way for you to get more information on what is going on in the USB Library. You can use so called Event Recorder and Debug variant of the USB Library and look into debug messages that USB Library will output.
To enable Event Recorder you need do the following: In Manage Run-Time Environment you should: - Component Compiler:Event Recorder:DAP check the checkbox - Component USB:CORE select Debug variant instead of Release In your main file: - add #include "EventRecorder.h" - in start of main function call EventRecorderInitialize (EventRecordAll, 1);
Then build the project, download to flash, start the debug session (Ctrl +F5), go to menu View -> Analysis Window -> Event Recorder
In Event Recorder window you should see debug messages output by USB Library, that should help you to determine what is going on in the USB Library.
Best regards, Milorad
Thanks Milorad I will try it and share results in here.
I have tested the Event recorder, There are some errors out there Please see the attached file for detailed info, I do not understand errors and how to solve them. what's Error=65 ?
Do you have any Idea why the custom class can not find my other non-HID mouse and keybaords? it seems all of my 10 different mouses generate the same data!
get the Event recorder data file at here
www.4shared.com/.../Genius_mouse_on_LPC4370_USB_Ho.html
See some pictures in here https://ibb.co/f3ehaa