Author Topic: Driver for USB HID demo program  (Read 26117 times)

dlelievre

  • Member
  • ***
  • Posts: 14
Driver for USB HID demo program
« on: November 16, 2010, 07:09:10 am »
Hi, I am trying to develop a USB PIC application controlled from VB6 and I am finding your example very helpful. However when I load and run the firmware on the PIC device I am having trouble with the windows driver ( I am using XP). When I plug in the USB port with firmware running, windows states found new hardware, but what driver shall I use? I tried the microchips inf files and they were rejected? Hope you can help please?

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Driver for USB HID demo program
« Reply #1 on: November 16, 2010, 09:59:16 am »
If it's a HID-class device, you don't need to provide an INF. bInterfaceClass=3 in the descriptors will cause the OS to assign the system's INF file for HIDs. What are your descriptors?

Jan

dlelievre

  • Member
  • ***
  • Posts: 14
Re: Driver for USB HID demo program
« Reply #2 on: November 16, 2010, 11:53:54 am »
Thanks Jan for getting back to me. I am using everything exactly as your example at the moment with no modifications just to get myself going first.
 Cannot find binterfaceclass statement in your example? Where should I add this?
I am using PC18F4550.
Thanks again Dave

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Driver for USB HID demo program
« Reply #3 on: November 16, 2010, 12:12:04 pm »
bInterfaceClass is in, if I recall correctly, descriptors.c in the PIC code.

Jan

dlelievre

  • Member
  • ***
  • Posts: 14
Re: Driver for USB HID demo program
« Reply #4 on: November 16, 2010, 02:41:31 pm »
Hi Jan, sorry to be a pain but I just can't make this work. I am just trying to make your pic code firmware work with your VB6 code as is first of all ,with no mods. I am a hardware eng and my software skills are rubbish. Anyway not sure what to edit but changed the following as shown below. Is this correct?
Windows still came up and stated found new hardware and wanted to know which driver to use. I am confused as I wonder if I need the installation described in http://msdn.microsoft.com/en-us/library/ff540283(VS.85).aspx
Hope you can help and thankyou again for your patience
Best Regards
Dave
/* Device Descriptor */
ROM USB_DEVICE_DESCRIPTOR device_dsc=
{
    0x12,                   // Size of this descriptor in bytes
    USB_DESCRIPTOR_DEVICE,  // DEVICE descriptor type
    0x0200,                 // USB Spec Release Number in BCD format       
    0x03,                   // Class Code default 00
    0x00,                   // Subclass code
    0x00,                   // Protocol code
    USB_EP0_BUFF_SIZE,      // Max packet size for EP0, see usb_config.h
    0x0925,                 // Vendor ID: 0x0925 is Lakeview Research's Vendor ID
    0x1456,                 // Product ID: 0x1456
    0x0001,                 // Device release number in BCD format
    0x01,                   // Manufacturer string index
    0x02,                   // Product string index
    0x00,                   // Device serial number string index
    0x01                    // Number of possible configurations
};


Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Driver for USB HID demo program
« Reply #5 on: November 16, 2010, 03:39:08 pm »
That's the device descriptor. Change Class Code (bDeviceClass) = 03h to 00h. In the interface descriptor, set bInterfaceClass = 03h..

Jan

dlelievre

  • Member
  • ***
  • Posts: 14
Re: Driver for USB HID demo program
« Reply #6 on: November 16, 2010, 03:55:28 pm »
Thanks Jan, you have got me further as it no longer wants to find the driver. However now in device manager I get the yellow excalmation mark with the error "This device cannot start (code10). I had both USB status LEDs flashing, then just the one on port D o/p 0 flashing  when I plugged in the USB cable. Then after a second or 2 reverted back to both leds flashing. Again thanks for your patience
Best Regards
Dave

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Driver for USB HID demo program
« Reply #7 on: November 16, 2010, 10:44:47 pm »
Are you using my generic HID PIC code with no changes? On what hardware? In Device Manager, do you see the device identified as a HID (with error)?

Jan

dlelievre

  • Member
  • ***
  • Posts: 14
Re: Driver for USB HID demo program
« Reply #8 on: November 17, 2010, 09:17:40 am »
Hi Jan, I am using your code with no modifications except for the binterfclass, code shown below. Should subclass and protocol be 0xFF? The hardware is from olimex link http://www.olimex.com/dev/pdf/PIC/PIC-USB-4550.pdf. I have also tried with debugger disconnected and PCB powered from USB bus

The drivers loaded are as follows hidclass.sys, hidparse.sys, hidusb.sys and hid.dll. I also tried it on a Vesta system with the same result. It is identified as a "USB Human Interfaces Device" Location 0 (WinUSB Demo) The device ID showed USB\VID-0925&PID_1456\5&2C93D4FD&0&1
Thanks again
Dave

    /* Interface Descriptor */
    0x09,//sizeof(USB_INTF_DSC),      // Size of this descriptor in bytes
    USB_DESCRIPTOR_INTERFACE,       // INTERFACE descriptor type
    0,                            // Interface Number
    0,                            // Alternate Setting Number
    4,                            // Number of endpoints in this intf
    0x03,                         // Class code was 0xFF
    0xFF,                         // Subclass code
    0xFF,                         // Protocol code
    0,   

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Driver for USB HID demo program
« Reply #9 on: November 17, 2010, 09:44:12 am »
My generic HID example has bInterfaceClass = 03h. It's available here:

http://www.lvr.com/hidpage.htm#MyExampleCode

Jan

dlelievre

  • Member
  • ***
  • Posts: 14
Re: Driver for USB HID demo program
« Reply #10 on: November 17, 2010, 11:55:40 am »
Thankyou so much Jan, it works at last. Sorry I must have downloaded the wrong example for some reason. I think without your help I would never have got there. One final question for now, is your VB6 program USBHIDIO2 compatible with this firmware. It seemed to work but not sure yet, can you confirm
I want to develop am application on the PIC controlled by VB6. I already use this application on a PCI card but would like to migrate to a USB interface so I can use a laptop.
Thanks again
Dave

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Driver for USB HID demo program
« Reply #11 on: November 18, 2010, 10:37:36 am »
Yes, the VB6 software should work though my .NET code is more full-featured.

You might have to change the Vendor ID and Product ID to match your device. I don't recall offhand if that's in the source code or user interface in that version.

Jan

dlelievre

  • Member
  • ***
  • Posts: 14
Re: Driver for USB HID demo program
« Reply #12 on: December 08, 2010, 11:42:47 am »
Hi Jan, just wanted to say thanks for getting me going. I have built my application now and so far it all appears working so I am progressing to PCB layout. I did find a few quirks using the system, such as reads appearing before writes and certain USB output buffer locations corrupted by USB input buffer locations. However although I did not solve these problems I always found a work around. Anyway thanks again for your help.
Best Regards
Dave

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Driver for USB HID demo program
« Reply #13 on: December 08, 2010, 02:08:30 pm »
You're welcome!

Jan