AVR-USB Device Not Recognized on Atmega8
-
- Rank 1
- Posts: 23
- Joined: Sat Mar 15, 2008 7:46 pm
-
- Rank 1
- Posts: 23
- Joined: Sat Mar 15, 2008 7:46 pm
I mean the handler for INT0, this is in the assembler module. Declare your own handler for INT0 and rename the function in usbdrvasm12.inc (or whatever module you use). The name is USB_INTR_VECTOR (a macro defined to the actual name). Temporarily rename it to something else to avoid linker conflicts.
-
- Rank 1
- Posts: 23
- Joined: Sat Mar 15, 2008 7:46 pm
I disabled USB_INTR_VECTOR in usbdrvasm.S and I added this code to main.c
Every time I reset I get the output from the message. Assuming I did this correctly it appears that INT0 is working.
Code: Select all
ISR(INT0_vect) {
DBG1 (0xFF,0XFF,4);
}
Every time I reset I get the output from the message. Assuming I did this correctly it appears that INT0 is working.
You can distinguish this log from the USB reset log because it's "ff: xx xx xx xx" (ff with four random bytes). To be sure that it's this log, you can use DBG1(0x50, NULL, 0) instead.
You should see a couple of interrupts after connecting USB. When the host gives up after a few seconds, these interrupts should stop.
Assuming that the interrupt works, the handler does not interpret the data correctly. In this case: Are you sure that you compile for the right clock rate? Are you sure D+ and D- are not swapped?
You should see a couple of interrupts after connecting USB. When the host gives up after a few seconds, these interrupts should stop.
Assuming that the interrupt works, the handler does not interpret the data correctly. In this case: Are you sure that you compile for the right clock rate? Are you sure D+ and D- are not swapped?
-
- Rank 1
- Posts: 23
- Joined: Sat Mar 15, 2008 7:46 pm
The interrupt vector I used:
The output I received:
The D- and D+ should be correct. D- is connected to PB0 and D+ is connected to PB1 and PD2. All of the configuration is set at 12Mhz and the fuse bytes are programmed as per the makefile:
Code: Select all
ISR(INT0_vect) {
DBG1(0x50, 0, 0);
}
The output I received:
Code: Select all
ff:
ff:
ff:
ff:
ff:
ff:
ff:
ff:
ff:
ff:
ff:
ff:
f50:
f:
The D- and D+ should be correct. D- is connected to PB0 and D+ is connected to PB1 and PD2. All of the configuration is set at 12Mhz and the fuse bytes are programmed as per the makefile:
Code: Select all
# Fuse low byte:
# 0xef = 1 1 1 0 1 1 1 1
# ^ ^ \+/ \--+--/
# | | | +------- CKSEL 3..0 (clock selection -> crystal @ 12 MHz)
# | | +--------------- SUT 1..0 (BOD enabled, fast rising power)
# | +------------------ CKOUT (clock output on CKOUT pin -> disabled)
# +-------------------- CKDIV8 (divide clock by 8 -> don't divide)
#
# Fuse high byte:
# 0xdb = 1 1 0 1 1 0 1 1
# ^ ^ ^ ^ \-+-/ ^
# | | | | | +---- RSTDISBL (disable external reset -> enabled)
# | | | | +-------- BODLEVEL 2..0 (brownout trigger level -> 2.7V)
# | | | +-------------- WDTON (watchdog timer always on -> disable)
# | | +---------------- SPIEN (enable serial programming -> enabled)
# | +------------------ EESAVE (preserve EEPROM on Chip Erase -> not preserved)
# +-------------------- DWEN (debug wire enable)
#fuse:
# $(AVRDUDE) -U hfuse:w:0xdb:m -U lfuse:w:0xef:m
-
- Rank 1
- Posts: 23
- Joined: Sat Mar 15, 2008 7:46 pm
OK. Then going back to your debug output from above: You see USB RESET (ff:) and one interrupt during reset (50:). You should see many more interrupts, one for each packet sent to the AVR. Since the AVR does not answer, the host should retry the packets several times and retry the entire enumeration procedure several times.
-
- Rank 1
- Posts: 23
- Joined: Sat Mar 15, 2008 7:46 pm
-
- Rank 1
- Posts: 23
- Joined: Sat Mar 15, 2008 7:46 pm
Since you don't get any data packets (or only one at most), I suspect an electrical problem. Did you measure voltage levels at D+ and D-? Is it possible that a wire in the cable is broken or that the pull-ups of the AVR are active for the I/O ports? Just guessing...
AVR-USB is proven to work on the ATMega8. This must be a simple issue. However, it's hard to say what it is from remote...
AVR-USB is proven to work on the ATMega8. This must be a simple issue. However, it's hard to say what it is from remote...