4
\$\begingroup\$

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.

\$\endgroup\$
3

3 Answers 3

2
\$\begingroup\$
  • 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.

\$\endgroup\$
6
  • 1
    \$\begingroup\$ "RS232 TTL" contradicts each other. RS232 is explicitly an UART having +/- 15 V. TTL UART is probably what you mean. \$\endgroup\$
    – glglgl
    Jul 7, 2014 at 12:03
  • \$\begingroup\$ 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? \$\endgroup\$
    – tgun926
    Jul 7, 2014 at 12:29
  • \$\begingroup\$ @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. \$\endgroup\$
    – Majenko
    Jul 7, 2014 at 12:42
  • 1
    \$\begingroup\$ @Majenko "Oh, and pedants aren't appreciated around here." That's what you say. On developing things, it is important to be precise. \$\endgroup\$
    – glglgl
    Jul 7, 2014 at 15:24
  • 1
    \$\begingroup\$ RS232 TTL is a commonly used phrase to describe RS232 using TTL signal levels. It is distinct from RS232 without the TTL specified. Other common phrases are TTL-232, TTL serial, etc. None are 100% perfect because there is no official designation for it. And anyway, it's EIA-232, NOT RS-232 :P See, I can be just as pedantic! \$\endgroup\$
    – Majenko
    Jul 7, 2014 at 15:38
5
\$\begingroup\$

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

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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