Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

AN2519

AVR® Microcontroller Hardware Design Considerations

Introduction
®
This application note provides basic guidelines to be followed while designing hardware using AVR
microcontrollers. Some known problems faced in typical designs have been addressed by providing
possible solutions and workarounds to resolve them.
The scope of this application note is to provide an introduction to potential design problems rather than
being an exhaustive document on designing applications using AVR microcontrollers.
Note:  Read application note AVR040 - “EMC Design Considerations” before starting a new design,
especially if the design is expected to meet the requirements of the EMC directive or other similar
directives in countries outside Europe.

Features
• Guidelines for Providing Robust Analog and Digital Power Supply
• Connection of Reset Line
• Interfacing Programmers/Debuggers to AVR Devices
• Using External Crystal or Ceramic Resonator Oscillators

© 2018 Microchip Technology Inc. Application Note DS00002519B-page 1


AN2519

Table of Contents

Introduction......................................................................................................................1

Features.......................................................................................................................... 1

1. Abbreviations.............................................................................................................4

2. Power Supply............................................................................................................ 5
2.1. Digital Supply............................................................................................................................... 5
2.2. Analog Supply.............................................................................................................................. 6

3. Connection of RESET Pin on AVR Devices.............................................................. 7


3.1. External RESET Switch................................................................................................................8

4. Connecting Programmer/Debugger Lines................................................................. 9


4.1. SPI Programming Interface.......................................................................................................... 9
4.2. JTAG Interface........................................................................................................................... 10
4.3. PDI Interface...............................................................................................................................11
4.4. TPI Interface...............................................................................................................................12
4.5. UPDI Interface............................................................................................................................12

5. Using Crystal and Ceramic Resonators.................................................................. 14


5.1. Selecting the Clock Source in the AVR MCU............................................................................. 14
5.2. About Crystals and Ceramic Resonators................................................................................... 14
5.3. Recommended Capacitor Values...............................................................................................16
5.4. Unbalanced External Capacitors................................................................................................17
5.5. RTC Crystals.............................................................................................................................. 17
5.6. PCB Layout................................................................................................................................ 17

6. Unused XTAL Pins...................................................................................................18

7. Example Layout of ATxmega32A4 and ATmega324PB Devices............................ 19

8. Revision History.......................................................................................................22

The Microchip Web Site................................................................................................ 23

Customer Change Notification Service..........................................................................23

Customer Support......................................................................................................... 23

Microchip Devices Code Protection Feature................................................................. 23

Legal Notice...................................................................................................................24

Trademarks................................................................................................................... 24

© 2018 Microchip Technology Inc. Application Note DS00002519B-page 2


AN2519

Quality Management System Certified by DNV.............................................................25

Worldwide Sales and Service........................................................................................26

© 2018 Microchip Technology Inc. Application Note DS00002519B-page 3


AN2519
Abbreviations

1. Abbreviations
ADC Analog-to-Digital Converter
AREF Analog Reference Voltage
CPU Central Processing Unit
DC Direct Current
DIP Dual In-line Package
EEPROM or E2PROM Electrically Erasable Programmable Read-Only Memory
EMC Electromagnetic Compatibility
ESD Electrostatic Discharge
GND Ground
HVPP High-Voltage/Parallel Programming
Hz Hertz
I/O Input and Output
IDE Integrated Development Environment
ISP In-System Programming
kHz KiloHertz
LED Light Emitting Diode
MCU Microcontroller Unit
MHz MegaHertz
MISO Master In Slave Out
MOSI Master Out Slave In
PCB Printed Circuit Board
PDI Program and Debug Interface
RC Filter Resistor-Capacitor Filter
RST Reset
SPI Serial Peripheral Interface
TPI Tiny Programming Interface
UPDI Unified Program and Debug Interface
VCC Supply Voltage
XTAL Crystal Oscillator

© 2018 Microchip Technology Inc. Application Note DS00002519B-page 4


AN2519
Power Supply

2. Power Supply
The power supply is a critical part of any hardware design and affects directly the performance of the
system. Two important aspects to be considered while designing a power supply for the discrete/digital
elements of an AVR device are ESD Protection and Noise Emission. These aspects are detailed in the
AVR040 application note, hence only a short summary is included in this document.

2.1 Digital Supply


Most AVR microcontrollers operate over a wide voltage range and draw only a few mA of supply current.
This may give the impression that the power supply is not critical but, as with any digital circuit, the supply
current is an average value. The current is drawn in very short spikes on the clock edges. If I/O lines are
switching, the spikes will be even higher. If all eight I/O lines of an I/O port change value simultaneously,
the current pulses on the power supply lines can be several hundred mA. If the I/O lines are not loaded,
the pulse may last for only a few nanoseconds.
Such a current spike cannot be delivered over long power supply lines; the main source should be the
decoupling capacitor.
Figure 2-1. Incorrect Decoupling
VCC
Power Plane
MCU
I=
VCC
V=
C
High Current
Out
Loop

GND

Ground Plane

