problems with using external interrupt different from INT0

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
MaxAnarki
Posts: 11
Joined: Tue Dec 25, 2007 6:54 pm
Contact:

Post by MaxAnarki » Thu Jan 10, 2008 5:08 pm

OK, then where are that users ? Why they are silent ? Here is no one why had success in this situation.
I completely sure what the driver 1.12.2007 doest work with interrupts other than INT0 because I have very simple device - only USB socket and there is an end to it. And I make tuning of the header file. In the hardware there aren't any problems.

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Thu Jan 10, 2008 6:11 pm

People usually only watch the forum while they work on a project. I know that andy from thread http://forums.obdev.at/viewtopic.php?t=1047 uses an ATMega32 where hardware interrupt 2 is used for USB. His usbconfig.h contains the following changes from the default:

#define USB_CFG_DMINUS_BIT 4
#define USB_CFG_DPLUS_BIT 2
#define USB_INTR_CFG MCUCSR
#define USB_INTR_CFG_SET (1 << ISC2)
#define USB_INTR_ENABLE_BIT INT2
#define USB_INTR_PENDING_BIT INTF2
#define USB_INTR_VECTOR SIG_INTERRUPT2

vobs
Posts: 5
Joined: Sun Jul 29, 2007 8:02 pm
Location: Stuttgart, Germany
Contact:

Post by vobs » Thu Jan 10, 2008 6:51 pm

MaxAnarki wrote:OK, then where are that users ? Why they are silent ? Here is no one why had success in this situation.

Sorry, I don't see any reason for not keeping silent! Yes, I managed to get the AVR-USB code working, using Int2 on a Mega162 and it only caused me about one hour to get it working -- so what? Does this information help you? I doubt it!

Belief me, I looked over your code and did not find any mistake in the code you posted, so I absolutely agree with Christian: The error is either at a location in your code that you did not post here or in your hardware!

And I'm very sorry, but you can believe me, I've got plenty of things to do and all of them are more important to me than fixing your mistakes!

Btw, do you really think you get support, after telling us something like this:
MaxAnarki wrote:I do not have time for learning not my so complicated code.


A last short comment from my side: Please take Christian's hints for serious: In my application neither Int0 nor Int1 are used when the USB interface is active.

Which cross compiler do you use? I don't know if chosing other interrupts than Int0 works for other compilers than gcc.

MaxAnarki
Posts: 11
Joined: Tue Dec 25, 2007 6:54 pm
Contact:

Post by MaxAnarki » Fri Jan 11, 2008 11:52 am

I use WinAvr and avr-gcc compiller.

So you are absolutly sure what the only thing what is needed to get it works - tuning the header file. And there arent any errors in the driver.. And no other fixing is needed in the driver.

OK. It IS information.

MaxAnarki
Posts: 11
Joined: Tue Dec 25, 2007 6:54 pm
Contact:

Post by MaxAnarki » Fri Jan 11, 2008 12:00 pm

to VOBS

Dear sir I asked answer from the authors of this driver and I do not need you to learn my code. I didnt post my code here.

Guest

Post by Guest » Fri Jan 11, 2008 12:47 pm

To: Christian

Thank you for example. I have tried again to resolve the problem. I tried to solder USB wires to INT1(DPLUS), INT2(DMINUS), tried amount of different combinations of:

#define USB_INTR_CFG MCUCSR // EICRB
#define USB_INTR_CFG_SET ((1 << ISC11) | (1 << ISC10))
//#define USB_INTR_CFG_CLR 0
//#define USB_INTR_ENABLE EIMSK //GIMSK
#define USB_INTR_ENABLE_BIT INT1
//#define USB_INTR_PENDING EIFR
#define USB_INTR_PENDING_BIT INTF1
#define USB_INTR_VECTOR SIG_INTERRUPT1

and

#define USB_CFG_IOPORTNAME D
#define USB_CFG_DMINUS_BIT 2
#define USB_CFG_DPLUS_BIT 1

but with no success.

