Noob question about Windows HID

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
Mark
Posts: 4
Joined: Fri Jan 20, 2012 3:08 pm

Noob question about Windows HID

Post by Mark » Fri Jan 20, 2012 3:21 pm

Hello to all,

I'm going to connect my first vusb board to a windows machine. Here the schematic:

Image

Here the fuse settings:

Code: Select all

   BODLEVEL = 4V3
   OCDEN = [ ]
   JTAGEN = [ ]
   SPIEN = [X]
   WDTON = [ ]
   EESAVE = [X]
   BOOTSZ = 4096W_7000
   BOOTRST = [ ]
   CKDIV8 = [ ]
   CKOUT = [ ]
   SUT_CKSEL = EXTXOSC_8MHZ_XX_16KCK_65MS


Using AVR Studio 5 I compiled the hid-data example for ATmega644 (even if on my board there's a ATmega644P, actually).
The MCU is running at the correct frequency of 20 MHz. I tested it with a sample program.

I'm still in trouble with the host software (I have errors with minGW) but in the meanwhile I tried to connect the USB cable to the computer.
Nothing happens. I'm wondering if I should see the new HID device in the device manager.

These are the main options in usbconfig.h :

Code: Select all

#define USB_CFG_IOPORTNAME      D
#define USB_CFG_DMINUS_BIT      4
#define USB_CFG_DPLUS_BIT       2
#define USB_CFG_CLOCK_KHZ       (20000)
#define USB_CFG_CHECK_CRC       0
#define USB_CFG_PULLUP_IOPORTNAME   D
#define USB_CFG_PULLUP_BIT          5
#define USB_CFG_HAVE_INTRIN_ENDPOINT    1
#define USB_CFG_HAVE_INTRIN_ENDPOINT3   0
#define USB_CFG_EP3_NUMBER              3
#define USB_CFG_IMPLEMENT_HALT          0
#define USB_CFG_SUPPRESS_INTR_CODE      0
#define USB_CFG_INTR_POLL_INTERVAL      100
#define USB_CFG_IS_SELF_POWERED         1
#define USB_CFG_MAX_BUS_POWER           50
#define USB_CFG_IMPLEMENT_FN_WRITE      1
#define USB_CFG_IMPLEMENT_FN_READ       1
#define USB_CFG_IMPLEMENT_FN_WRITEOUT   0
#define USB_CFG_HAVE_FLOWCONTROL        0
#define USB_CFG_DRIVER_FLASH_PAGE       0
#define USB_CFG_LONG_TRANSFERS          0
#define USB_COUNT_SOF                   0
#define USB_CFG_CHECK_DATA_TOGGLING     0
#define USB_CFG_HAVE_MEASURE_FRAME_LENGTH   0
#define USB_USE_FAST_CRC                1
#define  USB_CFG_VENDOR_ID       0xc0, 0x16 /* = 0x16c0 = 5824 = voti.nl */
#define  USB_CFG_DEVICE_ID       0xdf, 0x05 /* obdev's shared PID for HIDs */
#define USB_CFG_DEVICE_VERSION  0x00, 0x01
#define USB_CFG_VENDOR_NAME     'o', 'b', 'd', 'e', 'v', '.', 'a', 't'
#define USB_CFG_VENDOR_NAME_LEN 8
#define USB_CFG_DEVICE_NAME     'D', 'a', 't', 'a', 'S', 't', 'o', 'r', 'e'
#define USB_CFG_DEVICE_NAME_LEN 9
#define USB_CFG_DEVICE_CLASS        0
#define USB_CFG_DEVICE_SUBCLASS     0
#define USB_CFG_INTERFACE_CLASS     3
#define USB_CFG_INTERFACE_SUBCLASS  0
#define USB_CFG_INTERFACE_PROTOCOL  0
#define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH    22



Thanks in advance!
Mark

Peter Chaffe
Rank 1
Rank 1
Posts: 20
Joined: Fri Dec 02, 2011 12:25 pm

Re: Noob question about Windows HID

Post by Peter Chaffe » Fri Jan 20, 2012 5:26 pm

Mark you didn't say what the circuit is supposed to be doing!ft g

Just by looking at it quickly, there is several things I would change regardless!

(1) take usb pin3 to INT0.
(2) change crystal to 12 mhz.
(3) Your circuit suggests you want to control channels from the host, if so suggest not use hid but use the powerSwitch example.
(4) Regarding host soft. mingw for windows, are you using devC ? which if you are is outdated and unsupported.
Much better to use Visual C or port to Delphi...

Mark
Posts: 4
Joined: Fri Jan 20, 2012 3:08 pm

Re: Noob question about Windows HID

Post by Mark » Fri Jan 20, 2012 5:35 pm

Peter Chaffe wrote:Mark you didn't say what the circuit is supposed to be doing!ft g


It doesn't matter. I'm only trying to exchange data to a pc using the hid-data example.

(1) take usb pin3 to INT0.


It's already connected to INT0 (PD2)

(2) change crystal to 12 mhz.



Why? The doc of vusb says I can use a 20 MHz crystal. I need to go fast for the other activities.


(3) Your circuit suggests you want to control channels from the host, if so suggest not use hid but use the powerSwitch example.



Nope. I don't want to control channels from the host.
I will use the USB connection only to transfer small amount of data - user parameters.


(4) Regarding host soft. mingw for windows, are you using devC ? which if you are is outdated and unsupported.



At the moment, I'm just trying to compile the examples, from the command line, invoking mingw32-make.
Then I will use Qt4.

By the way, you didn't answer my question :D
When I program the MCU with the hid-data firmware and connect the usb cable to the pc, should I see the "new device found" popup? Should I found the new HID device in the device manager?

Thanks!
Mark

Peter Chaffe
Rank 1
Rank 1
Posts: 20
Joined: Fri Dec 02, 2011 12:25 pm

Re: Noob question about Windows HID

Post by Peter Chaffe » Fri Jan 20, 2012 8:26 pm

First priority is to get the usb connection functional. if necessary without the rest of the circuit connected(this is sometimes a sensible approach when using a different mcu than suggested in a working example).

choice of clock freq is all part of ensuring the primary goal of having a working usb connection. 20 mhz is the extreme top end of the 164 & 644 range, while it might well function at this speed I would tend to just get the v-usb working first at a more moderate clock speed, then experiment once the connection is up and working, believe me, getting a reliable usb connection first time around is somewhat hit or miss, especially over a range of different PC's, mainly because of the very approximate way in which v-usb adheres to the usb protocol.

observed reaction varies with different os's, but all will notify you on first time connect and will/should load the generic hid driver without input from user (other than plugging in the device into the usb in the first place). once recognized, the driver is loaded, details written to registry, so that with future use of that device you will only hear the 2-tone sound notification that a device has been plugged in.

To see a list of loaded devices there are a few free tools around, usbview from Ms.
Also have a look at the tools section on usb.org.

Mark
Posts: 4
Joined: Fri Jan 20, 2012 3:08 pm

Re: Noob question about Windows HID

Post by Mark » Sat Jan 21, 2012 11:13 am

Peter Chaffe wrote:First priority is to get the usb connection functional. if necessary without the rest of the circuit connected(this is sometimes a sensible approach when using a different mcu than suggested in a working example).


I know this. In fact I mounted only the MCU and the USB stuff. Nothing else.

choice of clock freq is all part of ensuring the primary goal of having a working usb connection. 20 mhz is the extreme top end of the 164 & 644 range, while it might well function at this speed I would tend to just get the v-usb working first at a more moderate clock speed, then experiment once the connection is up and working, believe me, getting a reliable usb connection first time around is somewhat hit or miss, especially over a range of different PC's, mainly because of the very approximate way in which v-usb adheres to the usb protocol.



Ok, I replaced the crystal with a 12 MHz one. No chance.
Nothings happens when connecting to PC.


observed reaction varies with different os's, but all will notify you on first time connect and will/should load the generic hid driver without input from user (other than plugging in the device into the usb in the first place). once recognized, the driver is loaded, details written to registry, so that with future use of that device you will only hear the 2-tone sound notification that a device has been plugged in.



That was what I knew. In the past a played a bit with a Microchip PIC to build some HID joystick.

What should I do in order to find out the problem? Wait....
.
.
.
Found the issue! There was a very small drop of tin between pin 4 and 5 of the smd usb connector :oops:

Now the examples work. I will go ahead with learning.

Peter Chaffe
Rank 1
Rank 1
Posts: 20
Joined: Fri Dec 02, 2011 12:25 pm

Re: Noob question about Windows HID

Post by Peter Chaffe » Sat Jan 21, 2012 1:19 pm

If absolutely nothing happens when its plugged in then D- is not being pulled high, good, looks like you've found the problem...

Post Reply