Sunday 7 June 2020

Programming AVR micro controller using Atmel Studio 7

In this blog, we will learn how to upload hex file using Atmel Studio. Atmel Studio is used for programming ATtiny, ATmega and AVR32 mirocontrollers. You can download atmel studio from:


Open Atmel Sudio from windows start menu:

File > New Project >  GCC C executable project

New Project


In device selection, choose Atmega8a

In main.c write down the following program for toggling PORTD

#define F_CPU 8000000
#include<avr/io.h>
#include<util/delay.h>

int main(void)
{
DDRD = 0xff;  // set portd as output
    while (1) 
    {
PORTD = ~PORTD; // toggle PORTD bits
_delay_ms(500); // delay of 500 ms
    }
}

Code Snippet

Follow the steps as mentioned above n the screenshot. 

Once the code is successfully compiled, we are ready for the next step i.e. uploading the program to the target board.

Go to: Tools > External Tools > 

External Tools


In arguments type this:
avrdude -c usbasp -p atmega8 -U flash:w:$(ProjectDir)Debug\$(TargetName).hex:i
since we are using atmega8.

Provide the path of avrdude in command. You can input USBasp in Title

Make connections as follows:

USBasp programmer                                                Atmega 8 target board

Vcc       ===========================>      Pin 7,20,21 
GND     ===========================>      Pin 8,22 
MOSI    ===========================>      Pin 11 
MISO    ===========================>      Pin 12 
SCK      ===========================>      Pin 13 
RST       ===========================>      Pin 1 

Now click on: Tools > USBasp

And voila your mcu is flashed!! 





4 comments:

  1. Amazing & informative blog on technology
    Thanks for sharing information.

    Keep Blogging

    Visit our website for smart lights, motion sensors, home automation devices and Motion sensor light switch.

    ReplyDelete
  2. I really appreciate your blog, it is really helpful for all. Keep blogging to attract reader's attention

    Visit our website for best student visa consultation service, We are top Australia Student Visa Consultants in Vadodara

    ReplyDelete
  3. Great share! Amazing write-up!

    I like Your articles and your information is so clear. I liked it. I appreciate your work

    Visit our website for Best Offers on Apple Products, We are authorised Apple Store in Vadodara

    ReplyDelete