Page 1 of 2

USB with atmega 32

Posted: Mon Dec 31, 2007 4:38 pm
by Phoenix
Hi,

First of al sorry for the bad English, I'm Dutch.

I'm trying to make a controller that works with USB and a atmega 32
But I'm not an expert in C++ and other langues.

I tried this software/hardware

http://www.obdev.at/products/avrusb/index.html
http://www.obdev.at/products/avrusb/bootloadhid.html

But I can't make it work.
So I'm asking for help with my project.

Crystal = 12 Mhz

What really helps me is that somebody tells me what as have te ajust and with witch programs because I find the readme file to basic and don't what that they mean.

Posted: Wed Jan 02, 2008 8:15 pm
by christian
Your link referred to AVR-USB's index page, not a particular project. As far as I know, there is no project on our site (or linked form our site) which uses the ATMega32. If you use the Mega32, you need to update some configurations and probably fuse values.

For a beginner, I would recommend that you use the same chip as your reference project, make this reference project work and then modify it according to your needs.

Posted: Thu Jan 03, 2008 2:14 pm
by Phoenix
I don't really have choise I have to make it work with the Mega32.
But I ajust it everyting. But when I compile it I get errors in WinAVR
This error I get when I compile the commandoline software

Code: Select all

gcc  -O2 -Wall  -c main.c -o main.o
process_begin: CreateProcess(NULL, gcc -O2 -Wall -c main.c -o main.o, ...) failed.
make (e=2): Het systeem kan het opgegeven bestand niet vinden.

make.exe: *** [main.o] Error 2


And when I compile the firmware I get.

Code: Select all

usbdrv/usbdrv.h:185: warning: 'usbFunctionDescriptor' used but never defined
usbdrv/usbdrv.c:213: warning: 'usbSetInterrupt' defined but not used

Posted: Thu Jan 03, 2008 2:49 pm
by christian
The first error message mentioned, when you compile the command line tool, is a misconfiguration of your gcc. The message says that it fails to execute gcc.

Regarding the firmware: You include usbdrv.c in your main code and define USB_PUBLIC to static, right? I'm not sure about the first message since usbFunctionDiscriptor() is not used in usbdrv.h. It might tell you that you have configured the driver to call your own function usbFunctionDescriptor() in order to read particular USB descriptors and you have not implemented this function.

The second message is harmless. It tells you that you don't send data through the interrupt endpoint.

Since both these messages are warnings only, you should still get an executable to flash into the chip. If not, there must be an error during linking. That error message would be interesting, too.

Posted: Thu Jan 03, 2008 3:24 pm
by Phoenix
Can the first error be solved by re-installing WinAVR or do I have to change some settings?

And no I doesn't program my chip with the .HEX file. I instal the .HEX file with an ohter program
But I don't get an ohter error.

Posted: Thu Jan 03, 2008 3:28 pm
by christian
The first error can be solved by re-installing MinGW, not WinAVR.

I'm afraid I don't understand your last comment about the hex file. But if a hex file is generated, no error occurred, only warnings.

Posted: Thu Jan 03, 2008 3:51 pm
by Phoenix
I have to program de .HEX file into the chip with an ohter program.

Posted: Thu Jan 03, 2008 4:41 pm
by Phoenix
I re-installed MinGW but it didn't do a thing.
So I put gcc.exe and g++ in the Bin directory of WinAVR.
And then I got thes errors

Code: Select all

gcc  -O2 -Wall  -c main.c -o main.o
gcc  -O2 -Wall  -c usbcalls.c -o usbcalls.o
gcc  -O2 -Wall  -o bootloadHID.exe main.o usbcalls.o -lhid -lusb -lsetupapi
\mingw\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot find -lusb
collect2: ld returned 1 exit status
make.exe: *** [bootloadHID.exe] Error 1

Posted: Thu Jan 03, 2008 6:00 pm
by Phoenix
This is when I write it to the chip

Code: Select all

$ make flash
avrdude -c stk200 -p atmega32 -U flash:w:main.hex:i

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude.exe: Device signature = 0x1e9502
avrdude.exe: NOTE: FLASH memory has been specified, an erase cycle will be performed
             To disable this feature, specify the -D option.
avrdude.exe: erasing chip
avrdude.exe: reading input file "main.hex"
avrdude.exe: writing flash (17404 bytes):

Writing | ################################################## | 100% 6.34s

avrdude.exe: 17404 bytes of flash written
avrdude.exe: verifying flash memory against main.hex:
avrdude.exe: load data flash data from input file main.hex:
avrdude.exe: input file main.hex contains 17404 bytes
avrdude.exe: reading on-chip flash data:

Reading | ################################################## | 100% 5.48s

avrdude.exe: verifying ...
avrdude.exe: verification error, first mismatch at byte 0x3c00
             0x0c != 0xff
avrdude.exe: verification error; content mismatch

avrdude.exe done.  Thank you.

make: *** [flash] Error 1

So I can't write the .HEX file to the MCU

Posted: Thu Jan 03, 2008 6:34 pm
by christian
As you can see, this is a verify error reported by avrdude. This may be a wiring problem, a bug in avrdude or your chip is broken.

Posted: Thu Jan 03, 2008 6:49 pm
by Phoenix
okey I succesfully programmed the chip.
But the computer software isn't working.
I still can't compile it.

Posted: Thu Jan 03, 2008 6:55 pm
by christian
OK. One thing after the other. Please make sure that the device is recognized by Windows. I don't know how you can distinguish a broken device from a device without drivers on Windows, but there should be a way to do that.

Regarding the host application: Please make sure you can compile a simple "Hello World!" example. If that does not work, something is wrong with your compiler installation and you should fix that first.

Posted: Thu Jan 03, 2008 7:30 pm
by Phoenix
Oke
Compiler works!
But I can't compile the commandline software.

And the device is NOT recognized by my computer.

Posted: Thu Jan 03, 2008 10:44 pm
by christian
I would recommend that you start analytically: Use one of the reference projects on an ATMega8 and get it running. Then move this same project over to the ATMega32, updating the usbconfig.h and other pin assignments as well as fuse values accordingly. Then bring in your firmware code, taking care that you don't break anything.

That's the procedure I would recommend for the firmware. Once you have a working example, change only one thing at a time.

When you have the firmware running, we can talk about the host software.

Posted: Fri Jan 04, 2008 3:38 pm
by Phoenix
Oke I will do that but I think I already have firmware running on my atmega32.
But the host software doesn't work because when I compile he doesn't find -lusb and I don't know what it is or where I can find it.