V-USB HID joystick doesn't work ... sometimes
Posted: Sat Jan 16, 2010 8:56 pm
Hi,
I'm tyring to create a HID joystick device based on V-USB and I'm nearly going mad. I took the HID-mouse example as basis for my project: I modified the descriptor, threw out the advanceCircleByFixedAngle() function, added the ADC routines and got it finally running. The device got recognized by windows 7 x64 and the captured analog data (1 axis, 10 bit) was shown in the gamepad controller panel.
Then I wanted to extend the firmware so that now 5 analog inputs are sampled by the ADC and sent to the host. First, I just added the ADC routines and didn't modify the USB descriptor (in usbSetInterrupt() the same data is sent as before) - the ADC routines are working fine (I checked this with AVR dragon and AVRStudio), but now the device doesn't get recognized by windows any more! The data sent via USB hasn't been modified and the structure to send the data hasn't also been modified - I just added some code to the ADC routine.
My assumption is that because of the ADC interrupt service routine gets triggered more often now this breaks the usb communication part somehow. I tried to get some information about time-criticial parts of V-USB, but either I'm blind or their not documented.
The problem occurs on an ATmega32 running at 12MHz. The endless loop in main.c looks like this:
Any ideas, anyone?
I'm tyring to create a HID joystick device based on V-USB and I'm nearly going mad. I took the HID-mouse example as basis for my project: I modified the descriptor, threw out the advanceCircleByFixedAngle() function, added the ADC routines and got it finally running. The device got recognized by windows 7 x64 and the captured analog data (1 axis, 10 bit) was shown in the gamepad controller panel.
Then I wanted to extend the firmware so that now 5 analog inputs are sampled by the ADC and sent to the host. First, I just added the ADC routines and didn't modify the USB descriptor (in usbSetInterrupt() the same data is sent as before) - the ADC routines are working fine (I checked this with AVR dragon and AVRStudio), but now the device doesn't get recognized by windows any more! The data sent via USB hasn't been modified and the structure to send the data hasn't also been modified - I just added some code to the ADC routine.
My assumption is that because of the ADC interrupt service routine gets triggered more often now this breaks the usb communication part somehow. I tried to get some information about time-criticial parts of V-USB, but either I'm blind or their not documented.
The problem occurs on an ATmega32 running at 12MHz. The endless loop in main.c looks like this:
Code: Select all
for(;;){ /* main event loop */
wdt_reset();
AdcGetCurrentStatus (&AdcCurrentState_en);
/* Get data from Adc if AD conversion is finished */
if (ADC_FINISHED == AdcCurrentState_en) {
/* Read single channel data from ADC */
AdcGetCurrentData(&AnalogAxisData_u16);
}
usbPoll();
if(usbInterruptIsReady()){
usbSetInterrupt((void *)&AnalogAxisData_u16, sizeof(AnalogAxisData_u16));
}
}
Any ideas, anyone?