The figure above shows an example of insufficient decoupling. The capacitor is placed too far away from
the microcontroller, creating a larger high-current loop. The power and ground planes are part of the high-
current loop. As a result, noise is spread more easily to other devices on the board and radiated emission
from the board is increased even further. The whole ground plane will act as an antenna for the noise,
instead of only the high-current loop. This will be the case when the power and ground pins are
connected directly to the planes (typical for hole-mounted components) and the decoupling capacitor is
connected to the planes some distance away. This is sometimes observed in boards with surface-mount
components where the integrated circuits are placed on one side of the board and the decoupling
capacitors are placed on the other side.
The figure below shows a better placement of the capacitor. The lines that are part of the high-current
loop are not part of the power or ground planes. This is important, as the power and ground planes
otherwise will spread a lot of noise. The figure also shows another method of improving decoupling; a
series ferrite bead is inserted to reduce the switching noise on the power plane. The series impedance of
the ferrite bead should be low enough to ensure that there is no significant drop in the DC voltage. The
ferrite bead may not be necessary, especially if the power supply itself is sufficiently filtered.

© 2018 Microchip Technology Inc. Application Note DS00002519B-page 5


AN2519
Power Supply

Figure 2-2. Decoupling with Series Inductor


VCC
Power Plane
MCU
I= L I=
VCC
Ferrite Bead V=
C
High Current
Out
Loop

GND

Ground Plane

Another decoupling alternative is to connect the device power and ground pins directly to the planes and
connect the decoupling capacitor(s) to the planes as close as possible to the power and ground pins. For
large packages, placing decoupling capacitors on the opposite side of the board may be the best way of
getting them as close as possible to the power and ground pins. Also, in this approach, it is critical to
minimize the loop area formed between the decoupling capacitor and device power and ground pin. The
downside of this approach is that power plane noise can more easily be coupled to the device power
supply - thus making sure that the power plane is properly filtered in general becomes more important.
In AVR devices, where power and ground pins are placed close together, there will be better decoupling
than in devices with industry standard pinout. In industry standard pinout, the power and ground pins are
placed in opposite corners of the DIP package. For devices with multiple pairs of power and ground pins,
it is essential that there is a decoupling capacitor for every pair of pins.
The main power supply should also have a tantalum or ceramic capacitor to stabilize it.

2.2 Analog Supply


AVR devices that have a built-in ADC may have a separate analog supply voltage pin, AVCC. This
separate voltage supply ensures that the analog circuits are less prone to the digital noise that originates
from the switching of the digital circuits.
To improve the accuracy of the ADC, the analog supply voltage must be decoupled separately, similar to
the digital supply voltage. AREF must also be decoupled. The typical value of the capacitor is 100 nF. If a
separate analog ground (AGND) is present, the analog ground should be separated from the digital
ground so that the analog and digital grounds are connected only at a single point (at the power supply
GND).

© 2018 Microchip Technology Inc. Application Note DS00002519B-page 6


AN2519
Connection of RESET Pin on AVR Devices

3. Connection of RESET Pin on AVR Devices


The RESET pin on the AVR device is active-low, and setting the pin low externally will reset the device.
The Reset has two purposes:
1. To release all the lines by tri-stating all pins (except XTAL pins), initialize all I/O registers and set
the Program Counter (PC) to zero.
2. To enter Programming mode (for some parts, the PEN line is also used to enter Programming
mode). It is also possible to enter High-Voltage/Parallel Programming (HVPP) mode by drawing the
RESET pin very high (11.5V – 12.5V). Refer to the respective device data sheet for more specific
information about the RESET pin and its functionality.
The Reset line has an internal pull-up resistor. If the environment is noisy, it can be insufficient and Reset
may occur sporadically. Refer to the device data sheet for the value of the pull-up resistor that must be
used for specific devices.
Connecting the Reset so that it is possible to enter both high-voltage programming and ordinary low-level
Reset can be achieved by using a pull-up resistor to the Reset line. This pull-up resistor avoids any
unintended low signal that will trigger a Reset. Theoretically, the pull-up resistor can be of any value, but if
the AVR device should be programmed using an external programmer, the pull-up should not be in such a
high state that the programmer is not able to activate Reset by drawing the Reset line low. The
®
recommended pull-up resistor value is 4.7 kΩ or larger when using STK 600 for programming. For
DebugWIRE to function properly, the pull-up must not be less than 10 kΩ.
To protect the Reset line from further noise, connect a capacitor from the RESET pin to ground. This is
not directly required since AVR devices internally have a low-pass filter to eliminate spikes and noise that
could cause reset. Using an extra capacitor is an additional protection. However, such extra capacitor
cannot be used when DebugWIRE or PDI is used.
ESD protection diode is not provided internally from Reset to VCC in order to allow HVPP. If HVPP is not
used, it is recommended to add an ESD protection diode externally from Reset to VCC. Alternatively, a
Zener diode can be used to limit the Reset voltage relative to GND. A Zener diode is highly
recommended in noisy environments. The components should be located physically close to the RESET
pin of the AVR device. A recommended circuit of a Reset line is shown in the following circuit diagram.
Figure 3-1. Recommended Reset Pin Connection
VCC

R D MCU
4.7kΩ
Reset Reset
External Reset Module

C
100nF

GND

Note:  The values of resistor R and capacitor C are typical values used for the RESET pin. For specific
design requirements of an application, these values must be changed accordingly.

© 2018 Microchip Technology Inc. Application Note DS00002519B-page 7


AN2519
Connection of RESET Pin on AVR Devices

3.1 External RESET Switch


