ATTiny85-Programming

From blwiki
Jump to: navigation, search

Outline of Steps to Program an ATTiny85

  • Buy or make an ICSP programmer
  • Wire up the programmer to the board
  • Install ArduinoISP on the Programmer
  • Upload the bootloader to the ATTiny85
  • Upload the sketch to the ATTiny85

Using an Arduino UNO to program an ATTiny85

Wiring (Using UNO as the programmer)

TINYDUINO85-X2-PROGRAMMER.JPG

Wiring here using a TinyDuino85 Rev X2

ATtiny45-85.png

ATTiny85 parts.PNG Board pictured is a Tiny85ISP

  • 6 F-F Jumper Wires
Arduino Pin ATTiny85 Pin TinyDuino Pin
13 Pin 2 D2(S)
12 Pin 1 D1(S)
11 Pin 0 D0(S)
10 Reset RES
VCC Vcc D0(V)
GND GND D0(G)

Run ArduinoISP on Arduino UNO

  • Run the Arduino IDE
  • Open ArduinoISP sketch (examples menu)

ArduinoISPSketch.png

  • For Arduino IDE versions less than 1.0.4
    • Make a small change to the ArduinoISP sketch before uploading it.
    • Find the line in the heartbeat() function that says "delay(40);" and change it to "delay(20);"
    • Comes already fixed in Arduino 1.0.4.
  • Select the board and serial port that correspond to your Arduino board (UNO).
  • Upload the ArduinoISP sketch.
  • Set the Programmer to "Arduino as ISP"

ArduinoAsISP.png

ATTiny85 Support in the Arduino IDE

ATTiny Support - Arduino version 1.8.8

  • Add path to support files (File|Preferences|Additional Boards Manager URLs):
  • Can use a comma to add to list or click the add box
  • Add the following
http://drazzy.com/package_drazzy.com_index.json
  • Boards will appear in boards list
  • I had to remove my other ATTiny boards
    • boards.txt was installed in my github repository location I had set up elsewhere in this procedure
    • Took a while to find it

BoardsManagerResult.png

ATTiny Support - Arduino version 1.6.3

Arduino IDE (v 1.6.3) provides native support for the ATTiny85 and our TinyGrid85. We verified that version 1.6.3 works for both burning the bootloader and downloading sketches to the card. We get this error message but it doesn't affect the compilation or download.

Third-party platform.txt does not define compiler.path. 
Please report this to the third-party hardware maintainer.

Select the ATTiny85 as shown:

Arduino-1-6-2-SelectATTiny85.png

Installing ATTiny support in older Arduino IDE (pre version 1.6)

  • If it is not already installed, then install the Arduino software
  • Download ATTiny master.zip file.
  • Unzip the attiny master.zip file. It should contain an "attiny-master" folder that contains an "attiny" folder.
  • Locate your Arduino installation location
  • Go to the sub-folder called "hardware" in the installation folder
  • For IDE 1.5.6-r2 go to the sub-folder called "arduino"
    • The typical path is C:\Program Files (x86)\Arduino\hardware\arduino
  • Copy the "attiny" folder (not the attiny-master folder) from the unzipped ATtiny master.zip to the "hardware" or "arduino" folder.
  • You should end up with folder structure like C:\Program Files (x86)\Arduino\hardware\arduino\attiny that contains the file boards.txt and another folder called variants.
  • Restart the Arduino development environment.
  • You should see ATtiny entries in the Tools > Board menu.
  • Select ATTiny85 (internal 8 MHz clock).

Burning ATTiny Bootloader into chips

  • By default, the ATtiny's run at 1 MHz.
  • Burn bootloader into chip to set the fuses for 8MHz internal clock.
  • You need to do an extra step to configure the microcontroller to run at 8 MHz – necessary for use of the SoftwareSerial library and timing functions like delay().
  • Once you have the microcontroller connected, select the appropriate item from the Boards menu (e.g. "ATtiny85 (8 MHz)").
  • Then, run the "Burn Bootloader" command from the Tools menu.
  • This configures the fuse bits of the microcontroller so it runs at 8 MHz.
  • Note that the fuse bits keep their value until you explicitly change them, so you'll only need to do this step once for each microcontroller. Describes this process
  • By issuing a "burn bootloader" command, the fuse values for the selected board are burned to the MCU.
  • Note in this case "burn bootloader" is a bit of a misnomer since there is no bootloader for a tiny85.
  • It should now be possible to compile ATTiny85 sketches and download them

Uploading Sketches

To upload sketches...

Arduino-1-6-2-UploadToATTiny85.png

or

  • Hold down shift key when using upload button.
    • Text will change to "Upload using Programmer".

ArduinoIDEUpload.png

Error Messages

PAGEL and BS2 signals Error Message

avrdude: please define Pagel and BS2 signals in the configuration file for part ATtiny85 
avrdude: please define Pagel and BS2 signals in the configuration file for part ATtiny85

To remedy the problem edit file avrdude.conf, found in

C:\Program Files (x86)\arduino-1.0.4\hardware\tools\avr\etc

Find the word Attiny85 and go down a few lines up to:

chip_erase_delay = 4500;
and add below these lines:
# Added to eliminate the bug to build. pagel = 0xB3; bs2 = 0xB4;
Find this section lower down and add the highlighted code"
    memory "lock"
       size          = 1;
       write         = "1 0 1 0  1 1 0 0  1 1 1 x  x x x x",
                       "x x x x  x x x x  1 1 i i  i i i i";
       read          = "0 1 0 1  1 0 0 0  0 0 0 0  0 0 0 0",
                       "0 0 0 0  0 0 0 0  o o o o  o o o o";
       min_write_delay = 9000;
       max_write_delay = 9000;
       ;

Repeat the same operation Attiny84 looking for the word, save the edited file and you're done.

libgcc.a Error message

This error does not happen with Arduino IDE 1.6.2.

This error message looks like:

arduino-1.0.1/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25/crttn85.o:(.init9+0x2):
relocation truncated to fit: R_AVR_13_PCREL against symbol `exit' defined in .fini9 section 
in /arduino-1.0.1/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr25\libgcc.a(_exit.o)

Solution is from here (copied here just in case the other site goes away)

  • Replace the Arduino compilers with the more up to date ones from WinAVR
  • Arduino will use whatever toolset is in the "{ArduinoRoot}\hardware\tools\avr" directory.
    • Shutdown Arduino
    • Download WinAVR
    • Install WinAVR (I installed to "C:\WinAVR")
    • Navigate to "{ArduinoRoot}\hardware\tools"
    • There should be an "avr" directory there. Rename it. (e.g. "avr (old)")
    • Create a new "avr" directory
    • Move (or copy) the entire contents of WinAVR ("C:\WinAVR") to the newly created "avr" directory ("{ArduinoRoot}\hardware\tools\avr")
    • Create an "etc" directory under the "avr" directory ("{ArduinoRoot}\hardware\tools\avr\etc")
    • Locate the "avrdude.conf" file in the new avr directory ("{ArduinoRoot}\hardware\tools\avr") (I think it was in "bin")
    • Move "avrdude.conf" to the "etc" directory ("{ArduinoRoot}\hardware\tools\avr\etc")
  • If you want to go back to the original toolset...
    • Shutdown Arduino
    • Rename the "avr" directory (e.g. rename "avr" to "avr (new)")
    • Rename the old avr directory ("avr (old)") to "avr"
    • Just swap the two avr directories.

Supported commands

The following Arduino commands should be supported: