AVR-USB Device Not Recognized on Atmega8

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
kwebdesigns
Rank 1
Rank 1
Posts: 23
Joined: Sat Mar 15, 2008 7:46 pm

AVR-USB Device Not Recognized on Atmega8

Post by kwebdesigns » Sat Mar 15, 2008 7:53 pm

I have built the PowerSwitch project to specifications with a few modifications. Whenever I connect the device I get a USB device not recognized error on more than one Windows computer. From what I have read I am most likely experiencing hardware problems, but I have been unable to find a solution. I have built the circuit exactly like the schematic except I have setup the USB port like the Easylogger project. The Atmega8 is powered by USB and is hooked up to PB0, PB1, and INT0 as in the schematic. Later today I will be able to run the circuit in debug mode and post the output. Thank you for any help.
Last edited by kwebdesigns on Mon Mar 17, 2008 3:53 pm, edited 1 time in total.

kwebdesigns
Rank 1
Rank 1
Posts: 23
Joined: Sat Mar 15, 2008 7:46 pm

Post by kwebdesigns » Mon Mar 17, 2008 3:50 pm

I am trying to debug the device, but I am having problems. I have successfully setup a RS232 port on the device through the UART pins (I tested it with another program and i could send and receive). Once I load the AVR-USB firmware with the debug level at 2 I get no output. What baud rate should I be listening at? Is there something else I did not set up correctly?

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

Post by christian » Mon Mar 17, 2008 6:33 pm

You must do a make clean after enabling debug because there are no dependencies in the Makefile. The output should be at 19200 bps and you must have F_CPU defined.

kwebdesigns
Rank 1
Rank 1
Posts: 23
Joined: Sat Mar 15, 2008 7:46 pm

Post by kwebdesigns » Mon Mar 17, 2008 8:37 pm

I am receiving something on the serial port now, but it shows up as spaces. What program would you recommend for Linux or Windows to debug this?

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

Post by christian » Mon Mar 17, 2008 8:54 pm

I'm using Kermit on Unix. Not because it's so good, but because it's so old that it has always been around and I'm somewhat used to it.

kwebdesigns
Rank 1
Rank 1
Posts: 23
Joined: Sat Mar 15, 2008 7:46 pm

Post by kwebdesigns » Mon Mar 17, 2008 10:07 pm

I am still getting nothing over the serial port. I ended up using TeraTerm. Kermit is ridiculously complicated to me. I have tried connecting the AVR differently from several of the projects, but I am still having problems. What can I do to get this to work? Thanks.

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

Post by christian » Tue Mar 18, 2008 12:02 pm

Did you check parity settings etc? You need 8 bit no parity. And are you sure that your level converter works correctly?

kwebdesigns
Rank 1
Rank 1
Posts: 23
Joined: Sat Mar 15, 2008 7:46 pm

Post by kwebdesigns » Tue Mar 18, 2008 4:11 pm

The parity settings are correct and I can confirm the max232 is working. I wrote a test program that can send and receive at 19200 bps with no problem. What kind of output should I be seeing with the firmware in debug mode? I am determined to make this work. Thank you for your patience.

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

Post by christian » Tue Mar 18, 2008 5:10 pm

You should expect hexadecimal output in the format:

01: 02 03 04 05 06

See oddebug.h for the initialization of the UART and oddebug.c for how the data is actually output. Newer devices might require additional initialization.

kwebdesigns
Rank 1
Rank 1
Posts: 23
Joined: Sat Mar 15, 2008 7:46 pm

Post by kwebdesigns » Tue Mar 18, 2008 6:35 pm

I am beginning to make some progress. I now have debugging set up and working correctly. The problem was a combination of oddebug.h not being included and DEBUG_LEVEL being defined in the wrong place. The functions uartPutc() and printHex() are now working correctly. The serial data I am now receiving is about a line of blank space then it displays "Debugging initialized", which I added in the main function after odDebugInit(). Is there some code I need to add to make powerswitch utilize debugging?

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

Post by christian » Tue Mar 18, 2008 6:49 pm

I don't understand why you get a line of blank lines, but let's ignore this for the moment.

AVR-USB uses DBG1() and DBG2() to print debug info. These are macros which expand to odDebug() when debugging is enabled. You should at least see "ff:" when a USB reset is detected.

kwebdesigns
Rank 1
Rank 1
Posts: 23
Joined: Sat Mar 15, 2008 7:46 pm

Post by kwebdesigns » Tue Mar 18, 2008 7:03 pm

Sometimes I get this compiler error:

Code: Select all

main.c:(.text+0x1bc): multiple definition of `odDebug'
usbdrv/oddebug.o:oddebug.c:(.text+0x2c): first defined here


I see what you mean about DBG1 and DBG2. What order should I be including the files in main?

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

Post by christian » Tue Mar 18, 2008 7:32 pm

You get this error if you link oddebug.o twice or if you link it AND include it in main.c. You should only link this file, not include it.

kwebdesigns
Rank 1
Rank 1
Posts: 23
Joined: Sat Mar 15, 2008 7:46 pm

Post by kwebdesigns » Tue Mar 18, 2008 7:51 pm

I am no longer getting compiler errors, but now I am back to getting no serial output. I can still run DBG1() and DBG2() fine. If I did not have the USB port connected to the AVR properly would I still see serial output?

EDIT: Whenever I unplug and plug the USB port in I get this:

Code: Select all

Àff:
ff:
ff:
ff:
ff:
ff:
ff:
ff:
ff:
ff:
ff:
ff:
ff:
Last edited by kwebdesigns on Tue Mar 18, 2008 7:55 pm, edited 1 time in total.

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

Post by christian » Tue Mar 18, 2008 7:54 pm

I don't think so, since there is no DBG1 or DBG2 in main(). Simply add a

DBG1(0x00, NULL, 0);

to main() so that you get debug output in any case. An always do a "make clean" before building because the Makefile has no dependencies.

Post Reply