If an external switch is connected to the RESET pin, it is important to add a series resistance. Whenever
the switch is pressed it will short the capacitor, and the current (I) through the switch can have high peak
values. This causes the switch to bounce and generate steep spikes in 2 ms - 10 ms (t) periods until the
capacitor is discharged. The PCB tracks and the switch metal introduces a small inductance (L) and the
high current through these tracks can generate high voltages up to VL = L * dI/dt.
This spike voltage, VL, is most likely outside the specification of the RESET pin. By adding a series
resistor between the switch and the capacitor, the peak currents generated will be significantly low and it
will not be large enough to generate high voltages at the RESET pin. An example connection is shown in
the following diagram.
Figure 3-2. Switch Connection for Reset Pin

© 2018 Microchip Technology Inc. Application Note DS00002519B-page 8


AN2519
Connecting Programmer/Debugger Lines

4. Connecting Programmer/Debugger Lines


AVR microcontrollers feature one or more interfaces for programming or debugging. In-System
Programming (ISP) is a programming interface used for programming the Flash, EEPROM, Lock bits, and
Fuse bits in almost all AVR devices. This feature makes it possible to program the AVR microcontroller in
the last stage of production of a target application board, reprogram if SW bugs are identified late in the
process, or update the AVR device in the field, if required. Some ISP interfaces may also be used for on-
chip debugging. It is therefore recommended to design the target application board so that the ISP
connectors are easily accessible.
Note:  Refer to the device-specific data sheet for information on the programming/debugging interfaces
supported by the device.

4.1 SPI Programming Interface


On devices that use a Serial Peripheral Interface (SPI) for ISP, these lines are usually located on the
same pins as a regular SPI, or on pins that can be used for other purposes. Refer to the device data
sheet to determine the pins used for the ISP.
Two standard SPI connectors are provided by the ISP programmers; a 6-pin and a 10-pin connector. In
addition to the data lines (MOSI and MISO) and the bus clock (SCK), the target voltage VTG, GND, and
Reset (RST) are also provided through these connectors.
Figure 4-1. Connections for the 6- and 10-pin ISP Headers

A few ISP programmers are powered by the target power supply. In this way they easily adapt to the
correct voltage level of the target board. Other ISP programmers, such as STK600, can alternatively
power the target board via the VTG line. In such a case, it is important that the power supply on the target
is not switched on.
Note:  Refer to the respective programmer user guide for more information on the capabilities and
physical interface.

4.1.1 Shared Use of SPI Programming Lines


If additional devices are connected to the ISP lines, the programmer must be protected from any device,
other than the AVR device, that may try to drive the lines. This is important with the SPI bus, as it is
similar to the ISP interface. Applying series resistors on the SPI lines, as depicted in Connecting the SPI
Lines to the ISP Interface, is the easiest way to achieve this. Typically, the resistor value R can be of
330Ω(1).

© 2018 Microchip Technology Inc. Application Note DS00002519B-page 9


AN2519
Connecting Programmer/Debugger Lines

Figure 4-2. Connecting the SPI Lines to the ISP Interface


SCK MOSI
MISO RST
SPI Bus
R
SCK SCK
R
MISO MOSI
R
MOSI MISO

Reset

®
AVR MCU
Note: 
1. These typical values are used to limit the input current to 10 mA for a supply voltage (VCC) of 3.3V.
It may vary depending on the programmer/debugger used and the requirements of specific
hardware design.
2. The AVR device will never drive the SPI lines in a programming situation. The AVR device is held in
Reset to enter Programming mode, which puts all AVR device pins to tri-states.
In a single application, multiple AVR devices can share the same ISP interface. This enables
programming of all the devices through a minimal interface. However, if there are no special design
considerations, then all the AVR devices will respond to the ISP instructions. The SPI clock lines should
be separately provided (can be gated using jumpers or DIP switches) so that only one AVR device at a
time receives SPI clock. Other SPI lines (MOSI and MISO) can be shared. This method ensures that AVR
devices are separated from the programmer by the same protection resistors since they are all held in
Reset while the ISP Reset line is activated. The ISP clock can be gated using jumpers or DIP switches.
An alternate solution is to use multiple ISP interfaces, one for each device, all protected separately with
series resistors.

4.2 JTAG Interface


Few devices have a JTAG interface that can be used for both programming and debugging. The JTAG
lines are shared with analog input and must be connected so that the JTAG programmer can control the
lines. JTAG programming tools can drive a resistive load, however, it is better to avoid capacitive load.
The following figure shows the standard JTAG connector supplied with ISP programmers. For the SPI
programming connector, the target’s voltage supply allows power to the device or ensures correct signal
levels when programming.
Figure 4-3. Pinout of the Standard JTAG Connector

Note:  Refer to the specific user guide of programmers/debuggers for more information about the JTAG
interfacing with AVR devices.

© 2018 Microchip Technology Inc. Application Note DS00002519B-page 10


AN2519
Connecting Programmer/Debugger Lines

4.2.1 Shared Use of JTAG Lines


By creating a JTAG daisy-chain, a single JTAG connector can serve as an ISP interface for several
®
devices. Typical connection for a daisy-chain using JTAG for AVR Dragon is shown in the following
schematic. The daisy-chain configuration can be used for any programmer/debugger that uses JTAG
interface. The GND and VTREF of JTAG, which is not shown in the figure, must be connected to the target
board.
Figure 4-4. JTAG Daisy-Chain
TCK
TMS

AVR® Dragon TDI AVR target AVR target AVR target


device device device
TDO

