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:
- Atmega32 microcontroller. š
- Programmer (any programmer recognized by Arduino IDE). I use the USBasp programmer.
- 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
- Download zip file attached to this instructables.
- Locate file boards.txt in arduino folder ā¦arduino-1.5.2\hardware\arduino\avr\boards.txt
- Append information from zip archiveĀ boards.txtĀ to originalĀ boards.txt
- Make a folder namedĀ mega32Ā in ā¦arduino-1.5.2\hardware\arduino\avr\variants
- Copy fileĀ pins_arduino.hĀ from the zip into folder created at step 4.
- Start Arduino IDE and select board.
- 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:
https://github.com/eaconner/ATmega32-Arduino
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.
Itās 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
/*Blink Turns on an LED on for one second, then off for one second, repeatedly. This example code is in the public domain. */ // Pin 13 has an LED connected on most Arduino boards. // give it a name: int led = 13; // the setup routine runs once when you press reset: void setup() { // initialize the digital pin as an output. pinMode(led, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }
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
const static uint8_t SDA = 8; //wrong const static uint8_t SCL = 9; //wrong
must be changed in:
const static uint8_t SDA = 17; //correct const static uint8_t SCL = 16; //correct
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.
UPDATE:
ForĀ Serial library to work properlyĀ must be made following changes to the fileĀ HardwareSerial.cpp
In ā¦\arduino-1.5.8\hardware\arduino\avr\cores\arduino\HardwareSerial.cpp
will replace:
#if defined(__AVR_ATmega8__) config |= 0x80; // select UCSRC register (shared with UBRRH) #endif
with:
#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega32__) || defined(__AVR_ATmega16__) config |= 0x80; // select UCSRC register (shared with UBRRH) #endif