Getting Started With AVR Microcontrollers

Keywords: Embedded Systems, Atmega32, AVR

As we are going to learn Embedded system development, its better I start with a brief introduction of embedded systems.

Embedded Systems:  In short, an embedded system is a computer system with a dedicated function with real-time computing constraints (though it’s not necessary).  For example a vending machine or remote control system, ATM and list go on as the world is full of the examples.

A typical example of embedded system

So basically an embedded system will consist of followings:

  • Micro-controller
  • Memory
  • Display Unit
  • Input devices
  • Sensors etc…

Now the most important part of an embedded system is its Micro-controller as this is the heart of the whole system.

Micro-controller:  A microcontroller is a small computer on a single integrated circuit containing a processor core, memory, and programmable input/output peripherals (Reference: Wikipedia).

Microcontroller

The difference b/w a complete computer (PC) and microcontroller is its limited memory, limited processing speed, and limited number of input/output. A microcontroller is designed for small embedded applications.

How to decide which microcontroller to use?

It’s completely based on the application. When you think to develop an embedded system for an application you have to consider the following:

  • Cost
  • Memory
  • Interfaces required
  • Input / Output port required
  • Processing Speed
  • Availability of development environment (programming) etc.

I am using AVR microcontroller ATmega32 [ 40 PIN, 32K Flash, 2KB Ram, 1KB EEPROM] for this tutorial series as its cost effective, has sufficient programming memory, execution speed is good and it provides almost all the interfaces. It has SPI, UART, I2C, Timers etc. For my tutorial series it was the best choice.

Introduction to AVR Microcontroller:

Some key features of the AVR microcontroller (specifically Atmega32) is discussed below:

 

  • The number of pins:  ATmeg32 has 40 pins. The more the number of pin a MCU has the more external hardware you can add to it at the same time. But it will be bigger in size and costly. So for cheaper and smaller final product you need to select the MCU with the minimum number of pins you can manage to attach all external peripherals. For example you can choose Atmega8 which has 28 pins.
  • Amount of Flash Memory: The flash memory is where the main program of MCU is stored. Atmega32 has 32 k flash memory. The more the flash memory the bigger and more complex program it can store. In the same time a MCU with larger flash memory tends to be more expensive. So the bottom line is to select the MCU which can just hold your final program. Example ATmega8 has 8K Flash.
  • Amount of RAM: RAM stores all the data hold by the MCU during runtime. So more the ram it can store more data at runtime. ATmega32 has 2KB RAM.
  • Amount of EEPROM: The data stored by RAM is lost once the MCU lost the power. In some applications you will require to keep some data stored in the memory. Here EEPROM comes in the picture. If you need to store some data then you have to write it in MCU’s internal EEPROM memory. Atmega32 has 1Kb EEPROM memory.
  • Timers with PWM.
  • USART for connection with PC and other microcontroller.
  • SPI can be used for connection with other chips like Data Flash, Graphical LCD, and Memory Cards.
  • TWI (I2C) Two Wire Interface to communicate with memory chips, real time clock, accelerometers etc.
  • Analogue to Digital Converter.

All the interfaces (SPI, UART, I2C etc) will be covered in this series later one by one, so you don’t have to worry about these for now. Also you can use Atmega8 or 16 as well.

The Development Process:

You will require the following:

  1. Development board with Atmega32/16/8 microcontroller
  2. One USB based programmer
  3. PC for application development
  4. IDE for application development

For my tutorial series I have chosen Ubuntu(Linux) for the application development so if you choose the same then you will make a cross-compiler. Follow this post to setup the required development environment. If you want to work on Windows platform then you have to download Atmel Studio. It’s free.

Once you have setup the development environment, the development process will be like below diagram.

Embedded System Application Development Process

The next post on this series will be about writing the first program to access GPIO of AVR microcontroller. If you like the post please like and share it’s facebook page.  🙂

Related posts

Leave a comment....