The protection resistors shown in Figure 4-2 are required if the JTAG lines are used in the application. For
example, ADC input pins often have analog filters on the lines. In such cases, the filter capacitor must be
removed while programming, to ensure that the load is resistive. The following figure illustrates the steps.
Figure 4-5. JTAG Interface Connections – Correct and Incorrect Ways
Connect to Vcc during programming

JTAG probe
R R
JTAG PIN Analog input signal
C
OK!

JTAG probe
R
JTAG PIN Analog input signal

Fails! C

JTAG probe
R R
JTAG PIN Analog input signal

Likely to fail C

4.3 PDI Interface


The Program and Debug Interface (PDI) is a Microchip proprietary two-line interface that was introduced
®
with the AVR XMEGA microcontroller family. As the name implies, this interface can be used for both In-
System Programming and on-chip debugging of devices.

© 2018 Microchip Technology Inc. Application Note DS00002519B-page 11


AN2519
Connecting Programmer/Debugger Lines

The following figure shows the standard PDI connector supplied with Microchip programmers. Only two
pins on the device are required for using this interface; RESET, also called PDI_CLK, and the dedicated
PDI_DATA pin. The target’s voltage supply allows power to the device or ensures correct signal levels
during programming.
Figure 4-6. Standard PDI Header

Note:  Refer to the respective programmer user guide for more information about the capabilities and
physical interface of PDI.

4.3.1 External Reset Circuitry


Since the Reset line is used for clocking the PDI, it is important to bypass or avoid any circuitry that can
distort the clock signal during programming or debugging, such as capacitors and external reset sources.
During normal operation, the RESET pin has an internal filter to prevent unintentional resets such as
those caused by short spikes on the Reset line. Despite the fact that the clock signal is deformed,
capacitive loads up to 1 nF have been tested to work with the STK600 and AVR Dragon during
programming. Pull-up resistors should be at least 10 kΩ or removed from the Reset line if a Microchip
programmer is used.

4.4 TPI Interface


®
The Tiny Programming Interface is featured on the tinyAVR devices with the lowest pin count.
The following figure shows the standard TPI connector supplied along with the Microchip programmer
device. Only three pins on the device are required for use of this interface; RESET, TPICLK, and
TPIDATA. The latter two pins are multiplexed with regular I/O pins.
Figure 4-7. Standard TPI Header

The RESET pin can be reconfigured as an I/O pin by programming the RSTDISBL fuse of the device.
This disables the reset functionality and requires +12V to be applied to Reset for programming to work.
Only a few programming tools are capable of generating this voltage.
Note:  Refer to the respective programmer user guide for more information about the capabilities and
physical interface of TPI.

4.5 UPDI Interface


The Unified Program and Debug Interface (UPDI) is a Microchip proprietary interface for external
programming and on-chip debugging of a device.

© 2018 Microchip Technology Inc. Application Note DS00002519B-page 12


AN2519
Connecting Programmer/Debugger Lines

Programming and debugging are performed using the UPDI Physical interface (UPDI PHY), which is a
UART-based half-duplex 1-wire interface for data reception and transmission. It uses the Reset line to
detect the debugger probe.
Figure 4-8. Standard UPDI Header

Single-wire interface can be enabled by setting a fuse or by 12V programming, which disables the reset
functionality. Not all programming tools are capable of generating this voltage.
Note:  Refer to the respective programmer user guide for more information about the capabilities and
physical interface of UPDI.

© 2018 Microchip Technology Inc. Application Note DS00002519B-page 13


AN2519
Using Crystal and Ceramic Resonators

5. Using Crystal and Ceramic Resonators


Most AVR MCUs can use different clock sources. The optional external clock sources are external clock,
RC oscillator, crystal, or ceramic resonator. The use of crystals and ceramic resonators cause problems
in some designs due to the fact that the use of these clock sources is not well understood. This section
addresses the topic of using crystals and ceramic resonators in relation to the AVR MCUs. The
description focuses on features and parameters relevant for designing applications where crystals or
ceramic resonators are used rather than trying to be a complete description of the theory related to the
topic. For more information and theory regarding crystals, refer to application note “AVR4100: Selecting
and Testing 32kHz Crystal Oscillators for AVR Microcontrollers”.

5.1 Selecting the Clock Source in the AVR MCU


The clock source used by the AVR devices are selected by setting the appropriate fuses. However, for the
AVR XMEGA family, the clock source is configured using software. Most ISP and parallel programmers
can program the fuses for selecting a clock source. The fuses are not erased when the AVR device
memory is erased and the fuses must only be programmed if the fuse settings should be altered.
Programming the fuses each time the device is erased and reprogrammed is thus not necessary. The
clock options that are relevant for this document are:
• External low-frequency crystal
• External crystal oscillator
• External ceramic resonator
Several sub-settings related to the start-up time of the AVR device can be selected, but the three clock
options mentioned are the fundamental settings that should be focused on. The clock options can vary
across different AVR devices, as not all devices support external oscillators. Refer to the device-specific
data sheet to determine the available clock options.
The AVR device may not run if a different clock source other than the clock source actually configured is
selected. The oscillator circuits are activated internally in the AVR device, based on the configured clock
option. The fuses are not cleared by a memory erase. Hence, it can cause problems if incorrect settings
are selected.

5.2 About Crystals and Ceramic Resonators


The typical crystal used for the AVR device is the AT-cut parallel resonant crystal. The ceramic resonator
is very similar to the AT-cut parallel resonant crystal but is a low-cost, low-quality version of the crystal.
The ceramic resonator has a lower Q-value, which is both an advantage and disadvantage. Due to the
lower Q-value, the oscillator frequency of the ceramic resonator can more easily be tuned to the desired
frequency. But, it is also more sensitive to temperature and load changes, causing undesired frequency
variations. The advantage of the ceramic resonator is that it has a faster start-up than crystals.
In this section, the term resonator refers to both Quartz Crystals and Ceramic Resonator.

Ceramic Resonator Quartz Crystal


Aging ±3000 ppm ±10 ppm
Frequency tolerance ±5000 ppm* ±20 ppm
Frequency temperature characteristics ±50 ppm/˚C* ±0.5 ppm/˚C

© 2018 Microchip Technology Inc. Application Note DS00002519B-page 14


AN2519
Using Crystal and Ceramic Resonators

Ceramic Resonator Quartz Crystal


Frequency pull-ability ±350 ppm/pF* ±15 ppm/pF
Oscillator rise time 0.01 ms - 0.5 ms 1 ms - 10 ms
Quality factor (Qm) 100 - 5000 103 – 5 x 105

Note:  The information provided in the table is to showcase the differences. For more details about the
oscillator, refer to the device-specific data sheet.
Note:  * The ppm variation in the ceramic resonator depends on the quality of the ceramic resonator.
The parallel resonator is used in circuits which contain reactive components such as capacitors. Such
circuits depend on the combination of the reactive components and the resonator to accomplish the
phase shift required to start and maintain the oscillation at a specific frequency. Basic oscillator circuits
used for parallel resonators are illustrated in the following diagram. The part of the circuit above the
dashed line represents the oscillator circuit present internally in the AVR device. Simply, the AVR device
built-in oscillator circuits can be understood as an inverter-based oscillator circuit, as shown in the
following figure.
Figure 5-1. Basic Inverter Circuits Equivalent to the Oscillator Circuits in AVR Devices

Ci1 Ci2

Internal
XTAL1/ XTAL2/ External
TOSC1 TOSC2

Ce1 Cs1 Cs2 Ce2

The circuit depicted in Figure 5-1 includes internal capacitive load (Ci), the stray capacitance (Cs) of a
circuit, and the optional external capacitance (Ce) to match the capacitive load (CL) of the resonator.
Note:  Some AVR devices may not include internal capacitors, or may have a fuse setting to enable/
disable the internal capacitors. Always check the device data sheet before choosing the resonator.
When using resonators with the AVR device, it may be necessary to apply (external) capacitors according
to the requirements of the resonator used. A parallel resonator will not be able to provide stable
oscillation if an insufficient capacitive load is applied. When the capacitive load is too high, the oscillation
may not start as expected due to drive level dependency of the load. The capacitive load of the crystal
(CL), found in the data sheet of the resonator, is the recommended capacitive load of the resonator
(viewed from the terminals of the resonator). To match the capacitive load (CL) the engineer must

© 2018 Microchip Technology Inc. Application Note DS00002519B-page 15


AN2519
Using Crystal and Ceramic Resonators

calculate the external capacitors (Ce) using Equation - 1. The closer the total capacitance of Ci, Cs, and
Ce are to CL, the more exact the frequency one should get.
Equation - 1
��1 + ��1 + ��1 ��2 + ��2 + ��2
�� =
��1 + ��2 + ��1 + ��2 + ��1 + ��2

Where Ce1 and Ce2 refer to the external capacitors seen in the figure above, and Cs1 and Cs2 are stray
capacitances at the XTAL/TOSC pins of the AVR device, and Ci1 and Ci2 are the internal capacitances.
Assuming symmetric layout, so that Ci1 and Ci2 = Ci and Cs1 and Cs2 = CS (CS can be estimated to be
2 pF - 5 pF), and then the external capacitors can be determined by the following equation, with CL given
by resonator data sheet.
Equation - 2
�� + �� = 2�� − ��

• Ce - is optional external capacitors as shown in Figure 5-1.


• Ci - is the pin capacitance of the XTAL and/or TOSC pin of the desired device.
• CL - is the load capacitance of the desired crystal.
• CS - is the total stray capacitance for one pin.
Examples are given in chapter Example Layout of ATxmega32A4 and ATmega324PB Devices.

5.3 Recommended Capacitor Values

Important: 
Recommendations given in this chapter are guiding values only. Always check the data sheet,
and calculate values accordingly.

When using the external crystal oscillator on non-PB AVR devices, crystals with a nominal frequency
range starting from 400 kHz can be used. For the standard high-frequency crystals, the recommended
capacitor value range is in the range of 22 pF - 33 pF. For the newer AVR PB, the recommended
capacitor value range is 12 pF - 22 pF, the total capacitance (Ce + Ci + Cs) for each pin must not exceed
22 pF.
The external low-frequency crystal is intended for 32.768 kHz crystals. When selecting this clock source,
the internal oscillator circuit might provide the required capacitive load. By programming the CKOPT Fuse
(1), the user can enable internal capacitors on XTAL1 and XTAL2. The value of the internal capacitor is

typical 20 pF but can vary. External capacitors are not required when using a 32.768 kHz crystal that
does not require more load. Then the value of the external capacitor can be determined using the
Equation - 2. The CKOPT Fuse should not be programmed when using external capacitors.
In other cases, an external capacitive load specified by the manufacturer of the crystal must be used.
When using the external ceramic resonator, refer to the device data sheet for determining the capacitors
values. Always use the recommended capacitive load, as the resonant frequency of the ceramic
resonator is very sensitive to capacitive load.
Note: 

