Arduino Micro as ISP and atTiny84A

Hi!

I'm done with building my first bigger project using an Arduino Micro.
Now I want to program the atTiny84A, which seems to be perfect for the project.
I red all examples about how to use an Arduino Uno as an ISP, but I'm not sure if these guides work with my 84A.
So here is what I made:
I flashed the ISP sketch to my arduino (right COM-Port, board set to Arduino Micro, Programmer set to avr isp witch is default).
According to the comments in the ISP sketch I added some LED's (heartbeat, error, programming). After flashing, the heartbeat LED pulses -> Very nice, it worked!

The comments also told me the following:

// pin name:    not-mega:         mega(1280 and 2560)
// slave reset: 10:               53 
// MOSI:        11:               51 
// MISO:        12:               50 
// SCK:         13:               52

I red the data sheet (http://www.atmel.com/Images/8183S.pdf) of the 84A to find the right pins, and so I connected arduino-pin 10 to RESET-pin of the 84A, 11 to MOSI, 12 to MISO and 13 to SCK.
GND and VCC is also clear!

Now I opened the blink sketch (changed pin from 13 to 0), switched the programmer to Arduino as ISP and selected atTiny84 @ 20 MHz as board.
After uploading, the log (update.verbose=true) shows me the following:

C:\Arduino\arduino-1.0.4\hardware/tools/avr/bin/avrdude -CC:\Arduino\arduino-1.0.4\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -pattiny84 -cstk500v1 -P\\.\COM13 -b19200 -Uflash:w:C:\Users\Flips\AppData\Local\Temp\build746589376383792063.tmp\Blink.cpp.hex:i 

avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Arduino\arduino-1.0.4\hardware/tools/avr/etc/avrdude.conf"

         Using Port                    : \\.\COM13
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
avrdude: Send: 0 [30]   [20] 
avrdude: Send: 0 [30]   [20] 
avrdude: Send: 0 [30]   [20] 
avrdude: Recv: 
avrdude: stk500_getsync(): not in sync: resp=0x00

avrdude done.  Thank you.
[\code]
Btw, neither the error nor the programming LED turned on...

I know that this error tells me that there seems to be no connection at all, connection between arduino and the 84A. But why? 
Does anyone know how to connect the pins correctly?

Thanks,
Flips

In the command line, replace "-cstk500v1" with "-carduino".

Thank you, now it works a little bit more.
But I still get an error, this time the following:

avrdude: Device signature = 0xffffff
avrdude: Yikes!  Invalid device signature.

I googled it and all I found out were wrong fuse bits. I made the misstake, that on my first try I flashed the tiny with board = atTiny84 @ 20 MHz EXTERNAL (I do not have any oscillators here). Is this the problem? Has this set the fuse bit to external clock (which isn't there) and because of this a second flash won't work until there is an external clock?

Sorry for double posting, but I think I'll quit that...
I'll order a few new 84A and this time I am going to set the right board (8Mhz INTERNAL!!!!).

I tried everything, I added an external oscialltor with those two 22pf capacitors as near as possible to the XTAL1/2, tried a second 5V Vcc source and finally tried this HV tutorial:

Nothing, still:

C:\Arduino\arduino-1.0.4\hardware/tools/avr/bin/avrdude -CC:\Arduino\arduino-1.0.4\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -pattiny84 -carduino -P\\.\COM13 -b19200 -Uflash:w:C:\Users\Flips\AppData\Local\Temp\build2346145638621125582.tmp\Blink.cpp.hex:i 
[...]
         AVR Part                      : ATtiny84
         Chip Erase delay              : 4500 us
         PAGEL                         : P00
         BS2                           : P00
         RESET disposition             : possible i/o
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65     6     4    0 no        512    4      0  4000  4500 0xff 0xff
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           flash         65     6    32    0 yes      8192   64    128  4500  4500 0xff 0xff
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino
[...]
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
[...]
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us
[...]
avrdude: AVR device initialized and ready to accept instructions

Reading | avrdude: Send: u [75]   [20] 
avrdude: Recv: . [14] . [ff] . [ff] . [ff] . [10] 
################################################## | 100% 0.02s

avrdude: Device signature = 0xffffff
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.

avrdude: Send: Q [51]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 

avrdude done.  Thank you.

I'm still hoping for anyone how is able to solve this problem!

Thanks, Flips

How about trying the Tiny core library? It could save you the headache of reinventing the wheel:

https://code.google.com/p/arduino-tiny/

Then you can use the Arduino IDE :wink:

Thanks for your reply!
Does that solve my problem? Because at the moment my main problem is that my tiny is kind of "dead", isn't it? (
I'm a little bit confused at all, because of the log message: "avrdude: AVR device initialized and ready to accept instructions"...)

Do you mean I should use this core for my next tries with a "fresh" tiny?

It is probably locked out, but the HV programmer should be able to unlock it and return it back to Factory 1 MHz. Only 4 data lines, 5VDC, 12VDC and GND. Just put the 1Ks between the ATtiny and your Micro.

The target just needs a clock signal on the XTAL1 pin. There are variations of the ArduinoISP sketch that provide the necessary signal.

After uploading the posted ISP sketch and connecting SCK, MISO, MOSI, RESET, GND, VCC and XTAL1 (with Pin 9), I tried to upload the blink sketch to the tiny.
First try -> Same result (Invalid device signature).
Second try:

avrdude: stk500_program_enable(): protocol error, expect=0x14, resp=0x50
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: Send: Q [51]   [20] 
avrdude: Recv: 
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

And that's always, only the second try gives me the "new" error. Searching for this error brings no "new" things.
I also checked every wire again.
I red that this seems not to be a problem of the tiny itself, but a problem of Arduino as ISP...

...and XTAL1 (with Pin 9)...

It is very likely a different pin from the Arduino Micro. Which means the sketch will have to be changed and your wiring will have to be changed. If I have time, I'll try to get it working tonight.

In the meantime, an LED (plus series resistor) connected to pin 9 then to GND should be dimly lit. If not then it is definitely the wrong pin.

And that's always, only the second try gives me the "new" error.

The ArduinoISP sketch gets a bit flaky when a problem occurs. Try resetting the programmer (your Arduino Micro) between attempts.

...and XTAL1 (with Pin 9)...

It is very likely a different pin from the Arduino Micro. [...]

According to the sketch pin 9 seems to be the right pin:

pinMode(9, OUTPUT);
// setup high freq PWM on pin 9 (timer 1)

An LED on pin 9 works, so there must be an output. I don't think that this is the problem because by connecting this pin to XTAL1 the error changed.

And resetting the arduino does nothing, I did it now 3 or 4 times: After every reset of the arduino, the first flash gives me the first error (Invalid device sig.) and a following second (or thirth or ...) flash gives me the second error...isn't that very strange at all?

Btw many thanks for your efforts!

Flips:
I made the misstake, that on my first try I flashed the tiny with board = atTiny84 @ 20 MHz EXTERNAL (I do not have any oscillators here).

When you say flashed the tiny with board = atTiny84 @ 20 MHz EXTERNAL do you mean you tried changing the fuses?

If you did try changing the fuses, are you certain that was successful?

No, I just wanted to flash a tiny using my arduino micro as ISP. But unfortunately I checked atTiny 84 @ 20 MHz External during the very first try.
So I thought my problem is that this first flash was successfull which implicates that the flashed tiny needs an external clock (doesn't it?). But now that seems not to be the problem because even with the ISP sketch that creates the necessary clock, I'm not able to flash a sketch to the tiny.

Edit: To answer your question, I didn't want to set any fuse, but I think I did it implicitly by flashing the tiny with the 20 MHz setting.

Flips:
Edit: To answer your question, I didn't want to set any fuse, but I think I did it implicitly by flashing the tiny with the 20 MHz setting.

No. The fuses are never set implicitly. They are set when you do it explicitly using avrdude from the command-line or when you execute Tools / Burn Bootloader from the Arduino IDE.

Did you do either successfully?

Ok that's nice to know.
No, I've done many tutorials and guides to "reset" the tiny. Yes, there have been instructions to burn the bootloader to the tiny via the arduino IDE...
But I can surely say that there wasn't any operation which was successful! Neither flashing a sketch to the tiny nor burning the bootloader has ever been successful.
For me, that's a little bit confusing because I'm not even able to read the fuse bits (avrdude says extended = high = low = 0xFF...).

Flips:
I red the data sheet (http://www.atmel.com/Images/8183S.pdf) of the 84A to find the right pins, and so I connected arduino-pin 10 to RESET-pin of the 84A, 11 to MOSI, 12 to MISO and 13 to SCK.

Is this the board you have...

If yes then you have to use the ICSP header (or modify the ArduinoISP sketch to use bit-bang SPI). From that same webpage...

SPI: on the ICSP header. These pins support SPI communication using the SPI library. Note that the SPI pins are not connected to any of the digital I/O pins as they are on the Arduino Uno, they are only available on the ICSP connector and on the nearby pins labelled MISO, MOSI and SCK.

Or...

Micro pin 8 (SS) to ATtiny Reset Pin
Micro pin 9 (SCK) to ATtiny SCK
Micro pin 10 (MOSI) to ATtiny MOSI
Micro pin 11 (MISO) to ATtiny MISO

Nice catch Coding Badly, I keep thinking of the mini when I see micro.

spcomputing:
Micro pin 8 (SS) to ATtiny Reset Pin
Micro pin 9 (SCK) to ATtiny SCK
Micro pin 10 (MOSI) to ATtiny MOSI
Micro pin 11 (MISO) to ATtiny MISO

I think those are physical pins. I think the diagram in the upper-left corner is the one of interest... MOSI is top-left; SS is next to MOSI; SCK is top-right; MISO is next to SCK.

I suspect the ArduinoISP sketch will have to be modified for the SS pin.

Nice catch Coding Badly, I keep thinking of the mini when I see micro.

Thanks.

I think those are physical pins. I think the diagram in the upper-left corner is the one of interest... MOSI is top-left; SS is next to MOSI; SCK is top-right; MISO is next to SCK.

I suspect the ArduinoISP sketch will have to be modified for the SS pin.

I checked, and the pins on the board and chip coincidentally correspond (Yeah, that does not happen often enough).

The SS/Reset trigger (D10 on the Uno) was a concern for me as well, but I can not find "D10" in the sketch. It appears to be a SPI hardware call (SS or chip select) and must be in the avr library. Gammon's programmer would need adjusting from D10 to D8, like the Mega2560. I will check it out with my Leonardo this weekend.

Edit ---

My bad, SPI is PB0-3. I put my brain back in and realize your correct on the pin-outs. Check the pins_arduino

Only access is through the ICSP header.

Ok the icsp header are the pins near to the reset button.
Is the conclusion now that on other arduinos, those pins (which were described in the isp sketch comments) are icsp-able but on my micro, I have to use the icsp header?

Edit:

[...] they are only available on the ICSP connector and on the nearby pins labelled MISO, MOSI and SCK

...ok icsp header or those pins.
(In Germany you say: Reading - Thinking - Posting...:wink: )
I'll try that this evening...