Sunteți pe pagina 1din 11

Home Sign Up!

Browse Community Submit


All Art Craft Food Games Green Home Kids Life Music Offbeat Outdoors Pets Photo Ride Science Tech

Arduino on all sorts of Atmels


by 02JanDal on February 6, 2011 Table of Contents Arduino on all sorts of Atmels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Intro: Arduino on all sorts of Atmels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 1: A list of that Atmels can be programmed with this and that is needed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 2: Setting up the software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 3: Program MCUs what don't have bootloaders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 4: Program MCUs with bootloader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 5: Using another ISP than the Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 6: Pin outs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 7: USB and CAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 2 4 5 6 7 8 9 9

Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

http://www.instructables.com/id/Arduino-on-all-sorts-of-Atmels/

Author:02JanDal
I'm only 14 years old, so don't expect my instructables to be as good as if a 30 year old engineer had done them. I like to do things my self and see what's inside things. I really like Arduino and AVRs. I do also like model railroading.

Intro: Arduino on all sorts of Atmels


Hello, this is my first instructable, so I hope someone can do anything good with it. So, what exactly is this about? Imagine: You are working on a project. You want to program in the Arduino language because of the simplicy. But you don't want to use a 28 pin monster. Or you need peripherals like CAN or similar what the normal Arduino supported MCUs don't have. So, what to do? Where are two alternatives: 1. Just don't use the Arduino language and use things like bits and ports what you can't understand. 2. Or continue reading this! So, this instructable is going to show how to use the core files available from avr-developers.com . I'm also going to show you how to program the different MCUs and how to connect them to do so. At the end I'm going to give some ideas on what you can to with your new knowledge earned from this. As a little side note I want to say something; I'm just 14 years old, so please, if something is not as good as if an 40 year old engineer had done it, have mercy, write a comment about it and I will try to fix it. If you have any problems, feel free to post a comment or drop me an email (jan[at]dalheimer[dot]de). If you can't figure out what to use instead of the [at] and [dot], I don't want an email from you. I just saw that some MCUs use the ArduinoISP as default and some use the USBtinyISP as default. To see how to change, see step 5. I want to say a big thank you to Mark Sproul for the modified core files at avr-developers.com. THANK YOU! So.... Let's get started! IMPORTANT: I give no warranty in any way for anything in this instructable. Some names like Atmel, ATmega etc. belong to their owners. Also almost all pictures do NOT belong to me.

Step 1: A list of that Atmels can be programmed with this and that is needed
Now you know something about that this is about, but you wonder; what MCUs exact can I program using this instructable? First of all, only ATmegas, AT90s or ATtinys. Perhaps some day, PICs to. Or ARM. Or.. Or.. But for now, just MCUs from Atmel. The frequency for each MCU can be found by choosing your MCU here , opening up the boards.txt file and then searching for your MCU. There will then stand yourBoard .bootloader.low_fuses=fuse and yourBoard .bootloader.high_fuses=fuse . Then copy the number that stands instead of fuse into the fields at the bottom of the page . Click "Apply Values" and then you can see what type and speed of crystal to use in the drop down menu further up on the page. To find out that type of upload you should use, go to the AVR developers page and look that stands there. So, here is a list of working MCUs, sorted by type and number: Name: == ATmega: ATmega8 ATmega8u2 ATmega16 ATmega32 ATmega32u4 ATmega48

http://www.instructables.com/id/Arduino-on-all-sorts-of-Atmels/