© 2018 Microchip Technology Inc. Application Note DS00002519B-page 16


AN2519
Using Crystal and Ceramic Resonators

1. Some AVR devices may not come with internal capacitors. Some AVR devices may not have the
CKOPT fuse, instead they have dedicated pins (TOSC1-TOSC2), to connect the 32.768 kHz
crystal.
2. Refer to the device data sheet for specific details related to oscillator connections.

5.4 Unbalanced External Capacitors


In noisy environments the oscillator can be crucially affected. If the noise is strong enough, the oscillator
can “lock up” and stop oscillating. To reduce the sensitivity of the oscillator to noise, the size of the
capacitor at the high-impedance input of the oscillator circuit, XTAL1, can be slightly increased.
Increasing only one of the capacitors does not affect the total capacitive load much, but unbalanced
capacitors can affect the resonant frequency to a higher degree than the change of the total capacitive
load. However, unbalanced capacitive loads will affect the duty cycle of the oscillation and should not be
used. This is especially critical if the AVR device is utilized close to its maximum speed limit.

5.5 RTC Crystals


Many AVR devices have the capability of using asynchronous clocking of the built-in timer/counter. Using
this feature, the counter can be used for real-time functions. A 32.768 kHz crystal should be connected to
the TOSCx pins of the AVR device.
In some AVR devices, the internal oscillator circuit used with the real-time counter provides a capacitive
load of approximately 20 pF, which should be appropriate for common 32.768 kHz crystals. Refer to the
device-specific data sheet for information about the capacitors. If the internal load is insufficient for the
applied crystal, external capacitors can be used.

5.6 PCB Layout


Finally, the physical location of the resonator, with respect to the AVR device, is important. Ensure that
the resonator is placed as close as possible to the AVR device and shield the resonator by surrounding it
with a ground plane.

© 2018 Microchip Technology Inc. Application Note DS00002519B-page 17


AN2519
Unused XTAL Pins

6. Unused XTAL Pins


If XTAL pins are not in use, they should be tied to ground. This helps to prevent unintentional behavior
during device start-up.

© 2018 Microchip Technology Inc. Application Note DS00002519B-page 18


AN2519
Example Layout of ATxmega32A4 and ATmega324PB ...

7. Example Layout of ATxmega32A4 and ATmega324PB Devices


The following schematic- and layout examples are recommended starting points for ATxmega32A and
ATmega324PB designs. Always check the respective data sheets to ensure the correct values are used
for all components. The key points to be considered are:
1. The connections for crystal oscillator and decoupling capacitors.
2. The number of layers on the PCB. It is recommended to have a multilayer design with supply and
ground plane on separate layers.
3. Decoupling of all digital supply pairs from VCC and isolating AVCC from VCC.
4. Short distance between the crystal/capacitors and the MCU.
5. Ground plane surrounding the crystal and the vias connected to the planes are close to the MCU
pins in the layout.
Note:  For ATmega PB devices, the total amount of capacitance must not exceed 22 pF. This includes
PCN traces and pin capacitance.
Figure 7-1. ATxmega32A4 - Basic Schematic Example of Required/Recommended Connections

© 2018 Microchip Technology Inc. Application Note DS00002519B-page 19


AN2519
Example Layout of ATxmega32A4 and ATmega324PB ...

Figure 7-2. ATxmega32A4 - Copper PCB Layout of Required/Recommended Connections

Figure 7-3. ATxmega32A4 - Top Silk Prints of Required/Recommended Connections

Figure 7-4. ATmega324PB - Basic Schematic Example of Required/Recommended Connections

© 2018 Microchip Technology Inc. Application Note DS00002519B-page 20


AN2519
Example Layout of ATxmega32A4 and ATmega324PB ...

Figure 7-5. ATmega324PB - Copper PCB Layout of Required/Recommended Connections

Figure 7-6. ATmega324PB - Top Silk Prints of Required/Recommended Connections

© 2018 Microchip Technology Inc. Application Note DS00002519B-page 21


AN2519
Revision History

8. Revision History
Doc Rev. Date Comments
B 02/2018 1. Explanations in the Digital Supply section were improved.
2. Obsolete section on Noise Implications was removed.

A 08/2017 1. Chapter “Unused XTAL Pins” is added.


2. A note for the Example Layout has been added.
3. New document template. Microchip DS00002519A replaces Atmel 2521S.

2521R 09/2016 1. The filename and the document number in part of this revision history have
been corrected.
2. Trademark corrections.
3. Some minor corrections in the text.

2521Q 06/2016 1. General improvement of descriptions.


2. Added example layout for ATmega324PB device.

2521P 10/2015 Updated the following sections:


1. About Crystals and Ceramic Resonators
2. Recommended Capacitor Values

2521O 09/2015 Corrected the figure Example Layout.


2521N 06/2015 Added Noise Implications.
2521M 09/2014 Fixed some typos in External RESET Switch.
2521L 07/2013 1. Updated Figure 4-5.
2. General improvements in regards of descriptions.

© 2018 Microchip Technology Inc. Application Note DS00002519B-page 22


AN2519

The Microchip Web Site


