Month: February 2017

How to start with ATmel AVR Studio 4- step by step

How to start with ATmel AVR Studio 4- step by step

To getting start with Atmel Studio 4, you have to install AVR Gcc & ATmel AVR Stduio 4… 

  1.  AVR Studio 4:  AVR studio professional is most commonly used software to program the AVR Microcontrollers due to its ease to use. It support Embedded C Language.  
    Coding & debugging in a high level language (like c/ java) is done with assembler. A compiler for high level language helps to reduce production time. To program the microcontroller, the WinAVR is used. 
  2. WinAVR :WinAVr is a suit of executable, open source software development tools for the ATmel AVR series of RISC microcontrollers. It includes the GNU GCC compiler for C & C++. WinAVR includes AVR-Gcc, AVR-GDB (debugger) etc. A .hex is generated for the “C” language program & then this hex file burn to the flash memory of the microcontroller. Our last post “LED Glow using ATmega32 step by step“How to glow led using ATmel ATmega32 is example of this process.

or you can get all software links here… 

After installing the WinAVR & ATmel AVR Studio 4, Open the AVR Studio 4 software in PC/ Laptop &  follow the step by step instruction. 

Step 1- In the menu bar, under the Project menu, select the New Project wizard as shown in given image:-

Step 2- Now in the dialog box, it shows tow options, one fort ATmel AVR Assembler & another AVR GCC. Select AVR GCC to program microcontroller in Embedded C language. 

Step 3- In the space provided for project name, write the name of project name but do not enter space between any words with in name as shown in image given below: 
Step 4- Click on select “create folder” by selecting the button, it create the separate program folder for your new project. 

Step 5- Select the new location to store new program folder & then click on “next” button. 
Step 6- In the dialog box, there is option to select debug platform & device. In the debug option, select “AVR Simulator” & on right of the dialog box, select the the device/ Microcontroller which you want to program link shown in figure atmega32. 
Step 7- Click on “finish” option in dialog box. 
Step 8- The workspace will be opened where program is to be written in “Embedded C” language shown in image. next window is your programming window where you can write the program. 

Step 9- After writing the code, under the build option in the menu bar, select the “build & run” option. 
Step 10- After clicking on “build & run” option, if the program runs without any error, then AVR Studio debug the code & create the .hex file (.hexadecimal) in the same folder which was created in step4. If there is any error in program, correct the error in code & compile again. 
Step 11- In the option “I/O View” on the right side of the screen as shown in given image, the status of each register & Port values can be checked. 
This program has taken from the book “Embedded System based on ATmega Microcontroller” chapter no 7, ATmega interfacing with led.

Feel free to suggest or post your query for any problem. 

LED Glow using ATmega32 – step by step

Figure shows the circuit diagram of the model in which LED is used for glow a LED.

One led is connected to C0 pin of PORTC, using 330 Ohm of register. how to calculate register value to glow an led? we use given formula to calculate the register value::

R=5V/10mA= 320 Ohm or 330 Ohm.

When controller gives an output as logic 1 at C0 pin, then the led will glow.

Lets start with circuit diagram:

We used ATmel ATmega32 Microcontrollers to operate the led.

This circuit diagram is includes on board +5V power supply with Reset button to reset ATmel ATmega Microcontroller.

You just open the ATmel AVR Stuido to write & compile the program for ATmel ICs. For this we will refer to our another post “how to start with ATmel AVR Studio”. For download AVR Studio, Please visit to ATmel website or click here to download AVR Studio.

first of all we include the avr lib to program as written program

#include<avr/io.h> // AVR Lib

void main() // Body of the program
DDRC=0b00000001;  // Set the direction of C0 pin as output (1)
PORTC=0b00000001; // set the voltage for pin C0 (1)

When compiling done, AVR Studio will generate a hexadecimal file include program name as ledglow.hex (if we save program name as ledglow)

After this you can see the results of your program in Proteus simulator to check that your program will work same as the them program you have created.

so you have to download the proteus software from Labcenter electronics site  for AVR microcontroller or go to this link to download location.
After that you have to pick & place ATmega32 microcontroller & led as the proteus simulation given below.

Paste the .hex file location to the ATmega32 by using double click on Atmega32 microcontroller. After it you run it & you will see that led will glow as per our instruction in program. 
Thank you very much. 
This program has taken from the book “Embedded System based on ATmega Microcontroller” chapter no 7, ATmega interfacing with led.

Feel free to suggest or post your query for any problem.