Hey Guys! Hope you are doing well. I am back to give you a daily dose of valuable information. Today, I'll discuss the details on the Introduction to ATtiny85.
It is an 8-bit AVR microcontroller
, introduced by Microchip, and is based on RISC CPU. It comes with 8-pin interface (PDIP) and falls under the category of low power controllers. Programmable watchdog timer and 10-bit ADC converter are added in the device that makes it suitable for sensor
interfacing and resetting the device in case it gets stuck in an infinite loop.Microchip never fails to satisfy the requirements of any individual by providing flawless microcontroller
modules that are directly or remotely connected with automation and embedded systems. With the invention of these tiny onboard modules, development of electronic projects has become easy and hassle-free more than ever before.In this tutorial, I'll cover each and everything related to ATtiny85, its pinout, pin description, main features, block diagram, and applications. Let get down to the nitty-gritty of this module and nail down everything you need to know.
Introduction to ATtiny85
- ATtiny85 is an 8-bit AVR microcontroller that comes with 8-pin interface and mainly used in automation and Arduino projects.
- The CPU is based on RISC architecture and is mainly called low power controller that stands fit for the real-time applications that can operate on minimum power.
- The program memory is 8KB while both EEPROM and RAM contain a memory space of around 512 bytes. These memory spaces are very useful for storing the number of instruction in the form of code.
- This module comes with only one port called Port B that is a bi-directional port and contains 6 I/O pins with internal pull-up resistors. The output buffers on PORTB are designed with symmetrical drive characteristics that come with both high sink and source capability. It is important to note that, Port B pins are externally pulled low and tri-stated that will source current if the pull-up resistors are activated.
- External and internal interrupts are available on the board, while 32 general purpose registers are included in the device that are mainly called data holding spaces.
- Two 8-bit timers are added in the device where one timer comes with compare modes and can be used both ways i.e. timer as well as a counter while other is high-speed timer/counter.
- This module comes with software select power saving modes that are very helpful for the applications that operate with minimum power.
- Like other controllers introduced by the Microchip, this module comes with 10-bit ADC converter that houses 4 analog channels that help in sensor interfacing and converting analog signals to digital ones.
- This tiny chip is available in four packages called PDIP, SOIC, TSSOP, and QFN where first three come with 8-pin interface while the last one contains 20 pins.
- Digital communications like I2C and SPI can be easily employed using this module that helps in developing a communication with external devices.
1. ATtiny85 Features
You have got a brief overview of this module. Now we cover the main features that will help you anticipate the major characteristic associated with the module.The following figure shows the complete features of ATtiny85.
|No. of Pins||8|
|CPU||RISC 8-Bit AVR|
|Operating Voltage||1.8 to 5.5 V|
|Program Memory Type||Flash|
|ADCNumber of ADC Channels||10-Bit4|
|Packages||PDIP (8-Pin)SOIC (8-Pin)TSSOP (8-Pin)QFN/MLF (20-Pin)|
|Oscillator||up to 20 MHz|
|Timer (2)||8-Bit Timers|
|Enhanced Power on Reset||Yes|
|Power Up Timer||Yes|
|Brown out detect (BOD)||Yes|
|USI (Universal Serial Interface)||Yes|
|Minimum Operating Temperature||-40 C|
|Maximum Operating Temperature||125 C|
- You must check these features before making a final decision to install and use this module for your relevant project.
2. ATtin85 Pinout and Description
Until now, you have got a hold of basic information and complete features of ATtiny85. In this section, we will discuss the pinout and pin description of the module.
Following figure shows the pinout of ATtiny85.
- The bottom pad available on the board must be soldered to the ground.
- The DNC marked on the pinout stands for don't connect.
Following table shows the pin description that will help you understand the major functions associated with each pin.
|Pin#||Pin Name||Pin Description|
|1||PB5PCINT5RESETADC0dW||I/O Bidirectional pinInterruptResetAnalog Channel 0Define Word|
|2||PB3PCINT3XTAL1CLKIOC1BADC3||I/O Bidirectional pinInterruptCrystal Oscillator Pin 1ClockAnalog Channel 3|
|3||PB4PCINT4XTAL2CLKOOC1BADC2 ||I/O Bidirectional pinInterruptCrystal Oscillator Pin 2ClockAnalog Channel 2 |
|5||PB0MOSIDISDAAIN0OC0AOC1AAREFPCINT0||I/O Bidirectional pinSPISerial Data (I2C)Analog InputCompare RegisterVoltage ReferenceInterrupt |
|6||PB1MISODOAIN1OC0BOC1APCINT1||I/O Bidirectional pinSPISerial Data (I2C)Analog InputCompare RegisterInterrupt|
|7||PB2SCKUSCKSCLADC1T0PCINT2||I/O Bidirectional pinSerial Clock Line (I2C)Analog Channel 1Timer 0Interrupt|
|8||Vcc||Voltage Supply Pin|
3. ATtiny85 Main Functions
ATtiny85 can perform a number of functions on a single chip. Some pins come with an ability to employ more than one functions. Following are the main functions of this module.
There are two timers included on the chip that help in generating a delay in the running process of certain function when they work in a timer mode.In the counter mode, these timers are used to count the number of the interval on a specific function inside in the controller. The timer mode increments the instruction cycle while the counter mode is used to increment the rising and falling edge of the pin.
ATtiny85 comes with a serial peripheral interface (SPI) that is mainly used for communication between the microcontroller and other peripheral devices such as SD cards, sensors
, and shift registers.
It incorporates separate clock and data lines with the addition of a select line to pick the required device for communication. This communication allows both connected device to lay out the same path of communication under one communication protocol.
I2C protocol is added in the device that is mainly two-wire protocol used to connect low-speed devices like ADC and DAC converters, I/O interfaces and microcontrollers
. The two wires, known as Serial Clock (SCL) and Serial Data (SDA), are the main part of this communication protocol.The SCL line behaves like a clock signal that is generated by the master device and synchronizes the data transfer between the devices. While the SDA line is used to carry the required data.
Brown Out Reset (BOD)
The BOD is a very useful function that helps in resetting the controller once the Vdd (voltage supply) drops below a brownout threshold voltage. The multiple voltage ranges are provided to secure the module once the power drops at the voltage supply line.
The interrupt plays a vital role in an emergency which puts the main function on hold and executes the required instructions that are necessary at that time. Once the interrupt is executed the running code puts the controller back to the main program.
ADC module is a valuable addition in the device that makes it compatible with the sensors
. It is a 10-bit module that contains 4 channels which are little less than the number of channels available on the modules introduced by Microchip that, more or less, come with 7 or 12 channels.
4. ATtiny85 Memory Interface
The memory of this little toy is designed and based on Atmel's high-density technology that is basically non-volatile in nature. The Program Memory can be reprogrammed through SPI serial interface using two ways i.e. On-chip boot code or non-volatile memory programmer.The main program execution is mainly done inside CPU that plays a vital role to access memories and perform calculations on the basis of the number of instructions incorporated into the controller.This module falls under the category of AVR controllers that are based on Harvard architecture and come with separate locations reserved for both program and data memory.
Program Memory (ROM)
Program memory, that is basically reprogrammable flash memory, works in a simple manner where next instruction stands in the queue once first is called and executed. This helps in executing the instructions with regular intervals in every clock cycle.The Flash memory comes with 8k memory space and contains memory endurance around 10,000 write/erase cycle (means you can erase and write the instructions 10,000 times on this board). The program counter available on the flash memory is 12bits wide that can address 4096 program memory locations.
Data Memory (RAM)
The data memory comes with 512bytes memory space and reserves the memory locations three ways i.e. first 32 locations access the file register, next 64 locations are reserved for standard I/O memory and remaining are used for internal data SRAM.The data memory is categorized into five addressing modes named as
- Indirect with Displacement
- Indirect with Pre-decrement
- Indirect with Post-increment
In the Register File, the registers ranging from R26 to R31 refer to the pointer registers with indirect addressing. While the direct addressing covers the entire data space. Similarly, the Indirect with Displacement mode covers 63 address locations using base address accessed by the Y- or Z register.
The address registers X, Y, and Z increment and decrement with regular intervals when indirect addressing modes are layered with both post-increment and pre-decrement.
EEPROM Data Memory
This memory comes with 512 bytes of memory space which is designed and laid out as a separate data space where single bytes can be accessed. It comes with a memory endurance around 100,000 write/erase cycles which is ten times more than program memory.
5. ATtiny85 Compilers
There are many compilers available for compiling the code in the AVR microcontroller. Some are better than others. Before you pick some compiler for your controller, make sure it is easy to use and stand fit for your needs and requirements.
- If you are in the learning phase, then IAR is the best compiler for AVR. It is highly professional, though expensive, what it lacks in economical price, it covers up by providing both flawless quality and ease of use where it can support most, if not all, of the MCU families.
Another compiler for AVR is the GCC Port for AVR that is available FREE for both Windows and Linux. It can compile the instructions with a decent pace, however, if you are a newbie and getting your hands on very first time with the controller, it might be hard to learn.
- ImageCraft is good option to start with that has made a decent place in the market but lack of GUI features make this compiler difficult to handle where editor and project management are quite daunting and can put you in a total stall in the start.
CodeVision is another easiest compiler that comes with CodeWizard and helps in starting a new project sooner than later. Also, it is highly economical.
6. ATtiny85 Block Diagram
Block diagram is very helpful to visualize the main function available inside the controllers and how each feature and component are connected with each other.Following figure shows the block diagram of ATtiny85.
- The AVR core is used to combine 32 general purpose register with the rich instruction set.
- Also, these 32 registers are directly connected with the ALU (Arithmetic Logic Unit) which helps in accessing the two independent registers using single instruction.
7. Interfacing ATtiny85 with Arduino
Tiny things can work wonders if used a proper way. Both ATtiny85 and Arduino, when connected, can easily drive automation in your project and help in executing the number of instructions.You can connect ATtiny85 with the Arduino following way.
- Arduino Pin 10 ...................... ATtiny85 Pin 1
- Arduino Pin 11 ...................... ATtiny85 Pin 5
- Arduino Pin 12 ...................... ATtiny85 Pin 6
- Arduino Pin 13 ...................... ATtiny85 Pin 7
- Arduino +5V...................... ATtiny85 Pin 8
- Arduino Ground ...................... ATtiny85 Pin 4
- It is mainly used in real time applications related to industrial automation.
- Embedded Systems Projects make use of this module to drive automation.
- It can be employed and incorporated in robotics.
- Aeronautical technology houses a wide range of AVR controllers covering Quad-copter and space Aeroplanes.
- Power monitoring and management systems use this module.
That's all for today. I hope you have found this piece of nugget useful and valuable as per your technical needs and demands. If you are unsure or have any question, you can ask me in the comment section below. I'd love to help you according to the best of my knowledge and skills. Feel free to keep us updated with your valuable feedback and suggestions, so we keep providing quality work and you keep coming back for what we have to offer. Thanks for reading the article.