Microchip provides online support via our web site at http://www.microchip.com/. This web site is used as
a means to make files and information easily available to customers. Accessible by using your favorite
Internet browser, the web site contains the following information:
• Product Support – Data sheets and errata, application notes and sample programs, design
resources, user’s guides and hardware support documents, latest software releases and archived
software
• General Technical Support – Frequently Asked Questions (FAQ), technical support requests,
online discussion groups, Microchip consultant program member listing
• Business of Microchip – Product selector and ordering guides, latest Microchip press releases,
listing of seminars and events, listings of Microchip sales offices, distributors and factory
representatives

Customer Change Notification Service


Microchip’s customer notification service helps keep customers current on Microchip products.
Subscribers will receive e-mail notification whenever there are changes, updates, revisions or errata
related to a specified product family or development tool of interest.
To register, access the Microchip web site at http://www.microchip.com/. Under “Support”, click on
“Customer Change Notification” and follow the registration instructions.

Customer Support
Users of Microchip products can receive assistance through several channels:
• Distributor or Representative
• Local Sales Office
• Field Application Engineer (FAE)
• Technical Support
Customers should contact their distributor, representative or Field Application Engineer (FAE) for support.
Local sales offices are also available to help customers. A listing of sales offices and locations is included
in the back of this document.
Technical support is available through the web site at: http://www.microchip.com/support

Microchip Devices Code Protection Feature


Note the following details of the code protection feature on Microchip devices:
• Microchip products meet the specification contained in their particular Microchip Data Sheet.
• Microchip believes that its family of products is one of the most secure families of its kind on the
market today, when used in the intended manner and under normal conditions.
• There are dishonest and possibly illegal methods used to breach the code protection feature. All of
these methods, to our knowledge, require using the Microchip products in a manner outside the
operating specifications contained in Microchip’s Data Sheets. Most likely, the person doing so is
engaged in theft of intellectual property.
• Microchip is willing to work with the customer who is concerned about the integrity of their code.

© 2018 Microchip Technology Inc. Application Note DS00002519B-page 23


AN2519

• Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their
code. Code protection does not mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the
code protection features of our products. Attempts to break Microchip’s code protection feature may be a
violation of the Digital Millennium Copyright Act. If such acts allow unauthorized access to your software
or other copyrighted work, you may have a right to sue for relief under that Act.

Legal Notice
Information contained in this publication regarding device applications and the like is provided only for
your convenience and may be superseded by updates. It is your responsibility to ensure that your
application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR
WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY
OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS
CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE.
Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life
support and/or safety applications is entirely at the buyer’s risk, and the buyer agrees to defend,
indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting
from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual
property rights unless otherwise stated.

Trademarks
The Microchip name and logo, the Microchip logo, AnyRate, AVR, AVR logo, AVR Freaks, BeaconThings,
BitCloud, CryptoMemory, CryptoRF, dsPIC, FlashFlex, flexPWR, Heldo, JukeBlox, KeeLoq, KeeLoq logo,
Kleer, LANCheck, LINK MD, maXStylus, maXTouch, MediaLB, megaAVR, MOST, MOST logo, MPLAB,
OptoLyzer, PIC, picoPower, PICSTART, PIC32 logo, Prochip Designer, QTouch, RightTouch, SAM-BA,
SpyNIC, SST, SST Logo, SuperFlash, tinyAVR, UNI/O, and XMEGA are registered trademarks of
Microchip Technology Incorporated in the U.S.A. and other countries.
ClockWorks, The Embedded Control Solutions Company, EtherSynch, Hyper Speed Control, HyperLight
Load, IntelliMOS, mTouch, Precision Edge, and Quiet-Wire are registered trademarks of Microchip
Technology Incorporated in the U.S.A.
Adjacent Key Suppression, AKS, Analog-for-the-Digital Age, Any Capacitor, AnyIn, AnyOut, BodyCom,
chipKIT, chipKIT logo, CodeGuard, CryptoAuthentication, CryptoCompanion, CryptoController,
dsPICDEM, dsPICDEM.net, Dynamic Average Matching, DAM, ECAN, EtherGREEN, In-Circuit Serial
Programming, ICSP, Inter-Chip Connectivity, JitterBlocker, KleerNet, KleerNet logo, Mindi, MiWi,
motorBench, MPASM, MPF, MPLAB Certified logo, MPLIB, MPLINK, MultiTRAK, NetDetach, Omniscient
Code Generation, PICDEM, PICDEM.net, PICkit, PICtail, PureSilicon, QMatrix, RightTouch logo, REAL
ICE, Ripple Blocker, SAM-ICE, Serial Quad I/O, SMART-I.S., SQI, SuperSwitcher, SuperSwitcher II, Total
Endurance, TSHARC, USBCheck, VariSense, ViewSpan, WiperLock, Wireless DNA, and ZENA are
trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.
SQTP is a service mark of Microchip Technology Incorporated in the U.S.A.
Silicon Storage Technology is a registered trademark of Microchip Technology Inc. in other countries.
GestIC is a registered trademark of Microchip Technology Germany II GmbH & Co. KG, a subsidiary of
Microchip Technology Inc., in other countries.
All other trademarks mentioned herein are property of their respective companies.

© 2018 Microchip Technology Inc. Application Note DS00002519B-page 24


AN2519

© 2018, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved.
ISBN: 978-1-5224-2611-0

Quality Management System Certified by DNV

