// EDUCATION & TECHNOLOGY: avr
Showing posts with label avr. Show all posts
Showing posts with label avr. Show all posts

Saturday, 4 July 2015

AVR Microcontroller (Atmega32) – An Introduction

Introduction to ATmega32 (AVR Series) 8bit Microcontroller

In our days, there have been many advancement in the field of Electronics and many cutting edge technologies are being  developed every day, but still 8 bit micro controllers have its own role in the digital electronics market dominated by 16-32 & 64 bit digital devices. Although powerful micro controller with higher processing capabilities exist in the market, 8 bit microcontroller still hold its value because of their easy-to-understand-operation, very much high popularity, ability to simplify a digital circuit, low-cost compared to features offered, addition of many new features in a single IC and interest of manufacturers and consumers.
Today’s micro controllers are much different from what it were in the initial stage, and the number of manufacturers are much more in count than it was a decade or two ago. At present some of the major manufacturers are Microchip (publication: PIC micro controllers), Atmel (publication: AVR microcontrollers), Hitachi, Phillips, Maxim, NXP, Intel etc.  Our interest is upon ATmega32. It belongs to Atmel’s AVR series micro controller family. Let’s see the features.
PIN count: Atmega32 has got 40 pins. Two for Power (pin no.10: +5v, pin no. 11: ground), two for oscillator (pin 12, 13), one for reset (pin 9), three for providing necessary power and reference voltage to its internal ADC, and 32 (4×8) I/O pins.
About I/O pins: ATmega32 is capable of handling analogue inputs. Port A can be used as either DIGITAL I/O Lines or each individual pin can be used as a single input channel to the internal ADC of ATmega32, plus a pair of pins AREF, AVCC & GND (refer to ATmega32 data sheet) together can make an ADC channel.
No pins can perform and serve for two purposes (for an example: Port A pins cannot work as a Digital I/O pin while the Internal ADC is activated) at the same time. It’s the programmers responsibility to resolve the conflict in the circuitry and the program. Programmers are advised to have a look to the priority tables and the internal configuration from the data sheet.
Digital I/O pins: ATmega32 has 32 pins (4portsx8pins) configurable as Digital I/O pins.
Timers: 3 Inbuilt timer/counters, two 8 bit (timer0, timer2) and one 16 bit (timer1).
ADC: It has one successive approximation type ADC in which total 8 single channels are selectable. They can also be used as 7 (for TQFP packages) or 2 (for DIP packages) differential channels. Reference is selectable, either an external reference can be used or the internal 2.56V reference can be brought into action.  Their external reference can be connected to the AREF pin.
Communication Options:  ATmega32 has three data transfer modules embedded in it. They are
  • Two  Wire Interface
  • USART
  • Serial Peripheral Interface
Atmega32 pin diagram
Analog comparator:  On-chip analog comparator is available. An interrupt is assigned for different comparison result obtained from the inputs.
External Interrupt: 3 external interrupt is accepted. Interrupt sense is configurable.
Memory:  It has 32Kbytes of In-System Self-programmable Flash program memory, 1024 Bytes EEPROM, 2Kbytes Internal SRAM. Write/Erase Cycles: 10,000 Flash / 100,000 EEPROM.
Clock: It can run at a frequency from 1 to 16 MHz. Frequency can be obtained from external Quartz Crystal, Ceramic crystal or an R-C network. Internal calibrated RC oscillator can also be used.
More Features: Up to 16 MIPS throughput at 16MHz. Most of the instruction executes in a single cycle. Two cycle on-chip multiplication. 32 × 8 General Purpose Working Registers
Debug: JTAG boundary scan facilitates on chip debug.
Programming: Atmega32 can be programmed either by In-System Programming via Serial peripheral interface or by Parallel programming. Programming via JTAG interface is also possible. Programmer must ensure that SPI programming and JTAG are not be disabled using  fuse bits; if the programming is supposed to be done using SPI or JTAG.

AVR Studio 4 and 5-Overview for Beginners

