AVR microcontrollers are chips you can program in the C, C++, and assembly languages. Using their 8-bit instruction set, developers can create robots, feedback-controlled systems, human interfaces, and much more.
These programmable chips can go from a completely unpowered state to executing real code in the blink of an eye. Before that can happen, the chip requires just a few basic materials to get it in a working state. While only you the developer will know what your future AVR projects will be working on, today’s project will hopefully guide newcomers through the AVRs most basic hardware needs.
Notice of Non-Affiliation and Disclaimer: As of the publication date, we are not affiliated with, associated with, authorized with, endorsed by, compensated by, or in any way officially connected with Microchip Technology Inc., the Atmel Corporation, Arm Holdings, Arm Ltd., or their owners, subsidiaries or affiliates. The names Microchip Technology Inc. Atmel, AVR, Microchip Studio, Arm, as well as related names, marks, emblems, and images are trademarks of their respective owners.
External Links: Links to external web pages have been provided as a convenience and for informational purposes only. Unboxing Tomorrow and Voxidyne Media bear no responsibility for the accuracy, legality or content of the external site or for that of subsequent links. Contact the external site for answers to questions regarding its content.
Step 1: Define the Application
The first step is to define in certain terms what the AVR will be doing. This initial step may involve drafting a system block diagram, while adding details as the job progresses. The purpose is to define requirements that will narrow the search for an AVR as much as possible.
At least for now, the most relevant AVRs in the Unboxing Tomorrow inventory are:
- The entry-level ATTiny2313
- The popular ATmega328P (used on Arduino Uno)
- The general-purpose ATmega8535 and ATmega16
- The automotive LINbus-capable ATTiny87-XU
Step 2: Choose a Voltage
Knowing your system voltage in advance is essential. Most AVRs will accept a range of voltages near 5 volts, 3.3 volts, 2.7 volts, and 1.8 volts. Online search engines can automatically filter out AVR models that do not meet your voltage specifications.
Step 3: Choose a Device Package
After you’ve selected a voltage, you need to decide on an integrated circuit (IC). Most AVRs are available in multiple package types:
- Dual Inline Packages (DIP) are the most beginner-friendly due to their larger pin spacing (i.e. pitch) and their compatibility with solderless breadboards. This is the only package you can easily use without soldering.
- Quad Flat No-lead (QFN) and Ball Grid Arrays (BGAs) are the most challenging.
- SOT, SOIC, PLCC, TQFP, TSSOP, and VSSOP fit somewhere in the middle.
Step 4: Choose a Purchasable Part Number
This step can be daunting because of the wide array of options. But if your project objectives are well-defined, a parametric search can easily narrow the field.
AVR part numbers are systematically named. The initial 6 or 7 letters indicate the AVR family. The remaining letters and digits indicate the family code, speed, IC packaging, and bulk packaging type. The most prominent families are:
- ATtiny – for basic peripherals and low cost
- ATmega – Adds peripherals and a hardware multiplier (very few ATtiny devices have a multiplier)
- ATxmega – Adds enhanced peripherals such as Direct Memory Access (DMA)
The official AVR Microcontrollers Peripheral Integration Quick Reference Guide will help guide you to the exact device family you need, and you can find a link to it in the References section below.
Step 5: Choose a Programmer (Uploader) Tool
To connect your AVR to your computer, you will need a programming and debugging device. The Microchip Studio software refers to this programming device simply as a tool.
A reliable way to tell which official tools are compatible with your chosen device is to visit the official product page, look for “emulators and debuggers,” and then view the latest list. For simple programming, most AVRs accept Atmel’s In-System Programming (ISP) wired interface. The tools most relevant to this blog are:
- The officially discontinued, yet still-popular AVR ISP Mk II (available from third-party sellers)
- The newer ATATMEL-ICE, which works on both Atmel AVR and Atmel ARM chips
Step 6: Internal Clock or External Clock?
Like any processor, the AVR needs a clock signal (i.e. pulse train) to operate. Modern AVRs give designers the option of using an internal or external clock.
The AVRs mentioned above provide an internal frequency of 8 MHz, which (by default) your AVR will optionally reduce to 1 MHz. The internal clock is inexact, and the true frequency will be heavily influenced by the system voltage and the internal temperature of the AVR itself.
For more accurate and precise timing, the AVR XTAL1 and XTAL2 pins can accept external clock sources. The AVRs featured here accept ceramic resonators, quartz crystal oscillators, plus additional signal sources (see your AVR datasheet for a detail). Today’s project will show how to connect a quartz oscillator.
Step 7: Get Passive Components
Finally, there are a few passive components that will get your AVR in a working state…
Bypass Capacitor: a ceramic capacitor placed close to the VCC and GND pins can improve the electrical noise immunity of the AVR. The ideal capacitor value varies by circuit, however projects here will typically use capacitors valued 100 nF to 1 µF. AVR models with multiple VCC pins must have a bypass capacitor for every VCC!
Reset circuit: The RESET pin should have a path to ground through a 100 nF capacitor and a pull-up resistor valued 10 kΩ to 100 kΩ. The datasheet will specify the acceptable range of resistances. The capacitor will hold the RESET pin low in the initial moments of startup until the VCC voltage approaches a stable level. The pull-up resistor will prevent the pin from floating at arbitrary voltages afterward.
Crystal circuit: Designs using an external quartz crystal oscillator will very likely need 2 identical non-polarized capacitors providing a path to GND. These are required to start and sustain the crystal oscillation. The capacitor values normally fall in the 6 pF to 30 pF range, and the exact value must be specified by the crystal’s own datasheet. This blog will typically use capacitors valued at 18 pF or 22 pF.
In System Programming interface: Once you have attached the above passive components, you may directly wire all 6 ISP programming lines directly to their corresponding pins on the AVR.
Minimum Hardware Example
Additional Resources
In the next part, we will install the Microchip Studio application and build a new application in the C language. In the meantime, here are a few information resources that will help you prepare…
- The device data sheet is an owner’s manual and instruction set summary for the AVR itself.
- The device errata sheet lists silicon-level errors or unexpected behaviors in the device.
If you’re committed to C Programming via the GNU Compiler Collection (GCC), it is also worth bookmarking…
Standard C library for AVR-GCC (avr-libc 2.0.0)
Frequently Asked Questions: AVR-GCC User Manual
References
[1] | Microchip Technology Inc., “8-bit AVR® MCUs,” Microchip Technology Inc., [Online]. Available: https://www.microchip.com/en-us/products/microcontrollers-and-microprocessors/8-bit-mcus/avr-mcus. [Accessed 14 Aug 2021]. |
Important Notice: This article and its contents (the “Information”) belong to Unboxing-tomorrow.com and Voxidyne Media LLC. No license is granted for the use of it other than for information purposes. No license of any intellectual property rights is granted. The Information is subject to change without notice. The Information supplied is believed to be accurate, but Voxidyne Media LLC assumes no responsibility for its accuracy or completeness, any error in or omission from it or for any use made of it. Liability for loss or damage resulting from any reliance on the Information or use of it (including liability resulting from negligence or where Voxidyne Media LLC was aware of the possibility of such loss or damage arising) is excluded.