49
Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from: http://code.google.com/p/ arduino-tiny/ (for Arduino 1.0, not 1.5!) ver 1.1 2/1/14

Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from: (for Arduino 1.0, not 1.5!) Unzip and

Embed Size (px)

Citation preview

Page 1: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

Welcome to Workshop 88’s

Tiny85 Class

Please download Tiny core libs from:http://code.google.com/p/arduino-tiny/(for Arduino 1.0, not 1.5!)Unzip and stash the ‘tiny’ folder for later.

ver 1.1 2/1/14

Page 2: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

Objective of class

You walk out with a Tiny85 with code that you wrote and that you burned into the chip.

Page 3: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

What we’ll cover• Why use a Tiny85 (or friends)? Why not?• How Arduino IDE works with Tinys• Putting new core libs on your IDE• Put a Tiny blinkie on your breadboard• Write your own blinkie• Porting code to Tiny85• Mapping Tiny85 pins to Arduino pins• How to burn code to a Tiny: programming, programmers, programs…• Burn your blinkie!• Fuses and avrdude• Using RESET as a 6th I/O pin• Commercial Tiny85s• Other Tinys: 84, 4313

Page 4: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

Atmel 8 bit AVR familes

• Mega family– AtMega328P (Arduino!)– AtMega2560 (Mega)– more

• Tiny family– AtTiny25/45/85– AtTiny24/44/84– AtTiny2313/4313– more

AVR stands for Alf (Egil Bogen) and Vegard (Wollan)'s RISC processor

(There’s also an Xmega family, as well as a 32 bit family.)

Page 5: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

What’s inside Mega328P

• 32K program flash• 2K RAM• 1K EEPROM• Two 8-bit counters• One 16-bit counter• Six PWM channels• Serial USART• I2C/TWI interface• 8 channel A/D converter• 23 I/O lines• SPI interface • Analog comparator• Watchdog timer

Page 6: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

What’s inside Mega328P

Tiny85

• 32K 8K program flash• 2K 512B RAM• 1K 512 B EEPROM• Two 8-bit counters• One 16-bit counter• Six Two PWM channels• Serial USART• I2C/TWI USI interface • 8 4 channel A/D converter• 23 6 I/O lines• SPI interface• Analog comparator• Watchdog timer

Page 7: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

From code to flash

Page 8: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

From code to flash

Page 9: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

From code to flash

compiler/linker

libraries

Binary executableUsually as a Hex File

Page 10: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

From code to flash: ascii hex file

Page 11: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

From code to flash

Hex Fileon host

Chip

?

Page 12: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

From code to flash

Hex File

Chip

Hardwareprogrammer

Page 13: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

From code to flash

Hex File

Chip

programmingsoftware

(avrdude)Hardware

programmer

usually serial

Page 14: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

From code to flash

Hex File

Chip

programmingsoftware

(avrdude)Hardware

programmer

usually serial

programminginterface

Page 15: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

From code to flash

Hex File

Chip

programmingsoftware

(avrdude)Hardware

programmer

usually serial

programminginterface

wires!

Page 16: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

From code to flash

Hex File

Chip

programmingsoftware

(avrdude)Hardware

programmer

usually serial

programminginterface

wires!

We’ll do it this way for Tiny85!

Page 17: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

From code to flash

Hex File

Chip

programmingsoftware

(avrdude)

USB serial!

programminginterface

wires!

Hardwareprogrammer

We’ll do it this way for Tiny85!

Page 18: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

From code to flash

Hex File

Chip

programmingsoftware

(avrdude)

USB serial!

programminginterface

wires!

running“ArduinoISP”

sketch

We’ll do it this way for Tiny85!

Page 19: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

From code to flash: Arduino

Hex File

Chip

programmingsoftware

(avrdude)

serial!

programminginterface

programmeremulatorprogram

Page 20: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

From code to flash: Arduino

Hex File

Chip

programmingsoftware

(avrdude)

serial!

programminginterface

Arduino bootloader!programmeremulatorprogram

Page 21: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

From code to flash: Arduino

Hex File

Chip

programmingsoftware

(avrdude)

serialprogramming

interface

Arduino bootloader!programmeremulatorprogram

USBserial driver

USB-serial chipon Arduino

USB

Page 22: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

Arduino bootloader burner

Page 23: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

From code to flash

Page 24: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

From code to flash

