Program ATTiny 4313 w/ISP Shield?
  • Is it possible to program the 4313 & 2313 with the ISP Shield?
  • Yes, of course.  The ISP Shield can be used to program any AVR microcontroller that has an ISP interface.
  • What would the process be?


    1. Load the Arduino ISP sketch.
    2. Place ATTiny 4313 in shield.
    3. Choose the ATTiny 4313 as the target board.
    4. Upload

    What about loading a .hex file to the Tiny? I'm guessing AVRDude command line is the way to go.


    Thanks.


     

  • Step 1 is correct.

    The ZIF socket is for ATmega48/88/168/328 and ATtiny25/48/85 (with one wire added).  For other AVRs, you need an external target board.

    The correct process to use for programming depends on what environment you're using.  We use AVR-GCC/Avrdude straight from the command line.  If you're using a hacked version of Arduino instead (as I'm guessing you're referring to), then you need to follow the appropriate directions for that environment.  Standard versions of Arduino do not support the '2313/'4313.

  • Yes, of course......
  • OK so I'm completely clear. I cannot use the Zif socket on the ISP Shield to program an AtTiny4313?
  • No, not without extensive rewiring. 
  • I wish I had known this before I purchased the programmer as the AtTiny4313 is what I bought the programmer for. So can someone tell me exactly how to connect up this programmer to the AtTiny4313 externally on a breadboard for example.
  • This article shows you how to connect up an ATtiny2313; the '4313 works identically:

    http://www.evilmadscientist.com/2007/using-avr-microcontrollers-minimalist-target-boards/
  • OK. I bought and built the ispShield and the 2313 target board. On the target board I installed a 6 pin ISP header with the leads facing upward and a 20 pin ZIF socket. I put positioned the jumpers to disable autoreset and to provide target power.

    I then connected the boards with your 6 pin cable. On the ispShield I oriented the ribbon cable connector with the red stripe connected to the triangle on the board. However on the target board the red stripe is opposite the triangle on the board. Is that correct or should the ISP header be installed on the bottom of the target board?

    I put the attiny4313 into the ZIF socket on the target board.

    I brought up the Arduino IDE and selected an Arduino Uno as the board then loaded and uploaded the ArduinoISP sketch. The pulse LED then cycles.

    I then ran avrdude with the following command line on my Mac:
    avrdude -c arduino -p t4313 -P /dev/tty.usbmodem1411 -F -U flash:w:TinyMatrix.hex:i

    I have to use the -F switch because the device signatures don't match. The signature returned is for the atmega 328 in the UNO I think.

    Here is the result:

    avrdude: AVR device initialized and ready to accept instructions

    Reading | ################################################## | 100% 0.00s

    avrdude: Device signature = 0x1e950f
    avrdude: Expected signature for ATtiny4313 is 1E 92 0D
    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 "TinyMatrix.hex"
    avrdude: writing flash (2016 bytes):

    Writing | ################################################## | 100% 0.52s

    avrdude: 2016 bytes of flash written
    avrdude: verifying flash memory against TinyMatrix.hex:
    avrdude: load data flash data from input file TinyMatrix.hex:
    avrdude: input file TinyMatrix.hex contains 2016 bytes
    avrdude: reading on-chip flash data:

    Reading | ################################################## | 100% 0.39s

    avrdude: verifying ...
    avrdude: verification error, first mismatch at byte 0x0000
             0x4c != 0x00
    avrdude: verification error; content mismatch

    avrdude: safemode: Fuses OK

    avrdude done.  Thank you.

    It looks like the code is not being programmed.

    Any idea what is going on?

    One other thing, when I load the sketch the pulse LED flashes until I try to program the device and then it goes off and stays off. The Prog LED never flashes.




  • The '2313 target board and the ISP shield both have the same orientation for the ISP header.  In both cases the headers need to be installed on the tops of the boards, and you need to orient the cable the same way at both ends.   This means that the red stripe side of the cable has to go towards the arrow-marked pin (pin 1) on both ends.

    So, it sounds like one end of your cable is backwards.

    You should never use the "-F" option to override signature checking-- *unless* you actually intend to program a chip as though it was one of a different type-- a very rare but possible circumstance.  Since you *are* programming a 't4313 as a 't4313, you should definitely NOT use the "-F" option.   If you use "-F", it will turn of important error checking that you actually should be using and paying attention to.

    Also, normally we use 'avrisp' not 'arduino' as the programmer type when doing this, and the USB port should be declared as "-P usb" not "-P /dev/xxxxx". 
  • Thanks Windell. The problem was not the cable it was using arduino as the programmer. As soon as I changed it to avrisp everything worked.

    Excellent!