Table of Contents
Introduction
AVR stands for a Alf and Vegard’s RISC processor and is a microcontroller. Microcontroller is like a mini computer or a processor dedicated for a particular task. We can code AVR using C, C++ or Assembly language.
Brief description of AVR pins
- Pin 1 – Pin 8 (PB0 – PB7): General Input / Output pins used as GPIOs i.e. General purpose Input-Output.
- Pin 9: It is a reset pin and resets the microcontroller. The bar above the RESET represents that it is active low i.e. when the reset pin is grounded then it resets the microcontroller.
- Pin 10, Pin 11 (Power Supply): These pins are used to give power to the microcontroller. We give a positive line to the VCC (Pin 10) and ground to GND (Pin 11). Generally, 5V is given as input.
- Pin 12, Pin 13 (Crystal Oscillator) : These pins are used to connect a crystal oscillator with AVR to give it an external clock.
- Pin 14 – Pin 21 (PD0 – PD7) : General Input / Output pins used as GPIOs i.e General purpose Input Output.
- Pin 22 – Pin 29 (PC0 – PC7) : General Input / Output pins used as GPIOs i.e General purpose Input Output.
- Pin 30 (AVCC) : It is used to provide power to Analog to Digital Converter of AVR. Also provides immunity to noise while conversion.
- Pin 31 (GND) : It is a common ground provided to be used.
- Pin 32 (AREF) : It is used to give a reference voltage to Analog to digital converter of AVR.
- Pin 33 – Pin 40 (PA0 – PA7) : These pins are used to take analog input and have Analog to Digital converter. For eg: we can sense temperature and convert from values 0-255 (8 bit) or 10 bit values.
Programming AVR
For any microcontroller to perform any action we need to put some code i.e. a set of instructions in it which it can follow. We write code in computer and then transfer the code to microcontroller using specific toolchain.
For AVR MCU, we can write code using different IDE like Atmel Studio, Arduino IDE, VsCode in Embedded-C language, C and C++ for hardware purposes. Some SDK used for writing code of AVR are ATMEL STUDIO IDE, Arduino IDE, WinAVR etc.
All of the mention SDK are recommended where Atmel Studio is a bit heavy software with loads of features for high performance laptops whereas WinAVR is a really light software to achieve the main motive of AVR coding with some basic and few extra features. WinAVR is recommended for people with laptops having low configurations.
WinAVR is a pretty simple tool and can be installed easily. Here we will be discussing on how to install and get Atmel Studio ready for coding of AVR.
Setting Up Atmel Studio
You should refer to Video 6 – Video 9 of the following playlist created by Gettobyte for detailed tutorial on Atmel Studio.
AVRDude
AVRDude is a tool or so called utility to download/upload/manipulate the contents of ROM and EEPROM of AVR microcontrollers using your PC and uses ISP i.e. in system programming technique.
It is a command line tool and has a huge list of commands which can be referred from its documentation or directly found from the internet as required. Link of Documentation is provided : http://download-mirror.savannah.gnu.org/releases/avrdude/avrdude-doc-6.3.pdf.
For quick reference you can also use command: ‘avrdude help’ in command line.
To use avrdude, you need to first download and install it which can be done from the provided link: http://download.savannah.gnu.org/releases/avrdude/avrdude-6.3-mingw32.zip.
After downloading follow the below steps:
1) Copy the address of folder containing unzipped files
2) Type Env in search bar in start
3) Select ‘Edit the system environment variables’
4) A dialog box will pop up. Click on environment variables in bottom right corner.
5) Select ‘Path’ in ‘System Variables’.
6) Click on edit button below system variables box.
7) Click on ‘New’
8) Paste the address that you copied.
9) Click ‘Ok’ on all the dialog boxes.
Now you are AVRDude is setup and ready to use.
Applications and use of AVR
AVR consist of multiple input output pins, ADC, oscillator, timer, interrupts and many more features hence useful in integrating multiple sensors and actuators (Devices that takes signal from microcontroller to perform some action in real world).
This lead to use of AVR in variety of applications like home automation, automobiles, medical devices etc. AVR comes in small size with less memory as well as big size with huge memory size and more processing power and features to cover from most simple to much complex applications.
Conclusion
Congratulations, now your pc is completely ready to code AVR microcontroller. In further blog series of AVR we will dive deep into concepts of programming the AVR and understand different concepts of AVR programming, AVR microcontroller and electronics itself so stay tuned!!