Page 25: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

Get your Tiny on!

• Refer to pinout and connect +5V and ground• The Tiny is preprogrammed with a blink

sketch on pin 5• Put an LED on pin 5 and verify that it works!

Page 26: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

Installing Tiny core libs• Unzip if needed• Copy “tiny” directory to the “hardware” directory

either:• In main Arduino installation

Win: Program Files/arduino-1.0.5/hardwarelinux: /usr/share/arduino/hardware

• In your Arduino directory (make dir “hardware” if needed)Win: My Documents/Arduino/hardwarelinux: $HOME/sketchbook/hardware

Page 27: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

boards.txt

• Contains definitions for all available boards• In top “tiny” directory, copy “Prospective

Boards.txt” to “boards.txt”• I suggest cleaning up your new “boards.txt”,

leaving only stanzas for– ATtiny85 @ 8 MHz– ATtiny85 @ 1 MHz

Page 28: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

Write your blinkie!

• Recognizable pattern• 1-3 LEDs (5 max)• Use variables or #defines for pins

Page 29: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

Porting

Tiny has:• Digital pins 0-5• Analog pins A0-A3• Change your pin numbers to ones Tiny has• Find the mapping in the Tiny core libs athardware/tiny/cores/tiny/pins_arduino.c

• Figure out which physical pins you’re using!

Page 30: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

Connecting Arduino as ISP to your Tiny85

You need 6 wires:• Power and ground• SPI lines MISO, MOSI, SCK• Reset

Line names are marked on the mini-shield

Page 31: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

Using Arduino as ISP• Plug in your Arduino• Select the board type of your Arduino• Load ArduinoISP from Examples• Upload to your Arduino• Plug in mini-shield (must be AFTER loading

ArduinoISP!)• Select Tiny85 board• Select Arduino as ISP as Programmer• Load your code• Click Upload!

Page 32: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

avrdude: path

• Windows: try \Program Files\arduino1.0.x\hardware\tools\avr\bin

• Linux: try<arduino-root>/hardware/tools(mine was /usr/share/arduino/hardware/tools)

Page 33: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

avrdude: command line

$ avrdude– P /dev/ttyUSB0 (/dev/ttyACM0)– P COM4 (or whatever)– b 19200– p t85– c <path to avrdude.conf>– t

Page 34: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

avrdude: stop complaining!part id = "t85"; desc = "ATtiny85"; has_debugwire = yes; flash_instr = 0xB4, 0x02, 0x12; eeprom_instr = 0xBB, 0xFF, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D, 0xBC, 0x02, 0xB4, 0x02, 0xBA, 0x0D, 0xBB, 0xBC, 0x99, 0xE1, 0xBB, 0xAC;

## next 2 are fakes so avrdude won't complain pagel = 1; bs2 = 1;

## no STK500 devcode in XML file, use the ATtiny45 one stk500_devcode = 0x14;

Page 35: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

Fuses

• (Not what it sounds like)• Nonvolatile configuration bits• There are 3:

– FUSE LOW BYTE– FUSE HIGH BYTE– FUSE EXTENDED BYTE

• Logic values confusing:1 (not programmed) = FALSE

Page 36: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

FUSE LOW BYTE

Page 37: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

FUSE HIGH BYTE

Page 38: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

FUSE EXTENDED BYTE

Page 39: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

HV programmer/fuse resetter

Page 40: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

HV programmer/fuse resetterhttps://sites.google.com/site/wayneholder/attiny-fuse-reset

Page 41: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

Other Tiny85s: Babygnusbuino

Page 42: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

Other Tiny85s: DigiSpark

Page 43: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

Other Tiny85s: Gemma

Page 44: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

Other Tiny85s: Trinket

Page 45: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

Other Tiny85s: EezeeTiny

Page 46: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

Other Tiny85s: PicoDuino

Page 47: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

Other Tiny85s: my dollhouse nodes

Page 48: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

Other TinysPins USART PWM

chansA/Dinputs

Flash/RAM/EEPROM

Tiny85 8 No 2 4 8K/512/512Tiny84 14 No 4 8 8K/512/512Tiny4313 20 Yes 4 0 4K/256/256Tiny13(a) 8 No 2 4 1K/64/64

There are lots more, but these are a fine starting place.

Page 49: Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from:  (for Arduino 1.0, not 1.5!) Unzip and

Architectures