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 } }
Why don't you start with C:\Keil\ARM\PACK\Keil\LPC4300_DFP\2.7.0\Boards\Keil\MCB4300\Middleware\USB\Host\Keyboard example
I have tested the keil sample program, But I still got the same error
I have made a simple program for my LPC1768 using keil V5.22 the LPC should act like a USB host to a mice that I have attached to it. the problem is that I will always got the usbDeviceError from the USBH_HID_GetDeviceStatus function.
Here is my USB thread code
void USB_Thread (void const *arg) { static usbStatus myst; static usbHID_MouseState mymouse; myst=USBH_Initialize (0); /* Initialize USB Host 0 */ while (1) { osDelay(10); myst=USBH_HID_GetDeviceStatus(0); } }
and this is my main function
osThreadDef(USB_Thread, osPriorityNormal, 1, 2048); osThreadId tsk_USB; int main (void) { osKernelInitialize (); // initialize CMSIS-RTOS osKernelStart (); // start thread execution tsk_USB = osThreadCreate(osThread(USB_Thread), NULL); //it's used for USB mouse while(1) { } }
Here are some pictures of my RTX and USB configuration boxes
http://uploads.im/Um93L.jpg http://uploads.im/rv1co.jpg http://uploads.im/dHwgi.jpg http://uploads.im/5fKWi.jpg
Which USB mouse are you connecting?
It's from A4tech, also I have connected my Keyboard to it and It does throw the same error it's Neco brand.
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/.../