Basic Programming

It explains how to make simple Embedded C examples on AVR Studio.

 

Creating Project

The procedure of creating project is as below.

 

1. Select "New Project" in Project menu.

createproject01.png

 

2. Select AVR GCC in Project type, and then set Location, Project Name, and Initial file.  Click "Next" button when the setting is complete.

* When you set the location, please use English.

createproject02.png

 

3. Select AVR ONE! in Debug platform, and then set Atmega2561 in Device.  Lastly, click "Finish."

createproject03.png

 

 

Creating Code and Compling

The following example is about the basic PORT I/O Control.

 

1. Write the following code on the created project.

#include <avr/io.h>

#include <util/delay.h>

int main(void)

{

DDRC  = 0x7F;

PORTC = 0x7E;

while (1)

{

int i;

for(i = 0; i <= 6; i++)

{

PORTC = ~(1<<i);

_delay_ms(250);

}

}

return 1;

}

 

2. Execute "Build" command in Build menu.

build.png

 

3. When compling is completed normally, you can find hex file in "Default" folder, which is inside of the Project folder.

 

Downloading hex file