if you are reading this you might be interest in our complete tutorial from beginning . if yes Start from : AVR Microcontroller (Atmega32) – An Introduction
For general purpose computers, programs written in one programming language can support different hardware configurations. But things are different for microcontroller.  Each family of micro controllers have its own unique type of hardware architecture, instruction sets, register configuration and memories.
So for each architecture of Micro controller family, there will be at least one compiler available, supporting that particular micro controller family or a couple of other families. Most of them support programming in assembly language while some of them support programs to be written in C language. In rare cases there are compilers that accept Java codes too. But I don’t recommend searching too much for a Java compiler, because most popular Integrated Development Environments (IDEs) don’t support it. AVR studio supports AVR series micro controllers. However the interesting fact is that, even AVR Studio doesn’t support all of the avr series micro controllers. I wrote it is “interesting”  because this IDE has been designed by the manufacturer (Atmel) itself. See release note of each version to know about supported micro controllers or the excluded ones.
So if you are a beginner, I’ll suggest you to begin with AVR studio 4. Later, when you gain experience, start using AVR studio5. They are much different from each other. We will provide a comparative table of their features.

AVR Studio 4

AVR studio 4 provides an integrated development environment(IDE), combined with two other supporting softwares, AVR Toolchain and WinAVR. AVR Toolchain installs the Library for AVR studio. AvrToolchain is a must to run AVR studio. If you install AVR Studio and AVR Toolchain, you’d be able to write program in assembly language. To write a program in C, you need to install WinAVR. If you are thinking to buy a development board from Atmel, it will be an even better decision because AVR Studio supports on board programming. You can write your programs in the AVR studio and you can instantly download & verify it too. Supported programmers are listed below:
  • AVR Dragon
  • AVR One
  • AVR Simulator
  • AVR Simulator 2
  • ICE 200
  • ICE 40
  • ICE 50
  • JTAG ICE
  • JTAG ICE mkll
Programming Languages:                           Assembly Language, C
Software requirements:                               AVR Toolchain 3.0.0, WinAVR 20100110
For supported devices, hardware and software requirement details, see release notes @
Helpful Features:   I/O view pane, multiple document editing in tabs, really good reference manual. Hex file generation.
Total Space Consumption:
  •  AVR Studio 4       307 MB
  • AVR Tool Chain   194 MB
  • Win AVR                 138 MB
  •  Total             639 MB (As calculated by Windows uninstaller)


AVR Studio 5

AVR Studio 5 is much better than that of AVR studio 4. The experience is pretty amazing with AVR Studio 5. It has auto suggestion facility, like, if you start to type a function name, it will look in the library and the C file itself for matches and will list them in a drop down list, from which you can select them. This reduces name conflict. Suppose you want to define a macro or variables or want to introduce a new function, this feature helps very much. This feature is really helpful for a new programmer for whom the library is almost unknown. In addition, using new functions and macros has been made much easier. But to do this, you need the help of Visual studio shell. All the library, compiler and linker are provided with the AVR Studio 5 installer. For rest of the information have look at the release notes.
Programming Languages:             Assembly Language, C
Software requirements: Microsoft visual studio Isolated Shell 2010, AVR Jungo USB, Microsoft .NET framework 4 client profile.For supported programmers, supported devices, hardware and software requirement details See release notes @AVR Studio 5 release notes
Helpful Features:    AVR studio 4 features + single compiler for 8 & 32 bit AVR controllers. In AVR Studio v5 there is no need of installing any additional tool chains. Another useful features of AVR studio 5 are, auto suggestion function, ready to use libraries, readily available examples, integrated online help,  integrated C Compiler,  Atmel AVR Software Framework, Standard APIs, Application Builder, Solution Explorer, In-system programming, JTAGICE3, I/O view etc and much more.
Total Space Consumption:    
  • AVR Studio 5                                          535 MB
  • Visual Studio Isolated Shell             533 MB
  •  .NET framework 4 client profile    182MB
  • AVR Jungo USB                                     2 MB
  • Total                                         1.22 GB (As calculated by windows uninstaller)
For Programming Guide and programming help, see my upcoming posts. For Help about installation, post your comments here.