USB Device Not Recognised with AVR Studio and D1/2 for D-/+
Posted: Sat Mar 29, 2008 11:50 pm
I am trying to get AVR-USB to work with a project based on the HIDKeys code. So far the only thing I have changed is the hardware and a little bit of the code.
On my hardware, D- is PD1 and D+ is PD2, so D+ is directly connected to INT0. I am using 3.6V zener diodes with a 2k2 pull-up (works fine with joystick controller based on Igor Cesko's code, see http://joystick.world3.net).
I made the following changes in the code:
usbconfig.h: (to reflect different USB port connections)
main.c (renamed to Replay_Gain_HW.c, shouldn't make any difference, and altered to init port D for USB)
I am using AVR Studio with avr-gcc 4.2.2 (WinAVR 20071221). I have tried with the supplied makefile and one of my own creation.
I can verify that the AVR gets as far the the infinite loop in main() and through at least one cycle of usbPoll(). After what seems like a few cycles the loop stops executing (my in-loop PWM LED turns off, and it doesn't work with the LED code removed either, just in case that was an issue).
I always get a "USB Device Not Recognised" error. Any ideas?
On my hardware, D- is PD1 and D+ is PD2, so D+ is directly connected to INT0. I am using 3.6V zener diodes with a 2k2 pull-up (works fine with joystick controller based on Igor Cesko's code, see http://joystick.world3.net).
I made the following changes in the code:
usbconfig.h: (to reflect different USB port connections)
Code: Select all
#define USB_CFG_IOPORTNAME D
/* This is the port where the USB bus is connected. When you configure it to
* "B", the registers PORTB, PINB and DDRB will be used.
*/
#define USB_CFG_DMINUS_BIT 1
/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
* This may be any bit in the port.
*/
#define USB_CFG_DPLUS_BIT 2
main.c (renamed to Replay_Gain_HW.c, shouldn't make any difference, and altered to init port D for USB)
Code: Select all
static void hardwareInit(void)
{
uint8_t i, j;
PORTB = 0xff; /* activate all pull-ups */
DDRB = 0; /* all pins input */
PORTC = 0xff; /* activate all pull-ups */
DDRC = 0; /* all pins input */
PORTD = 0b00111011; /* activate pull-up on PD4/int1 */
DDRD = 0b11110101; /* all pins output except PD4/int1 */
j = 0;
while(--j) /* USB Reset by device only required on Watchdog Reset */
{
i = 0;
while(--i); /* delay >10ms for USB reset */
}
PORTD = 0b00111111; /* activate pull-up on PD4/int1 */
DDRD = 0b11110001; /* remove USB reset condition and make int0 input */
//PORTD = 0b00111010; /* activate pull-up on PD4/int1 */
/* configure timer 0 for a rate of 12M/(1024 * 256) = 45.78 Hz (~22ms) */
TCCR0 = 5; /* timer 0 prescaler: 1024 */
}
I am using AVR Studio with avr-gcc 4.2.2 (WinAVR 20071221). I have tried with the supplied makefile and one of my own creation.
I can verify that the AVR gets as far the the infinite loop in main() and through at least one cycle of usbPoll(). After what seems like a few cycles the loop stops executing (my in-loop PWM LED turns off, and it doesn't work with the LED code removed either, just in case that was an issue).
I always get a "USB Device Not Recognised" error. Any ideas?