ISO/TS 16949
Microchip received ISO/TS-16949:2009 certification for its worldwide headquarters, design and wafer
fabrication facilities in Chandler and Tempe, Arizona; Gresham, Oregon and design centers in California
® ®
and India. The Company’s quality system processes and procedures are for its PIC MCUs and dsPIC
®
DSCs, KEELOQ code hopping devices, Serial EEPROMs, microperipherals, nonvolatile memory and
analog products. In addition, Microchip’s quality system for the design and manufacture of development
systems is ISO 9001:2000 certified.

© 2018 Microchip Technology Inc. Application Note DS00002519B-page 25


Worldwide Sales and Service

AMERICAS ASIA/PACIFIC ASIA/PACIFIC EUROPE


Corporate Office Australia - Sydney India - Bangalore Austria - Wels
2355 West Chandler Blvd. Tel: 61-2-9868-6733 Tel: 91-80-3090-4444 Tel: 43-7242-2244-39
Chandler, AZ 85224-6199 China - Beijing India - New Delhi Fax: 43-7242-2244-393
Tel: 480-792-7200 Tel: 86-10-8569-7000 Tel: 91-11-4160-8631 Denmark - Copenhagen
Fax: 480-792-7277 China - Chengdu India - Pune Tel: 45-4450-2828
Technical Support: Tel: 86-28-8665-5511 Tel: 91-20-4121-0141 Fax: 45-4485-2829
http://www.microchip.com/ China - Chongqing Japan - Osaka Finland - Espoo
support Tel: 86-23-8980-9588 Tel: 81-6-6152-7160 Tel: 358-9-4520-820
Web Address: China - Dongguan Japan - Tokyo France - Paris
www.microchip.com Tel: 86-769-8702-9880 Tel: 81-3-6880- 3770 Tel: 33-1-69-53-63-20
Atlanta China - Guangzhou Korea - Daegu Fax: 33-1-69-30-90-79
Duluth, GA Tel: 86-20-8755-8029 Tel: 82-53-744-4301 Germany - Garching
Tel: 678-957-9614 China - Hangzhou Korea - Seoul Tel: 49-8931-9700
Fax: 678-957-1455 Tel: 86-571-8792-8115 Tel: 82-2-554-7200 Germany - Haan
Austin, TX China - Hong Kong SAR Malaysia - Kuala Lumpur Tel: 49-2129-3766400
Tel: 512-257-3370 Tel: 852-2943-5100 Tel: 60-3-7651-7906 Germany - Heilbronn
Boston China - Nanjing Malaysia - Penang Tel: 49-7131-67-3636
Westborough, MA Tel: 86-25-8473-2460 Tel: 60-4-227-8870 Germany - Karlsruhe
Tel: 774-760-0087 China - Qingdao Philippines - Manila Tel: 49-721-625370
Fax: 774-760-0088 Tel: 86-532-8502-7355 Tel: 63-2-634-9065 Germany - Munich
Chicago China - Shanghai Singapore Tel: 49-89-627-144-0
Itasca, IL Tel: 86-21-3326-8000 Tel: 65-6334-8870 Fax: 49-89-627-144-44
Tel: 630-285-0071 China - Shenyang Taiwan - Hsin Chu Germany - Rosenheim
Fax: 630-285-0075 Tel: 86-24-2334-2829 Tel: 886-3-577-8366 Tel: 49-8031-354-560
Dallas China - Shenzhen Taiwan - Kaohsiung Israel - Ra’anana
Addison, TX Tel: 86-755-8864-2200 Tel: 886-7-213-7830 Tel: 972-9-744-7705
Tel: 972-818-7423 China - Suzhou Taiwan - Taipei Italy - Milan
Tel: 86-186-6233-1526
Fax: 972-818-2924 Tel: 886-2-2508-8600 Tel: 39-0331-742611
China - Wuhan
Detroit Thailand - Bangkok Fax: 39-0331-466781
Tel: 86-27-5980-5300
Novi, MI Tel: 66-2-694-1351 Italy - Padova
China - Xian
Tel: 248-848-4000 Vietnam - Ho Chi Minh Tel: 39-049-7625286
Tel: 86-29-8833-7252 Tel: 84-28-5448-2100
Houston, TX Netherlands - Drunen
China - Xiamen
Tel: 281-894-5983 Tel: 31-416-690399
Tel: 86-592-2388138
Indianapolis Fax: 31-416-690340
China - Zhuhai
Noblesville, IN Norway - Trondheim
Tel: 86-756-3210040
Tel: 317-773-8323 Tel: 47-7289-7561
Fax: 317-773-5453 Poland - Warsaw
Tel: 317-536-2380 Tel: 48-22-3325737
Los Angeles Romania - Bucharest
Mission Viejo, CA Tel: 40-21-407-87-50
Tel: 949-462-9523 Spain - Madrid
Fax: 949-462-9608 Tel: 34-91-708-08-90
Tel: 951-273-7800 Fax: 34-91-708-08-91
Raleigh, NC Sweden - Gothenberg
Tel: 919-844-7510 Tel: 46-31-704-60-40
New York, NY Sweden - Stockholm
Tel: 631-435-6000 Tel: 46-8-5090-4654
San Jose, CA UK - Wokingham
Tel: 408-735-9110 Tel: 44-118-921-5800
Tel: 408-436-4270 Fax: 44-118-921-5820
Canada - Toronto
Tel: 905-695-1980
Fax: 905-695-2078

© 2018 Microchip Technology Inc. Application Note DS00002519B-page 26

You might also like