Attiny84 Datasheet: Its Pin Configuration and Programming Steps

Introduction to Attiny84

The Attiny84 is a low-power, high-performance microcontroller that belongs to Atmel’s AVR family. It is an 8-bit microcontroller with 8KB of flash memory, 512 bytes of EEPROM, and 512 bytes of internal SRAM. The Attiny84 operates at a maximum frequency of 20MHz and offers a wide range of peripherals, making it suitable for a variety of embedded applications.

Key Features of Attiny84

  1. 8KB of in-system programmable flash memory
  2. 512 bytes of EEPROM
  3. 512 bytes of internal SRAM
  4. 12 general-purpose I/O lines
  5. 32 general-purpose working registers
  6. One 8-bit timer/counter with compare modes
  7. One 16-bit timer/counter with compare modes
  8. Universal Serial Interface (USI) supporting SPI and I2C
  9. 10-bit ADC with 8 channels
  10. Programmable Watchdog Timer with internal oscillator
  11. Power-on Reset and programmable Brown-out Detection
  12. Internal calibrated oscillator

Attiny84 Pin Configuration

The Attiny84 comes in a 14-pin PDIP (Plastic Dual Inline Package) or 14-pin SOIC (Small Outline Integrated Circuit) package. Here’s a detailed look at the pin configuration:

Pin Number Pin Name Description
1 VCC Power supply
2 PB0 Port B, bit 0 (PCINT8/XTAL1/CLKI)
3 PB1 Port B, bit 1 (PCINT9/XTAL2)
4 PB3 Port B, bit 3 (PCINT11/RESET/ADC3)
5 PB2 Port B, bit 2 (PCINT10/INT0/ADC2)
6 PA7 Port A, bit 7 (PCINT7/ADC7/MOSI/DI/SDA)
7 PA6 Port A, bit 6 (PCINT6/ADC6/MISO/DO)
8 PA5 Port A, bit 5 (PCINT5/OC0B/ADC5/T0/USCK/SCL)
9 PA4 Port A, bit 4 (PCINT4/T1/ADC4/SCK/USCK)
10 PA3 Port A, bit 3 (PCINT3/ADC3)
11 PA2 Port A, bit 2 (PCINT2/AIN1/ADC2)
12 PA1 Port A, bit 1 (PCINT1/AIN0/ADC1)
13 PA0 Port A, bit 0 (PCINT0/AREF/ADC0)
14 GND Ground

Pin Functions

  1. VCC: This pin is used to supply power to the microcontroller. The Attiny84 operates at a voltage range of 1.8V to 5.5V.

  2. GND: This pin is connected to the ground of the circuit.

  3. Port B (PB0-PB3): These pins serve as general-purpose I/O lines and can be configured as inputs or outputs. They also have alternate functions:

  4. PB0 (PCINT8/XTAL1/CLKI): This pin can be used as an external clock input or as a pin change interrupt (PCINT8).
  5. PB1 (PCINT9/XTAL2): This pin can be used as an external clock output or as a pin change interrupt (PCINT9).
  6. PB2 (PCINT10/INT0/ADC2): This pin can be used as an external interrupt (INT0), analog input (ADC2), or pin change interrupt (PCINT10).
  7. PB3 (PCINT11/RESET/ADC3): This pin serves as the reset pin for the microcontroller. It can also be used as an analog input (ADC3) or pin change interrupt (PCINT11).

  8. Port A (PA0-PA7): These pins serve as general-purpose I/O lines and have alternate functions:

  9. PA0 (PCINT0/AREF/ADC0): This pin can be used as an analog reference voltage (AREF), analog input (ADC0), or pin change interrupt (PCINT0).
  10. PA1 (PCINT1/AIN0/ADC1): This pin can be used as an analog comparator negative input (AIN0), analog input (ADC1), or pin change interrupt (PCINT1).
  11. PA2 (PCINT2/AIN1/ADC2): This pin can be used as an analog comparator positive input (AIN1), analog input (ADC2), or pin change interrupt (PCINT2).
  12. PA3 (PCINT3/ADC3): This pin can be used as an analog input (ADC3) or pin change interrupt (PCINT3).
  13. PA4 (PCINT4/T1/ADC4/SCK/USCK): This pin can be used as a timer/counter1 input (T1), analog input (ADC4), SPI clock (SCK), USI clock (USCK), or pin change interrupt (PCINT4).
  14. PA5 (PCINT5/OC0B/ADC5/T0/USCK/SCL): This pin can be used as a timer/counter0 output compare match B (OC0B), analog input (ADC5), timer/counter0 input (T0), USI clock (USCK), I2C clock (SCL), or pin change interrupt (PCINT5).
  15. PA6 (PCINT6/ADC6/MISO/DO): This pin can be used as an analog input (ADC6), SPI master in slave out (MISO), USI data output (DO), or pin change interrupt (PCINT6).
  16. PA7 (PCINT7/ADC7/MOSI/DI/SDA): This pin can be used as an analog input (ADC7), SPI master out slave in (MOSI), USI data input (DI), I2C data (SDA), or pin change interrupt (PCINT7).

