Page 1 of 1

INT0 on D- instead of D+

Posted: Fri Dec 14, 2012 5:55 pm
by Nitz76
Hello,

I've got a board already in production that has INT0 connected to D- instead of D+. See: http://www.retronicdesign.com/wp-content/uploads/2012/07/UsbJoyAdapter.jpg
Is it possible to modify the behavior of V-USB to accept this?

I already tried couple of things but it does not work. I doubt there is something to modify in the USBDRVASM.

Anybody experimented that before?

Thanks!

Nitz

Re: INT0 on D- instead of D+

Posted: Fri Dec 14, 2012 6:40 pm
by ulao
You define your D pins in the usbconfig.h file (Hardware Config). You can set them up on any pins that are int pins.

Re: INT0 on D- instead of D+

Posted: Fri Dec 14, 2012 7:23 pm
by Nitz76
Yup, already done. But it does not work because INT0 is on D- instead of D+.

The important thing mentionned in the code is: "You may
wire the lines to any other port, as long as D+ is also wired to INT0."

Not my case...

Code: Select all

General Description:
This file is an example configuration (with inline documentation) for the USB
driver. It configures AVR-USB for an ATMega8 with USB D+ connected to Port D
bit 2 (which is also hardware interrupt 0) and USB D- to Port D bit 0. You may
wire the lines to any other port, as long as D+ is also wired to INT0.
To create your own usbconfig.h file, copy this file to the directory
containing "usbdrv" (that is your project firmware source directory) and
rename it to "usbconfig.h". Then edit it accordingly.
*/

/* ---------------------------- Hardware Config ---------------------------- */

#define USB_CFG_IOPORTNAME      B
/* 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      0
/* 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       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. Please note that D+ must also be connected
 * to interrupt pin INT0!
 */

Re: INT0 on D- instead of D+

Posted: Fri Dec 14, 2012 8:27 pm
by ulao
Ah right you are, I forgot about that caveat. I can't offer much more help on that. Wait around and see if another can.

Re: INT0 on D- instead of D+

Posted: Sun Dec 16, 2012 8:25 pm
by Nitz76
Hum... looks like it's not as easy as just changing interrupt polarity...

Help anyone? :?:

Code: Select all

/* ----------------------- Optional MCU Description ------------------------ */

/* The following configurations have working defaults in usbdrv.h. You
 * usually don't need to set them explicitly. Only if you want to run
 * the driver on a device which is not yet supported or with a compiler
 * which is not fully supported (such as IAR C) or if you use a differnt
 * interrupt than INT0, you may have to define some of these.
 */
 #define USB_INTR_CFG            MCUCR
 //#define USB_INTR_CFG_SET        ((1 << ISC00) | (1 << ISC01))
 #define USB_INTR_CFG_SET        (1 << ISC01)
 #define USB_INTR_CFG_CLR        0
 #define USB_INTR_ENABLE         GIMSK
 #define USB_INTR_ENABLE_BIT     INT0
 #define USB_INTR_PENDING        GIFR
 #define USB_INTR_PENDING_BIT    INTF0
 #define USB_INTR_VECTOR         SIG_INTERRUPT0

Re: INT0 on D- instead of D+

Posted: Mon Dec 17, 2012 11:51 am
by winelight
Sorry - misunderstood.

Re: INT0 on D- instead of D+

Posted: Mon Dec 17, 2012 8:55 pm
by Nitz76
Hello,

Actually, it works. This issue was with initial port configuration of the device. Just by changing the pins name and number and the interrupt polarity it's good. :wink:

Thanks!

Re: INT0 on D- instead of D+

Posted: Tue Dec 18, 2012 2:54 pm
by winelight
Glad to hear you got it working. Perhaps this topic might be of use to someone else in the future too. Great!

Re: INT0 on D- instead of D+

Posted: Wed Dec 26, 2012 8:45 pm
by Nitz76
Glad if this can help!

Now I have some issue with HIDBootFlash that cannot reprogram the boot flash itself. I will post on another topic.

Thanks!

Re: INT0 on D- instead of D+

Posted: Wed Jan 01, 2014 7:22 am
by moefoe
Could you detail what changes you made to get your code to work on PB0 and PB1?

Thanks.

Re: INT0 on D- instead of D+

Posted: Thu Jan 02, 2014 12:10 am
by blargg
What problems are you having with using PB0 and PB1? If you don't also wire one to an interrupt pin, you'll need to be on a device that supports PCINT (pin change interrupt) that you can configure for one of those two pins.