Menu Close

Hooking up with ATtiny85

ATtiny85 Microcontroller Introduction

It is always a good idea to start with few basics of ATtiny85 so even if are you new to Microcontrollers then you won’t be missing a single thing.

ATtiny85 is a 8 bit microcontroller from Microchip and the architecture is based on RISC type. It is a low power controller with 8 pins on it and can be used same as any other microcontroller except the fact that it lacks few features but does almost every work.

Pin diagram of ATtiny85
Board Variations available for common use

Here’s some features of ATtiny85 Microcontroller :

  • 8 pins
  • 8KB ISP flash memory
  • 512-Byte EEPROM
  • 512-Byte SRAM
  • One 8-bit timer/counter with compare modes
  • USI
  • 32 general purpose working registers
  • 6 general purpose I/O lines
  • The device achieves a throughput of 20 MIPS at 20 MHz and operates between 2.7-5.5 volts
  • One 8-bit high speed timer/counter
  • DebugWIRE for on-chip debugging.
  • Internal and external Interrupts
  • 4-channel 10-bit A/D converter
  • Programmable watchdog timer with internal oscillator
  • Three software selectable power saving modes

For more information on this and other ATiny microcontrollers, see Atmel’s web site. This web site also contains detailed and summarized versions of the datasheets for each microcontroller.

ATtiny85 never got the fame like other microcontrollers (atmega8 / atmega328p etc.) but still it has great potential and due to its small size and cheap in price it can be used very frequently and sometime when we talk about the ATtiny85 board that means 99% chances we are talking about the ATtiny chip.

Programming ATtiny85

Programmming ATtiny85 is same as programming other microcontrollers and we need an AVR programmer (in case of tiny series : Tiny AVR Programmer) and can be found on ebay, amazon, adafruit, sparkfun etc.

 

The tiny chip have on board MISO/MOSI/ SCK/GND/VCC/RESET pins which are multiplexed with the general input-output pins. 

the same set of pins are available on the AVR programmer and are clearly marked to avoid any confusion (wrong connection may damage your IC or the code won’t be uploaded) while making connection.

A simple USB-asp programmer can be used (the cheapest available in my knowledge, correct me if i’m wrong) to program the tiny and at the same go it can also program other controllers like atmega8/16/32 etc. long series.

In few cases the programmer you get delivered may have a separate USB Cable to connect with but that’s not a issue and if the programmer have the on board USB option then you can directly connect it to your laptop or computer. 

usb-avr-isp-programmer- electronicsforgeeks
USB-asp Programmer
Header pins to program

the driver for USB-asp and the instructions to setup is mentioned here : USB-asp installation guide.

 

After successfully installing the driver for USB-asp connect the corresponding pins of ATtiny to the USB-asp programmer using some jumper wires, refer the image shown above “Header pins to program”.

Now, we need some software to write our code in c language (programming language may vary) and hence after compilation of the code the produced hex file would be burned into to ATtiny through the USB-asp programmer.

Preferably we can use AVR dude (other IDE available too) and will help us to compile our code, generate the hex file, and flash it into the chip.

Here’s a simple program to blink a LED at PB4.

//electronicsforgeeks.com 
//
// A simple blink program for ATtiny85
// Connect LED at pin 3 (PB4)
//

#include <avr/io.h>
#include <util/delay.h>

int main ()
{
PORTB=0b00000000;  //set Pins low as default case
DDRB = 0b00010000;  // set PB4 to be output

while (1) {

PORTB = 0b00010000;    // set PB4 high
_delay_ms(200);

PORTB = 0b00000000;   // set PB4 low
_delay_ms(200);

}

return 1;
}

So, here we make up this tutorial and hopefully now you have some idea about ATtiny85 and programming environment.

Useful links to follow up on ATtiny85 : Microchip 

ATtiny85 datasheet : click here.

Leave a Reply

Your email address will not be published. Required fields are marked *