Showing posts with label AVR. Show all posts
Showing posts with label AVR. Show all posts

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!! 





Sunday, 11 June 2017

Generating a delay of 1s using timer in atmega8

Hello Friends,

In this tutorial, we will learn how to generate a delay of 1second using timer0 in atmega8.

We are writing the code in Avr studio 4.

Timer 0 is a 8-bit timer means we can feed any value from 0 (0x00) to 255 (0xff)

Timing Diagram
In this example, we are using prescaler of value8. Prescaler divides the base frequency (provided by crystal or internal rc oscillator).

Machine Cycle = 1/Fosc      (Fosc is 8 MHz)

M.C = 1/8 us or 0.125 us

Delay = (256-x) * 0.125 * Pre scaler  (Pre scaler = 8)

Saturday, 27 August 2016

Password protected system with AVR using DTMF

Password protected system using DTMF

Hello guys, this project is about password protected system using DTMF module. By using a predefined number we can make output either high or low by using the three digit code.
The codes can be changed in the program.

Components required:

  • Atmega 16A
  • USBasp programmer
  • AVRdudes (for burning hex file)
  • AVRStudio 4
  • Compiler used: GCC
  • DTMF module
  • 3.5 mm audio jack

FOR OUTPUT LOW CODE IS str1="248"
FOR OUTPUT HIGH CODE IS str2="842"

Connections are as follows:

Q0-PD0
Q1-PD1
Q2-PD2
Q3-PD3

Output is from: PB0.

Friday, 10 July 2015

DIY arduino board

You can make your own arduino board provided you need a  programmer to upload programme on the board. We can make USBasp programmer from the previous post.
 
Arduino had lots of varities e.g. Arduino NG, Arduino Uno, Arduino Mega , etc.

We are going to use Arduino NG which uses Atmega8/Atmega168 or we can also use Arduino UNO which uses Atmega328.

We are using Arduino IDE 1.6.0 and we have to click on Tools>Programmer>USBasp


 Then we have to click on Tools>Boards>Arduino NG or older.