Page 1 of 3

AVR-USB Device Not Recognized on Atmega8

Posted: Sat Mar 15, 2008 7:53 pm
by kwebdesigns
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.

Posted: Mon Mar 17, 2008 3:50 pm
by kwebdesigns
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?

Posted: Mon Mar 17, 2008 6:33 pm
by christian
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.

Posted: Mon Mar 17, 2008 8:37 pm
by kwebdesigns
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?

Posted: Mon Mar 17, 2008 8:54 pm
by christian
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.

Posted: Mon Mar 17, 2008 10:07 pm
by kwebdesigns
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.

Posted: Tue Mar 18, 2008 12:02 pm
by christian
Did you check parity settings etc? You need 8 bit no parity. And are you sure that your level converter works correctly?

Posted: Tue Mar 18, 2008 4:11 pm
by kwebdesigns
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.

Posted: Tue Mar 18, 2008 5:10 pm
by christian
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.

Posted: Tue Mar 18, 2008 6:35 pm
by kwebdesigns
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?

Posted: Tue Mar 18, 2008 6:49 pm
by christian
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.

Posted: Tue Mar 18, 2008 7:03 pm
by kwebdesigns
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?

Posted: Tue Mar 18, 2008 7:32 pm
by christian
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.

Posted: Tue Mar 18, 2008 7:51 pm
by kwebdesigns
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:

Posted: Tue Mar 18, 2008 7:54 pm
by christian
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.