NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » Led Blink

October 05, 2011
by rajdua
rajdua's Avatar

I am trying to make led blink with ATMega168 controller.

Why do we need led_blink.hex and led_blink.o files?

Do I have to make .hex and .o files for every program??

How to make .hex and .o files???

Also, can anyone provide me with C programming tutorial for ATMega168 and tutorial for "Make" file.

October 05, 2011
by rajdua
rajdua's Avatar

Forget to add:

What is difference between these too-> DDRC |= (1<<PC4); and PORTC |= (1<<PC4);

October 05, 2011
by Ralphxyz
Ralphxyz's Avatar

well rajdua the best answer is to suggest you read the specsheet!

PORTC – The Port C Data Register
Bit              7      6       5      4      3      2      1      0
0x08 (0x28)      -  PORTC6 PORTC5 PORTC4 PORTC3 PORTC2 PORTC1 PORTC6   PORTC
Read/Write       R      R/W     R/W    R/W    R/W    R/W    R/W     R/W 
InitialValue     0      0       0      0      0      0      0      0

DDRC – The Port C Data Direction Register
Bit              7      6       5      4      3      2     1       0
0x07 (0x27)      -   DDRC6   DDRC5  DDRC4   DDRC3   DDRC2  DDRC1  DDRC0   DDRC
Read/Write       R      R/W    R/W   R/W      R/W    R/W R/W    R/W 
InitialValue     0      0       0      0      0      0     0       0

Obviously they are two different things. PortC is a data register while DDRC is a Data Direction Register.

Now re: Why do we need led_blink.hex and led_blink.o files?

Well what else would you like to do?

A MCU does not understand a C file so it seems as if making a file the MCU understands would be a good idea.

This is from http://imakeprojects.com/Projects/avr-tutorial/

[quote] A successful compile will result in a .hex file being generated. This is the binary code in a format ready to be burned into your AVR chip by the programmer. [/quote]

The .o file is the compilers interpretation of the .hex code instructions, so yes both are required.

re: How to make .hex and .o files???

Type make from a command line!! Of course you need the AVR-gcc compiler installed.

re: Also, can anyone provide me with C programming tutorial for ATMega168 and tutorial for "Make" file.

Google AVR programing and Make

If you have nothing better to do for the rest of your life you can always start here.

Ralph

Post a Reply

Please log in to post a reply.

Did you know that a thermometer can be made "faster" by using a bit of math? Learn more...