If you are reading this tutorial, you should be already familiar with electricity and microcontroller basics. If not, read through “Introduction to Electricity” and “Microcontroller tutorial” and then return.
AVR microcontrollers can be termed as a mini computer with all peripherals on the chip. A typical AVR microcontroller can contain peripherals like RAM, EEPROM, Flash memory, Input-Output (I/O) pins, Analog to Digital converters, PWM channels, Timers etc. It also has a CPU for processing, but not as fast and complex as the one within a computer.
These AVR microcontroller (from now on termed as µc’s) is an 8-bit microcontroller and based on Reduced Instruction Set Computer (RISC) architecture. 8-bit means that the µc can transmit and receive data in a set of 8 bits. Atmel manufactures 3 variations of 8-bit microcontrollers.
The figure below shows three different types of AVR Microcontrollers.
These variations are there to distinguish based on their physical size, memory size, number of inbuilt peripherals and their applications. MegaAVR is the most popular one with enough memory for our basic projects with suitable peripherals.
Atmega8 is one such MegaAVR which will be discussed here, in this tutorial. Atmel provides datasheets for each AVR manufactured. They look so complex and huge that it is easier to get lost within that. However it is recommended to understand one datasheet and the format remains same for others too. Atmega8 data sheet can be found here, with 300 and odd pages. The first page provides information on all the features included in Atmega8 and the second details pin configuration. Information in these two pages can be kept handy as a basic reference. Some of the features can be highlighted here:
- Based on RISC architecture
- 8KB of flash memory (This is where programs are stored)
- 512 bytes of EEPROM - “Electrically Erasable Programmable Read Only Memory”, a non-volatile memory which can come in handy to store data values or initial parameters for the microcontroller. Information stored will not be destroyed in Non-volatile memory even when powered off.
- 1 KB internal SRAM – “Static Random Access Memory”, a fast power efficient storage for data values. However SRAM is volatile, meaning data is lost on power off.
- 10,000 Flash/100,000 EEPROM: This means you can rewrite your program 10,000 times before your AVR dies (technically).
- 23 programmable Input-Output (I/O) lines and 28 pins: These I/O lines are what you use to interact with your Atmega8, and it contains 28 pins (5 pins for power lines and control)
- Operating voltage: 4.5 - 5.5V: This means your can use your Atmega8 within this power range. Less voltage? It does not respond. More Voltage? You fry your µc and need to purchase a new one
There are also other features like interrupts, timers, PWM controls, Analog to Digital Converters (ADC) and more, which we will discuss as and when we use those features in our projects.