Making a .hex file with avrstudio4

Hello
I can’t make a hex file in avrstudio4! I tried to add all the source files and headers, but when I push the “build” button nothing happens! any thoughts?
Arbel

You say nothing happens when you hit the build button, is your project actually building? Do you see information in the build window, ending in a “Build Succeeded…” line?

If you created a project in AVRStudio with mostly default settings, and the build completed with no errors (warnings are ok), the .hex file will be in the project directory, inside a directory called “default”. If it’s not there, you might try creating a new project with a new project directory, and re-importing the code.

-Adam

here is some of the errors I got (thers 68 of them!!!).

…/vbcode.c:305: error: ‘IN2_BIT’ undeclared (first use in this function)
…/vbcode.c:313: error: ‘IN3_PORT’ undeclared (first use in this function)
…/vbcode.c:313: error: ‘IN3_BIT’ undeclared (first use in this function)
…/vbcode.c:319: error: ‘IN4_PORT’ undeclared (first use in this function)
…/vbcode.c:319: error: ‘IN4_BIT’ undeclared (first use in this function)
…/vbcode.c: In function ‘main’:
…/vbcode.c:345: warning: control reaches end of non-void function
make: *** [vbcode.o] Error 1
Build failed with 68 errors and 9 warnings…

I think that I am missing a H file… maybe avr/io.h…
Arbel

now I got this error:
avr-gcc (GCC) 4.2.2 (WinAVR 20071221)
Copyright © 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

make: *** No rule to make target vbcode.elf', needed byelf’. Stop.
Build failed with 1 errors and 0 warnings…
but I don’t want to make an elf file, I want a hex file…
Arbel

My understanding of the process is that the .elf (Executable and Linking Format) is built directly from your code, then its contents are translated into the hex file (right?). So I do think you want to build an .elf file.

It still sounds like a project configuration problem (the error you’re currently getting, the ones before were totally code-related). I would try creating a new project in AVR Studio, with some super-simple program like:

int main(){ return 0; }
This should compile, and create a small hex file. If it does, you know everything is configured properly, and you can start dragging in your code files. If not, you can start playing with the various settings.

-Adam

O.K

I tried to use that small code you gave me and it did compile just fine. but when I tried to include other files, I got lots and lots of errors (1 error for each undeclared function) how can I include those files??? I tried to add them to the project header files and it steal won’t work
Arbel

o.k

I maneged to make a hex file, and to include the headers. but there is 1 function that bealongs to the avr/interraps.h that he dose not recognise… here is the error:
C:\Documents and Settings\arbelmichal\My Documents\default/…/…/…/…/robotech/vbfunctions.c:14: undefined reference to `_delay_ms’
make: *** [vbproject.elf] Error 1
Build failed with 1 errors and 1 warnings…
Arbel

Excellent!

To get the _delay_ms() function working, you should include this code:

#define F_CPU 20000000//your clock frequency in Hz
#include <util/delay.h>

You may need to change the frequency number to match your clock frequency (in Hz), and the definition should go before the include line. You may also need to turn on code optimization in the project configuration options to get the delay functions to work properly.

-Adam