Summary of Programming ATMEGA32 (or Any Other AVR) Using Arduino IDE
This article explains how to use an Arduino board to program an ATMEGA32 microcontroller, allowing you to reduce the number of Arduino boards needed for multiple projects. By loading the ArduinoISP sketch onto an Arduino (such as the UNO), it can act as a programmer/debugger for the ATMEGA32. Then, the Arduino IDE can be configured by modifying the boards.txt file and adding variant files, enabling programming and deployment of sketches directly to the ATMEGA32. This approach leverages the versatility of the ATMEGA32 in a 40-pin PDIP package suitable for prototyping.
Parts used in the ATMEGA32 Programming Project:
- Arduino Uno board (or other Arduino boards)
- ATMEGA32 microcontroller (40-pin PDIP package)
- Breadboard or prototype board
- USB cable for Arduino IDE connection
- ArduinoISP sketch (software)
- Modified boards.txt file (software modification)
- Variants folder for ATMEGA32 (software files)
The Arduino is a very cool development board where you could create hundreds of projects. But it doesn’t mean that for every project you create, you would need an Arduino board dedicated to that project alone. A hundred projects and a hundred Arduinos? That’s a waste of money! Depending upon the requirements of your project, you could choose from a wide array of microcontrollers – try AVRs from Atmel (now Microchip, yes the maker of the PIC). One microcontroller which is very tinkerer-friendly is the ATMEGA32, which is offered in a 40-pin PDIP package. This makes it very easy to be incorporated in prototype board and breadboard set-ups. In this ‘ible, ATMEGA32 will be used but the same flow applies to other AVRs.
Step 1: Convert Your Arduino Into a Debugger/programmer
There’s a sketch that you could load to your Arduino which can transform this development board into a debugger or programmer. This means we can use the Arduino to load a program to another microcontroller – in this case, the ATMEGA32. Programs (yes, sketches) can be created and compiled using the Arduino IDE then flashed to the ATMEGA32. If things go well, you can eliminate the Arduino development board from your project and the ATMEGA32 does all the work from that point on. Go to Examples and find the ArduinoISP sketch. Make sure everything is set up correctly. In my case, I’m using an UNO board and to program the sketch to my UNO board, I’ll use the AVRISP mkII (my default). Go to Sketch then click Upload.
Unzip. Inspect the files. The things we need are the “boards.txt” and the contents of the “variants” folder. Open your Arduino folder in Program Files. Go to hardware>arduino>avr. You will see the “board.txt” file. This file lists all boards available for use on your Arduino. We need to add boards for ATMEGA32 into this file. To do this,append the contents of the downloaded board.txt file to the original board.txt file. CAUTION: You need not include the first few lines (see image).
Next, go to hardware>arduino>avr>variants. Copy into this folder the contents of the downloaded “variants” folder. It is named mega32.
Now, check to see that ATMEGA32 boards are now available for use in the Arduino IDE. Go to Tools>Board.
Read More: Programming ATMEGA32 (or Any Other AVR) Using Arduino IDE