Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I understand the "most raw" method to program an AVR microcontroller is probably with an ISP such as the AVRISP mkII.

However, I'm after a method that doesn't involve me having to purchase a $40 tool for a one-off project.

I have at my disposal a computer, an Arduino Uno, and a Raspberry Pi.

I'm not really interested in using the Arduino IDE and writing sketches. I want to get down into the low level code which is possible in C, preferably using an IDE such as Atmel Studio.

As I understand the Arduino Uno has an ATmega16U2 which connects to a computer via USB, which is used to program the ATmega328P.

Is the ATmega16U2 acting as a ISP here? If so, can I use it to program the ATtiny? I've gone through the schematic, and it shows the mega16u2 has an ICSP header, but it's connected to the mega328 via TX/RX lines.

share|improve this question
    
You better buy a store.atmel.com/PartDetail.aspx?q=p:10500053#tc:description. Thank me later. –  user34920 Jul 7 at 10:53
1  
UsbAsp clone can be had from ebay for 5$ or so if you don't want to hook up Arduino as a programmer each time. –  miceuz Jul 7 at 11:46
    

3 Answers 3

up vote 2 down vote accepted
  • Is the ATmega16U2 acting as a ISP here?

No, that chip is acting as a USB -> RS232 TTL adapter. The 328P chip has a serial bootloader installed on it which accepts commands through RS232 to program the chip.

You can install the ArduinoISP sketch on the Arduino (included with the Arduino IDE), which then turns the Arduino into an ISP that can be controlled via AvrDude (command line program) to program the ATTiny through ISP.

There are many tutorials and examples on the Arduino forums and playground.

share|improve this answer
    
"RS232 TTL" contradicts each other. RS232 is explicitly an UART having +/- 15 V. TTL UART is probably what you mean. –  glglgl Jul 7 at 12:03
    
Awesome. Slightly OT, but has the 16u2 been programmed with an ISP or something before being shipped? Also, if the 328P chip's bootloader is erased manually, does this mean that the Arduino won't be able to load sketches the normal way, unless you use an ISP to reload the bootloader? –  tgun926 Jul 7 at 12:29
    
@glglgl RS-232 is used in this situation coupled with TTL (as it is used everywhere) to define an RS-232 system that uses TTL voltage levels. UART is not RS-232, but can generate signals with RS-232 timings. The "U" means "Universal". Oh, and pedants aren't appreciated around here. –  Majenko Jul 7 at 12:42
    
@tgun926 Yes and yes. –  Majenko Jul 7 at 12:42
    
@Majenko "Oh, and pedants aren't appreciated around here." That's what you say. On developing things, it is important to be precise. –  glglgl Jul 7 at 15:24

Both Arduino and the Raspberry Pi can be wired up as an ISP programmer with AVRDUDE.

share|improve this answer

You can use a 5x2 10 pin header and wire up your own programmer, such as this:

enter image description here

That was taken from Sparkfun's tutorial on microcontroller programming. The entire tutorial is about getting code onto a Microcontroller. The microcontroller used is an AVRMega, but the same will hold true for a Tiny.

Use the Serial port programmer, with supporting hardware it should be far less than $40.

This programmer will be specific to AVRs, so that 'one off project' thing isn't entirely true for this piece of hardware.

That's how you physically get the code onto the board. There are several ways to compile and upload the code as well, using any of your favorite editors, makefiles, and the like.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.