Hi,
I'm running the code on an AT90USB1287 ... *not* using the hardware USB, running v-usb to see how it works out. Everything looks right level wise, other code on the system runs fine, my i2c buss is doing its thing, lights lighting etc etc. I can see the 1.5K get pulled high when I call usbConnect(); and I can see my Linux box try and talk to the system, but never enumerates ... and setting a breakpoint on usbProcessRx(){...} never hits. I thought it might just be a funny with the JTAG debugger, so it set it to light an LED if the routine ever gets called ... it never does. So, it looks like the ISR is never calling home for some reason.
I thought it might be becuase I am using non-standard pins and interrupts.
Because im using i2c, port D pins 0,1 are in already in use, so INT0 and INT1 are not available either.
I'm running USB into PORTD 2 and 3, D+ on 2, D- on 3, PORTD 2 is INT2. Im unsing PORTC 0 as my pullup via 1.5K
Maybe I missed somethign obvious in the config? I can see the global interrupt get enabled, so im wonderign if maybe INT0 got hardwired somewhere in the assy?? Maybe someone can spot somethign obvious I missed?
Any clues gratefully received.
My usb config includes:
#define USB_CFG_CLOCK_KHZ 12000
#define USB_CFG_IOPORTNAME D
#define USB_CFG_DMINUS_BIT 3
#define USB_CFG_DPLUS_BIT 2
#define USB_CFG_PULLUP_IOPORTNAME C
#define USB_CFG_PULLUP_BIT 0
// #define USB_INTR_CFG MCUCR
// #define USB_INTR_CFG_SET ((1 << ISC01) | (1 << ISC01))
// #define USB_INTR_CFG_CLR 0
/* #define USB_INTR_ENABLE GIMSK */
#define USB_INTR_ENABLE_BIT INT2
/* #define USB_INTR_PENDING GIFR */
#define USB_INTR_PENDING_BIT INTF2
#define USB_INTR_VECTOR INT2_vect
my hardware init is :
static void initHardware(void)
{
DDRC = 1;
PORTC = 0x00;
/*
unsure why this isn't handled in usbInit(), but anyway, set it up here
*/
DDRD = 0xF0; /* 1111 0000 bin */
PORTD = 0x00; /* 0000 0000 bin */
}
and ... in main.c
initHardware();
usbDeviceDisconnect();
_delay_ms(250.0);
usbDeviceConnect();
usbInit();
sei();
for(;;){ /* main event loop */
wdt_reset();
usbPoll();
}
Never hits the interrupt
Re: Never hits the interrupt
I tried V-USB on the same chip recently. One change was having clock_prescale_set( clock_div_1 ); at the beginning of main, but you probably already have this since your other code isn't running in slow-motion.
I used INT0 and had to reconfigure the interrupt:
For INT2, a quick look shows that this is probably correct:
And probably not the cause of the problem, but I don't think you need to configure the USB port's DDR/PORT, as the default input with no pull-up at reset is what usbdrv works with.
I used INT0 and had to reconfigure the interrupt:
Code: Select all
#define USB_INTR_CFG EICRA
#define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01))
#define USB_INTR_CFG_CLR 0
#define USB_INTR_ENABLE EIMSK
#define USB_INTR_ENABLE_BIT INT0
#define USB_INTR_PENDING EIFR
#define USB_INTR_PENDING_BIT INTF0
#define USB_INTR_VECTOR INT0_vect
For INT2, a quick look shows that this is probably correct:
Code: Select all
#define USB_INTR_CFG EICRA
#define USB_INTR_CFG_SET ((1 << ISC20) | (1 << ISC21))
#define USB_INTR_CFG_CLR 0
#define USB_INTR_ENABLE EIMSK
#define USB_INTR_ENABLE_BIT INT2
#define USB_INTR_PENDING EIFR
#define USB_INTR_PENDING_BIT INTF2
#define USB_INTR_VECTOR INT2_vect
And probably not the cause of the problem, but I don't think you need to configure the USB port's DDR/PORT, as the default input with no pull-up at reset is what usbdrv works with.
Re: Never hits the interrupt
Ah ha! ICS20 & ICS21 ... that did it .. all is good.
It won't run with the JTAG debugger doing it's thing, but its just fine otherwise, thank ye!
It won't run with the JTAG debugger doing it's thing, but its just fine otherwise, thank ye!