ATmega64 ATmega88P ATmega128 ATmega128rfa1 ATmega165 ATmega165P ATmega168 ATmega169 ATmega324P ATmega328P ATmega640 ATmega644 ATmega644P ATmega645 ATmega1280 ATmega1281 ATmega1284P ATmega2560 ATmega2561 ATmega3290P ATmega8515 ATmega8535 == ATtiny: ATtiny26 ATtiny45 ATtiny85 ATtiny2313 == Others: AT90CAN128 AT90CAN32 AT90CAN64 AT90USB1286 AT90USB1287 AT90USB162 AT90USB646 AT90USB647 Now you know what MCUs you will be able to program with this. But what do you need? 1. An ISP programmer. This instructable will use an Arduino as ISP, but I will add a category on how you can use other ISP programmers at the end of the instructable. 2. An USB <-> Serial converter or an RS232 <-> UART converter (only needed for programming MCUs with bootloader). 3. An breadboard. You can also solder on a perfboard or a custom PCB, but that is up to you and will not be covered here. 4. An computer. (I think you have one, otherwise you couldn't read this :)) 5. The Arduino program. It can be downloaded from here . 6. The core files available at avr-developers.com . See the next step for how to install it right. 7. The MCU to program. 8. Some really cool idea on that you want to do after reading this. (Optional, but recommend)

Image Notes 1. ATmega128

http://www.instructables.com/id/Arduino-on-all-sorts-of-Atmels/

Image Notes 1. AT90USB646

Image Notes 1. ATtiny45 2. ATtiny2313

Step 2: Setting up the software


This step is mainly about how to setting things up on the computer side. First, if not already done, install the Arduino IDE from www.arduino.cc/en/Main/Software Second, download the core files from www.avr-developers.com/corefiles/ . There is an instruction on how to install it right on the site, but to make it easy: just unzip the files to arduinoInstallPath\hardware there arduinoInstallPath is the path there you have installed the IDE. Third, start the Arduino IDE and open File -> Examples -> Arduino ISP . Fourth, connect your Arduino board to the computer. Fifth, choose your Arduino board from the Tools -> Board and choose the serial port from Tools -> Serial Port . Sixth, press upload. Now you have set up everything on the computer side and made your ISP (Arduino) ready. You are now ready to start setting up your MCU to program.

http://www.instructables.com/id/Arduino-on-all-sorts-of-Atmels/

Step 3: Program MCUs what don't have bootloaders


It will be different if you want to program MCUs without bootloaders or if you want to program ones with bootloader. For the ones without bootloader, continue reading directly, for the rest, go to the next step. So, first, set your MCU into a breadboard. Open up the datasheet of the MCU to program (links on the second step). Look for the pinout and use this to connect VCC and GND to a 5V supply(this can be an Arduino). If there is an AVCC or AGND or similar, connect them to VCC (for AVCC) and GND (for AGND). Connect your Arduino to the MCU in the following way: MCU Arduino SCK 13 MISO 12 MOSI 11 CS(reset) 10 Also connect an 10k resistor from the reset pin of the MCU to program to VCC. And connect the XTAL pins to a crystal (see second step on that frequency) and with 22pF capacitors to ground. After this you can start the programing! Important : Remember the Arduino and the other MCUs do NOT have the same pin mapping. See this for what pin is that Port/Bit.

Image Notes 1. ATtiny45 2. ATtiny2313

Image Notes 1. MCU to program 2. Arduino working as ISP (ArduinoISP) 3. SCK, MISO and MOSI data lines 4. Supply lines 5. Reset pull-up resistor 6. CS (ChipSelect) (reset)

http://www.instructables.com/id/Arduino-on-all-sorts-of-Atmels/

Step 4: Program MCUs with bootloader


Now we have arrived at the part for the programming of MCUs with bootloader. This is a bit more difficult than programming ones without bootloader. You can see witch MCUs have bootloader on the second step. First, again, set your MCU into a breadboard, open the datasheet of the MCU and look for the pin out. Look for VCC and GND and connect them to a 5V supply. Connect your Arduino to the MCU after the following: MCU Arduino SCK 13 MISO 12 MOSI 11 CS(reset) 10 Also connect an 10k resistor from the reset pin of the MCU to program to VCC. And connect the XTAL pins to a crystal (see second step on that frequency) and with 22pF capacitors to ground. Second, go to Tools -> Board and choose your board. Go to Tools -> Burn Bootloader -> w/ Arduino as ISP . Now the bootloader will be burned onto the MCU. This may take some time, so do something good in the time like designing your next project or similar. Then the bootloader is burned you can disconnect your Arduino from the MCU. Now you can start the programming. For this you can use your Arduino again. Take out the ATmega328 (Arduino) from it's position and connect the reset pin of the Arduino to the reset pin of the MCU to program. Also connect Arduino pin 0 to the TxD pin of your MCU and Arduino pin 1 to the RxD pin of your MCU (see pin out in datasheet again) You can also use an breakout board of the FT232. Connect CTS to ground if you do!!! If you do, connect like this: MCU FT232 Rx Tx Tx Rx Reset RTS VCC 5V GND GND GND CTS Connections not mentioned from the breakout board of the FT232 should not be connected. Choose your serial port under Tools -> Serial Port . Open the code you want to upload and press upload. Done. Important : Remember the Arduino and the other MCUs do NOT have the same pin mapping. See this for what pin is that Port/Bit.

Image Notes 1. remove

Image Notes 1. AT90USB646

http://www.instructables.com/id/Arduino-on-all-sorts-of-Atmels/

Image Notes 1. ATmega128

Step 5: Using another ISP than the Arduino


If you don't have an Arduino to use as ISP, there is another way. You can also use the following ISP programmers: AVR ISP AVRISP mkII USBtinyISP Parallel Programmer To use one of these, you must do some things different. First of all; then burning the bootloader on MCUs with bootloader you must use Tools -> Burn Bootloader and then the ISP to use. Then uploading code to MCUs without bootloader, you must go into arduinoInstallPath/hardware/arduino-extras/boards.txt and find your MCU. To find the right one can be a bit tricky, but if you use Ctrl+F and type the number (not the letters. for example: type 646 instead of AT90USB646 or 2313 instead of ATtiny2313 etc.) into the search field you should be able to find it. Then type type .upload.using=programmer , there type is the name of the MCU (look at the lines around) and programmer can be any of the following: avrisp (AVRISP) avrispmkii (AVRISP mkII) usbtinyisp (USBtinyISP) parallel (Parallel Programmer) arduinoisp (Arduino ISP) For example, in the boards.txt for the ATtiny2313 it stands: arduino_attiny2313.name=Arduino-ATtiny2313 arduino_attiny2313.upload.using=arduinoisp arduino_attiny2313.upload.protocol=stk500 arduino_attiny2313.upload.maximum_size=2048 arduino_attiny2313.upload.speed=19200 arduino_attiny2313.bootloader.low_fuses=0xe4 arduino_attiny2313.bootloader.high_fuses=0xdf arduino_attiny2313.bootloader.path=attiny45 arduino_attiny2313.bootloader.file=ATmegaBOOT.hex arduino_attiny2313.bootloader.unlock_bits=0x3F arduino_attiny2313.bootloader.lock_bits=0x0F arduino_attiny2313.build.mcu=attiny2313 arduino_attiny2313.build.f_cpu=8000000L arduino_attiny2313.build.core=arduino Now add arduino_attiny2313.upload.using=avrisp , save the file, restart the Arduino IDE and voila! If you need help you can write a comment.

http://www.instructables.com/id/Arduino-on-all-sorts-of-Atmels/

Image Notes 1. MOSI 2. GND 3. VCC 4. MISO 5. SCK 6. CS (reset)

Image Notes 1. AVRISP mkII 2. ISP connector

Image Notes 1. to computer 2. USBtinyISP 3. ISP connectors

Image Notes 1. AVR ISP 2. to computer 3. ISP connector

Step 6: Pin outs


The pin outs are always like the following: Digital pins: Digital pin 1: Port A, Bit 0 = PA0 Digital pin 2: Port A, Bit 1 = PA1 ... Digital pin 8: Port A, Bit 7 = PA7 Digital pin 9: Port B, Bit 0 = PB0 Digital pin 10: Port B, Bit 1 = PB1 etc. etc. etc. Analog pins: The analog pins are defined like the above, but the ADC pin with the first register (after the alphabet; Port A is before Port B etc.) what has ADC and the first bit (bit 0) is analog pin 0, the ADC pin with the first register what has ADC and the second bit of that register is analog pin 1. etc. etc. PWM pins: PWM pins have the same pin numbers as normal digital pins. To see witch digital pins are PWM enabled, look at the pin out in the datasheet. At some pins, there will stand "OC#@" There the # is a number and the @ is a letter. The @ is not always present. So on every pin there is stand OC + a number + a letter (not always) has

http://www.instructables.com/id/Arduino-on-all-sorts-of-Atmels/

hardware PWM. Serial pins: Serial pins are defined as RXD and TXD. Some times there are multiply hardware Serial lines. If this is present, TXD and RXD are Serial, TXD1 and RXD1 are Serial1 etc. etc. Other pins: To see that pins have I,,2,,C, SPI etc. look at the datasheet and search for the corresponding pins (I,,2,,C: SDA and SCL etc.) Interrupts: The interrupt pins are labeled with INT#, there # is the number of the interrupt.

If anything is unclear, post a comment.

Image Notes 1. PWM pin 2. Hardware Serial pins 3. Interrupt 0 and 1

Step 7: USB and CAN


Some of the MCUs listed in the second step have onboard USB or CAN. For how to connect them, see here: USB: Just use 22ohm resistors between D+ & D+ and D- & D-. In some datasheets it doesn't stand D+ or D-, it stands DM (for D-) and DP (for D+). CAN: There are many CAN circuits out there, with different ICs etc. Exchange nameOfDevice with the name of your MCU on this link. You should then find images with your device and CAN.

Related Instructables

Turn Your Arduino Into an ISP by mr_mac3

How to program a AVR (arduino) with another arduino by kabturek

How to fix dead atmega and attiny avr chips by manekinen

Apple-style LED pulsing using a $1.30 MCU by hardwarehank

How to control a Stripboard 16x2 LCD using Arduino by an AVR icecreamterror ATtiny2313 by roznerd

http://www.instructables.com/id/Arduino-on-all-sorts-of-Atmels/

Comments
15 comments Add Comment

themroc says:
This is a great Instructable and Ill give you 5 Stars, when youll edit it in a few steps.

Mar 20, 2011. 5:46 AM REPLY

Please be careful taking images from other sources (Atmel-Logo etc.) I dont know the law for sure, but I think they are not free too use). You are a really smart boy, but consider the reader is not as smart as you. Some steps need a little bit more Explanation. Try to explain Step by Step in an example (ATtiny2313 or other). themroc