Remember, my schematic has only one connector - USB which works perfectly on many computers and notebooks using INT0.

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Fri Jan 11, 2008 5:08 pm

You mentioned that you updated usbconfig.h. That's all there is to change for the driver itself.

But did you also update the hardware initialization in main()? Note that the USB pins must be configured as inputs without pull-up resistor. If you do a USB RESET in main, you must also update this code.

Guest

Post by Guest » Fri Jan 11, 2008 5:28 pm

But the configuration of that pins is made by the following part of the driver:

int main(void)
{
// cli();

dev_init(); // all pins as output

/* clear usb ports */
USB_CFG_IOPORT &= (uchar)~((1<<USB_CFG_DMINUS_BIT)|(1<<USB_CFG_DPLUS_BIT));

/* make usb data lines outputs */
USBDDR |= ((1<<USB_CFG_DMINUS_BIT)|(1<<USB_CFG_DPLUS_BIT));

/* USB Reset by device only required on Watchdog Reset */
_delay_loop_2(40000); // 10ms

/* make usb data lines inputs */
USBDDR &= ~((1<<USB_CFG_DMINUS_BIT)|(1<<USB_CFG_DPLUS_BIT));


usbInit();

/* Reset WDT
//__watchdog_reset();
wdt_reset();
// Write logical one to WDCE and WDE
WDTCR |= (1<<WDCE) | (1<<WDE);
// Turn off WDT
WDTCR = 0x00;
*/


sei();

/* configure timer 0 for a rate of 12M/(1024 * 256) = 45.78 Hz (~22ms) */
// TCCR0 = 5;

// wdt_enable(WDTO_1S);
......


And what did u mean about "USB RESET" ? I dont understand that.

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Fri Jan 11, 2008 6:38 pm

The main() code looks OK since you use the constants from usbconfig.h. USB RESET is the condition while in the delay loop. BTW: I would recommend to increase the RESET time to 500 ms. That's not related to the interrupt problem, though.

I'm afraid I'm out of ideas here, other than the general hints I already gave. Sorry...

MaxAnarki
Posts: 11
Joined: Tue Dec 25, 2007 6:54 pm
Contact:

Post by MaxAnarki » Fri Jan 25, 2008 5:43 pm

Ok, admin, please delete this topic..

baddemanax

different INT doesn't work yet on tiny45

Post by baddemanax » Tue Feb 05, 2008 7:41 pm

Hi all,

I am having same kind of issue on a tiny45 where i am trying to get the usb working on a different interrupt level.

I started from the easylogger demo as such, in order not to use external crystal. this works succesfully.
Then i moved the USB line to PINB3 and PINB4, with a cable to INT0.
This version also works.

Then i configure the usbconfig.h file in order to use the interrupt on PCINT3.
But this version doesn't work yet.

code example :

#define USB_CFG_DMINUS_BIT 4
#define USB_CFG_DPLUS_BIT 3

#define USB_INTR_CFG PCMSK
#define USB_INTR_CFG_SET (1 << PCINT3)
/* #define USB_INTR_CFG_CLR 0 */
/* #define USB_INTR_ENABLE GIMSK */
#define USB_INTR_ENABLE_BIT PCIE
/* #define USB_INTR_PENDING GIFR */
#define USB_INTR_PENDING_BIT PCIF

For the time being I don't know yet how to debug. maybe you have some hints in order to progress.

Also i am not using any other interrupts. My main application is doing nothing except initalising usb and setting interrupts, it is based on the easyloger demo.


int main(void)
{
uchar i;

uchar calibrationValue = eeprom_read_byte(0);
if(calibrationValue != 0xff){
OSCCAL = calibrationValue; /* a calibration value is supplied */
}else{
/* we have no calibration value, assume 8 MHz calibration and adjust from there */
if(OSCCAL < 125){
OSCCAL += 3; /* should be 3.5 */
}else if(OSCCAL >= 128){
OSCCAL += 7; /* should be 7 */
}else{ /* must be between 125 and 128 */
OSCCAL = 127; /* maximum possible avoiding discontinuity */
}
}

DDRB = (1 << USB_CFG_DMINUS_BIT) | (1 << USB_CFG_DPLUS_BIT);
PORTB = 0; /* indicate USB disconnect to host */
for(i=0;i<20;i++){ /* 300 ms disconnect, also allows our oscillator to stabilize */
_delay_ms(15);
}
DDRB = 1 << BIT_LED; /* output for LED is pinB1*/

usbInit();
sei();
for(;;){ /* main event loop */

usbPoll();
if(usbInterruptIsReady() && nextDigit != NULL){ /* we can send another key */
buildReport();
usbSetInterrupt(reportBuffer, sizeof(reportBuffer));
if(*++nextDigit == 0xff) /* this was terminator character */
nextDigit = NULL;
}

}
return 0;
}

if you see something.

regards

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Tue Feb 05, 2008 8:06 pm

Can you please mail me the entire project to the avrusb8 at obdev dot at address? I'd like to have a look at the disassembled binary.

baddemanax

problem solved

Post by baddemanax » Wed Feb 06, 2008 4:34 pm

Hi all,

thanks to christian's remarks i found out the solution.

in the file usbconfig-prototype. h there is the following define :

#define USB_INTR_VECTOR SIG_INTERRUPT0


this define must be change to :

#define USB_INTR_VECTOR SIG_PIN_CHANGE

in order to be able to use PCINT interrupts.

now it works.

many thanks.

apollononnno
Rank 1
Rank 1
Posts: 25
Joined: Wed Jul 23, 2008 5:31 am
Location: JAPAN

Re: problem solved

Post by apollononnno » Wed Jul 23, 2008 5:39 am

I am use "Atmega168p", and consecutive port "2*8BIT" 4pin of PC2 except RESET, PC0,
and PC1, PC3, PC4, and PC5 will be effectively used.
I want to change "Terminal USB" from standard "D+PD4,D-PD2" to "D+PC0,D-PC1".
I changed as follows.
To apply the name etc. of the function , for instance, "USB_INTR_ENABLE" more, I
want to learn in detail.
Is it correct which to be selected? "usbconfig.h" "usbdrv.h" "usbconfig-prototype.h" "bootloaderconfig.h"
I
I wrote made ".hex" in atmega168p.
However, it was not able not to operate at all, and to confirm the content as a
programmer.
I. If another problem is not solved more, the pin change of USB cannot be confirmed.

I did not find the item which fell under "1".
I validated "2" and got a result of compiling it.
However, I was not "three" negative results in that, but watched a slightly bad part.
Do not I need to pay attention to this item?

/* "usbconfig-prototype.h" "bootloaderconfig.h" */
/* Atmega168p */
/* ----------------------- Optional Hardware Config ------------------------ */
#define USB_CFG_IOPORTNAME C
#define USB_CFG_DMINUS_BIT 1
#define USB_CFG_DPLUS_BIT 0
/* ----------------------- Optional Hardware Config ------------------------ */
/* #define USB_CFG_PULLUP_IOPORTNAME C */
/* #define USB_CFG_PULLUP_BIT 1 */

/* usbconfig.h */
1
/* #define USB_INTR_CFG MCUCR / IVSEL? IVCE? */
/* #define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01)) / EICRA?INT0 */
2
#define USB_INTR_CFG_CLR 0
#define USB_INTR_ENABLE PCMSK1
#define USB_INTR_ENABLE_BIT PCINT8
#define USB_INTR_PENDING PCIFR
#define USB_INTR_PENDING_BIT PCIF1
3
usbdrv/usbdrv.h:198: warning: 'usbFunctionDescriptor' used but never defined
4
avr-objcopy -j .text -j .data -O ihex main.bin main.hex
avr-size main.hex
text data bss dec hex filename
0 2520 0 2520 9d8 main.hex
Build succeeded with 1 Warnings...

Post Reply