Generating HEX files: newbie

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Generating HEX files: newbie

Postby wurth51 » Fri Feb 18, 2011 2:05 am

Hi, I'm new to this and I have attempted to take the hex file for the "Blink" program compiled in the Adruino IDE (blink.cpp.hex) and upload it to a barebones m328p via AVRDUDE (using usbtiny). Upload was successful but no blinking light!!!

I have no problem with the "blink.hex" program from Adafruit (downloaded from their site) as it downloads and works fine.

I have alternated uploading the two different "blink" files to confirm that the 328 didn't get bricked. Each time the Adafruit blink.hex file loads and runs, where as the Adruino IDE "blink.cpp.hex" file downloads successfully but nothing (no blinking) happens.

NOTE: I noticed there is a "bytes" size difference (588 vice 1588) as well, the Adafruit hex file is much smaller.

Bottom line.... I'm trying to learn how to generate the proper hex file for burning aN ATmega328 chip via AVRDUDE.

Help.!
wurth51
 
Posts: 2
Joined: Fri Feb 18, 2011 1:58 am

Re: Generating HEX files: newbie

Postby eventhorizon » Fri Feb 18, 2011 10:24 am

Arduino code is different from the proper C/C++ code. It will burn the 328 even with the .hex made specifically for arduino, but since the 328 is a bare AVR, it won't run.
-----------------------------------------------------------------------------------------------
Out of one hole, and into another.
eventhorizon
 
Posts: 114
Joined: Tue Jan 25, 2011 5:09 pm
Location: Quezon City, Philippines

Re: Generating HEX files: newbie

Postby wurth51 » Fri Feb 18, 2011 12:01 pm

Thanks for the feedback. Figured out my problem (2am this morning). I used Adruino IDE to generate the .hex file but failed to change the board selection to match the 328 chip. Once I did this the program downloads and runs......... however, it runs at a much slower clock rate than expected. Guess I will be researching how to tell the program which clock rate to use.
wurth51
 
Posts: 2
Joined: Fri Feb 18, 2011 1:58 am

Re: Generating HEX files: newbie

Postby stinkbutt » Fri Feb 18, 2011 1:51 pm

wurth51 wrote:Thanks for the feedback. Figured out my problem (2am this morning). I used Adruino IDE to generate the .hex file but failed to change the board selection to match the 328 chip. Once I did this the program downloads and runs......... however, it runs at a much slower clock rate than expected. Guess I will be researching how to tell the program which clock rate to use.


Usually changing the clock entails burning fuses. That usually involves bricking a bunch of chips before you get it right. :(

Be careful.
Red M&M, Blue M&M: They all wind up the same color
stinkbutt
 
Posts: 583
Joined: Wed Feb 17, 2010 1:40 am

Re: Generating HEX files: newbie

Postby Len17 » Sat Feb 19, 2011 5:04 pm

I think the default setting on a new chip is a 1MHz clock rate. A regular Arduino runs at 16Mhz but it uses an external clock crystal. If you're not using an external crystal, the 328's internal oscillator can only go to 8MHz.

There's a good fuse calculator here: http://www.engbedded.com/fusecalc
But make sure you select the correct chip at the top of the page, or else...
User avatar
Len17
 
Posts: 393
Joined: Sat Mar 14, 2009 6:20 pm

Re: Generating HEX files: newbie

Postby eventhorizon » Sun Feb 20, 2011 12:43 am

I really don't suggest playing with fuses right now since it can work without changing fuses. You first need a makefile for a 328, if you download winavr, it comes with avrdude and MFile, which I use to make makefiles. try to make that LED blink first before you even think about changing the fuses..
-----------------------------------------------------------------------------------------------
Out of one hole, and into another.
eventhorizon
 
Posts: 114
Joined: Tue Jan 25, 2011 5:09 pm
Location: Quezon City, Philippines


Return to Microcontrollers

Who is online

Users browsing this forum: No registered users and 1 guest

Stuff to buy from the Adafruit store and links to product documentation!


New Products [114]

Raspberry Pi[82]
 
FLORA[24]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[12]
Arduino[60]
 
NETduino[14]
 
BeagleBone[23]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[39]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[9]


 
Breakout Boards[35]
LCDs & Displays[49]
Components & Parts[70]
Batteries & Power[54]
EL Wire/Tape/Panel[52]
LEDs[112]
 
Wireless[16]
Cables[66]
 
Lasers[6]
Sensors/Parts[147]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[41]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[25]


 
Stickers[41]
 
Skill badges[55]
 
Books[26]
 
Circuit Playground[7]
 
Gift Certificates[4]