02JanDal says:
1. The USBasp has it's own Arduino core files and has not to much to do with this. 2. Quote: You mean, finding the MCU and changing the programmer-option? Please explain it. ??? Please explain more about what you mean. 3. Quote: It would be fine if youd said, that the image is an ATtiny2313. If you hower over the yellow field you will see that the image is an ATtiny2313. 4. I've asked for permission for all of the images.

Mar 20, 2011. 6:25 AM REPLY

5. I've already thought about making a step-by-step for one AVR, but I haven't came to that yet, especially since my only ATtiny2313 has the reset disabled (wrong fuse...) and I've been waiting for more AVR's to come, but I live in Sweden and some times packages get totaly lost for some mounths. JanD

themroc says:

Mar 20, 2011. 6:52 AM REPLY Look at your Step 5. You wrote about finding the MCU in boards.txt. I guess you mean finding the MCU and then changing the programmer-option for the apropriate programmer (for Example AVRISP etc.) ? Please do an example. If you have the permission for the images ok. Sorry in my version of this instructable the yellow fields in Step 6 only show the pins not the MCU. If you need a Attiny2313, Ill send you two (under 20g). Themroc

02JanDal says:
Ok, now I understood.

Mar 20, 2011. 7:19 AM REPLY

It would be great if you could send me one or two ATtiny2313, but I think I can't take that offer, if you don't really want me to have them. JanD

themroc says:

Mar 20, 2011. 7:50 AM REPLY If your Instructable really works (and I think it will) see this as a kind of fee for your efforts. Ill contact you per e-mail. I didnt find another source about that issue in the web and the avr-developers site is great, but the explanation is worse (it is not for beginners). On what kind of AVR did you try it?

02JanDal says:
Good, my email is jan[at]dalheimer[dot]de (try to figure that out!) That's one of the main things that made me do this.

Mar 20, 2011. 8:44 AM REPLY

I tried the blink sketch on ATmega644, ATtiny25, ATtiny45, ATtiny85 and on my ATtiny2313 (it worked until I accidentally disabled the reset pin...). JanD

themroc says:

Mar 20, 2011. 5:32 AM REPLY It would be fine if youd said, that the image is an ATtiny2313. To have a better access to this example try to have the pinmapping in a table. A great job for a 14 Year old boy! themroc

http://www.instructables.com/id/Arduino-on-all-sorts-of-Atmels/

themroc says:
Great Instructable, but needs some differentiation: You mean, finding the MCU and changing the programmer-option? Please explain it.

Mar 20, 2011. 5:28 AM REPLY

What about USBasp? Im using a Metaboard-Arduino-clone (much cheaper then the original one) with USBasp-Firmware. AVRDude in the normal ArduinoIDE supports it, but does the modified core work with it? I tried to change the board.txt file, but there is a NullPointerExeption with the modified core. themroc

heatseeker96 says:

Feb 28, 2011. 11:47 AM REPLY Here's a little question: If I load this program on a ATmega328P (I think it's the regular Arduino), can I then use the Arduino socket on the board (like Arduino Ono) to program it again (with the bootloader)? Thank you for your help (and instructable)! (sorry for my bad English)

02JanDal says:

Feb 28, 2011. 12:11 PM REPLY You would not need this as the bootloader for the ATmega328P is included with all IDE releases. But you can use this on how to burn the bootloader, but after burning the bootloader it can be placed into the socket of any Standard Arduino. JanD

heatseeker96 says:
Thank you!

Mar 1, 2011. 9:59 AM REPLY

frank26080115 says:
Excuse me? "The best way to find out that pin number is what pin is to test." ? That is wrong. Just read the files you are using.

Feb 7, 2011. 5:16 PM REPLY

02JanDal says:
Changed. I didn't think of that. I will make some pin mappings as soon as I get home from school. Thanks for pointing that out, JanD

Feb 7, 2011. 10:08 PM REPLY

02JanDal says:
Fixed this and the links to the datasheets.

Feb 8, 2011. 12:33 PM REPLY

02JanDal says:
I also just saw I forgot to add the link to the usable MCUs list. I will do that after school to. Jan

Feb 7, 2011. 10:10 PM REPLY

http://www.instructables.com/id/Arduino-on-all-sorts-of-Atmels/

S-ar putea să vă placă și