You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Christian Ulrich 0ca8da6916 add .gitignore 2 years ago
.gitignore add .gitignore 2 years ago
COPYING initial commit 2 years ago
Makefile initial commit 2 years ago
README.md initial commit 2 years ago
default.nix initial commit 2 years ago
evinlight.c initial commit 2 years ago

README.md

ATTiny85 Hello World

Blinking an LED using an ATTiny85 programmed with avr-gcc and avrdude on Mac OS X.

Mac OS X AVR toolchain install

Using Homebrew, tap larsimmisch's homebrew-avr repository:

brew tap larsimmisch/avr
brew install avr-libc

Build steps

  1. Compile with avr-gcc
  2. Prepare the hex file with avr-objcopy
  3. Flash the hex with avrdude
avr-gcc -Wall -Os -DF_CPU=1000000 -mmcu=attiny85 -o hello.o hello.c
avr-objcopy -j .text -j .data -O ihex hello.o hello.hex
avrdude -c usbtiny -p t85 -U flash:w:hello.hex:i

F_CPU must be defined at the avr-gcc command line or above the #include <util/delay.h> so the delay library knows the microcontroller's clock speed.

Breadboard configuration

Wire the ISP-6 cable from the USBTinyISP to the breadboarded ATTiny85 using jumpers.

ISP-6 pinout

Looking at the ISP-6 cable with the connector key at the bottom, the pins are numbered like this:

+-----------+
|(6) (4) (2)|
|(5) (3) (1)|
+-----------+
     |_|
  1. MISO
  2. Vcc
  3. SCK
  4. MOSI
  5. Reset
  6. Ground

(See also this photo)

ATTiny85 pintout

The ATTiny85's pins are:

 (8) (7) (6) (5)
+---------------+
|               |
| o             |
+---------------+
 (1) (2) (3) (4)
  1. PB5 (Reset)
  2. PB3
  3. PB4
  4. Ground
  5. PB0 (MOSI)
  6. PB1 (MISO)
  7. PB2 (SCK)
  8. Vcc

Programming jumpers

Connect the ISP and the ATTiny85 together on the Ground, MISO (Master In, Slave Out), MOSI (Master Out, Slave In), SCK (Serial ClocK), Reset, and Vcc pins:

  • ISP-6 pin 1–ATTiny85 pin 6 (MISO)
  • ISP-6 pin 2–ATTiny85 pin 8 (Vcc)
  • ISP-6 pin 3–ATTiny85 pin 7 (SCK)
  • ISP-6 pin 4–ATTiny85 pin 5 (MOSI)
  • ISP-6 pin 5–ATTiny85 pin 1 (Reset)
  • ISP-6 pin 6–ATTiny85 pin 4 (Ground)

N.B. The ATTiny's pins 2 and 3 are unconnected.

LED circuit

Power the LED with a transistor and a series resistor, switching the transistor using a resistor from the ATTiny's pin 2 to the transistor's base.

References