compiler for creating .hex files?
Moderators: adafruit_support_bill, adafruit

compiler for creating .hex files?

by ben123324 on Sat Jun 18, 2011 3:33 pm

hello people, i am a complete noob at programming micro-controllers(other than Aduino) and recently i decided to give it a try.
i plan on buying the usbtiny, and have already downloaded and installed avrdude. i think i have the process down. i type in...
avrdude -c usbtiny -p <micro-controller id> -U <hex file to be used>
...into the command prompt. anyways, how do i create the program? i am somewhat familiar with the c language from arduino. but how do i create the .hex file to be used? are there any free compilers i can use?
-----i know NOTHING about the creation of the program, so PLEASE explain thoroughly----

thanks,
ben
ben123324
 
Posts: 2
Joined: Sat Jun 18, 2011 3:22 pm

Re: compiler for creating .hex files?

by adafruit_support_bill on Sat Jun 18, 2011 3:45 pm

The hex file is the output from the compiler. It is the machine code that the compiler generates from your C or C++ program.
User avatar
adafruit_support_bill
 
Posts: 30696
Joined: Sat Feb 07, 2009 10:11 am

Re: compiler for creating .hex files?

by jchristensen on Sat Jun 18, 2011 3:47 pm

Here's one approach. It's fairly thoroughly explained...
http://winavr.sourceforge.net/
http://www.nongnu.org/avr-libc/

Also have a look at:
http://code.google.com/p/arduino-tiny/

jchristensen
 
Posts: 111
Joined: Mon Jan 03, 2011 11:45 am

Re: compiler for creating .hex files?

by abqlewis on Sun Jun 19, 2011 5:33 pm

My reply is a little off your original subject, but I think it's close enough to mention here.
If you want to move up (relatively speaking) from Arduino to discrete AVR projects, instead of a USBTinyISP, I would get a ATMega32u4 Breakout Board+ (from Adafruit) or equivalent. I first went the USBTinyISP route (with ATTINY2313s), and it is a great little programmer, but I haven't used it since I got my first 32u4 BB+. I got the 32u4BB+ (and later a Teensy), and it programs using a built-in bootloader and USB, so I didn't need an ISP for that. Even though it has a USB port, you can still write easy, non-USB programs to get your feet wet. And to reprogram, the only extra hardware you need is an USB cable. But then there is LUFA; a free USB library you can use to create custom USB apps (Joystick, mini-keyboard, serial-port, etc). Now here is the key - LUFA includes an ISP app that works very simply right out of the box on the 32u4BB+. So when you're ready to program discrete AVRs (I still use an ATtiny every once in a while), you can breadboard the simple circuit, load the hex file, and viola, you got programmer. Now I have a little daughter card (shield) that I can just plug in to the BB+ when I want to program something, and it was cheaper than any Arduino shield. The only thing I have found that my simple (out of the box) 32UBB+ ISP won't do, that the USBTinyISP will, is 3.3v device programming. But I'm in the process of updating my little programmer card to add that. I even like the mini-B connector on the BB+ better than the big B connector on the USBTinyISP.
BTW, I noticed Lady Ada uses an ATMega32u4BB+ (not a USBTinyISP) to program her new iCufflinks.

Bottom line: USBTinyISP = great programmer, but just programmer | ATMega32u4BB+ = OK programmer, but a lot more.

Michael
abqlewis
 
Posts: 67
Joined: Fri Dec 11, 2009 2:19 am

Re: compiler for creating .hex files?

by ben123324 on Thu Jun 23, 2011 8:01 pm

actually, i want to program avr micros because i want to leave them embedded in projects. i build sstc's and drsstc's, so these would be interrupters, and drive circuit ics. with an arduino, i would have to buy a new 20$+ board every time i needed a new ic chip! so again, what would my best option be if i wanted to program lots of these avrs? i know how to compile a c code into hex now, and i guess i can use avrdude(hopefully).
ben123324
 
Posts: 2
Joined: Sat Jun 18, 2011 3:22 pm

Re: compiler for creating .hex files?

by eventhorizon on Thu Jun 23, 2011 10:37 pm

i would have to buy a new 20$+ board every time i needed a new ic chip!


Not really. You can remove the uC of an Arduino and use it without the board. Just provide it the 5 volts and crystal it needs, and it'll run like it was on the Arduino board. Buy extra uC's that are similar with the arduino you're using, prolly an atmega8, and load them with an Arduino bootloader so that they'd work with the Arduino.

You can also buy bare uC's, and use an ISP Programmer. Once you have produced your .hex, you can simply program one uC after another.
-----------------------------------------------------------------------------------------------
Out of one hole, and into another.
eventhorizon
 
Posts: 114
Joined: Tue Jan 25, 2011 6:09 pm
Location: Quezon City, Philippines

Re: compiler for creating .hex files?

by eventhorizon on Thu Jun 23, 2011 10:42 pm

BTW, try downloading "WinAVR" and most of the time it already has avrdude, and avr-gcc in it, and there's a program there called Programmer's Notepad which automates the compiling and programming of the uC's a bit, as it has a makeFile and Program tool so you don't have to open cmd everytime.
-----------------------------------------------------------------------------------------------
Out of one hole, and into another.
eventhorizon
 
Posts: 114
Joined: Tue Jan 25, 2011 6:09 pm
Location: Quezon City, Philippines