Using Atmega32 with Arduino IDE

Содержание

Using Atmega32 with Arduino IDE

Over time I have used all kinds of Atmel microcontrollers in various projects.
One of the most suitable was ATmega32. I have a small collection of development boards for Atmega32/16, some bought as-is, some made on stripboard.
Although the original Arduino boards offers a pleasant experience and a rapid development of the projects, when it was necessary to “extract” these projects to give them final shape I hit the well-known problem: arduino board must be “locked” in the project.

It is not only the price. Although a microcontroller in thru-hole package is significantly bigger than SMD version, it is still much smaller than an Arduino board.
And still I want to use the Arduino IDE to benefit from the collection of (very well made) (ready-to-use) libraries.
So I gathered together information useful for this purpose.

Step 1: Things you will need:

  1. Atmega32 microcontroller. 🙂
  2. Programmer (any programmer recognized by Arduino IDE). I use the USBasp programmer.
  3. Minimal setup for power-up Atmega32 microcontroller (breadboard, stribpoard or a classical development board).

We do not need all, photos above are for exemplification only.

Step 2: Software Set-up

  1. Download zip file attached to this instructables.
  2. Locate file boards.txt in arduino folder …arduino-1.5.2\hardware\arduino\avr\boards.txt
  3. Append information from zip archive boards.txt to original boards.txt
  4. Make a folder named mega32 in …arduino-1.5.2\hardware\arduino\avr\variants
  5. Copy file pins_arduino.h from the zip into folder created at step 4.
  6. Start Arduino IDE and select board.
  7. Select programmer

Later edit:

I removed link to github projet where I originally found. As long as there source changed and not fit this instructable.

After a message from the author: Eric Conner, I put back link to github project where I originally found this library:

Note: Zip file attached to this article is an older version of above library. This will work as this instructable was written.

Over time, after some feedback I noticed that source from github has changed.

Also, in comments you will see references to some errors, and how to to correct it.

This article and answers from comments is relate to version attached here, not github (newer) version.

Step 3: Done.

Now you can try some simple examples that are already in Arduino.

Be very careful about correlation between ARDUINO pin and microcontroller pin.

Here is blink example: Files-Examples-Basics-Blink

Pin13 Arduino == Pin19 (PD5) Atmega32

After some comments I found two errors in the file pins_arduino.h

So I’ll post here the errors and correct values.

erroneous definition of SCL and SDA

must be changed in:

Since I am not the author of the project on github, it is subject to change beyond my control.

So please use code attached to this instructable and make above modifications.


Источник: atmega32-avr.com