Programming the Attiny84

To program the Attiny84, you need an AVR programmer, such as the AVR ISP (In-System Programmer) or the Arduino ISP. Here are the steps to program the Attiny84 using the Arduino ISP:

  1. Hardware Setup:
  2. Connect the Arduino board to your computer via USB.
  3. Connect the Attiny84 to the Arduino board according to the following connections:

    • VCC (Attiny84) to 5V (Arduino)
    • GND (Attiny84) to GND (Arduino)
    • PB0 (Attiny84) to Pin 10 (Arduino)
    • PB1 (Attiny84) to Pin 11 (Arduino)
    • PB2 (Attiny84) to Pin 12 (Arduino)
    • PB3 (Attiny84) to Pin 13 (Arduino)
  4. Configure Arduino as ISP:

  5. Open the Arduino IDE.
  6. Go to File > Examples > ArduinoISP.
  7. Upload the ArduinoISP sketch to your Arduino board.

  8. Install Attiny Support in Arduino IDE:

  9. Go to File > Preferences.
  10. In the “Additional Boards Manager URLs” field, enter the following URL: https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json
  11. Click “OK” to save the preferences.
  12. Go to Tools > Board > Boards Manager.
  13. Search for “attiny” and install the “ATTinyCore by Spence Konde” package.

  14. Configure Board Settings:

  15. Go to Tools > Board and select “ATtiny24/44/84”.
  16. Set the following options:

    • Processor: “ATtiny84”
    • Clock: “Internal 1 MHz”
    • Programmer: “Arduino as ISP”
  17. Write and Upload Code:

  18. Write your Arduino sketch for the Attiny84.
  19. Click the “Upload” button to compile and upload the code to the Attiny84.

Example Code

Here’s a simple example code that blinks an LED connected to PB0 of the Attiny84:

void setup() {
  pinMode(0, OUTPUT);  // Set PB0 as an output
}

void loop() {
  digitalWrite(0, HIGH);  // Turn the LED on
  delay(1000);            // Wait for 1 second
  digitalWrite(0, LOW);   // Turn the LED off
  delay(1000);            // Wait for 1 second
}

This code sets PB0 as an output pin and alternately turns the LED on and off with a delay of 1 second.

Frequently Asked Questions (FAQ)

  1. What is the difference between Attiny84 and Attiny85?
  2. The main difference between Attiny84 and Attiny85 is the number of I/O pins and memory size. Attiny84 has 12 I/O pins and 8KB of flash memory, while Attiny85 has 6 I/O pins and 8KB of flash memory.

  3. Can I use the Attiny84 with a higher clock frequency?

  4. Yes, the Attiny84 can operate at a maximum frequency of 20MHz. However, you need to ensure that the power supply voltage is sufficient for the desired clock frequency.

  5. How do I set the fuse bits for the Attiny84?

  6. Fuse bits are used to configure various settings of the Attiny84, such as clock source, brown-out detection, and more. You can set the fuse bits using an AVR programmer and the appropriate software, such as AVRdude.

  7. Can I use the Attiny84 for PWM (Pulse Width Modulation)?

  8. Yes, the Attiny84 has two timer/counters that can be used for PWM generation. You can use the OC0A, OC0B, or OC1A pins for PWM output.

  9. What is the maximum analog input voltage for the Attiny84?

  10. The maximum analog input voltage for the Attiny84 is VCC, which is the power supply voltage of the microcontroller. If VCC is 5V, the maximum analog input voltage is also 5V.

Conclusion

The Attiny84 is a versatile and powerful microcontroller that offers a range of features and capabilities. By understanding its pin configuration and programming steps, you can effectively utilize the Attiny84 in your embedded projects. With its small size, low power consumption, and rich set of peripherals, the Attiny84 is well-suited for applications such as sensor monitoring, control systems, and IoT devices.

Remember to refer to the official Attiny84 Datasheet for more detailed information on its specifications, electrical characteristics, and register descriptions. Happy programming with the Attiny84!

CATEGORIES:

Uncategorized

Tags:

No responses yet

Leave a Reply

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

Latest Comments

No comments to show.