// EDUCATION & TECHNOLOGY: ATmega32
Showing posts with label ATmega32. Show all posts
Showing posts with label ATmega32. 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.

ISP Programmer for ATmega32 Microcontroller

if you are reading this you might be interest from beginning , if yes start here : ATmega32 Microcontroller introduction
So far I’ve discussed about the micro controller basics and the compiler software. I’ve yet not written anything about programming.
ATmega32 series micro controllers support 3 types of programming
  •   Parallel Programming
  •   ISP Programming or serial Programming
  •   Programming via JTAG
Here ISP stands for In System Programmer. To burn a micro controller just the burning Hardware is not enough, it requires software also that would download the program present in a computer or memory device into the micro controller.
Now the software which I am talking about is named PONY PROGRAMMER 2.06. My circuit is adapted from the website of Pony Programmer. It uses PC COM PORT to download the program into the micro controller. It has a signal amplitude of +5 to +12 volt representing binary ‘1’ and -5 to -12 representing ‘0’.
The micro controller, ATmega32 is programmed using the pins meant for SPI communication. To enable programming, the microcontroller must be taken to the RESET state by pulling its reset pin LOW (Logic 0, or say 0 V). In this state, microcontroller is programmable in either mode (Parallel programming or serial programming). Micro controller always accepts 0 V as logic 0and +5 V as logic one.
The signals transmitted from PC is not in a form that could be accepted directly by the micro controller. Those signals from PC should be made suitable for micro controller. In the programmer, Zener diodes provide necessary conditioning for the signals. It is wired in such a way that it converts ±12 volt signal to +5-0 volt signal which is suitable for the micro controller.  A resistance is necessary to limit the current in the nodes of Zener diodes, without the which the Zener diode may burn off. And computer internal circuits may also receive harms.
A high signal (+5V) in the ‘Reset’ pin of micro controller brings it into operational state. A low signal (Ground) drives it into programming mode. Internal pull up resistors are provided at the reset pins and if nothing is connected to this pin, the micro controller tries to execute the program written within it. Designers can provide a resistance capacitance reset circuit, but it’s not always necessary. Whatever, a push button is used in most cases to provide reset facility. Here in the burner circuit an open collector output is provided to the reset pin and it is driven by the programmer through the port. This much is enough.
The necessary data transmission and reception work portion is handled by the pony programmer. Follow the links provided to download pony programmer. The following burner circuit can burn ATmega32 microcontroller. Connect the derived signals to the adjacent pins, attach the cable to com port, power up the device i.e. micro controller, and the micro controller is ready to be programmed.

ISP Programmer Circuit Diagram

Image:  Circuit diagram of the ISP Burner
ISP burner cable
ISP programmer connection arrangement
So that is how the circuit is set up. Now let me tell you that the micro controller runs upon the internal calibrated RC oscillator in the pictures. So that there is no crystal is attached. Yet the micro controller is programmable. Let us see the software settings. First of all, select the port, to which you have attached the device!  And the programming device from the menu “Set Up>Interface Set Up…”. Select “SI Prog I/O”, this one provides fastest programming speed. And about the ports, it should becom port for this programming cable! Now select the port you have the cable attached to.
Now come to the device selection menu. Here ATmega32 belongs to the AVR family. So it is listed under “Devices> AVR micro”. Select ATmega32 as your device. Auto detection will also do.
Now after this two vital things check out If your circuit is working or not. Choose “Command>Read All”
Now if you see that it is reading the micro controller without any error message, your programming cable is working and you can program the micro controller with it.
You can Burn your hex file with it (Compilers provide hex files to program micro controllers). Just open “File> Open Device File…” now an window will open, now browse for your hex file, load it into the pony programmer, and burn. Pony programmer supports click and drag operation too. That means, if you drop the hex file into the pony programmer, it will automatically catch it.

Components:

  • DB9 female connector
  • 2 X 1K resistors
  • 2 X 5.1 V Zener diode
  • 1 X 15K resistor
  • Vero board
  • BC 547 or any general purpose NPN transistor
  • Male Relimate connector (6PIN & 2PIN)

Links for Reference:

Note: 1. Make sure that you have a COM PORT in your computer hardware and your operating system recognizes it. Check it from “Control Panel > Administrative Tools > Computer Management”. In the cascaded list pane, find the following
“Computer Management > System Tools > Device Manager > Ports (com & LPT)”. If COM ports are present under this list, this circuit will work fine. Else, look for a USB based burner.
Note 2. This burner will work fine for ATmega16 too.  For ATmega8, you need to connect the signals to the respected pins.
Note 3 .You can omit the male 2-PIN Relimate connector