Here is what to do to set up an Atmega32L to use arduino ide made hex files!!! ide support not yet working.. but should be in the future.. I'll explain later
1a. Wire up the board as shown:
Uploaded with ImageShack.us
1b. Flash the Arduino As ISP sketch to your arduino if you are going to use it as an avr programmer, or skip this step if you already have an icsp programmer.
-
Go here: Alternate CORE files for Arduino
download the arduino-extras.zip -
Make sure to make a backup of your arduino folder as we will be changing some files.
-
Go to: your arduino folder to here: arduino-0022\hardware\arduino Delete all files in this folder.
-
Dump the contents of the Arduino Extras zip (within the arduino extras folder) into the directory you just deleted the arduino files from.
-
In your arduino folder go here: arduino-0022\hardware\arduino\bootloaders\atmega
-
Copy the ATmegaBOOT_168_diecimila.hex file into this folder: arduino-0022\hardware\tools\avr\bin
-
Now we are going to get things going. DO THIS EXACTLY AS I DO!!!!! with the exception of what port/baudrate/and programmer you have
Go to the command prompt, and get to the arduino-0022\hardware\tools\avr\bin\ folder
*Windows Vista, and 7 users, just right click away from a file in this directory while holding shift and select "open command prompt here"
First we will check to ensure everything is ok. Type this:
avrdude -p m32 -c name of your programmer -P port/com/usb -b 19200
It should say this:
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.14s
avrdude: Device signature = 0x1e9502
avrdude: safemode: Fuses OK
avrdude done. Thank you.
This will set the chip to be unlocked, and use the internal 8mhz oscillator. To use an external resonator or another speed, go here: AVR® Fuse Calculator – The Engbedded Blog
avrdude chipname programmer name baudrate com-port erase-chip.
avrdude -p m32 -c avrisp -b 19200 -P com4 -e -U lfuse:w:0xd4:m -U hfuse:w:0x99:m
Now unlock to bootloader:
avrdude -p m32 -c avrisp -b 19200 -P com4 -U lock:w:0x3F:m
Now flash the arduino bootloader:
avrdude -p m32 -c avrisp -b 19200 -P com4 -e -U flash:w:AtmegaBOOT_168_diecimila.hex
You should see this:
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.12s
avrdude: Device signature = 0x1e9502
avrdude: erasing chip
avrdude: reading input file "AtmegaBOOT_168_diecimila.hex"
avrdude: input file AtmegaBOOT_168_diecimila.hex auto detected as Intel Hex
avrdude: writing flash (16294 bytes):Writing | ################################################## | 100% 3.35s
avrdude: 16294 bytes of flash written
avrdude: verifying flash memory against AtmegaBOOT_168_diecimila.hex:
avrdude: load data flash data from input file AtmegaBOOT_168_diecimila.hex:
avrdude: input file AtmegaBOOT_168_diecimila.hex auto detected as Intel Hex
avrdude: input file AtmegaBOOT_168_diecimila.hex contains 16294 bytes
avrdude: reading on-chip flash data:Reading | ################################################## | 100% 18.74s
avrdude: verifying ...
avrdude: 16294 bytes of flash verifiedavrdude: safemode: Fuses OK
avrdude done. Thank you.
Now LOCK the bootloader! failure to do so will cause you to overwrite the bootloader when you do the next step!
avrdude -p m32 -c avrisp -b 19200 -P com4 -U lock:w:0x0f:m
You should see this:
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.12s
avrdude: Device signature = 0x1e9502
avrdude: reading input file "0x0f"
avrdude: writing lock (1 bytes):Writing | ################################################## | 100% 0.12s
avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x0f:
avrdude: load data lock data from input file 0x0f:
avrdude: input file 0x0f contains 1 bytes
avrdude: reading on-chip lock data:Reading | ################################################## | 100% 0.03s
avrdude: verifying ...
avrdude: 1 bytes of lock verifiedavrdude: safemode: Fuses OK
avrdude done. Thank you.
Minimize the command line for a moment. It's time to make a blinky sketch!
Now, go into the modified arduino folder, and run the IDE. Throw this code in.
/*
atmega32blinkpin32- *modified blink sketch for atmega32L by hexskrew*
Turns on an LED on for one second, then off for one second, repeatedly, one by one for all 32 outputs.
This example code is in the public domain.
*/
void setup() {
// initialize the digital pin as an output.
pinMode(32, OUTPUT);
pinMode(31, OUTPUT);
pinMode(30, OUTPUT);
pinMode(29, OUTPUT);
pinMode(28, OUTPUT);
pinMode(27, OUTPUT);
pinMode(26, OUTPUT);
pinMode(25, OUTPUT);
pinMode(24, OUTPUT);
pinMode(23, OUTPUT);
pinMode(22, OUTPUT);
pinMode(21, OUTPUT);
pinMode(20, OUTPUT);
pinMode(19, OUTPUT);
pinMode(18, OUTPUT);
pinMode(17, OUTPUT);
pinMode(16, OUTPUT);
pinMode(15, OUTPUT);
pinMode(14, OUTPUT);
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
pinMode(4, OUTPUT);
pinMode(3, OUTPUT);
pinMode(2, OUTPUT);
pinMode(1, OUTPUT);
}
void loop() {
int pinwrite = 0;
do
{
digitalWrite(pinwrite, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(pinwrite, LOW); // set the LED off
delay(1000); // wait for a second
pinwrite++;
}
while(pinwrite < 33);
}
Now! Make sure you select "Embedded Market Atmega32" for the 8mhz internal oscillator version if you changed to the outboard oscillator and running 16mhz, chose "Arduino-Penguino AVR"
Hold shift, and hit the play button on the arduino ide and anytime for now that you write a sketch for your atmega32. Notice the folder (just the numbers, ill tell you the rest).
Go to this folder (Windows 7 or Vista, XP users it will be different so just look at what folder the ide outputted to):
C:\Users\YourName\AppData\Local\Temp\buildbuncha numbers i told you to remember.tmp\
Copy the file: atmega32blinkpin32.cpp.hex
Paste that hex file into the arduino-0022\hardware\tools\avr\bin folder.
For a final horah before we get to the happy ending, open a beer, grab every led you can, and try to fill all 32 outputs on the Atmega32L.
Go back to the command line, and type this to flash the arduino sketch to your chip.
avrdude -p m32 -c avrisp -b 19200 -P com4 -U flash:w:atmega32blinkpin32.cpp.hex
You should see this:
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.12s
avrdude: Device signature = 0x1e9502
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "atmega32blinkpin32.cpp.hex"
avrdude: input file atmega32blinkpin32.cpp.hex auto detected as Intel Hex
avrdude: writing flash (1212 bytes):Writing | ################################################## | 100% 1.56s
avrdude: 1212 bytes of flash written
avrdude: verifying flash memory against atmega32blinkpin32.cpp.hex:
avrdude: load data flash data from input file atmega32blinkpin32.cpp.hex:
avrdude: input file atmega32blinkpin32.cpp.hex auto detected as Intel Hex
avrdude: input file atmega32blinkpin32.cpp.hex contains 1212 bytes
avrdude: reading on-chip flash data:Reading | ################################################## | 100% 1.44s
avrdude: verifying ...
avrdude: 1212 bytes of flash verifiedavrdude: safemode: Fuses OK
avrdude done. Thank you.
If everything went ok, then you should see your lights blinking in ecstacy one by one for the delay time you have in the sketch
Final Step Very important
Chug your beer, slap your girlfriend's A** and grunt like hell. You just did what people thought was almost impossible