Atmel 42005 8 and 16 Bit AVR Microcontrollers XMEGA E Manual
Atmel 42005 8 and 16 Bit AVR Microcontrollers XMEGA E Manual
Atmel 42005 8 and 16 Bit AVR Microcontrollers XMEGA E Manual
XMEGA E MANUAL
This document contains complete and detailed description of all modules included in the
Atmel®AVR® XMEGA® E microcontroller family. The XMEGA E is a family of low-power, high-
performance, and peripheral-rich CMOS 8/16-bit microcontrollers based on the AVR enhanced
RISC architecture. The available XMEGA E modules described in this manual are:
Atmel AVR CPU
Memories
EDMA - Enhanced direct memory access
Event system
System clock and clock options
Power management and sleep modes
Reset system
WDT - Watchdog timer
Interrupts and programmable multilevel interrupt controller
PORT - I/O ports
TC4/5 - 16-bit timer/counters
WeX - Waveform extension
Hi-Res - High resolution extension
Fault - Fault extension
RTC - Real-time counter
TWI - Two-wire serial interface
SPI - Serial peripheral interface
USART - Universal synchronous and asynchronous serial receiver and transmitter
IRCOM - Infrared communication module
XCL - XMEGA custom logic
CRC - Cyclic redundancy check
ADC - Analog-to-digital converter
DAC - Digital-to-analog converter
AC - Analog comparator
PDI - Program and debug interface
Memory Programming
Peripheral module address map
Instruction set summary
Manual revision history
Table of contents
Atmel–42005E–AVR–XMEGA E–11/2014
1. About the Manual
This document contains in-depth documentation of all peripherals and modules available for the Atmel AVR XMEGA E
microcontroller family. All features are documented on a functional level and described in a general sense. All peripherals
and modules described in this manual may not be present in all XMEGA E devices.
For all device-specific information such as characterization data, memory sizes, modules, peripherals available and their
absolute memory addresses, refer to the device datasheets. When several instances of a peripheral exists in one device,
each instance will have a unique name. For example each port module (PORT) have unique name, such as PORTA,
PORTB, etc. Register and bit names are unique within one module instance.
For more details on applied use and code examples for peripherals and modules, refer to the Atmel AVR XMEGA
specific application notes available from http://www.atmel.com/avr.
1.2 Resources
A comprehensive set of development tools, application notes, and datasheets are available for download from
http://www.atmel.com/avr.
This manual contains general modules and peripheral descriptions. The AVR XMEGA E device datasheets contains the
device-specific information. The XMEGA application notes and Atmel Software Framework contain example code and
show applied use of the modules and peripherals.
For new users, it is recommended to read the AVR1000 - Getting Started Writing C Code for Atmel XMEGA.
XMEGA E [MANUAL] 2
Atmel–42005E–AVR–XMEGA E–11/2014
2. Overview
The AVR XMEGA E microcontrollers is a family of low-power, high-performance, and peripheral-rich CMOS 8/16-bit
microcontrollers based on the AVR enhanced RISC architecture. By executing powerful instructions in a single clock
cycle, the XMEGA E devices achieve throughputs approaching one million instructions per second (MIPS) per
megahertz, allowing the system designer to optimize power consumption versus processing speed.
The AVR CPU combines a rich instruction set with 32 general purpose working registers. All 32 registers are directly
connected to the arithmetic logic unit (ALU), allowing two independent registers to be accessed in a single instruction,
executed in one clock cycle. The resulting architecture is more code efficient while achieving throughputs many times
faster than conventional single-accumulator or CISC based microcontrollers.
The XMEGA E devices provide the following features: in-system programmable flash; internal EEPROM and SRAM;
four-channel enhanced DMA controller (EDMA); eight-channel event system with asynchronous event support;
programmable multilevel interrupt controller; up to 26 general purpose I/O lines; 16-bit real-time counter (RTC) with
digital correction; up to three flexible, 16-bit timer/counters with capture, compare and PWM modes; up to two USARTs;
one I2C and SMBUS compatible two-wire serial interfaces (TWI); one serial peripheral interfaces (SPI); one XMEGA
custom logic (XCL) with timer/counter and logic functions; CRC module; one 16-channel, 12-bit ADC with programmable
gain, offset and gain correction, averaging, oversampling and decimation; one 2-channel, 12-bit DAC; two analog
comparators with window mode; programmable watchdog timer with separate internal oscillator; accurate internal
oscillators with PLL and prescaler; and programmable brown-out detection.
The program and debug interface (PDI), a fast, two-pin interface for programming and debugging, is available. Selected
devices also have an IEEE std. 1149.1 compliant JTAG interface, and this can also be used for on-chip debug and
programming.
The Atmel AVR XMEGA devices have five software selectable power saving modes. The idle mode stops the CPU while
allowing the SRAM, EDMA controller, event system, interrupt controller, and all peripherals to continue functioning. The
power-down mode saves the SRAM and register contents, but stops the oscillators, disabling all other functions until the
next TWI, or pin-change interrupt, or reset. In power-save mode, the asynchronous real-time counter continues to run,
allowing the application to maintain a timer base while the rest of the device is sleeping. In standby mode, the external
crystal oscillator keeps running while the rest of the device is sleeping. This allows very fast startup from the external
crystal, combined with low power consumption. In extended standby mode, both the main oscillator and the
asynchronous timer continue to run. To further reduce power consumption, the peripheral clock to each individual
peripheral can optionally be stopped in active mode and idle sleep mode. The low power internal 8MHz oscillator allows
very fast start-up time, combined with low power modes.
The devices are manufactured using Atmel high-density, nonvolatile memory technology. The program flash memory can
be reprogrammed in-system through the PDI interface. A boot loader running in the device can use any interface to
download the application program to the flash memory. By combining an 8/16-bit RISC CPU with In-system, self-
programmable flash, the Atmel AVR XMEGA is a powerful microcontroller family that provides a highly flexible and cost
effective solution for many embedded applications.
The XMEGA E devices are supported with a full suite of program and system development tools, including C compilers,
macro assemblers, program debugger/simulators, programmers, and evaluation kits.
XMEGA E [MANUAL] 3
Atmel–42005E–AVR–XMEGA E–11/2014
2.1 Block Diagram
XTAL2 /
TOSC2
ACA RESET /
PDI_CLK
Prog/Debug PDI
ADCA BUS Matrix PDI_DATA
Controller
AREFA
VCC/10
OCD
Int. Refs.
Tempref
CPU Interrupt
AREFD Controller
CRC
NVM Controller
Flash EEPROM
PD[0..7] PORT D (8)
TCD5
TWIC
SPIC
XCL
PORT C (8)
PC[0..7]
Note: 1. AVCC is only powering the following I/Os and analog functions:
PA0 to PA7, AREF, ADC, DAC, AC0:1, Power Supervision, tempref, VREF, and Watchdog Oscillator.
VCC is powering all other functions and I/Os.
XMEGA E [MANUAL] 4
Atmel–42005E–AVR–XMEGA E–11/2014
In Table 2-1 on page 5 a feature summary for the XMEGA E family is shown, split into one feature summary column for
each sub-family. Each sub-family has identical feature set, but different memory options, refer to their device datasheet
for ordering codes and memory options.
Total 32
Pins, I/O
Programmable I/O pins 26
TQFP 32A
Package
QFN /VQFN 32Z
Channels 8
Rotary 1
TC4 - 16-bit, 4 CC 1
TC5 - 16-bit, 2 CC 2
Hi-Res 1
Timer / Counter
WeX 1
FAULT 2
RTC Yes
BTC0 - 8-bit, 1 CC 1
XMEGA E [MANUAL] 5
Atmel–42005E–AVR–XMEGA E–11/2014
Feature Details / sub-family E5
USART 2
Serial Communication
SPI 1
TWI 1
CRC-16 Yes
CRC
CRC-32 Yes
Resolution (bits) 12
Conversion channels 1
Resolution (bits) 12
Digital to Analog Converter (DAC)
Sampling speed (kbps) 1000
XMEGA E [MANUAL] 6
Atmel–42005E–AVR–XMEGA E–11/2014
3. Atmel AVR CPU
3.1 Features
8/16-bit, high-performance Atmel AVR RISC CPU
141 instructions
Hardware multiplier
32x8-bit registers directly connected to the ALU
Stack in RAM
Stack pointer accessible in I/O memory space
Direct addressing of up to 16MB of program memory and 16MB of data memory
True 16/24-bit access to 16/24-bit I/O registers
Efficient support for 8-, 16-, and 32-bit arithmetic
Configuration change protection of system-critical features
3.2 Overview
All Atmel AVR XMEGA devices use the 8/16-bit AVR CPU. The main function of the CPU is to execute the code and
perform all calculations. The CPU is able to access memories, perform calculations, control peripherals, and execute the
program in the flash memory. Interrupt handling is described in a separate section, “PMIC – Interrupts and
Programmable Multilevel Interrupt Controller” on page 132.
XMEGA E MANUAL 7
Atmel–42005E–AVR–XMEGA E–11/2014
The arithmetic logic unit (ALU) supports arithmetic and logic operations between registers or between a constant and a
register. Single-register operations can also be executed in the ALU. After an arithmetic operation, the status register is
updated to reflect information about the result of the operation.
The ALU is directly connected to the fast-access register file. The 32 x 8-bit general purpose working registers all have
single clock cycle access time allowing single-cycle arithmetic logic unit operation between registers or between a
register and an immediate. Six of the 32 registers can be used as three 16-bit address pointers for program and data
space addressing, enabling efficient address calculations.
The memory spaces are linear. The data memory space and the program memory space are two different memory
spaces.
The data memory space is divided into I/O registers, SRAM, and external RAM. In addition, the EEPROM is memory
mapped in the data memory.
All I/O status and control registers reside in the lowest 4KB addresses of the data memory. This is referred to as the I/O
memory space. The lowest 64 addresses can be accessed directly, or as the data space locations from 0x00 to 0x3F.
The rest is the extended I/O memory space, ranging from 0x0040 to 0x0FFF. I/O registers here must be accessed as
data space locations using load (LD/LDS/LDD) and store (ST/STS/STD) instructions.
The SRAM holds data. Code execution from SRAM is not supported. It can easily be accessed through the five different
addressing modes supported in the AVR architecture. The first SRAM address is 0x2000.
Data addresses 0x1000 to 0x1FFF are reserved for EEPROM.
The program memory is divided in two sections, the application program section and the boot program section. Both
sections have dedicated lock bits for write and read/write protection. The SPM instruction that is used for self-
programming of the application flash memory must reside in the boot program section. The application section contains
an application table section with separate lock bits for write and read/write protection. The application table section can
be used for save storing of nonvolatile data in the program memory.
XMEGA E MANUAL 8
Atmel–42005E–AVR–XMEGA E–11/2014
3.5 Program Flow
After reset, the CPU starts to execute instructions from the lowest address in the flash program memory ‘0.’ The program
counter (PC) addresses the next instruction to be fetched.
Program flow is provided by conditional and unconditional jump and call instructions capable of addressing the whole
address space directly. Most AVR instructions use a 16-bit word format, while a limited number use a 32-bit format.
During interrupts and subroutine calls, the return address PC is stored on the stack. The stack is allocated in the general
data SRAM, and consequently the stack size is only limited by the total SRAM size and the usage of the SRAM. After
reset, the stack pointer (SP) points to the highest address in the internal SRAM. The SP is read/write accessible in the
I/O memory space, enabling easy implementation of multiple stacks or stack areas. The data SRAM can easily be
accessed through the five different addressing modes supported in the AVR CPU.
clkCPU
Figure 3-3 shows the internal timing concept for the register file. In a single clock cycle, an ALU operation using two
register operands is executed and the result is stored back to the destination register.
clkCPU
Total Execution Time
XMEGA E MANUAL 9
Atmel–42005E–AVR–XMEGA E–11/2014
3.7 Status Register
The status register (SREG) contains information about the result of the most recently executed arithmetic or logic
instruction. This information can be used for altering program flow in order to perform conditional operations. Note that
the status register is updated after all ALU operations, as specified in the “Instruction Set Summary” on page 432. This
will in many cases remove the need for using the dedicated compare instructions, resulting in faster and more compact
code.
The status register is not automatically stored when entering an interrupt routine nor restored when returning from an
interrupt. This must be handled by software.
The status register is accessible in the I/O memory space.
XMEGA E MANUAL 10
Atmel–42005E–AVR–XMEGA E–11/2014
Figure 3-4. AVR CPU General Purpose Working Registers
7 0 Addr.
R0 0x00
R1 0x01
R2 0x02
…
R13 0x0D
General R14 0x0E
Purpose R15 0x0F
Working R16 0x10
Registers R17 0x11
…
R26 0x1A X-register Low Byte
R27 0x1B X-register High Byte
R28 0x1C Y-register Low Byte
R29 0x1D Y-register High Byte
R30 0x1E Z-register Low Byte
R31 0x1F Z-register High Byte
The register file is located in a separate address space, and so the registers are not accessible as data memory.
The lowest register address holds the least-significant byte (LSB), and the highest register address holds the most-
significant byte (MSB). In the different addressing modes, these address registers function as fixed displacement,
automatic increment, and automatic decrement (see the “Instruction Set Summary” on page 432 for details).
XMEGA E MANUAL 11
Atmel–42005E–AVR–XMEGA E–11/2014
3.10 RAMP and Extended Indirect Registers
In order to access program memory or data memory above 64KB, the address pointer must be larger than 16 bits. This is
done by concatenating one register to one of the X-, Y-, or Z-registers. This register then holds the most-significant byte
(MSB) in a 24-bit address or address pointer.
These registers are available only on devices with external bus interface and/or more than 64KB of program or data
memory space. For these devices, only the number of bits required to address the whole program and data memory
space in the device is implemented in the registers.
Bit (Individually) 7 0 7 0 7 0
RAMPX XH XL
Bit (X-pointer) 23 16 15 8 7 0
Bit (Individually) 7 0 7 0 7 0
RAMPY YH YL
Bit (Y-pointer) 23 16 15 8 7 0
Bit (Individually) 7 0 7 0 7 0
RAMPZ ZH ZL
Bit (Z-pointer) 23 16 15 8 7 0
When reading (ELPM) and writing (SPM) program memory locations above the first 128KB of the program memory,
RAMPZ is concatenated with the Z-register to form the 24-bit address. LPM is not affected by the RAMPZ setting.
Bit (Individually) 7 0 15 0
RAMPD K
Bit (D-pointer) 23 16 15 0
Bit (Individually) 7 0 7 0 7 0
EIND ZH ZL
Bit (D-pointer) 23 16 15 8 7 0
XMEGA E MANUAL 12
Atmel–42005E–AVR–XMEGA E–11/2014
3.11 Accessing 16-bit Registers
The AVR data bus is 8 bits wide, and so accessing 16-bit registers requires atomic operations. These registers must be
byte-accessed using two read or write operations. 16-bit registers are connected to the 8-bit bus and a temporary register
using a 16-bit bus.
For a write operation, the low byte of the 16-bit register must be written before the high byte. The low byte is then written
into the temporary register. When the high byte of the 16-bit register is written, the temporary register is copied into the
low byte of the 16-bit register in the same clock cycle.
For a read operation, the low byte of the 16-bit register must be read before the high byte. When the low byte register is
read by the CPU, the high byte of the 16-bit register is copied into the temporary register in the same clock cycle as the
low byte is read. When the high byte is read, it is then read from the temporary register.
This ensures that the low and high bytes of 16-bit registers are always accessed simultaneously when reading or writing
the register.
Interrupts can corrupt the timed sequence if an interrupt is triggered and accesses the same 16-bit register during an
atomic 16-bit read/write operation. To prevent this, interrupts can be disabled when writing or reading 16-bit registers.
The temporary registers can also be read and written directly from user software.
XMEGA E MANUAL 13
Atmel–42005E–AVR–XMEGA E–11/2014
3.13 Fuse Lock
For some system-critical features, it is possible to program a fuse to disable all changes to the associated I/O control
registers. If this is done, it will not be possible to change the registers from the user software, and the fuse can only be
reprogrammed using an external programmer. Details on this are described in the datasheet module where this feature is
available.
XMEGA E MANUAL 14
Atmel–42005E–AVR–XMEGA E–11/2014
3.14 Register Descriptions
Bit 7 6 5 4 3 2 1 0
+0x04 CCP[7:0]
Read/Write W W W W W W R/W R/W
Initial value 0 0 0 0 0 0 0 0
XMEGA E MANUAL 15
Atmel–42005E–AVR–XMEGA E–11/2014
Bit 7:0 – RAMPX[7:0]: Extended X-pointer Address Bits
These bits hold the MSB of the 24-bit address created by RAMPX and the 16-bit X-register. Only the number of
bits required to address the available data memory is implemented for each device. Unused bits will always read
as zero.
XMEGA E MANUAL 16
Atmel–42005E–AVR–XMEGA E–11/2014
Bit 7:0 – EIND[7:0]: Extended Indirect Address Bits
These bits hold the MSB of the 24-bit address created by EIND and the 16-bit Z-register. Only the number of bits
required to access the available program memory is implemented for each device. Unused bits will always read as
zero.
Bit 7 6 5 4 3 2 1 0
+0x0E SP[15:8]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
(1)
Initial value 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1
XMEGA E MANUAL 17
Atmel–42005E–AVR–XMEGA E–11/2014
Bit 6 – T: Bit Copy Storage
The bit copy instructions bit load (BLD) and bit store (BST) use the T bit as source or destination for the operated
bit. A bit from a register in the register file can be copied into this bit by the BST instruction, and this bit can be cop-
ied into a bit in a register in the register file by the BLD instruction.
Bit 5 – H: Half Carry Flag
The half carry flag (H) indicates a half carry in some arithmetic operations. Half carry is useful in BCD arithmetic.
Bit 4 – S: Sign Bit, S = N V
The sign bit is always an exclusive or between the negative flag, N, and the two’s complement overflow flag, V.
Bit 3 – V: Two’s Complement Overflow Flag
The two’s complement overflow flag (V) supports two’s complement arithmetic.
Bit 2 – N: Negative Flag
The negative flag (N) indicates a negative result in an arithmetic or logic operation.
Bit 1 – Z: Zero Flag
The zero flag (Z) indicates a zero result in an arithmetic or logic operation.
Bit 0 – C: Carry Flag
The carry flag (C) indicates a carry in an arithmetic or logic operation.
XMEGA E MANUAL 18
Atmel–42005E–AVR–XMEGA E–11/2014
3.15 Register Summary
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Page
+0x00 Reserved – – – – – – – –
+0x01 Reserved – – – – – – – –
+0x02 Reserved – – – – – – – –
+0x03 Reserved – – – – – – – –
+0x05 Reserved – – – – – – – –
+0x06 Reserved – – – – – – – –
+0x07 Reserved – – – – – – – –
+0x0F SREG I T H S V N Z C 17
XMEGA E MANUAL 19
Atmel–42005E–AVR–XMEGA E–11/2014
4. Memories
4.1 Features
Flash program memory
One linear address space
In-system programmable
Self-programming and boot loader support
Application section for application code
Application table section for application code or data storage
Boot section for application code or bootloader code
Separate read/write protection lock bits for all sections
Built in fast CRC check of a selectable flash program memory section
Data memory
One linear address space
Single-cycle access from CPU
SRAM
EEPROM
Byte and page accessible
Memory mapped for direct load and store
I/O memory
Configuration and status registers for all peripherals and modules
Four bit-accessible general purpose registers for global variables or flags
Bus arbitration
Deterministic handling of priority between CPU, EDMA controller, and other bus masters
Separate buses for SRAM, EEPROM, I/O memory, and external memory access
Simultaneous bus access for CPU and EDMA controller
Production signature row memory for factory programmed data
ID for each microcontroller device type
Serial number for each device
Calibration bytes for factory calibrated peripherals
User signature row
One flash page in size
Can be read and written from software
Content is kept after chip erase
4.2 Overview
This section describes the different memory sections. The AVR architecture has two main memory spaces, the program
memory and the data memory. Executable code can reside only in the program memory, while data can be stored in the
program memory and the data memory. The data memory includes the internal SRAM, and EEPROM for nonvolatile
data storage. All memory spaces are linear and require no memory bank switching. Nonvolatile memory (NVM) spaces
can be locked for further write and read/write operations. This prevents unrestricted access to the application software.
A separate memory section contains the fuse bytes. These are used for configuring important system functions, and can
only be written by an external programmer.
XMEGA E MANUAL 20
Atmel–42005E–AVR–XMEGA E–11/2014
of the different sections are fixed, but device-dependent. These two sections have separate lock bits, and can have
different levels of protection. The store program memory (SPM) instruction, used to write to the flash from the application
software, will only operate when executed from the boot loader section.
The application section contains an application table section with separate lock settings. This enables safe storage of
nonvolatile data in the program memory.
Application Flash
Section
Application Table
Flash Section
End Application
Start Boot Loader
Boot Loader Flash
Section
Flashend
XMEGA E MANUAL 21
Atmel–42005E–AVR–XMEGA E–11/2014
4.3.4 Production Signature Row
The production signature row is a separate memory section for factory programmed data. It contains calibration data for
functions such as oscillators and analog modules. Some of the calibration values will be automatically loaded to the
corresponding module or peripheral unit during reset. Other values must be loaded from the signature row and written to
the corresponding peripheral registers from software. For details on calibration conditions such as temperature, voltage
references, etc., refer to the device datasheet.
The production signature row also contains an ID that identifies each microcontroller device type and a serial number for
each manufactured device. The serial number consists of the production lot number, wafer number, and wafer
coordinates for the device.
The production signature row cannot be written or erased, but it can be read from application software and external
programmers.
XMEGA E MANUAL 22
Atmel–42005E–AVR–XMEGA E–11/2014
Figure 4-2. Data Memory Map
Start/End
Data Memory
Address
0x0000
I/O Memory
(Up to 4KB)
0x1000
EEPROM
(Up to 1KB)
0x2000
Internal SRAM
(Up to 4KB)
I/O memory, EEPROM, and SRAM will always have the same start addresses for all XMEGA devices.
4.7 EEPROM
All XMEGA devices have EEPROM for nonvolatile data storage. It is addressable in a separate memory mapped space
and accessed in normal data space. The EEPROM supports both byte and page access. EEPROM is accessible using
load and store instructions, allowing highly efficient EEPROM reading and EEPROM buffer loading. EEPROM always
starts at the hexadecimal address 0x1000.
XMEGA E MANUAL 23
Atmel–42005E–AVR–XMEGA E–11/2014
Figure 4-3. Bus Access
Bus matrix
Event Interrupt
Flash CRC system controller SRAM
Power Oscillator
EEPROM management
USART control
RAM
Timer /
Non-volatile AC SPI Counter
memory
Real Time
ADC TWI Counter
XMEGA
DAC I/O Custom Logic
XMEGA E MANUAL 24
Atmel–42005E–AVR–XMEGA E–11/2014
4.12 I/O Memory Protection
Some features in the device are regarded as critical for safety in some applications. Due to this, it is possible to lock the
I/O register related to the clock system, the event system, and the advanced waveform extensions. As long as the lock is
enabled, all related I/O registers are locked and they can not be written from the application software. The lock registers
themselves are protected by the configuration change protection mechanism. For details, refer to “Configuration Change
Protection” on page 13.
XMEGA E MANUAL 25
Atmel–42005E–AVR–XMEGA E–11/2014
4.13 Register Description – NVM Controller
Bit 7 6 5 4 3 2 1 0
+0x01 ADDR[15:8]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x02 ADDR[23:16]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
XMEGA E MANUAL 26
Atmel–42005E–AVR–XMEGA E–11/2014
4.13.5 DATA1 – Data Register 1
Bit 7 6 5 4 3 2 1 0
+0x05 DATA[15:8]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x06 DATA[23:16]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x0A – CMD[6:0]
Read/Write R R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 – Reserved
This bit is unused and reserved for future use. For compatibility with future devices, always write this bit to zero
when this register is written.
Bit 6:0 – CMD[6:0]: Command
These bits define the programming commands for the flash. Bit 6 is only set for external programming commands.
See “Memory Programming” on page 411 for programming commands.
Bit 7 6 5 4 3 2 1 0
+0x0B – – – – – – – CMDEX
Read/Write R R R R R R R S
Initial value 0 0 0 0 0 0 0 0
XMEGA E MANUAL 27
Atmel–42005E–AVR–XMEGA E–11/2014
4.13.9 CTRLB – Control Register B
Bit 7 6 5 4 3 2 1 0
+0x0C – – – – – – EPRM SPMLOCK
Read/Write R R R R R R R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x0D – – – – SPMLVL[1:0] EELVL[1:0]
Read/Write R R R R R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
XMEGA E MANUAL 28
Atmel–42005E–AVR–XMEGA E–11/2014
4.13.11 STATUS – Status Register
Bit 7 6 5 4 3 2 1 0
+0x0F NVMBUSY FBUSY – – – – EELOAD FLOAD
Read/Write R R R R R R R R
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x10 BLBB[1:0] BLBA[1:0] BLBAT[1:0] LB[1:0]
Read/Write R R R R R R R R
Initial Value 1 1 1 1 1 1 1 1
This register is a mapping of the NVM lock bits into the I/O memory space which enables direct read access from
the application software. Refer to “LOCKBITS – Lock Bit Register” on page 33 for a description.
XMEGA E MANUAL 29
Atmel–42005E–AVR–XMEGA E–11/2014
4.14 Register Descriptions – Fuses and Lock Bits
Bit 7 6 5 4 3 2 1 0
+0x01 WDWPER[3:0] WDPER[3:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x02 – BOOTRST – – – – BODPD[1:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 1 1 1 1 1 1 1 1
Bit 7 – Reserved
This bit is unused and reserved for future use. For compatibility with future devices, always write this bit to one
when this register is written.
Bit 6 – BOOTRST: Boot Loader Section Reset Vector
This fuse can be programmed so the reset vector is pointing to the first address in the boot loader flash section.
The device will then start executing from the boot loader flash section after reset.
XMEGA E MANUAL 30
Atmel–42005E–AVR–XMEGA E–11/2014
Table 4-2. BOD Operation Modes in Sleep Modes
BODPD[1:0] Description
00 Reserved
11 BOD disabled
Bit 7 6 5 4 3 2 1 0
+0x04 – – – RSTDISBL STARTUPTIME[1:0] WDLOCK –
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 1 1 1 1 1 1 1 1
00 64
01 4
10 Reserved
11 0
WDLOCK Description
XMEGA E MANUAL 31
Atmel–42005E–AVR–XMEGA E–11/2014
Bit 0 – Reserved
This bit is unused and reserved for future use. For compatibility with future devices, always write this bit to one
when this register is written.
Bit 7 6 5 4 3 2 1 0
+0x05 – – BODACT[1:0] EESAVE BODLEVEL[2:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 1 1 – – – – – –
BODACT[1:0] Description
00 Reserved
11 BOD disabled
EESAVE Description
Changes to the EESAVE fuse bit take effect immediately after the write timeout elapses. Hence, it is possible to
update EESAVE and perform a chip erase according to the new setting of EESAVE without leaving and reentering
programming mode.
Bit 2:0 – BODLEVEL[2:0]: Brownout Detection Voltage Level
These fuse bits sets the BOD voltage level. Refer to “Reset Sequence” on page 121 for details. For BOD level
nominal values, see Table 9-2 on page 123.
XMEGA E MANUAL 32
Atmel–42005E–AVR–XMEGA E–11/2014
4.14.5 FUSEBYTE6 – Fuse Byte 6
Bit 7 6 5 4 3 2 1 0
+0x06 FDACT5 FDACT4 VALUE[5:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 1 1 1 1 1 1 1 1
FDACT Description
In reset state and until a timer/counter compare channel is enabled, the port pins are forced to the value set in
0
the corresponding VALUEn fuse.
VALUEn Description
Bit 7 6 5 4 3 2 1 0
+0x07 BLBB[1:0] BLBA[1:0] BLBAT[1:0] LB[1:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 1 1 1 1 1 1 1 1
XMEGA E MANUAL 33
Atmel–42005E–AVR–XMEGA E–11/2014
Table 4-9. Boot Lock Bit for the Boot Loader Section
11 NOLOCK No lock – no restrictions for SPM and (E)LPM accessing the boot loader section.
10 WLOCK Write lock – SPM is not allowed to write the boot loader section.
Read lock – (E)LPM executing from the application section is not allowed to
read from the boot loader section.
01 RLOCK
If the interrupt vectors are placed in the application section, interrupts are
disabled while executing from the boot loader section.
Read and write lock – SPM is not allowed to write to the boot loader section, and
(E)LPM executing from the application section is not allowed to read from the
00 RWLOCK boot loader section.
If the interrupt vectors are placed in the application section, interrupts are
disabled while executing from the boot loader section.
11 NOLOCK No Lock - no restrictions for SPM and (E)LPM accessing the application section.
10 WLOCK Write lock – SPM is not allowed to write the application section.
Read lock – (E)LPM executing from the boot loader section is not allowed to
read from the application section.
01 RLOCK
If the interrupt vectors are placed in the boot loader section, interrupts are
disabled while executing from the application section.
Read and write lock – SPM is not allowed to write to the application section, and
(E)LPM executing from the boot loader section is not allowed to read from the
00 RWLOCK application section.
If the interrupt vectors are placed in the boot loader section, interrupts are
disabled while executing from the application section.
XMEGA E MANUAL 34
Atmel–42005E–AVR–XMEGA E–11/2014
Table 4-11. Boot Lock Bit for the Application Table Section
No lock – no restrictions for SPM and (E)LPM accessing the application table
11 NOLOCK
section.
10 WLOCK Write lock – SPM is not allowed to write the application table
Read lock – (E)LPM executing from the boot loader section is not allowed to
read from the application table section.
01 RLOCK
If the interrupt vectors are placed in the boot loader section, interrupts are
disabled while executing from the application section.
Read and write lock – SPM is not allowed to write to the application table
section, and (E)LPM executing from the boot loader section is not allowed to
00 RWLOCK read from the application table section.
If the interrupt vectors are placed in the boot loader section, interrupts are
disabled while executing from the application section.
Write lock – programming of the flash and EEPROM is disabled for the
10 WLOCK programming interface. Fuse bits are locked for write from the programming
interface.
Read and write lock – programming and read/verification of the flash and
00 RWLOCK EEPROM are disabled for the programming interface. The lock bits and fuses
are locked for read and write from the programming interface.
Note: 1. Program the Fuse bits and Boot Lock bits before programming the Lock Bits.
XMEGA E MANUAL 35
Atmel–42005E–AVR–XMEGA E–11/2014
4.15 Register Description – Production Signature Row
Note: The initial value for these registers will read as 0xFFFF if production calibration is not done.
Bit 7 6 5 4 3 2 1 0
+0x00 RCOSC8M[7:0]
Read/Write R R R R R R R R
Initial value x x x x x x x x
Bit 7 6 5 4 3 2 1 0
+0x02 RCOSC32K[7:0]
Read/Write R R R R R R R R
Initial value x x x x x x x x
Bit 7 6 5 4 3 2 1 0
+0x03 RCOSC32M[7:0]
Read/Write R R R R R R R R
Initial value x x x x x x x x
Bit 7 6 5 4 3 2 1 0
+0x04 RCOSC32MA[7:0]
Read/Write R R R R R R R R
Initial value x x x x x x x x
XMEGA E MANUAL 36
Atmel–42005E–AVR–XMEGA E–11/2014
4.15.5 LOTNUM0 – Lot Number Register 0
LOTNUM0, LOTNUM1, LOTNUM2, LOTNUM3, LOTNUM4, and LOTNUM5 contain the lot number for each device.
Together with the wafer number and wafer coordinates, this gives a serial number for the device.
Bit 7 6 5 4 3 2 1 0
+0x08 LOTNUM0[7:0]
Read/Write R R R R R R R R
Initial value x x x x x x x x
Bit 7 6 5 4 3 2 1 0
+0x09 LOTNUM1[7:0]
Read/Write R R R R R R R R
Initial value x x x x x x x x
Bit 7 6 5 4 3 2 1 0
+0x0A LOTNUM2[7:0]
Read/Write R R R R R R R R
Initial value x x x x x x x x
Bit 7 6 5 4 3 2 1 0
+0x0B LOTNUM3[7:0]
Read/Write R R R R R R R R
Initial value x x x x x x x x
Bit 7 6 5 4 3 2 1 0
+0x0C LOTNUM4[7:0]
Read/Write R R R R R R R R
Initial value x x x x x x x x
XMEGA E MANUAL 37
Atmel–42005E–AVR–XMEGA E–11/2014
4.15.10 LOTNUM5 – Lot Number Register 5
Bit 7 6 5 4 3 2 1 0
+0x0D LOTNUM5[7:0]
Read/Write R R R R R R R R
Initial value x x x x x x x x
Bit 7 6 5 4 3 2 1 0
+0x10 WAFNUM[7:0]
Read/Write R R R R R R R R
Initial value 0 0 0 x x x x x
Bit 7 6 5 4 3 2 1 0
+0x13 COORDX1[7:0]
Read/Write R R R R R R R R
Initial value x x x x x x x x
Bit 7 6 5 4 3 2 1 0
+0x14 COORDY0[7:0]
Read/Write R R R R R R R R
Initial value x x x x x x x x
XMEGA E MANUAL 38
Atmel–42005E–AVR–XMEGA E–11/2014
4.15.15 COORDY1 – Wafer Coordinate Y Register 1
Bit 7 6 5 4 3 2 1 0
+0x15 COORDY1[7:0]
Read/Write R R R R R R R R
Initial value x x x x x x x x
Bit 7 6 5 4 3 2 1 0
+0x1E ROOMTEMP[7:0]
Read/Write R R R R R R R R
Initial value x x x x x x x x
Bit 7 6 5 4 3 2 1 0
+0x1F HOTTEMP[7:0]
Read/Write R R R R R R R R
Initial value x x x x x x x x
Bit 7 6 5 4 3 2 1 0
+0x21 ADCACAL1[7:0]
Read/Write R R R R R R R R
Initial value x x x x x x x x
XMEGA E MANUAL 39
Atmel–42005E–AVR–XMEGA E–11/2014
4.15.20 ACACURRCAL – ACA Current Calibration Register
Bit 7 6 5 4 3 2 1 0
+0x28 ACACURRCAL[7:0]
Read/Write R R R R R R R R
Initial value 0 0 0 0 x x x x
Bit 7 6 5 4 3 2 1 0
+0x2D TEMPSENSE3[7:0]
Read/Write R R R R R R R R
Initial value 0 0 0 0 x x x x
XMEGA E MANUAL 40
Atmel–42005E–AVR–XMEGA E–11/2014
4.15.24 TEMPSENSE1 – Temperature Sensor Calibration Register 1
Bit 7 6 5 4 3 2 1 0
+0x2F TEMPSENSE1[7:0]
Read/Write R R R R R R R R
Initial value 0 0 0 0 x x x x
Bit 7 6 5 4 3 2 1 0
+0x30 DACA0OFFCAL[7:0]
Read/Write R R R R R R R R
Initial value 0 0 0 0 x x x x
Bit 7 6 5 4 3 2 1 0
+0x31 DACA0GAINCAL[7:0]
Read/Write R R R R R R R R
Initial value 0 0 0 0 x x x x
Bit 7 6 5 4 3 2 1 0
+0x34 DACA1OFFCAL[7:0]
Read/Write R R R R R R R R
Initial value 0 0 0 0 x x x x
XMEGA E MANUAL 41
Atmel–42005E–AVR–XMEGA E–11/2014
4.15.28 DACA1GAINCAL – DACA Gain Calibration Register
Bit 7 6 5 4 3 2 1 0
+0x35 DACA1GAINCAL[7:0]
Read/Write R R R R R R R R
Initial value 0 0 0 0 x x x x
Bit 7 6 5 4 3 2 1 0
+n GPIORn[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
These are general purpose registers that can be used to store data, such as global variables and flags, in the bit-
accessible I/O memory space.
Bit 7 6 5 4 3 2 1 0
+0x01 DEVID1[7:0]
Read/Write R R R R R R R R
Initial value 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0
XMEGA E MANUAL 42
Atmel–42005E–AVR–XMEGA E–11/2014
4.17.3 DEVID2 – Device ID Register 2
Bit 7 6 5 4 3 2 1 0
+0x02 DEVID2[7:0]
Read/Write R R R R R R R R
Initial value 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0
Bit 7 6 5 4 3 2 1 0
+0x03 – – – – REVID[3:0]
Read/Write R R R R R R R R
Initial value 0 0 0 0 1/0 1/0 1/0 1/0
Bit 7 6 5 4 3 2 1 0
+0x07 – – – – STARTUPDLYD[1:0] STARTUPDLYA[1:0]
Read/Write R R R R R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
11 2CLK 2 * ClkPER
10 8CLK 8 * ClkPER
11 32CLK 32 * ClkPER
XMEGA E MANUAL 43
Atmel–42005E–AVR–XMEGA E–11/2014
4.17.6 EVSYSLOCK – Event System Lock Register
Bit 7 6 5 4 3 2 1 0
+0x08 – – – EVSYS1LOCK – – – EVSYS0LOCK
Read/Write R R R R/W R R R R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x09 – – – – – – – WEXCLOCK
Read/Write R R R R R R R R/W
Initial value 0 0 0 0 0 0 0 0
XMEGA E MANUAL 44
Atmel–42005E–AVR–XMEGA E–11/2014
4.17.8 FAULTLOCK – Fault Extension Lock Register
Bit 7 6 5 4 3 2 1 0
+0x03 – – – – – – FAULTC5LOCK FAULTC4LOCK
Read/Write R R R R R R R R
Initial value 0 0 0 0 0 0 0 0
XMEGA E MANUAL 45
Atmel–42005E–AVR–XMEGA E–11/2014
4.18 Register Summary – NVM Controller
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Page
+0x00 Reserved - - - - - - - -
+0x01 FUSEBYTE1 WDWPER[3:0] WDPER[3:0] 30
+0x02 FUSEBYTE2 - BOOTRST - - - - BODPD[1:0] 30
+0x03 Reserved - - - - - - - -
+0x04 FUSEBYTE4 - - - RSTDISBL STARTUPTIME[1:0] WDLOCK - 31
+0x05 FUSEBYTE5 - - BODACT[1:0] EESAVE BODLEVEL[2:0] 32
+0x06 FUSEBYTE6 FDACT5 FDACT4 VALUE[5:0] 33
+0x07 LOCKBITS BLBB[1:0] BLBA[1:0] BLBAT[1:0] LB[1:0] 33
XMEGA E MANUAL 46
Atmel–42005E–AVR–XMEGA E–11/2014
Address Auto Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 3 Bit 1 Bit 0 Page
XMEGA E MANUAL 47
Atmel–42005E–AVR–XMEGA E–11/2014
Address Auto Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 3 Bit 1 Bit 0 Page
XMEGA E MANUAL 48
Atmel–42005E–AVR–XMEGA E–11/2014
4.21 Register Summary – General Purpose I/O Registers
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Page
+0x05 Reserved - - - - - - - -
+0x06 Reserved - - - - - - - -
+0x07 Reserved - - - - - - - -
+0x08 Reserved - - - - - - - -
+0x09 Reserved - - - - - - - -
+0x0A Reserved - - - - - - - -
+0x0B Reserved - - - - - - - -
+0x0C Reserved - - - - - - - -
+0x0D Reserved - - - - - - - -
+0x0E Reserved - - - - - - - -
+0x0F Reserved - - - - - - - -
Table 4-14. NVM Interrupt vectors and their word offset address from NVM controller interrupt base.
XMEGA E MANUAL 49
Atmel–42005E–AVR–XMEGA E–11/2014
5. EDMA – Enhanced Direct Memory Access
5.1 Features
The EDMA Controller allows data transfers with minimal CPU intervention
From data memory to data memory
From data memory to peripheral
From peripheral to data memory
From peripheral to peripheral
Four peripheral EDMA channels with separate:
Transfer triggers
Interrupt vectors
Addressing modes
Data match
Up to two standard EDMA with separate:
Transfer triggers
Interrupt vectors
Addressing modes
Data search
Programmable channel priority
From 1 byte to 128KB of data in a single transaction
Up to 64K block transfer with repeat
1 or 2 bytes burst transfers
Multiple addressing modes
Static
Increment
Optional reload of source and destination address at the end of each
Burst
Block
Transaction
Optional Interrupt on end of transaction
Optional connection to CRC Generator module for CRC on EDMA data
5.2 Overview
The enhanced direct memory access (EDMA) controller can transfer data between memories and peripherals, and thus
off-load these tasks from the CPU. It enables high data transfer rates with minimum CPU intervention, and frees up CPU
time. The four EDMA channels enable up to four independent and parallel transfers.
The EDMA controller can move data between SRAM and peripherals, between SRAM locations and directly between
peripheral registers. With access to all peripherals, the EDMA controller can handle automatic transfer of data to/from
communication modules. The EDMA controller can also read from memory mapped EEPROM.
Data transfers are done in continuous bursts of 1 or 2 bytes. They build block transfers of configurable size from 1 byte to
64KB. Repeat option can be used to repeat once each block transfer for single transactions up to 128KB. Source and
destination addressing can be static or incremental. Automatic reload of source and/or destination addresses can be
done after each burst or block transfer, or when a transaction is complete. Application software, peripherals, and events
can trigger EDMA transfers.
The EDMA channels have individual configuration and control settings. This includes source or destination pointers,
transfer triggers, and transaction sizes. They have individual interrupt settings. Interrupt requests can be generated when
a transaction is complete or when the EDMA controller detects an error on an EDMA channel.
To have flexibility in transfers, channels can be interlinked so that the second takes over the transfer when the first is
finished.
XMEGA E MANUAL 50
Atmel–42005E–AVR–XMEGA E–11/2014
The EDMA controller supports extended features such as double buffering, data match for peripherals or data search for
SRAM or EEPROM.
The EDMA controller supports two types of channel. Each channel type can be selected individually.
XMEGA E MANUAL 51
Atmel–42005E–AVR–XMEGA E–11/2014
Figure 5-2. EDMA – Full Standard Channel Mode Overview
Slave port
Read /
Write
EDMA transaction
XMEGA E MANUAL 52
Atmel–42005E–AVR–XMEGA E–11/2014
A complete EDMA read and write operation between memories and/or peripherals is called an EDMA transaction. A
transaction is done in data blocks, and the size of the transaction (number of bytes to transfer) is selectable from
software and controlled by the block size and repeat bit settings. Each block transfer is divided into bursts.
XMEGA E MANUAL 53
Atmel–42005E–AVR–XMEGA E–11/2014
When 2-byte burst option is used to address 16-bit peripheral, the first byte access of the burst will be for the low byte of
the 16-bit register (ex: ACDA.CH0RESL) the second, for the high byte (ex: ACDA.CH0RESH). The 1-byte burst option is
reserved for 8-bit peripherals.
XMEGA E MANUAL 54
Atmel–42005E–AVR–XMEGA E–11/2014
Figure 5-5. EDMA - Double Buffer Modes Versus Channel Modes
Per-Ch0 Per-Ch0
Std-Ch0 Std-Ch0
m ble
m ble
e
e
Per-Ch1 Per-Ch1
od
od
DBUFMODE=01
er u
er u
ff d o
ff d o
Per-Ch2 Per-Ch2 (BUF01)
bu no
bu no
Std-Ch2 Std-Ch2
Per-Ch3 Per-Ch3
Per-Ch0 Per-Ch0
Std-Ch0 Std-Ch0
m ble
m ble
Per-Ch1
e
Per-Ch1 DBUFMODE=10
od
od
er u
er u
ff d o
ff do
Per-Ch2 Per-Ch2 (BUF23)
bu no
bu no
Std-Ch2 Std-Ch2
Per-Ch3 Per-Ch3
Per-Ch0 Per-Ch0
Std-Ch0 Std-Ch0
Per-Ch1 Per-Ch1 DBUFMODE=11
Per-Ch2 Per-Ch2 (BUF0123)
Std-Ch2 Std-Ch2
Per-Ch3 Per-Ch3
XMEGA E MANUAL 55
Atmel–42005E–AVR–XMEGA E–11/2014
Figure 5-6. EDMA – Data Match
st t
1 occurrence of ((peripheral _data & mask ) == (data & mask)) = Match
t
Update : data <= peripheral _data
st t t
1 occurrence of either (peripheral _data == data 1) or (peripheral _data == data 2) = Match
t
Update: data1 <= peripheral _data
t
st
1 occurrence of ((peripheral _data , peripheral _data t+1 == (data1 , data 2)) = Match
t
data1 = peripheral_data
t+1
data2 = peripheral_data
t-1 t t+1
serialized
(2-byte burst length) 16 -bit input
from peripheral
- - time
st t
1 occurrence of ((peripheral _data == (data 1, data 2)) = Match
t
data1 = ( lsb ) peripheral _data
t
data2 = (msb) peripheral_data
XMEGA E MANUAL 56
Atmel–42005E–AVR–XMEGA E–11/2014
Figure 5-7. EDMA – Data Search
1 s t occurrence of ((mem_buf [n] & mask) == (data & mask)) = Match Pointer position on match
1s t occurrence of either (mem_buf [n] == data 1) or (mem_buf [n] == data 2) = Match Pointer position on match
1s t occurrence of ((mem_buf [n], mem_buf [n+1]) == (data1 , data 2)) = Match Pointer position on match
st
1 occurrence of (mem_buf [2]) == (data1 , data2)) = Match Pointer position on match
XMEGA E MANUAL 57
Atmel–42005E–AVR–XMEGA E–11/2014
5.11 Protection
In order to enable a safe operation:
The channel mode bits (CTRL.CHMODE) are protected against user modification when the EDMA controller is
enabled (ENABLE=1)
Some channel bits and registers are protected against user modification during a transaction (CTRL.ENABLE=1):
REPEAT and SINGLE bits in CTRLA register
ADDCTRL (SRCADDCRTL) and DESTADDCTRL registers
ADDR (SRCADDR) and DESTADDR 16-bit registers
TRFCNTL (TRFCNT) and TRFCNTH registers.
Note that TRFREQ bit in CTRLA register and TRIGSRC register are not protected.
5.12 Interrupts
The EDMA controller can generate interrupts when an error is detected on an EDMA channel or when a transaction is
complete for an EDMA channel. Each EDMA channel has a separate interrupt vector, and there are different interrupt
flags for error and transaction complete.
XMEGA E MANUAL 58
Atmel–42005E–AVR–XMEGA E–11/2014
5.13 Register Description – EDMA Controller
Bit 7 6 5 4 3 2 1 0
+0x00 ENABLE RESET CHMODE[1:0] DBUFMODE[1:0] PRIMODE[1:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
This field can be set only when the EDMA controller is disabled (ENABLE = 0).
Bit 3:2 – DBUFMODE[1:0]: Double Buffer Mode
These bits enable the double buffer on the different channels according to Table 5-2 on page 59.
- If CHMOD = 00:
Double buffer enabled on peripheral channels 0
and 1 and also on peripheral channels 2 and 3
11 BUF0123
- If CHMOD ! = 00:
Double buffer enabled on channels 0 and 2
(irrespective of the channel configuration)
XMEGA E MANUAL 59
Atmel–42005E–AVR–XMEGA E–11/2014
In buffer modes, REPEAT bit of each channel controls the link (ex: to set-up a link from CHx to CHy, REPEAT bit of CHy
must be set).
There are no predefined channels order in the double buffer mode. The first channel that is enabled by software starts
first and, at the end of its transaction, it enables the second channel for a new transaction if the corresponding REPEAT
bit is set (hardware setting of CTRLA.ENABLE bit).
Bit 1:0 – PRIMODE[1:0]: Priority Mode
These bits determine the internal channel priority according to Table 5-3 on page 60.
Bit 7 6 5 4 3 2 1 0
+0x03 CH3ERRIF CH2ERRIF CH1ERRIF CH0ERRIF CH3TRNIF CH2TRNIF CH1TRNIF CH0TRNIF
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x04 CH3BUSY CH2BUSY CH1BUSY CH0BUSY CH3PEND CH2PEND CH1PEND CH0PEND
Read/Write R R R R R R R R
Initial value 0 0 0 0 0 0 0 0
XMEGA E MANUAL 60
Atmel–42005E–AVR–XMEGA E–11/2014
5.13.4 TEMP – Temporary Register
Bit 7 6 5 4 3 2 1 0
+0x06 TEMP[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x00 ENABLE RESET REPEAT TRFREQ – SINGLE – BURSTLEN
Read/Write R/W R/W R/W R/W R R/W R R/W
Initial value 0 0 0 0 0 0 0 0
XMEGA E MANUAL 61
Atmel–42005E–AVR–XMEGA E–11/2014
Table 5-4. Peripheral Channel Burst Length
Bit 7 6 5 4 3 2 1 0
+0x01 CHBUSY CHPEND ERRIF TRNIF ERRINTLVL[1:0] TRNINTLVL[1:0]
Read/Write R R R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
XMEGA E MANUAL 62
Atmel–42005E–AVR–XMEGA E–11/2014
5.14.3 ADDCTRL – Address Control Register
Bit 7 6 5 4 3 2 1 0
+0x02 - - RELOAD[1:0] - DIR[2:0]
Read/Write R R R/W R/W R R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
01 BLOCK Memory address register is reloaded with initial value at end of each block transfer.
10 BURST Memory address register is reloaded with initial value at end of each burst transfer.
11 TRANSACTION Memory address register is reloaded with initial value at end of each transaction.
Bit 3 – Reserved
This bit is unused and reserved for future use. For compatibility with future devices, always write this bit to zero
when this register is written.
Bit 2:0 – DIR[2:0]: Memory Address Mode
These bits decide the memory address mode, according to Table 5-6 on page 63 and Table 5-7 on page 63.
These bits cannot be changed if the channel is busy.
010 – Reserved
011 – Reserved
1xx – Reserved
010 – Reserved
XMEGA E MANUAL 63
Atmel–42005E–AVR–XMEGA E–11/2014
DIR[2:0] Group configuration Description
011 – Reserved
“Mask-Match” (1 byte)
- data: ADDRL register
100 DP1
- mask: ADDRH register (active bit-mask=1)
Note: Only available in 1-byte burst length mode
“OR-Match” (1 byte)
- data1: ADDRL register
101 DP2 OR
- data2: ADDRH register
Note: Only available in 1-byte burst length mode
111 – Reserved
Bit 7 6 5 4 3 2 1 0
+0x04 TRIGSRC[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Note: 1. It is recommended to set BURST2 configuration when reading or writing 16-bits registers.
XMEGA E MANUAL 64
Atmel–42005E–AVR–XMEGA E–11/2014
Table 5-9. EDMA Trigger Source Offset Values for ADC Triggers
ADC channel 0
+0x00 CH0 - transfer direction: peripheral to memory
- EDMA reads CH0RES register
Table 5-10. EDMA Trigger Source Offset Values for DAC Triggers
DAC channel 0
+0x00 CH0 - transfer direction: memory to peripheral
- EDMA writes CH0DATA register
DAC channel 1
+0x01 CH1 - transfer direction: memory to peripheral
- EDMA writes CH1DATA register
Table 5-11. EDMA Trigger Source Offset Values for USART Triggers
Receive complete
+0x00 RXC - transfer direction: peripheral to memory
- EDMA reads DATA register
Table 5-12. EDMA Trigger Source Offset Values for SPI Triggers
XMEGA E MANUAL 65
Atmel–42005E–AVR–XMEGA E–11/2014
5.14.5 TRFCNT – Block Transfer Count Register
TRFCNT defines the number of bytes in a block transfer. The value of TRFCNT is decremented after each byte read by
the EDMA channel.
When TRFCNT reaches zero, the register is reloaded with the last value written to it.
Bit 7 6 5 4 3 2 1 0
+0x06 TRFCNT[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 1
Bit 7 6 5 4 3 2 1 0
+0x09 ADDR[15:8]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
XMEGA E MANUAL 66
Atmel–42005E–AVR–XMEGA E–11/2014
5.15 Register Description – Standard Channel
Bit 7 6 5 4 3 2 1 0
+0x00 ENABLE RESET REPEAT TRFREQ - SINGLE - BURSTLEN
Read/Write R/W R/W R/W R/W R R/W R R/W
Initial value 0 0 0 0 0 0 0 0
XMEGA E MANUAL 67
Atmel–42005E–AVR–XMEGA E–11/2014
5.15.2 CTRLB – Control Register B
Bit 7 6 5 4 3 2 1 0
+0x01 CHBUSY CHPEND ERRIF TRNIF ERRINTLVL[1:0] TRNINTLVL[1:0]
Read/Write R R R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x02 - - SRCRELOAD[1:0] - SRCDIR[2:0]
Read/Write R R R/W R/W R R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
XMEGA E MANUAL 68
Atmel–42005E–AVR–XMEGA E–11/2014
Table 5-14. Source Address Reload Settings
Source address register is reloaded with initial value at end of each block
01 BLOCK
transfer.
Source address register is reloaded with initial value at end of each burst
10 BURST
transfer.
Bit 3 – Reserved
This bit is unused and reserved for future use. For compatibility with future devices, always write this bit to zero
when this register is written.
Bit 2:0 – SRCDIR[2:0]: Source Address Mode
These bits decide the source address mode, according to Table 5-15 on page 69.
These bits cannot be changed if the channel is busy.
010 - Reserved
011 - Reserved
1xx - Reserved
Bit 7 6 5 4 3 2 1 0
+0x03 - - DESTRELOAD[1:0] - DESTDIR[2:0
Read/Write R R R/W R/W R R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
XMEGA E MANUAL 69
Atmel–42005E–AVR–XMEGA E–11/2014
Table 5-16. EDMA Channel Source Address Reload Settings
Bit 3 – Reserved
This bit is unused and reserved for future use. For compatibility with future devices, always write this bit to zero
when this register is written.
Bit 2:0 – DESTDIR[2:0]: Destination Address Mode
These bits decide the destination address mode, according to Table 5-17 on page 70.
These bits cannot be changed if the channel is busy.
010 - Reserved
011 - Reserved
“Mask-Search” (1 byte)
- data: DESTADDRL register
100 DP1
- mask: DESTADDRH register (active bit-mask=1)
Note: Only available in 1-byte burst length mode
“OR-Search” (1 byte)
- data1: DESTADDRL register
101 DP2 OR
- data2: DESTADDRH register
Note: Only available in 1-byte burst length mode
111 - Reserved
XMEGA E MANUAL 70
Atmel–42005E–AVR–XMEGA E–11/2014
5.15.5 TRIGSRC – Trigger Source Register
Bit 7 6 5 4 3 2 1 0
+0x04 TRIGSRC[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Table 5-18. EDMA Trigger Source Base Values for all Modules and Peripherals
Table 5-19. EDMA Trigger Source Offset Values for ADC Triggers
Table 5-20. EDMA Trigger Source Offset Values for DAC Triggers
XMEGA E MANUAL 71
Atmel–42005E–AVR–XMEGA E–11/2014
Table 5-21. EDMA Trigger Source Offset Values for Event System Triggers
Table 5-22. EDMA Trigger Source Offset Values for Event System Triggers
Table 5-23. EDMA Trigger Source Offset Values for USART Triggers
Table 5-24. EDMA Trigger Source Offset Values for SPI Triggers
The group configuration is the “base_offset;” for example, TCC5_CCA for the timer/counter C5 CC channel A the transfer
trigger.
XMEGA E MANUAL 72
Atmel–42005E–AVR–XMEGA E–11/2014
5.15.6 TRFCNTL – Block Transfer Count Register Low
The TRFCNTH and TRFCNTL register pair represents the 16-bit value TRFCNT. TRFCNT defines the number of bytes
in a block transfer. The value of TRFCNT is decremented after each byte read by the EDMA standard channel.
The default value of this 16-bit register is 0x0101 (not 0x0001). If the user writes 0x0000 to this 16-bit register and fires
an EDMA trigger, EDMA will perform 65536 transfers or searches.
When TRFCNT reaches zero, the register is reloaded with the last value written to it.
Bit 7 6 5 4 3 2 1 0
+0x06 TRFCNT[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 1
Bit 7 6 5 4 3 2 1 0
+0x07 TRFCNT [15:8]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 1
Bit 7 6 5 4 3 2 1 0
+0x09 SRCADDR[15:8]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
XMEGA E MANUAL 73
Atmel–42005E–AVR–XMEGA E–11/2014
5.15.10 DESTADDRL – Destination Address Register Low
DESTADDRL and DESTADDRH represent the16-bit value DESTADDR, which is the destination address in a transaction
executed by a standard channel. DESTADDRH is the most significant byte in the register. DESTADDR may be
automatically incremented based on settings in the DESTDIR bits in “DESTADDCTRL – Destination Address Control
Register” .
In data search mode, DESTADDR is used for data to recognize according to Table 5-17 on page 70.
Bit 7 6 5 4 3 2 1 0
+0x08 DESTADDR[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x09 DESTADDR[15:8]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
XMEGA E MANUAL 74
Atmel–42005E–AVR–XMEGA E–11/2014
5.16 Register Summary – EDMA Controller in PER0123 Configuration
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Page
+0x01 Reserved – – – – – – – –
+0x02 Reserved – – – – – – – –
+0x04 STATUS CH3BUSY CH2BUSY CH1BUSY CH0BUSY CH3PEND CH2PEND CH1PEND CH0PEND 60
+0x05 Reserved – – – – – – – –
+0x07 Reserved – – – – – – – –
+0x01 Reserved – – – – – – – –
+0x02 Reserved – – – – – – – –
+0x05 Reserved – – – – – – – –
+0x07 Reserved – – – – – – – –
+0x20/0x2F Reserved – – – – – – – –
XMEGA E MANUAL 75
Atmel–42005E–AVR–XMEGA E–11/2014
5.18 Register Summary – EDMA Controller in STD2 Configuration
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 bit 0 Page
+0x01 Reserved – – – – – – – –
+0x02 Reserved – – – – – – – –
CH1ERRI
+0x03 INTFLAGS – CH2ERRIF
F
CH0ERRIF – CH2TRNFIF CH1TRNFIF CH0TRNFIF 60
+0x05 Reserved – – – – – – – –
+0x07 Reserved – – – – – – – –
+0x40/0x4F Reserved – – – – – – – –
+0x01 Reserved – – – – – – – –
+0x02 Reserved – – – – – – – –
+0x05 Reserved – – – – – – – –
+0x07 Reserved – – – – – – – –
+0x20/0x2F Reserved – – – – – – – –
+0x40/0x4F Reserved – – – – – – – –
XMEGA E MANUAL 76
Atmel–42005E–AVR–XMEGA E–11/2014
5.20 Register Summary – EDMA Peripheral Channel
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Page
+0x03 Reserved – – – – – – – –
+0x05 Reserved – – – – – – – –
+0x07 Reserved – – – – – – – –
+0x0A Reserved – – – – – – – –
+0x0B Reserved – – – – – – – –
+0x0C Reserved – – – – – – – –
+0x0D Reserved – – – – – – – –
+0x0E Reserved – – – – – – – –
+0x0F Reserved – – – – – – – –
+0x05 Reserved – – – – – – – –
+0x0A Reserved – – – – – – – –
+0x0B Reserved – – – – – – – –
+0x0E Reserved – – – – – – – –
+0x0F Reserved – – – – – – – –
XMEGA E MANUAL 77
Atmel–42005E–AVR–XMEGA E–11/2014
5.22 Interrupt Vector Summary
Table 5-25. EDMA Interrupt Vectors and their Word Offset Addresses from the EDMA Controller Interrupt Base
XMEGA E MANUAL 78
Atmel–42005E–AVR–XMEGA E–11/2014
6. Event System
6.1 Features
System for direct peripheral-to-peripheral communication and signalling
Peripherals can directly send, receive, and react to peripheral events
CPU and EDMA controller independent operation
100% predictable signal timing
Short and guaranteed response time
Eight event channels for up to eight different and parallel signal routings and configurations
Events can be sent and/or used by most peripherals, clock system, and software
Additional functions include
Quadrature decoders with rotary filtering
Digital filtering of I/O pin state with flexible prescaler clock options
Simultaneous synchronous and asynchronous events provided to peripheral
Works in all sleep modes
6.2 Overview
The event system enables direct peripheral-to-peripheral communication and signalling. It allows a change in one
peripheral’s state to automatically trigger actions in other peripherals. It is designed to provide a predictable system for
short and predictable response times between peripherals. It allows for autonomous peripheral control and interaction
without the use of interrupts, CPU, or EDMA controller resources, and is thus a powerful tool for reducing the complexity,
size and execution time of application code. It allows for synchronized timing of actions in several peripheral modules.
The event system enables also asynchronous event routing for instant actions in peripherals.
A change in a peripheral’s state is referred to as an event, and usually corresponds to the peripheral’s interrupt
conditions. Events can be directly passed to other peripherals using a dedicated routing network called the event routing
network. How events are routed and used by the peripherals is configured in software.
Figure 6-1 on page 80 shows a basic diagram of all connected peripherals. The event system can directly connect
together analog to digital converters, analog comparators, I/O port pins, the real-time counter, timer/counters, IR
communication module (IRCOM) and XMEGA Custom Logic (XCL). It can also be used to trigger EDMA transactions
(EDMA controller). Events can also be generated from software and peripheral clock.
XMEGA E MANUAL 79
Atmel–42005E–AVR–XMEGA E–11/2014
Figure 6-1. Event System Overview and Connected Peripherals
CPU / EDMA
Software Controller
Real Time
Event Counter
AC System
Controller Timer /
Counters
DAC XMEGA
Custom Logic
The event routing network consists of eight software-configurable multiplexers that control how events are routed and
used. These are called event channels, and allow up to eight parallel event configurations and routings. The maximum
routing latency of an external synchronous event is two peripheral clock cycles due to re-synchronization, but several
peripherals can directly use the asynchronous event without any clock delay. The event system works in all sleep modes,
but only asynchronous events can be routed in sleep modes where the system clock is not available.
6.3 Events
In the context of the event system, an indication that a change of state within a peripheral has occurred is called an
event. There are three main types of events: signalling events, synchronous data events, and asynchronous data events.
Signalling events only indicate a change of state while data events contain additional information about the event.
The peripheral from which the event originates is called the event generator. Within each peripheral (for example, a
timer/counter), there can be several event sources, such as a timer compare match or timer overflow. The peripheral
using the event is called the event user, and the action that is triggered is called the event action.
Timer/Counter ADC
Compare Match
Event Syncsweep
Over-/Underflow
| Routing
Network Single
Conversion
Error
XMEGA E MANUAL 80
Atmel–42005E–AVR–XMEGA E–11/2014
6.4 Signalling Events
Signalling events are the most basic type of event. A signalling event does not contain any information apart from the
indication of a change in a peripheral. Most peripherals can only generate and use signalling events. Unless otherwise
stated, all occurrences of the word ”event” are to be understood as meaning signalling events, which is a strobe.
0 0 No Event No Event
XMEGA E MANUAL 81
Atmel–42005E–AVR–XMEGA E–11/2014
Figure 6-3. Event Routing Network
Event Channel 7
Event Channel 6
Event Channel 5
Event Channel 4
Event Channel 3
Event Channel 2
Event Channel 1
Event Channel 0
(PORTC)
(8) TCC4 (6)
TCC5 (4)
CH0CTRL[7:0]
(PORTD) CH0MUX[7:0]
(8)
TCD5 (4)
CH1CTRL[7:0]
CH1MUX[7:0]
CH2CTRL[7:0]
(30) CH2MUX[7:0]
(8) ADCA (1)
(8)
(ACA)
(8) AC0 (3) CH3CTRL[7:0]
CH4MUX[7:0]
ClkPER (16)
CH5CTRL[7:0]
CH5MUX[7:0]
CH6CTRL[7:0]
CH6MUX[7:0]
(24)
PORTA (8)
PORTC (8)
PORTD (8)
CH7CTRL[7:0]
CH7MUX[7:0]
Eight multiplexers means that it is possible to route up to eight events at the same time. It is also possible to route one
event through several multiplexers.
Not all XMEGA devices contain all peripherals. This only means that a peripheral is not available for generating or using
events. The network configuration itself is compatible between all devices.
Event selection for each channel and event type is shown in Table 6-2 on page 83:
XMEGA E MANUAL 82
Atmel–42005E–AVR–XMEGA E–11/2014
Table 6-2. Event Selection and Event Type
Event type
RTC_OVF x x
RTC
RTC_CMP x x
AC_CH0 x x
AC AC_CH1 x x
AC_WIN x
ADC ADC_CH x
PRESCALER PRESC_M x
PORTn_PIN0 x x x
PORTn_PIN1 x x x
PORTn_PIN2 x x x
PORTn_PIN3 x x x
PORTn
PORTn_PIN4 x x x
PORTn_PIN5 x x x
PORTn_PIN6 x x x
PORTn_PIN7 x x x
TC4_OVF x
TC4_ERR x
TC4_CCA x
TC4
TC4_CCB x
TC4_CCC x
TC4_CCD x
TC5_OVF x
TC5_ERR x
TC5
TC5_CCA x
TC5_CCB x
XMEGA E MANUAL 83
Atmel–42005E–AVR–XMEGA E–11/2014
Event type
XCL_UNF0 x
XCL_UNF1 x
XCL_CC0 x
XCL_CC1 x
XCL
XCL_PEC0 x
XCL_PEC1 x
XCL_LUT0 x x x
XCL_LUT1 x x x
6.10 Filtering
Each event channel includes a digital filter. When this is enabled, an event must be sampled with the same value for a
configurable number of system clock or prescaler clock cycles before it is accepted. This is primarily intended for pin
change events. The default clock for a digital filter is the system clock. Optionally, the clock can be divided by using the
prescaler with individual settings for each channel 0 to channel 3 or channel 4 to channel 7.
Event channels with quadrature decoder extension support rotary filter. Figure 6-4 on page 85 shows the output signals
of the rotary filter. The rotary filter output controls the QDEC up, down and index operation. The digital filter can be
enabled when using the rotary encoder.
XMEGA E MANUAL 84
Atmel–42005E–AVR–XMEGA E–11/2014
Figure 6-4. Rotary Encoder Output Signals
FORWARD
PHASE0
DETECTA
PHASE90 DETECTC
PHASE0 DETECTD
DETECTB
unglitch
PHASE90
unglitch
PHASE Q0 Q2 Q3 Q1 Q0 Q2 Q3 Q1
PHASE EVENT
DIRECTION
BACKWARD
PHASE0
DETECTB
PHASE90 DETECTD
DETECTC
PHASE0
unglitch DETECTA
PHASE90
unglitch
PHASE Q0 Q1 Q3 Q2 Q0 Q1 Q3 Q2
DIRECTION
XMEGA E MANUAL 85
Atmel–42005E–AVR–XMEGA E–11/2014
Table 6-3. Quadrature Decoder Data Events
0 0 No Event No Event
0 1 Index/reset No Event
Forward Direction
QDPH0
QDPH90
QDINDX
00 10 11 01
Backward
Direction
QDPH0
QDPH90
QDINDX
01 11 10 00
Figure 6-5 on page 86 shows typical quadrature signals from a rotary encoder. The signals QDPH0 and QDPH90 are the
two quadrature signals. When QDPH90 leads QDPH0, the rotation is defined as positive or forward. When QDPH0 leads
QDPH90, the rotation is defined as negative or reverse. The concatenation of the two phase signals is called the
quadrature state or the phase state.
In order to know the absolute rotary displacement, a third index signal (QDINDX) can be used. This gives an indication
once per revolution.
XMEGA E MANUAL 86
Atmel–42005E–AVR–XMEGA E–11/2014
3. Set the pin configuration for QDPH0 and QDPH90 to low level sense.
4. Select the QDPH0 pin as a multiplexer input for an event channel, n.
5. Enable quadrature decoding and digital filtering in the event channel.
6. Optional:
1. Set the digital filter control register (DFCTRL) options.
2. Set up a QDEC index (QINDX).
3. Select a third pin for QINDX input.
4. Set the pin direction for QINDX as input.
5. Set the pin configuration for QINDX to sense both edges.
6. Select QINDX as a multiplexer input for event channel n+1.
7. Set the quadrature index enable bit in event channel n+1.
8. Select the index recognition mode for event channel n+1.
9. Set quadrature decoding as the event action for a timer/counter.
10. Select event channel n as the event source for the timer/counter.
Set the period register of the timer/counter to ('line count' * 4 - 1), the line count of the quadrature encoder
Enable the timer/counter without clock prescaling
The angle of a quadrature encoder attached to QDPH0, QDPH90 (and QINDX) can now be read directly from the
timer/counter count register. If the count register is different from BOTTOM when the index is recognized, the
timer/counter error flag is set. Similarly, the error flag is set if the position counter passes BOTTOM without the
recognition of the index.
XMEGA E MANUAL 87
Atmel–42005E–AVR–XMEGA E–11/2014
6.12 Register Description
Bit 7 6 5 4 3 2 1 0
+n CHnMUX[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
0000 0 0 0 1 (Reserved)
0000 0 0 1 x (Reserved)
0000 0 1 x x (Reserved)
0000 1 0 1 x (Reserved)
0000 1 1 x x (Reserved)
0001 0 x x x (Reserved)
0010 x x x x (Reserved)
0011 x x x X (Reserved)
0100 x x x x (Reserved)
0101 1 x x x (Reserved)
0111 x x x x (Reserved)
XMEGA E MANUAL 88
Atmel–42005E–AVR–XMEGA E–11/2014
CHnMUX[7:4] CHnMUX[3:0] Group configuration Event source
1001 x x x x (Reserved)
1010 x x x x (Reserved)
1011 1 x x x (Reserved)
1101 0 x X x (Reserved)
1110 x x x x (Reserved)
1111 x x x x (Reserved)
Note: 1. The description of how the ports generate events is described in “Port Event” on page 146.
0 1 x (Reserved)
XMEGA E MANUAL 89
Atmel–42005E–AVR–XMEGA E–11/2014
6.12.2 CHnCTRL – Event Channel n Control Register
Bit 7 6 5 4 3 2 1 0
+8x08 +n ROTARY QDIRM[1:0] QDIEN QDEN DIGFILT[2:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
XMEGA E MANUAL 90
Atmel–42005E–AVR–XMEGA E–11/2014
6.12.3 STROBE – Event Strobe Register
If the STROBE register location is written, each event channel will be set according to the STROBE[n] and corresponding
DATA[n] bit settings, if any are unequal to zero.
A single event lasting for one peripheral clock cycle will be generated.
Bit 7 6 5 4 3 2 1 0
+0x10 STROBE[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x12 PRESCFILT[3:0] FILTSEL PRESC[2:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
XMEGA E MANUAL 91
Atmel–42005E–AVR–XMEGA E–11/2014
Table 6-10. Prescaler Options
101 – (Reserved)
110 – (Reserved)
1111 – (Reserved)
XMEGA E MANUAL 92
Atmel–42005E–AVR–XMEGA E–11/2014
6.13 Register Summary
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Page
XMEGA E MANUAL 93
Atmel–42005E–AVR–XMEGA E–11/2014
7. System Clock and Clock Options
7.1 Features
Fast start-up time
Safe run-time clock switching
Internal oscillators:
32MHz run-time calibrated oscillator
8MHz calibrated oscillator with 2MHz output and fast start-up
32.768kHz calibrated oscillator
32kHz ultra low power (ULP) oscillator with 1kHz output
External clock options
0.4MHz - 16MHz crystal oscillator
32.768kHz crystal oscillator
External clock
PLL with 20MHz - 128MHz output frequency
Internal and external clock options and 1× to 31× multiplication
Lock detector
Clock prescalers with 1× to 2048× division
Fast peripheral clocks running at 2 and 4 times the CPU clock
Automatic run-time calibration of internal 32MHz oscillator
External oscillator and PLL lock failure detection with optional non-maskable interrupt
7.2 Overview
XMEGA devices have a flexible clock system supporting a large number of clock sources. It incorporates both accurate
internal oscillators and external crystal oscillator and resonator support. A high-frequency phase locked loop (PLL) and
clock prescalers can be used to generate a wide range of clock frequencies. A calibration feature (DFLL) is available,
and can be used for automatic run-time calibration of the internal oscillators to remove frequency drift over voltage and
temperature. An oscillator failure monitor can be enabled to issue a non-maskable interrupt and switch to the internal
oscillator if the external oscillator or PLL fails.
When a reset occurs, all clock sources except the 32kHz ultra low power oscillator are disabled. After reset, the device
will always start up running from the 2MHz output of 8MHz internal oscillator. During normal operation, the system clock
source and prescalers can be changed from software at any time.
Figure 7-1 on page 95 presents the principal clock system in the XMEGA family of devices. Not all of the clocks need to
be active at a given time. The clocks for the CPU and peripherals can be stopped using sleep modes and power
reduction registers, as described in “Power Management and Sleep Modes” on page 112.
XMEGA E MANUAL 94
Atmel–42005E–AVR–XMEGA E–11/2014
Figure 7-1. The Clock System, Clock Sources, and Clock Distribution
clkPER
clkCPU
clkPER2
clkPER4
clk RTC
clkSYS
DIV32
DIV32
PLL
PLLSRC
DIV4
DIV4
XOSCSEL
TOSC2
XTAL1
XTAL2
XMEGA E MANUAL 95
Atmel–42005E–AVR–XMEGA E–11/2014
7.3.2 CPU Clock – ClkCPU
The CPU clock is routed to the CPU and nonvolatile memory. Halting the CPU clock inhibits the CPU from executing
instructions.
XMEGA E MANUAL 96
Atmel–42005E–AVR–XMEGA E–11/2014
7.4.2 External Clock Sources
The XTAL1 and XTAL2 pins can be used to drive an external oscillator, either a quartz crystal or a ceramic resonator.
XTAL1 or pin 4 from port C (PC4) can be used as input for an external clock signal. The TOSC1 and TOSC2 pins are
dedicated to driving a 32.768kHz crystal oscillator.
C1
XTAL1
GND
Two capacitors, C1 and C2, may be added to match the required load capacitance for the connected crystal.
General
Purpose XTAL2
I/O
External
Clock XTAL1 / PC4
Signal
XMEGA E MANUAL 97
Atmel–42005E–AVR–XMEGA E–11/2014
7.4.2.3 32.768kHz Crystal Oscillator
A 32.768kHz crystal oscillator can be connected between the TOSC1 and TOSC2 pins and enables a dedicated low
frequency oscillator input circuit. A typical connection is shown in Figure 7-4 on page 98. A low power mode with reduced
voltage swing on TOSC2 is available. This oscillator can be used as a clock source for the system clock and RTC, and as
the DFLL reference clock.
C1
TOSC1
GND
Two capacitors, C1 and C2, may be added to match the required load capacitance for the connected crystal. For details
on recommended TOSC characteristics and capacitor load, refer to device datasheet.
External Clock .
Prescaler A divides the system clock, and the resulting clock is clkPER4. Prescalers B and C can be enabled to divide the
clock speed further to enable peripheral modules to run at twice or four times the CPU clock frequency. If Prescalers B
and C are not used, all the clocks will run at the same frequency as the output from Prescaler A.
The system clock selection and prescaler registers are protected by the configuration change protection mechanism,
employing a timed write procedure for changing the system clock and prescaler settings. For details, refer to
“Configuration Change Protection” on page 13.
XMEGA E MANUAL 98
Atmel–42005E–AVR–XMEGA E–11/2014
7.6 PLL with 1x-31x Multiplication Factor
The built-in phase locked loop (PLL) can be used to generate a high-frequency system clock. The PLL has a user-
selectable multiplication factor of from 1 to 31. The output frequency, fOUT, is given by the input frequency, fIN, multiplied
by the multiplication factor, PLL_FAC.
f OUT f IN * PLL _ FAC
Four different clock sources can be chosen as input to the PLL:
2MHz output from 8MHz internal oscillator
8MHz internal oscillator
32MHz internal oscillator divided by 4
0.4MHz - 16MHz crystal oscillator
External clock
To enable the PLL, the following procedure must be followed:
1. Enable reference clock source.
2. Set the multiplication factor and select the clock reference for the PLL.
3. Wait until the clock reference source is stable.
4. Enable the PLL.
Hardware ensures that the PLL configuration cannot be changed when the PLL is in use. The PLL must be disabled
before a new configuration can be written.
It is not possible to use the PLL before the selected clock source is stable and the PLL has locked.
The reference clock source cannot be disabled while the PLL is running.
TOSC1
32.768 kHz Crystal Osc
TOSC2
XTAL1
External Clock
PC4
DIV32
clkRC32MCREF
DFLL32M
XMEGA E MANUAL 99
Atmel–42005E–AVR–XMEGA E–11/2014
The value that should be written to the COMP register is given by the following formula:
f OSC
COMP hex( )
f RC 32MCREF
When the DFLL is enabled, it controls the ratio between the reference clock frequency and the oscillator frequency. If the
internal oscillator runs too fast or too slow, the DFLL will decrement or increment its calibration register value by one to
adjust the oscillator frequency. The oscillator is considered running too fast or too slow when the error is more than a half
calibration step size.
clkRC32MCREF
COMP
RCOSC slow,
Frequency CALA incremented
OK RCOSC fast,
CALA decremented
The DFLL will stop when entering a sleep mode where the oscillators are stopped. After wake up, the DFLL will continue
with the calibration value found before entering sleep. The reset value of the DFLL calibration register can be read from
the production signature row.
When the DFLL is disabled, the DFLL calibration register can be written from software for manual run-time calibration of
the oscillator.
Bit 7 6 5 4 3 2 1 0
+0x00 – – – – – SCLKSEL[2:0]
Read/Write R R R R R R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
This register is write protected if the bit LOCK has been set in the LOCK register.
Bit 7:3 – Reserved
These bits are unused and reserved for future use. For compatibility with future devices, always write these bits to
zero when this register is written.
Bit 2:0 – SCLKSEL[2:0]: System Clock Selection
These bits are used to select the source for the system clock. See Table 7-1 for the different selections. Changing
the system clock source will take two clock cycles on the old clock source and two more clock cycles on the new
clock source. These bits are protected by the configuration change protection mechanism. For details, refer to
“Configuration Change Protection” on page 13.
SCLKSEL cannot be changed if the new clock source is not stable. The old clock can not be disabled until the
clock switching is completed.
110 – Reserved
111 – Reserved
Bit 7 6 5 4 3 2 1 0
+0x01 – PSADIV[4:0] PSBCDIV[1:0]
Read/Write R R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
This register is write protected if the bit LOCK has been set in the LOCK register.
Bit 7 - Reserved
This bit is unused and reserved for future use. For compatibility with future devices, always write this bit to zero
when this register is written.
Bit 6:2 – PSADIV[4:0]: Prescaler A Division Factor
These bits define the division ratio of the clock prescaler A according to Table 7-2. These bits can be written at
run-time to change the frequency of the ClkPER4 clock relative to the system clock, ClkSYS.
00000 1 No division
00001 2 Divide by 2
00011 4 Divide by 4
00101 8 Divide by 8
00111 16 Divide by 16
01001 32 Divide by 32
01011 64 Divide by 64
10011 6 Divide by 6
10101 10 Divide by 10
10111 12 Divide by 12
11001 24 Divide by 24
11011 48 Divide by 48
11101 – Reserved
11111 – Reserved
Bit 7 6 5 4 3 2 1 0
+0x02 – – – – – – – LOCK
Read/Write R R R R R R R R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x03 – – – – RTCSRC[2:0] RTCEN
Read/Write R R R R R R R R/W
Initial value 0 0 0 0 0 0 0 0
011 - Reserved
100 - Reserved
Bit 7 6 5 4 3 2 1 0
+0x00 – RC8MLPM RC8MEN PLLEN XOSCEN RC32KEN RC32MEN RC2MEN
Read/Write R R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 1
Bit 7 – Reserved
This bit is unused and reserved for future use. For compatibility with future devices, always write this bit to zero
when this register is written.
Bit 6 – RC8MLPM: 8MHz Internal Oscillator Low Power Mode
Setting this bit enables the low power mode for the internal 8MHz oscillator. For details on characteristics and
accuracy of the internal oscillator in this mode, refer to the device datasheet.
Bit 5 – RC8MEN: 8MHz Internal Oscillator Enable
Setting this bit will enable the 8MHz output of the internal oscillator. The oscillator must be stable before it is
selected as the source for the system clock. See “STATUS – Oscillator Status Register” on page 104.
Bit 4 – PLLEN: PLL Enable
Setting this bit enables the PLL. Before the PLL is enabled, it must be configured with the desired multiplication
factor and clock source. See “STATUS – Oscillator Status Register” on page 104.
Bit 3 – XOSCEN: External Oscillator Enable
Setting this bit enables the selected external clock source. Refer to “XOSCCTRL – XOSC Control Register” on
page 105 for details on how to select the external clock source. The external clock source should be allowed time
to stabilize before it is selected as the source for the system clock. See “STATUS – Oscillator Status Register” on
page 104.
Bit 2 – RC32KEN: 32.768kHz Internal Oscillator Enable
Setting this bit enables the 32.768kHz internal oscillator. The oscillator must be stable before it is selected as the
source for the system clock. See “STATUS – Oscillator Status Register” on page 104.
Bit 1 – RC32MEN: 32MHz Internal Oscillator Enable
Setting this bit will enable the 32MHz internal oscillator. The oscillator must be stable before it is selected as the
source for the system clock. See “STATUS – Oscillator Status Register” on page 104.
Bit 0 – RC2MEN: 2MHz Internal Oscillator Enable
Setting this bit will enable the 2MHz output of 8MHz internal oscillator. The oscillator must be stable before it is
selected as the source for the system clock. See “STATUS – Oscillator Status Register” on page 104.
By default, the 2MHz output from RC8MHz internal oscillator is enabled and this bit is set.
Bit 7 6 5 4 3 2 1 0
+0x01 – – RC8MRDY PLLRDY XOSCRDY RC32KRDY RC32MRDY RC2MRDY
Read/Write R R R R R R R R
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
XOSCPWR
+0x02 FRQRANGE[1:0] X32KLPM XOSCSEL[3:0]
XOSCSEL[4]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7:6 – FRQRANGE[1:0]: 0.4 - 16MHz Crystal Oscillator Frequency Range Select
These bits select the frequency range for the connected crystal oscillator according to Table 7-5 on page 105.
10 9TO12 9 - 12 10-40
11 12TO16 12 - 16 10-30
Note: 1. Refer to Electrical Characteristics in device datasheet for finding the best setting for a given frequency.
Notes: 1. This option should be used only when frequency stability at startup is not important for the application. The option is not suitable for crystals.
2. This option is intended for use with ceramic resonators. It can also be used when the frequency stability at startup is not important for the
application.
3. When the external oscillator is used as the reference for a DFLL, only EXTCLK and 32KHZ can be selected.
Bit 7 6 5 4 3 2 1 0
+0x03 – – – – PLLFDIF PLLFDEN XOSCFDIF XOSCFDEN
Read/Write R R R R R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x04 RC32KCAL[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x05 PLLSRC[1:0] PLLDIV PLLFAC[4:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Note: 1. The 32.768kHz TOSC cannot be selected as the source for the PLL. An external clock must be a minimum 0.4MHz to be used as the source clock.
Bit 7 6 5 4 3 2 1 0
+0x06 – – – – – RC32MCREF[1:0] –
Read/Write R R R R R R/W R/W R
Initial value 0 0 0 0 0 0 0 0
1x – Reserved
Bit 0 - Reserved
This bit is unused and reserved for future use. For compatibility with future devices, always write this bit to zero
when this register is written.
Bit 7 6 5 4 3 2 1 0
+0x07 RC8MCAL[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x00 – – – – – – – ENABLE
Read/Write R R R R R R R R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 – Reserved
This bit is unused and reserved for future use. For compatibility with future devices, always write this bit to zero
when this register is written.
Bit 6:0 – CALA[6:0]: DFLL Calibration Bits
These bits hold the part of the oscillator calibration value that is used for automatic runtime calibration. A factory-
calibrated value is loaded from the signature row of the device and written to this register during reset, giving an
oscillator frequency approximate to the nominal frequency for the oscillator. The bits cannot be written when the
DFLL is enabled.
Bit 7 6 5 4 3 2 1 0
+0x03 – – CALB[5:0]
Read/Write R R R/W R/W R/W R/W R/W R/W
Initial value 0 0 x x x x x x
Bit 7 6 5 4 3 2 1 0
+0x06 COMP[15:8]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Table 7-9. Nominal DFLL32M COMP Values for Different Output Frequencies
30.0 0x7270
32.0 0x7A12
34.0 0x81B3
36.0 0x8954
38.0 0x90F5
40.0 0x9896
42.0 0xA037
44.0 0xA7D8
46.0 0xAF79
48.0 0xB71B
50.0 0xBEBC
52.0 0xC65D
54.0 0xCDFE
+0x04 Reserved – – – – – – – –
+0x05 Reserved – – – – – – – –
+0x06 Reserved – – – – – – – –
+0x07 Reserved – – – – – – – –
+0x00 CTRL – RC8MLPM RC8MEN PLLEN XOSCEN RC32KEN RC32MEN RC2MEN 104
XOSCPWR
+0x02 XOSCCTRL FRQRANGE[1:0] X32KLPM XOSCSEL[3:0] 105
XOSCSEL[4]
+0x01 Reserved – – – – – – – –
+0x04 Reserved – – – – – – – –
+0x07 Reserved – – – – – – – –
Table 7-10. Oscillator Failure Interrupt Vector and its Word Offset Address PLL and External Oscillator Failure Interrupt Base
0x00 OSCF_vect PLL and external oscillator failure interrupt vector (NMI)
8.1 Features
Power management for adjusting power consumption and functions
Five sleep modes:
Idle
Power down
Power save
Standby
Extended standby
Power reduction register to disable clock and turn off unused peripherals in active and idle modes
8.2 Overview
Various sleep modes and clock gating are provided in order to tailor power consumption to application requirements.
This enables the XMEGA microcontroller to stop unused modules to save power.
All sleep modes are available and can be entered from active mode. In active mode, the CPU is executing application
code. When the device enters sleep mode, program execution is stopped and interrupts or a reset is used to wake the
device again. The application code decides which sleep mode to enter and when. Interrupts from enabled peripherals
and all enabled reset sources can restore the microcontroller from sleep to active mode.
In addition, power reduction registers provide a method to stop the clock to individual peripherals from software. When
this is done, the current state of the peripheral is frozen, and there is no power consumption from that peripheral. This
reduces the power consumption in active mode and idle sleep modes and enables much more fine-tuned power
management than sleep modes alone.
All interrupts
CPU clock
RTC clock
Idle X X X X X X X X
Power down X X
Standby X X X X
Extended standby X X X X X X X
The wake-up time for the device is dependent on the sleep mode and the main clock source. The startup time for the
system clock source must be added to the wake-up time for sleep modes where the system clock source is not kept
running. For details on the startup time for the different oscillator options, refer to “System Clock and Clock Options” on
page 94.
The content of the register file, SRAM and registers are kept during sleep. If a reset occurs during sleep, the device will
reset, start up, and execute from the reset vector.
Bit 7 6 5 4 3 2 1 0
+0x00 – – – – SMODE[2:0] SEN
Read/Write R R R R R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
001 – Reserved
100 – Reserved
101 – Reserved
Bit 7 6 5 4 3 2 1 0
+0x00 XCL – – – – RTC EVSYS EDMA
Read/Write R/W R R R R R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x01 – – – – – DAC ADC AC
Read/Write R R R R R R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
Note: Disabling of analog modules stops the clock to the analog blocks themselves and not only the interfaces.
Bit 7 6 5 4 3 2 1 0
+0x03/+0x04 – TWI – USART0 SPI HIRES TC5 TC4
Read/Write R R/W R R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
Bit 7 – Reserved
This bit is unused and reserved for future use. For compatibility with future devices, always write this bit to zero
when this register is written.
Bit 6 – TWI: Two-Wire Interface
Setting this bit stops the clock to the two-wire interface. When this bit is cleared, the peripheral should be reinitial-
ized to ensure proper operation.
Bit 5 – Reserved
This bit is unused and reserved for future use. For compatibility with future devices, always write this bit to zero
when this register is written.
Bit 4 – USART0
Setting this bit stops the clock to USART0. When this bit is cleared, the peripheral should be reinitialized to ensure
proper operation.
Bit 3 – SPI: Serial Peripheral Interface
Setting this bit stops the clock to the SPI. When this bit is cleared, the peripheral should be reinitialized to ensure
proper operation.
Bit 2 – HIRES: High-Resolution Extension
Setting this bit stops the clock to the high-resolution extension for the timer/counters. When this bit is cleared, the
peripheral should be reinitialized to ensure proper operation.
Bit 1 – TC5: Timer/Counter 5
Setting this bit stops the clock to timer/counter 5. When this bit is cleared, the peripheral will continue like before
the shut down.
Bit 0 – TC4: Timer/Counter 4
Setting this bit stops the clock to timer/counter 4. When this bit is cleared, the peripheral will continue like before
the shut down.
+0x02 Reserved – – – – – – – –
+0x05 Reserved – – – – – – – –
+0x06 Reserved – – – – – – – –
+0x07 Reserved – – – – – – – –
9.1 Features
Reset the microcontroller and set it to initial state when a reset source goes active
Multiple reset sources that cover different situations
Power-on reset
External reset
Watchdog reset
Brownout reset
PDI reset
Software reset
Asynchronous operation
No running system clock in the device is required for reset
Reset status register for reading the reset source from the application code
9.2 Overview
The reset system issues a microcontroller reset and sets the device to its initial state. This is for situations where
operation should not start or continue, such as when the microcontrollers operates below its power supply rating. If a
reset source goes active, the device enters and is kept in reset until all reset sources have released their reset. The I/O
pins are immediately tri-stated. The program counter is set to the reset vector location, and all I/O registers are set to
their initial values. The SRAM content is kept. However, if the device accesses the SRAM when a reset occurs, the
content of the accessed location can not be guaranteed.
After reset is released from all reset sources, the default oscillator is started and calibrated before the device starts
running from the reset vector address. By default, this is the lowest program memory address, 0, but it is possible to
move the reset vector to the lowest address in the boot section.
The reset functionality is asynchronous, and so no running system clock is required to reset the device. The software
reset feature makes it possible to issue a controlled system reset from the user software.
The reset status register has individual status flags for each reset source. It is cleared at power-on reset, and shows
which sources have issued a reset since the last power-on.
An overview of the reset system is shown in Figure 9-1 on page 121.
MCU Status
Register (MCUSR)
PORF
BORF
EXTRF
WDRF
JTRF
Power-on Reset
Brown-out
BODLEVEL [2:0] Reset
Pull-up Resistor
SPIKE External
FILTER Reset
PDI
Reset
Software
Reset
Watchdog
Reset
ULP
Delay Counters
Oscillator TIMEOUT
SUT[1:0]
10 Reserved –
Whenever a reset occurs, the clock system is reset and the 2MHz output from the internal 8MHz oscillator is chosen as
the source for ClkSYS.
VRST
RESET
tTOUT
TIME-OUT
INTERNAL
RESET
VRST
RESET
tTOUT
TIME-OUT
INTERNAL
RESET
VCC VBOT+
VBOT-
TIME-OUT tTOUT
INTERNAL
RESET
For BOD characterization data consult the device datasheet. The programmable BODLEVEL setting is shown in Table 9-
2.
Notes: 1. The values are nominal values only. For accurate, actual numbers, consult the device datasheet.
2. Changing these fuse bits will have no effect until leaving programming mode.
00 Reserved
01 Sampled
10 Enabled
11 Disabled
tEXT
For information on configuration and use of the WDT, refer to the “WDT – Watchdog Timer” on page 127.
Bit 7 6 5 4 3 2 1 0
+0x00 – – SRF PDIRF WDRF BORF EXTRF PORF
Read/Write R R R/W R/W R/W R/W R/W R/W
Initial Value – – – – – – – –
Bit 7 6 5 4 3 2 1 0
+0x01 – – – – – – – SWRST
Read/Write R R R R R R R R/W
Initial Value 0 0 0 0 0 0 0 0
10.1 Features
Issues a device reset if the timer is not reset before its timeout period
Asynchronous operation from dedicated oscillator
1kHz output of the 32kHz ultra low power oscillator
11 selectable timeout periods, from 8ms to 8s
Two operation modes:
Normal mode
Window mode
Configuration lock to prevent unwanted changes
10.2 Overview
The watchdog timer (WDT) is a system function for monitoring correct program operation. It makes it possible to recover
from error situations such as runaway or deadlocked code. The WDT is a timer, configured to a predefined timeout
period, and is constantly running when enabled. If the WDT is not reset within the timeout period, it will issue a
microcontroller reset. The WDT is reset by executing the WDR (watchdog timer reset) instruction from the application
code.
The window mode makes it possible to define a time slot or window inside the total timeout period during which WDT
must be reset. If the WDT is reset outside this window, either too early or too late, a system reset will be issued.
Compared to the normal mode, this can also catch situations where a code error causes constant WDR execution.
The WDT will run in active mode and all sleep modes, if enabled. It is asynchronous, runs from a CPU-independent clock
source, and will continue to operate to issue a system reset even if the main clocks fail.
The configuration change protection mechanism ensures that the WDT settings cannot be changed by accident. For
increased safety, a fuse for locking the WDT settings is also available.
Bit 7 6 5 4 3 2 1 0
+0x00 – – PER[3:0] ENABLE CEN
Read/Write (unlocked) R R R/W R/W R/W R/W R/W R/W
Read/Write (locked) R R R R R R R R
Initial value (x = fuse) 0 0 X X X X X 0
1011 – Reserved
1100 – Reserved
1101 – Reserved
1110 – Reserved
1111 – Reserved
Bit 7 6 5 4 3 2 1 0
+0x01 – – WPER[3:0] WEN WCEN
Read/Write (unlocked) R R R/W R/W R/W R/W R/W R/W
Read/Write (locked) R R R R R R R/W R/W
Initial value (x = fuse) 0 0 X X X X X 0
1011 – Reserved
1100 – Reserved
1101 – Reserved
1110 – Reserved
1111 – Reserved
Note: Reserved settings will not give any timeout for the window.
Bit 7 6 5 4 3 2 1 0
+0x02 – – – – – – – SYNCBUSY
Read/Write R R R R R R R R
Initial value 0 0 0 0 0 0 0 0
11.1 Features
Short and predictable interrupt response time
Separate interrupt configuration and vector address for each interrupt
Programmable multilevel interrupt controller
Interrupt prioritizing according to level and vector address
Three selectable interrupt levels for all interrupts: low, medium and high
Selectable, round-robin priority scheme within low-level interrupts
Non-maskable interrupts for critical functions
Interrupt vectors optionally placed in the application section or the boot loader section
11.2 Overview
Interrupts signal a change of state in peripherals, and this can be used to alter program execution. Peripherals can have
one or more interrupts, and all are individually enabled and configured. When an interrupt is enabled and configured, it
will generate an interrupt request when the interrupt condition is present. The programmable multilevel interrupt
controller (PMIC) controls the handling and prioritizing of interrupt requests. When an interrupt request is acknowledged
by the PMIC, the program counter is set to point to the interrupt vector, and the interrupt handler can be executed.
All peripherals can select between three different priority levels for their interrupts: low, medium, and high. Interrupts are
prioritized according to their level and their interrupt vector address. Medium-level interrupts will interrupt low-level
interrupt handlers. High-level interrupts will interrupt both medium- and low-level interrupt handlers. Within each level, the
interrupt priority is decided from the interrupt vector address, where the lowest interrupt vector address has the highest
interrupt priority. Low-level interrupts have an optional round-robin scheduling scheme to ensure that all interrupts are
serviced within a certain amount of time.
Non-maskable interrupts (NMI) are also supported, and can be used for system critical functions.
11.3 Operation
Interrupts must be globally enabled for any interrupts to be generated. This is done by setting the global interrupt enable
( I ) bit in the CPU “SREG – Status Register” on page 17. The I bit will not be cleared when an interrupt is acknowledged.
Each interrupt level must also be enabled before interrupts with the corresponding level can be generated.
When an interrupt is enabled and the interrupt condition is present, the PMIC will receive the interrupt request. Based on
the interrupt level and interrupt priority of any ongoing interrupts, the interrupt is either acknowledged or kept pending
until it has priority. When the interrupt request is acknowledged, the program counter is updated to point to the interrupt
vector. The interrupt vector is normally a jump to the interrupt handler; the software routine that handles the interrupt.
After returning from the interrupt handler, program execution continues from where it was before the interrupt occurred.
One instruction is always executed before any pending interrupt is served.
The PMIC status register contains state information that ensures that the PMIC returns to the correct interrupt level when
the RETI (interrupt return) instruction is executed at the end of an interrupt handler. Returning from an interrupt will return
the PMIC to the state it had before entering the interrupt. The status register (SREG) is not saved automatically upon an
interrupt request. The RET (subroutine return) instruction cannot be used when returning from the interrupt handler
routine, as this will not return the PMIC to its correct state.
INT LEVEL
INT LEVEL CPU
CPU INT REQ
Peripheral n
INT REQ
INT REQ
INT ACK
INT ACK Global
Interrupt
LEVEL Enable STATUS Enable Wake-up Sleep
CTRL INTPRI CPU.SREG Controller
11.4 Interrupts
All interrupts and the reset vector each have a separate program vector address in the program memory space. The
lowest address in the program memory space is the reset vector. All interrupts are assigned with individual control bits for
enabling and setting the interrupt level, and this is set in the control registers for each peripheral that can generate
interrupts. Details on each interrupt are described in the peripheral where the interrupt is available.
Each interrupt has an interrupt flag associated with it. When the interrupt condition is present, the interrupt flag will be set,
even if the corresponding interrupt is not enabled. For most interrupts, the interrupt flag is automatically cleared when
executing the interrupt vector. Writing a logical one to the interrupt flag will also clear the flag. Some interrupt flags are
not cleared when executing the interrupt vector, and some are cleared automatically when an associated register is
accessed (read or written). This is described for each individual interrupt flag.
If an interrupt condition occurs while another, higher priority interrupt is executing or pending, the interrupt flag will be set
and remembered until the interrupt has priority. If an interrupt condition occurs while the corresponding interrupt is not
enabled, the interrupt flag will be set and remembered until the interrupt is enabled or the flag is cleared by software.
Similarly, if one or more interrupt conditions occur while global interrupts are disabled, the corresponding interrupt flag
will be set and remembered until global interrupts are enabled. All pending interrupts are then executed according to their
order of priority.
Interrupts can be blocked when executing code from a locked section; e.g., when the boot lock bits are programmed.
This feature improves software security. Refer to “Memory Programming” on page 411 for details on lock bit settings.
Interrupts are automatically disabled for up to four CPU clock cycles when the configuration change protection register is
written with the correct signature. Refer to “Configuration Change Protection” on page 13 for more details.
If an interrupt occurs when the device is in sleep mode, the interrupt execution response time is increased by five clock
cycles. In addition, the response time is increased by the start-up time from the selected sleep mode.
A return from an interrupt handling routine takes four to five clock cycles, depending on the size of the program counter.
During these clock cycles, the program counter is popped from the stack and the stack pointer is incremented.
01 LO Low-level interrupt
11 HI High-level interrupt
The interrupt level of an interrupt request is compared against the current level and status of the interrupt controller. An
interrupt request of a higher level will interrupt any ongoing interrupt handler from a lower level interrupt. When returning
from the higher level interrupt handler, the execution of the lower level interrupt handler will continue.
:
:
:
IVEC x
IVEC x+1
:
:
:
IV EC 0 IV EC 0
: :
: :
: :
IV EC N IV EC N
1 0 0x0000 0x0002
Bit 7 6 5 4 3 2 1 0
+0x00 NMIEX – – – – HILVLEX MEDLVLEX LOLVLEX
Read/Write R R R R R R R R
Initial Value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x01 INTPRI[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x02 RREN IVSEL – – – HILVLEN MEDLVLEN LOLVLEN
Read/Write R/W R/W R R R R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
12.1 Features
General purpose input and output pins with individual configuration
Output driver with configurable driver and pull settings:
Totem-pole
Wired-AND
Wired-OR
Bus-keeper
Inverted I/O
Input with synchronous and/or asynchronous sensing with interrupts and events:
Sense both edges
Sense rising edges
Sense falling edges
Sense low level
Optional pull-up and pull-down resistor on input and Wired-OR/AND configurations
Optional slew rate control per I/O port
Asynchronous pin change sensing that can wake the device from all sleep modes
Port interrupt with pin masking
Efficient and safe access to port pins
Hardware read-modify-write through dedicated toggle/clear/set registers
Configuration of multiple pins in a single operation
Mapping of port registers into bit-accessible I/O memory space
Peripheral clocks output on port pin
Real-time counter clock output to port pin
Event channels can be output on port pin
Remapping of digital peripheral pin functions
Selectable USART, and timer/counter input/output pin locations
Selectable analog comparator outputs pins locations
12.2 Overview
AVR XMEGA microcontrollers have flexible general purpose I/O ports. One port consists of up to eight port pins: pin 0 to
7. Each port pin can be configured as input or output with configurable driver and pull settings. They also implement
synchronous and asynchronous input sensing with interrupts and events for selectable pin change conditions.
Asynchronous pin-change sensing means that a pin change can wake the device from all sleep modes, included the
modes where no clocks are running.
All functions are individual and configurable per pin, but several pins can be configured in a single operation. The pins
have hardware read-modify-write (RMW) functionality for safe and correct change of drive value and/or pull resistor
configuration. The direction of one port pin can be changed without unintentionally changing the direction of any other
pin.
The port pin configuration also controls input and output selection of other device functions. It is possible to have both the
peripheral clock and the real-time clock output to a port pin, and available for external use. The same applies to events
from the event system that can be used to synchronize and control external functions. Other peripherals, such as analog
comparator outputs, USART and timer/counters, can be remapped to selectable pin locations in order to optimize pin-out
versus application needs.
Figure 12-1 on page 140 shows the I/O pin functionality and the registers that are available for controlling a pin.
Pull Enable
C
o Pull Keep
n
PINnCTRL
t Pull Direction
D Q r
o
l
R
L
o Input Disable
g
i Wired AND/OR
c Slew Rate Limit
Inverted I/O
OUTn
Pxn
D Q
DIRn
D Q
Synchronizer
INn
Q D Q D
R R
Analog Input/Output
12.3.1 Totem-pole
In the totem-pole (push-pull) configuration, the pin is driven low or high according to the corresponding bit setting in the
OUT register. In this configuration, there is no current limitation for sink or source other than what the pin is capable of. If
the pin is configured for input, the pin will float if no external pull resistor is connected.
OUTxn Pxn
INxn
Figure 12-3. I/O Pin Configuration - Totem-pole with Pull-down (on Input)
DIRxn
OUTxn Pxn
INxn
Figure 12-4. I/O Pin Configuration - Totem-pole with Pull-up (on Input)
DIRxn
OUTxn Pxn
INxn
12.3.2 Bus-keeper
In the bus-keeper configuration, it provides a weak bus-keeper that will keep the pin at its logic level when the pin is no
longer driven to high or low. If the last level on the pin/bus was 1, the bus-keeper configuration will use the internal pull
resistor to keep the bus high. If the last logic level on the pin/bus was 0, the bus-keeper will use the internal pull resistor
to keep the bus low.
DIRxn
OUTxn Pxn
INxn
OUTxn
Pxn
INxn
12.3.4 Wired-AND
In the wired-AND configuration, the pin will be driven low when the corresponding bits in the OUT and DIR registers are
written to zero. When the OUT register is set to one, the pin is released allowing the pin to be pulled high with the internal
or an external pull-resistor. If internal pull-up is used, this is also active if the pin is set as input.
INxn
Pxn
OUTxn
PERIPHERAL CLK
SYNCHRONIZER FLIPFLOP
INxn
tpd, min
EDGE
DETECT Interrupt
IRQ
Control
Synchronous sensing
Pxn
Synchronizer
INn
EDGE Synchronous
D Q D Q
DETECT Events
R R
INVERTED I/O
Asynchronous
Events
Low level Yes Pin level must be kept unchanged during wake up
Low level Yes Pin level must be kept unchanged during wake up
Rising edge No -
Falling edge No -
Any edge Yes Pin level must be kept unchanged during wake up
Low level Yes Pin level must be kept unchanged during wake up
Pull Enable
Pull Keep
C
o
Pull Direction
n
PINnCTRL t
r
D Q
o
l
R
L Digital Input Disable (DID)
o DID Override Value
g
i DID Override Enable
c
Wired AND/OR
Slew Rate Limit
Inverted I/O
OUTn
Pxn
D Q
DIRn
D Q
Synchronizer
INn
Q D Q D
R R
Analog Input/Output
Bit 7 6 5 4 3 2 1 0
+0x00 DIR[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x01 DIRSET[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x02 DIRCLR[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x03 DIRTGL[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x04 OUT[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x05 OUTSET[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x06 OUTCLR[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x07 OUTTGL[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x08 IN[7:0]
Read/Write R R R R R R R R
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x09 – – – – – – INTLVL[1:0]
Read/Write R R R R R R R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x0A INTMASK[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x0C INT7IF INT6IF INT5IF INT4IF INT3IF INT2IF INT1IF INT0IF
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
OC4A
OC5A
OCA
Bit 7 6 5 4 3 2 1 0
+0x10 +n – INVEN OPC[2:0] ISC[2:0]
Read/Write R R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 – Reserved
This bit is unused and reserved for future use. For compatibility with future devices, always write this bit to zero
when this register is written.
Bit 6 – INVEN: Inverted I/O Enable
Setting this bit will enable inverted output and input data on pin n.
Bit 5:3 – OPC: Output and Pull Configuration
These bits set the output/pull configuration on pin n according to Table 12-5 on page 153.
Description
100 – Reserved
101 – Reserved
Notes: 1. A low-level pin value will not generate events, and a high-level pin value will continuously generate events.
2. Only PORTA - PORTD support the input buffer force enable option. If the pin is not used for asynchronous event generation, it is recommended to
not use this configuration.
3. Only PORTA - PORTD support the input buffer disable option. If the pin is used for analog functionality, such as AC or ADC, it is recommended to
configure the pin to INPUT_DISABLE.
Bit 7 6 5 4 3 2 1 0
+0x00 MPCMASK[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x04 CLKEVPIN RTCOUT[1:0] - CLKOUTSEL[1:0] CLKOUT[1:0]
Read/Write R/W R/W R/W R R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 4 – Reserved
This bit is unused and reserved for future use. For compatibility with future devices, always write this bit to zero
when this register is written.
Bits 3:2 – CLKOUTSEL[1:0]: Clock Output Select
These bits are used to select which of the peripheral clocks will be output to the port pin if CLKOUT is configured.
11 – Reserved
Bit 7 6 5 4 3 2 1 0
+0x06 ACOUT[1:0] EVOUT[1:0] EVASYEN EVOUTSEL[2:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x07 SRLENR – – – SRLEND SRLENC – SRLENA
Read/Write R/W R R R R/W R/W R R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x00 DIR[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x01 OUT[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x02 IN[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x03 INT7IF INT6IF INT5IF INT4IF INT3IF INT2IF INT1IF INT0IF
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
+0x0B Reserved - - - - - - - -
+0x0C INTFLAGS INT7IF INT6IF INT5IF INT4IF INT3IF INT2IF INT1IF INT0IF 151
+0x0D Reserved - - - - - - - -
+0x18 Reserved - - - - - - - -
+0x19 Reserved - - - - - - - -
+0x1A Reserved - - - - - - - -
+0x1B Reserved - - - - - - - -
+0x1C Reserved - - - - - - - -
+0x1D Reserved - - - - - - - -
+0x1E Reserved - - - - - - - -
+0x1F Reserved - - - - - - - -
+0x01 Reserved - - - - - - - -
+0x02 Reserved - - - - - - - -
+0x03 Reserved - - - - - - - -
+0x05 Reserved - - - - - - - -
+0x03 INTFLAGS INT7IF INT6IF INT5IF INT4IF INT3IF INT2IF INT1IF INT0IF 157
Table 12-13. USART Interrupt Vectors and their Word Offset Address
13.1 Features
16-bit timer/counter
32-bit timer/counter support by cascading two timer/counters
Up to four compare or capture (CC) channels:
Four CC channels for timer/counters of type 4
Two CC channels for timer/counters of type 5
Double buffered timer period setting
Double buffered capture or compare channels
Waveform generation:
Frequency generation
Single-slope pulse width modulation
Dual-slope pulse width modulation
Input capture:
Input capture with noise cancelling
Frequency capture
Pulse width capture
32-bit input capture
Timer overflow and error interrupts/events
One compare match or input capture interrupt/event per CC channel
Can be used with event system for:
Quadrature decoding
Count and direction control
Capture
Can be used with EDMA and to trigger EDMA transactions
High-resolution extension:
Increases frequency and waveform resolution by 4x (2-bit) or 8x (3-bit)
Waveform extension:
Low- and high-side output with programmable dead-time insertion (DTI)
Fault extension:
Event controlled fault protection for safe disabling of drivers
13.2 Overview
Atmel AVR XMEGA devices have a set of flexible, 16-bit timer/counters (TC). Their capabilities include accurate program
execution timing, frequency and waveform generation, and input capture with time and frequency measurement of digital
signals. Two timer/counters can be cascaded to create a 32-bit timer/counter with optional 32-bit capture.
A timer/counter consists of a base counter and a set of compare or capture (CC) channels. The base counter can be
used to count clock cycles or events. It has direction control and period setting that can be used for timing. The CC
channels can be used together with the base counter to do compare match control, frequency generation, and pulse
width waveform modulation (PWM) generation, as well as various input capture operations. A timer/counter can be
configured for either capture or compare functions, but cannot perform both at the same time.
A timer/counter can be clocked and timed from the peripheral clock with optional prescaling or from the event system.
The event system can also be used for direction control and capture trigger or to synchronize operations.
There are two differences between timer/counter type 4 and type 5. Timer/counter 4 has four CC channels, and
timer/counter 5 has two CC channels. All information related to CC channels 3 and 4 is valid only for timer/counter 4.
Both timer/counter 4 and 5 can be in 8-bit mode, allowing the application to double the number of compare and capture
channels that then get 8-bit resolution.
13.2.1 Definitions
The following definitions are used throughout the documentation:
Name Description
BOTTOM The counter reaches BOTTOM when it becomes zero (one in single slope counting-up mode).
The counter reaches TOP when it becomes equal to the highest value in the count sequence. The TOP value
TOP can be equal to the period (PER) or the compare channel A (CCA) register setting. This is selected by the
waveform generator mode.
UPDATE The timer/counter signals an update when it reaches BOTTOM or TOP, depending on the direction settings.
In general, the term “timer” is used when the timer/counter clock control is handled by an internal source, and the term
“counter” is used when the clock control is handled externally (e.g. counting external events). When used for compare
operations, the CC channels are referred to as “compare channels.” When used for capture operations, the CC channels
are referred to as “capture channels.”
Base Counter
Clock Select
BV PERBUF CTRLA
Event
Select
PER CTRLD
"count"
Counter
"clear"
OVF/UNF
(INT/EDMA Req.)
"load"
CNT Control Logic
"direction"
ERRIF
(INT Req.)
TOP
UPDATE
=
"ev"
BOTTOM
=0
Compare/Capture
(Unit x = {A,B,C,D})
CCx
Waveform
Generation
OCx Out
"match" CCxIF
= (INT/EDMA
Req.)
The counter register (CNT), period registers with buffer (PER and PERBUF), and compare and capture registers with
buffers (CCx and CCxBUF) are 16-bit registers. All buffer register have a buffer valid (BV) flag that indicates when the
buffer contains a new value.
During normal operation, the counter value is continuously compared to zero and the period (PER) value to determine
whether the counter has reached TOP or BOTTOM.
The counter value is also compared to the CCx registers. These comparisons can be used to generate interrupt
requests, request EDMA transactions or generate events for the event system. The waveform generator modes use
these comparisons to set the waveform period or pulse width.
A prescaled peripheral clock and events from the event system can be used to control the counter. The event system is
also used as a source to the input capture. Combined with the quadrature decoding functionality in the event system
(QDEC), the timer/counter can be used for quadrature decoding.
Common clkPER /
clkPER
2{0,...,15}
Event system events
prescaler
clkPER /
{1,2,4,8,64,256,1024} event channels
CLKSEL
Control logic
EVSEL
CNT
EVACT (Encoding)
The peripheral clock is fed into a common prescaler (common for all timer/counters in a device). Prescaler outputs from 1
to 1/1024 are directly available for selection by the timer/counter. In addition, the whole range of prescaling from 1 to 215
times are available through the event system.
Clock selection (CLKSEL) selects one of the prescaler outputs directly or an event channel as the counter (CNT) input.
This is referred to as normal operation of the counter. For details, refer to “Normal Operation” on page 164. By using the
event system, any event source, such as an external clock signal on any I/O pin, may be used as the clock input.
In addition, the timer/counter can be controlled via the event system. The event selection (EVSEL) and event action
(EVACT) settings are used to trigger an event action from one or more events. This is referred to as event action
controlled operation of the counter. For details, refer to “Event Action Controlled Operation” on page 165. When event
action controlled operation is used, the clock selection must be set to use an event channel as the counter input.
UPDATE
BV EN CCxBUF
CIRCEN
EN CCx
UPDATE
CNT
"match"
=
When the CC channels are used for a capture operation, a similar double buffering mechanism is used, but in this case
the buffer valid flag is set on the capture event, as shown in Figure 13-5. For input capture, the buffer register and the
corresponding CCx register act like a FIFO. When the CC register is empty or read, any content in the buffer register is
passed to the CC register. The buffer valid flag is passed to set the CCx interrupt flag (IF) and generate the optional
interrupt.
BV EN CCxBUF
IF EN CCx
"INT/DMA
request" data read
Both the CCx and CCxBUF registers are available as an I/O register. This allows initialization and bypassing of the buffer
register and the double buffering function.
MAX
"update"
TOP
CNT
CCx
BOTTOM
DIR
WG output
As shown in Figure 13-6, it is possible to change the counter value when the counter is running. The write access has
higher priority than count, clear, or reload, and will be immediate. The direction of the counter can also be changed
during normal operation.
Normal operation must be used when using the counter as timer base for the input capture. When a waveform
generation (WG) mode is enabled, the waveform is output to a pin. For details, refer to “Waveform Generation” on page
169.
MAX
"update"
"write"
CNT
BOTTOM
A counter wraparound can occur in any mode of operation when up-counting without buffering, as shown in Figure 13-8.
This due to the fact that CNT and PER are continuously compared, and if a new TOP value that is lower than current
CNT is written to PER, it will wrap before a compare match happen.
MAX
"update"
"write"
CNT
BOTTOM
When double buffering is used, the buffer can be written at any time and still maintain correct operation. The period
register is always updated on the UPDATE condition, as shown for dual-slope operation in Figure 13-9. This prevents
wraparound and the generation of odd waveforms.
MAX
"update"
"write"
CNT
BOTTOM
Event System
CCA capture
CH0MUX Event channel 0
CH1MUX Event channel 1 CCB capture
CCC capture
CHnMUX Event channel n
CCD capture
Rotate
The event action setting in the timer/counter will determine the type of capture that is done.
The CC channels must be enabled individually before capture can be done. When the capture condition occur, the
timer/counter will time-stamp the event by copying the current CNT value in the count register into the enabled CC
channel register.
When an I/O pin is used as an event source for the capture, the pin must be configured for edge sensing. For details on
sense configuration on I/O pins, refer to “Input Sense Configuration” on page 144.
For details on event channels source selection, refer to Table 13-10 on page 177.
events
TOP
CNT
BOTTOM
When selecting the pulse width and frequency capture event action, the enabled CCA or CCB channels perform input
captures on positive edge event on CCA channel and on negative edge event on CCB channel. Counter restart is
performed on positive edge event. This enables measurement of signal pulse width and frequency directly. The CCA
capture result will be the period (T) from the previous timer/counter restart until the event occurred. This can be used to
calculate the frequency (f) of the signal:
1
f = ---
T
The CCB capture result will be pulse width (tp) of the signal. The event source must be an I/O pin, and the sense
configuration for the pin must be set to generate an event on both edges.
Figure 13-12 on page 168 shows an example where the period and pulse width of an external signal is measured twice.
MAX
"update"
TOP
CNT
BOTTOM
WG Output
CNT
CCx
BOTTOM
WG Output
The PER register defines the PWM resolution. The minimum resolution is two bits (PER=0x0003), and the maximum
resolution is 16 bits (PER=MAX).
The following equation calculate the exact resolution for single-slope PWM (RPWM_SS):
The single-slope PWM frequency (fPWM_SS) depends on the period setting (PER) and the peripheral clock frequency
(fclkPER), and can be calculated by the following equation:
fclk PER
f PWM_SS = -------------------------------------
N PER + DIR
where N represents the prescaler divider used. The waveform generated will have a maximum frequency of half of the
peripheral clock frequency (fclkPER) when CCA is set to zero (0x0000) and no prescaling is used. This also applies when
using the hi-res extension, since this increases the resolution and not the frequency.
The pulse width (PPWM_SS) depends on the compare channel settings (CCx), the direction (DIR) and the peripheral clock
frequency (fclkPER), and can be calculated by the following equation:
N CCx
P PWM_SS = -----------------------
fclk PER
where N represents the prescaler divider used. When counting up, the minimum pulse width is one peripheral clock.
Using dual-slope PWM results in a lower maximum operation frequency compared to the single-slope PWM operation.
The period register (PER) defines the PWM resolution. The minimum resolution is two bits (PER=0x0003), and the
maximum resolution is 16 bits (PER=MAX).
The following equation calculate the exact resolution for dual-slope PWM (RPWM_DS):
log PER + 1
R PWM_DS = ---------------------------------
log 2
The PWM frequency depends on the period setting (PER) and the peripheral clock frequency (fclkPER), and can be
calculated by the following equation:
fclk PER
f PWM_DS = ---------------------
2N PER
N represents the prescaler divider used. The waveform generated will have a maximum frequency of half of the
peripheral clock frequency (fclkPER) when PER is set to one (0x0001) and no prescaling is used. This also applies when
using the hi-res extension, since this increases the resolution and not the frequency.
The pulse width (PPWM_DS) depends on the compare channel settings (CCx) and the peripheral clock frequency (fclkPER),
and can be calculated by the following equation:
2 N * ( PER CCx )
PPWM _ DS
fclk PER
where N represents the prescaler divider used. In this mode, the pulse can be inhibited.
WG output updates
ERRIF N/A
Bit 7 6 5 4 3 2 1 0
+0x00 – SYNCHEN EVSTART UPSTOP CLKSEL[3:0]
Read/Write R R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 – Reserved
This bit is unused and reserved for future use. For compatibility with future devices, always write this bit to zero
when this register is written.
Bit 6 – SYNCHEN: Synchronization Enabled
When this bit is set, the event actions and software commands are synchronized with the internal timer/counter
clock. When the bit is cleared, the event actions and software commands are synchronized with the peripheral
clock (CLKPER).
Bit 5 – EVSTART: Start on Next Event
Setting this bit will enable the timer/counter on the next event from event line selected by EVSEL bits. If the bit is
cleared, the timer/counter can be enabled only by software, by clearing the STOP bit in CTRLGSET register.
Bit 4 – UPSTOP: Stop on Next Update
Setting this bit will disable the timer/counter on next update condition (overflow/underflow or retrigger). The bit has
no effect if the timer/counter has been disabled by software.
Bit 3:0 – CLKSEL[3:0]: Clock Select
These bits select the clock source for the timer/counter according to Table 13-4.
Setting CLKSEL to a no null value will start the timer, if EVSTART is written to 0 at the same time.
DIV1 configuration must be set to ensure a correct output from the waveform generator when the Hi-Res extension
is enabled.
Bit 7 6 5 4 3 2 1 0
+0x01 BYTEM[1:0] CIRCEN[1:0] – WGMODE[2:0]
Read/Write R/W R/W R/W R/W R R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
One 8-bit timer/counter with doubled CC channels. Upper byte of the counter
01 BYTEMODE
(CNTH) will be set to zero after each counter clock cycle.
10 - Reserved
11 - Reserved
Bit 3 – Reserved
This bit is unused and reserved for future use. For compatibility with future devices, always write this bit to zero
when this register is written.
Bit 2:0 – WGMODE[2:0]: Waveform Generation Mode
These bits select the waveform generation mode, and control the counting sequence of the counter, TOP value,
UPDATE condition, interrupt/event condition, and type of waveform that is generated according to Table 13-7.
The result from the waveform generator can be directed to the port pins if the corresponding CCxMODE bits have
been set to enable this. The port pin direction must be set as output.
Bit 7 6 5 4 3 2 1 0
+0x02 POLD POLC POLB POLA CMPD CMPC CMPB CMPA
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x03 EVACT[2:0] EVDLY EVSEL[3:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
111 – Reserved
Note: 1. Set the EVACT[2:0] to 000 (Off condition) and select the event channel with the EVSEL[3:0] bits. Also, the CTRLE.CCxMODE has to be set to
CAPT.
0001 - Reserved
0010 - Reserved
0011 - Reserved
0100 - Reserved
0101 - Reserved
0110 - Reserved
0111 - Reserved
By default, the selected event channel n will be the event channel source for CC channel A, and event channel
(n+1)%8, (n+2)%8, and (n+3)%8 will be the event channel source for CC channel B, C, and D.
Table 13-10 shows the event channel source for each CC channel, depending of EVACT settings.
Bit 7 6 5 4 3 2 1 0
+0x04 CCDMODE[1:0] CCCMODE[1:0] CCBMODE[1:0] CCAMODE[1:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x06 – – TRGINTLVL[1:0] ERRINTLVL[1:0] OVFINTLVL[1:0]
Read/Write R R R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x07 CCDINTLVL[1:0] CCCINTLVL[1:0] CCBINTLVL[1:0] CCAINTLVL[1:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
– – STOP – CMD[1:0] LUPD DIR
Read/Write R R R/W R R/W R/W R/W R/W
Initial value 0 0 1 0 0 0 0 0
00 NONE None
Bit 7 6 5 4 3 2 1 0
+0x0C CCDIF CCCIF CCBIF CCAIF – TRGIF ERRIF OVFIF
Read/Write R/W R/W R/W R/W R R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x0F TEMP[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x20 CNT[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x21 CNT[15:8]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x27 PER[15:8]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
CCx[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
CCx[15:8]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x38 PERBUF[15:8]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
CCxBUF[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
CCxBUF[15:8]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x00 – SYNCHEN EVSTART UPSTOP CLKSEL[3:0]
Read/Write R R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 – Reserved
This bit is unused and reserved for future use. For compatibility with future devices, always write this bit to zero
when this register is written.
Bit 6 – SYNCHEN: Synchronization Enabled
When this bit is set, the event actions and software commands are synchronized with the internal timer/counter
clock. When the bit is cleared, the event actions and software commands are synchronized with the peripheral
clock (CLKPER).
Bit 5 – EVSTART: Start on Next Event
Setting this bit will enable the timer/counter on the next event from event line selected by EVSEL bits. If the bit is
cleared, the timer/counter can be enabled only by software, by clearing the LSTOP bit in CTRLGSET register.
Bit 4 – UPSTOP: Stop on next update
Setting this bit will disable the timer/counter on next update condition (overflow/underflow or retrigger). The bit has
no effect is the timer/counter has been disabled by software.
Bit 3:0 – CLKSEL[3:0]: Clock Select
These bits select the clock source for the timer/counter according to Table 13-13.
DIV1 configuration must be set to ensure a correct output from the waveform generator when the hires extension
is enabled.
Bit 7 6 5 4 3 2 1 0
+0x01 BYTEM[1:0] CIRCEN[1:0] – WGMODE[2:0]
Read/Write R/W R/W R/W R/W R R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
One 8-bit timer/counter with doubled CC channels. Upper byte of the counter
01 BYTEMODE
(CNTH) will be set to zero after each counter clock cycle.
10 – Reserved
11 – Reserved
Bit 3 – Reserved
This bit is unused and reserved for future use. For compatibility with future devices, always write this bit to zero
when this register is written.
Bit 2:0 – WGMODE[2:0]: Waveform Generation Mode
These bits select the waveform generation mode, and control the counting sequence of the counter, TOP value,
UPDATE condition, interrupt/event condition, and type of waveform that is generated according to Table 13-16.
The result from the waveform generator can be directed to the port pins if the corresponding CCxMODE bits have
been set to enable this. The port pin direction must be set as output.
Bit 7 6 5 4 3 2 1 0
+0x02 HCMPD HCMPC HCMPB HCMPA LCMPD LCMPC LCMPB LCMPA
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x03 EVACT[2:0] EVDLY EVSEL[3:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
111 - Reserved
Note: 1. This mode is available only for timer/counter with FAULT extension. For timer/counter without FAULT extension, an input capture will be done.
0001 – Reserved
0010 – Reserved
0011 – Reserved
0100 – Reserved
0101 – Reserved
0110 – Reserved
0111 – Reserved
By default, the selected event channel n will be the event channel source for CC channel A, and event channel
(n+1)%8, (n+2)%8, and (n+3)%8 will be the event channel source for CC channel B, C, and D.
Table 13-19 and Table 13-20 show the event channel source for each CC channel, depending of EVACT settings:
Bit 7 6 5 4 3 2 1 0
+0x04 LCCDMODE[1:0] LCCCMODE[1:0] LCCBMODE[1:0] LCCAMODE[1:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x05 HCCDMODE[1:0] HCCCMODE[1:0] HCCBMODE[1:0] HCCAMODE[1:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Note: 1. This mode should be used only if the Fault Unit extension is set in conditional capture fault mode. For more details, refer to“Fault Extension” on
page 209 for description.
Bit 7 6 5 4 3 2 1 0
+0x06 – – TRGINTLVL[1:0] ERRINTLVL[1:0] OVFINTLVL[1:0]
Read/Write R R R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x07 LCCDINTLVL[1:0] LCCCINTLVL[1:0] LCCBINTLVL[1:0] LCCAINTLVL[1:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
– – STOP – CMD[1:0] LUPD DIR
Read/Write R R R/W R R/W R/W R/W R/W
Initial value 0 0 1 0 0 0 0 0
00 NONE None
Bit 7 6 5 4 3 2 1 0
+0x0C LCCDIF LCCCIF LCCBIF LCCAIF – TRGIF ERRIF OVFIF
Read/Write R/W R/W R/W R/W R R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x20 LCNT[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x26 LPER[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
LCCx[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
HCCx[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x37 LPERBUF[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
LCCxBUF[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
HCCxBUF[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
+0x02 CTRLC POLD POLC POLB POLA CMPD CMPC CMPB CMPA 176
+0x05 Reserved - - - - - - - -
+0x0C INTFLAGS CCDIF CCCIF CCBIF CCAIF - TRGIF ERRIF OVFIF 180
+0x0D Reserved - - - - - - - -
+0x0E Reserved - - - - - - - -
Table 13-23. Timer/counter interrupt vectors and their word offset address
+0x02 CTRLC HCMPD HCMPC HCMPB HCMPA LCMPD LCMPC LCMPB LCMPA 186
+0x0C INTFLAGS LCCDIF LCCCIF LCCBIF LCCAIF - TRGIF ERRIF OVFIF 191
+0x0D Reserved - - - - - - - -
+0x0E Reserved - - - - - - - -
+0x0F Reserved - - - - - - - -
+0x21 Reserved - - - - - - - -
+0x27 Reserved - - - - - - - -
+0x37 Reserved - - - - - - - -
Table 13-24. Timer/counter interrupt vectors and their word offset address
0x0A CCD_ vect(1) Timer/Counter compare or capture channel D interrupt vector offset
14.1 Features
Module for more customized and advanced PWM and waveform output
Optimized for various types of motor, ballast and power stage control
Output matrix for timer/counter compare channel distribution:
Configurable distribution of compare channel outputs across port pins
Redistribution of dead-time insertion resources between TC4 and TC5.
Four dead-time insertion (DTI) units, each with:
Complementary high and low channel with non overlapping outputs
Separate dead-time setting for high and low side
8-bit resolution
Four swap (SWAP) units:
Separate port pair or low/high side drivers swap
Double buffered swap feature
Pattern generation creating synchronized bit pattern across the port pins
Double buffered pattern generation
14.2 Overview
The waveform extension (WEX) provides extra functions to the timer/counter in waveform generation (WG) modes. It is
primarily intended for use in different types of motor control, ballast, LED, H-bridge, power converter and other types of
power control applications. The WEX consists of five independent and successive units, as shown in Figure 14-1.
Px5
Fault
Output Matrix
HIRES
Px3
DTI1 SWAP1
Px2
T/C4
Fault Px1
Unit 4 DTI0 SWAP0
Px0
The output matrix (OTMX) can distribute and route out the waveform outputs from timer/counter 4 and 5 across the port
pins in different configurations, each optimized for different application types.
The dead time insertion (DTI) unit splits the four lower OTMX outputs into a two non-overlapping signals, the non-
inverted low side (LS) and inverted high side (HS) of the waveform output with optional dead-time insertion between LS
and HS switching.
The swap (SWAP) unit can swap the LS and HS pin position. This can be used for fast decay motor control.
The pattern generation unit generates synchronized output waveform with constant logic level. This can be used for easy
stepper motor and full bridge control.
The output override disable unit can disable the waveform output on selectable port pins to optimize the pins usage. This
is to free the pins for other functional use, when the application does not need the waveform output spread across all the
port pins as they can be selected by the OTMX configurations.
OTMX[2x+1] PGV[2x+1]
P[2x+1]
LS
PGO[2x+1] INV[2x+1]
OTMX OTMX[x] DTIx DTIxEN SWAPx
PGO[2x] INV[2x]
HS
P[2x]
OTMX[2x] PGV[2x]
101 – – – – – – – –
110 – – – – – – – –
111 – – – – – – – –
1. Configuration 000 is default configuration. The pin location is the default one, and corresponds to the default
timer/counter configuration.
2. Configuration 001 distributes the waveform outputs from timer/counter 5 compare channel A and B (TC5 CCA and
TC5 CCB) on four pin locations. This provides for example, the enable control of the four transistors of a full bridge
with only the use of two compare channels. Using pattern generation, some of these four outputs can be overwrit-
ten by a constant level, enabling flexible drive of a full bridge in all quadrant configurations.
3. Configuration 010 distributes the waveform outputs from compare channels A and B (CCA and CCB) from both
timer/counter 4 and 5 on two other pin locations.
4. Configuration 011 distributes the waveform outputs from timer/counter 4 compare channel A (TC4CCA) to all port
pins. Enabling pattern generation in this mode will control a stepper motor.
5. Configuration 100 distributes the waveform output from timer/counter 5 compare channel A (TC5 CCA) to pin 7
and the waveform output from timer/counter 4 compare channel A (TC4 CCA) to all other pins (Px0 to Px6). This,
together with pattern generation and the fault extension, enable control of one to seven LED strings.
As shown in Figure 14-4, the 8-bit dead-time counter is decremented by one at each peripheral clock cycle, until it
reaches zero. A nonzero counter value will force both the low side and high side outputs into their OFF state. When the
output matrix (OTMX) output changes, the dead-time counter is reloaded according to the edge of the input. When the
output changes from low to high (positive edge) it initiates counter reload of the DTLS register, and when the output
changes from high to low (negative edge) a reload of the DTHS register.
As with other double buffered timer/counter registers, the register update is synchronized to the UPDATE condition, set
by the timer/counter waveform generation mode. If the synchronization provided is not required by the application, the
application code can simply access the PGO, PGV, or PORTx registers directly.
In addition to port override condition, the timer/counter channel CCxMode associated to output port must be set to COMP
or BOTHCC to make corresponding pattern generator be visible on the port.
Bit 7 6 5 4 3 2 1 0
+0x00 UPSEL OTMX[2:0] DTI3EN DTI2EN DTI1EN DTI0EN
Read/Write R R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x01 DTBOTH[7:0]
Read/Write W W W W W W W W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x02 DTLS[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x03 DTHS[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x04/0x05 – – – – – SWAPBUFV PGVBUFV PGOBUFV
Read/Write R R R R R R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x06 – – – – SWAP3 SWAP2 SWAP1 SWAP0
Read/Write R R R R R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x07 PGO[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x08 PGV[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x0A – – – – SWAP3BUF SWAP2BUF SWAP1BUF SWAP0BUF
Read/Write R R R R R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x0B PGOBUF[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x0C PGVBUF[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x0F OUTOVDIS[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
+0x09 Reserved – – – – – – – –
+0x0D Reserved – – – – – – – –
+0x0E Reserved – – – – – – – –
15.1 Features
Increases waveform generator resolution up to 8x (3 bits)
Supports frequency, single-slope PWM, and dual-slope PWM generation
Supports the waveform extension when this is used for the same timer/counter
15.2 Overview
The high-resolution (hi-res) extension can be used to increase the resolution of the waveform generation output from a
timer/counter by four or eight. It can be used for a timer/counter doing frequency, single-slope PWM, or dual-slope PWM
generation. It can also be used with the waveform extension (WeX) if this is used for the same timer/counter.
The hi-res extension uses the peripheral 4x clock (ClkPER4). The system clock prescalers must be configured so the
peripheral 4x clock frequency is four times higher than the peripheral and CPU clock frequency when the hi-res extension
is enabled. Refer to “System Clock Selection and Prescalers” on page 98 for more details.
Override Disable
extension
Generation
Dead-Time
Insertion
Fault
Pattern
Output
Output
SWAP
Matrix
When the hi-res extension is enabled, the timer/counter must run from a non-prescaled peripheral clock. The
timer/counter will ignore its two least-significant bits (lsb) in the counter, and counts by four for each peripheral clock
cycle. Overflow/underflow and compare match of the 14 most-significant bits (msb) is done in the timer/counter. Count
and compare of the two lsb is handled and compared in the hi-res extension running from the peripheral 4x clock.
The two lsb of the timer/counter period register must be set to zero to ensure correct operation. If the count register is
read from the application code, the two lsb will always be read as zero, since the timer/counter run from the peripheral
clock. The two lsb are also ignored when generating events.
When the hi-res plus feature is enabled, the function is the same as with the hi-res extension, but the resolution will
increase by eight instead of four. This also means that the three lsb are handled by the hi-res extension instead of two
lsb, as when only hi-res is enabled. The extra resolution is achieved by counting on both edges of the peripheral 4x clock.
The hi-res extension will not output any pulse shorter than one peripheral clock cycle; i.e., a compare value lower than
four will have no visible output.
Bit 7 6 5 4 3 2 1 0
+0x00 – – – – HRPLUS[1:0] HREN[1:0]
Read/Write R R R R R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
00 NONE None
00 NONE None
16.1 Features
Connected to timer/counter output and waveform extension input
Event controlled fault protection for instant and predictable fault triggering
Fast, synchronous and asynchronous fault triggering
Flexible configuration with multiple fault sources
Recoverable fault modes:
Restart or halt the timer/counter on fault condition
Timer/counter input capture on fault condition
Waveform output active time reduction on fault condition
Non-recoverable faults:
Waveform output is forced to a pre-configured safe state on fault condition
Optional fuse output value configuration defining the output state during system reset
Flexible fault filter selections:
Digital filter to prevent false triggers from I/O pin glitches
Fault blanking to prevent false triggers during commutation
Fault input qualification to filter the fault input during the inactive output compare states
16.2 Overview
The fault extension enables event controlled fault protection by acting directly on the generated waveforms from
timer/counter compare outputs. It can be used to trigger two types of faults with the following actions:
Recoverable faults: the timer/counter can be restarted or halted as long as the fault condition is preset. The compare
output pulse active time can be reduced as long as the fault condition is preset. This is typically used for current
sensing regulation, zero crossing re-triggering, demagnetization re-triggering, and so on.
Non-recoverable faults: the compare outputs are forced to a safe and pre-configured values that are safe for the
application. This is typically used for instant and predictable shut down and to disable the high current or voltage
drivers.
Events are used to trigger a fault condition. One or several simultaneous events are supported, both synchronously or
asynchronously. By default, the fault extension supports asynchronous event operation, ensuring predictable and instant
fault reaction, including system power modes where the system clock is stopped.
By using the input blanking, the fault input qualification or digital filter option in event system, the fault sources can be
filtered to avoid false faults detection.
Cycle A B A B
"update"
"match"
Period (T) CCx=BOT CCx=TOP
MAX
TOP
CNT
CCA/CCB
BOTTOM
WG Output A
WG Output B
0$;
XSGDWH
723
PDWFK
&17 &&$
%27720
)DXOW,QSXW$
'7/6 '7/6!
:*2XWSXW$
.HHS .HHS 1R.HHS
MAX
"update"
TOP
"match"
CNT CCA
CCB
BOTTOM
Fault Input A
Fault Input B
Figure 16-4. Fault Input Qualification in RAMP2 Mode with Inverted Polarity
Cycle A B A B
MAX
"update"
TOP
"match"
CNT CCA
CCB
BOTTOM
Fault Input A
Fault Input B
MAX
"update"
TOP
"match"
CNT CCA
BOTTOM
Fault Input A
NO
WG Output A KEEP
KEEP
MAX
"update"
TOP
"match"
CCA
CNT
CCB
BOTTOM
Restart Restart
Fault Input A
WG Output A
WG Output B
Note that in RAMP2 mode of operation, when a new timer/counter cycle starts, the cycle index will change automatically,
as shown in Figure 16-7 on page 214. Fault A and fault B are qualified only during the cycle A and cycle B respectively,
i.e. the compare channel outputs are not forced to inactive level as long as the fault condition is present in cycle B or
cycle A respectively.
Cycle A B A B
"update"
Period (T) CCx=BOT CCx=TOP "match"
MAX
TOP
CNT
CCA/CCB
BOTTOM
No fault A action
in cycle B Restart
Fault Input A
WG Output A
WG Output B
The Control logic of the restart command is shown in Figure 16-8 below.
MAX
"update"
TOP
"match"
CNT CCA
HALT
BOTTOM
Resume
Fault Input A
WG Output A KEEP
If the restart action is enabled, the timer/counter is halted as long as the fault condition is present and restarted when the
fault condition is no longer present, as shown in Figure 16-12 on page 216. The compare channel output A is clamped to
inactive level as long as the timer/counter is halted. Note that in RAMP2 mode of operation, when a new timer/counter
cycle starts, the cycle index will change automatically.
MAX
"update"
TOP
"match"
CCA
CNT
HALT
BOTTOM
Restart Restart
Fault Input A
WG Output A
MAX
"update"
TOP
"match"
CNT CCA
HALT
BOTTOM
Restart Restart
Fault Input A
Software Clear
NO
WG Output A KEEP
KEEP
Bit 7 6 5 4 3 2 1 0
+0x00 RAMP[1:0] FDDBD PORTCTRL FUSE FILTERE SRCE[1:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x01 SOFTA HALTA[1:0] RESTARTA KEEPA – SRCA[1:0]
Read/Write R/W R/W R/W R/W R/W R R/W R/W
Initial value 0 0 0 0 0 0 0 0
11 – Reserved
Fault A input source is linked to the fault B state from the end of the
previous cycle. If keep action is disabled, the fault A duration is one
11 LINK
peripheral clock cycle. Alternatively, if the keep action is enabled, the fault
A duration is one complete timer/counter cycle.
Bit 7 6 5 4 3 2 1 0
+0x02 – – CAPTA – – FILTERA BLANKA QUALA
Read/Write R R R/W R R R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x03 SOFTB HALTB[1:0] RESTARTB KEEPB – SRCB[1:0]
Read/Write R/W R/W R/W R/W R/W R R/W R/W
Initial value 0 0 0 0 0 0 0 0
11 – Reserved
Fault B input source is linked to the fault A state from the end of the previous
cycle. If keep action is disabled, the fault B duration is one peripheral clock
11 LINK
cycle. Alternatively, if the keep action is enabled, the fault B duration is one
complete timer/counter cycle.
Bit 7 6 5 4 3 2 1 0
+0x04 – – CAPTB – – FILTERB BLANKB QUALB
Read/Write R R R/W R R R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x05 STATEB STATEA STATEE – IDX FAULTBIN FAULTAIN FAULTEIN
Read/Write R R R R R R R R
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x06 HALTBCLR HALTACLR STATEECLR – – FAULTB FAULTA FAULTE
Read/Write R/W R/W R/W R R R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x07 FAULTBSW FAULTASW FAULTESW IDXCMD[1:0] – – –
Read/Write R/W R/W R/W R/W R/W R R R
Initial value 0 0 0 0 0 0 0 0
11 HOLD Hold IDX: the next cycle will be the same as the current cycle.
+0x05 STATUS STATEB STATEA STATEE - IDX FAULTBIN FAULTAIN FAULTEIN 222
17.1 Features
16-bit resolution
Selectable clock source
32.768kHz external crystal
External clock
32.768kHz internal oscillator
32kHz internal ULP oscillator
Programmable 10-bit clock prescaling
One Compare register
One Period register
Clear counter on period overflow
Optional interrupt/event on overflow and compare match
Correction for external crystal selection
17.2 Overview
The 16-bit real-time counter (RTC) is a counter that typically runs continuously, including in low-power sleep modes, to
keep track of time. It can wake up the device from sleep modes and/or interrupt the device at regular intervals.
The RTC clock is typically the 1.024kHz output from a high-accuracy crystal of 32.768kHz, and this is the configuration
most optimized for low power consumption. The faster 32.768kHz output can be selected if the RTC needs a resolution
higher than 1ms. The RTC can also be clocked from an external clock signal, the 32.768kHz internal oscillator or the
32kHz internal ULP oscillator.
The RTC includes a 10-bit programmable prescaler that can scale down the reference clock before it reaches the
counter. A wide range of resolutions and time-out periods can be configured. With a 32.768kHz clock source, the
maximum resolution is 30.5μs, and time-out periods can range up to 2000 seconds. With a resolution of 1s, the
maximum time-out period is more than 18 hours (65536 seconds). The RTC can give a compare interrupt and/or event
when the counter equals the compare register value, and an overflow interrupt and/or event when it equals the period
register value.
The RTC also supports correction when operated using external crystal selection. An externally calibrated value will be
used for correction. The RTC can be calibrated by software to an accuracy of ±0.5PPM relative to a minimum reference
clock of 2MHz. The RTC correction operation will either speed up (by skipping count) or slow down (adding extra cycles)
the prescaler to account for the clock error.
External Clock
TOSC1
32.768 kHz Crystal
TOSC2 Osc
DIV32
DIV32
(DIV32)
RTCSRC
CALIB PER
clkRTC
TOP/
=
Overflow
Correction Hold Count 10-bit
Counter
CNT
prescaler
”match”/
=
Compare
COMP
17.5 Correction
The RTC can do internal correction on the RTC crystal clock by taking the PPM error value from the CALIB Register. The
CALIB register will be written by software after external calibration or temperature corrections. Correction is done within
an interval of approximately 1 million cycles. The correction operation is performed as a single cycle operation – adding
or removing one cycle, depending on the nature of error. These single cycle operations will be performed repeatedly the
error number of times (ERROR[6:0] - CALIB Register) spread through out the 1 million cycle correction interval. The
correction spread over this correction interval is based on the error value. The final correction of the clock will be reflected
in the RTC count value available through the CNTL and CNTH registers. When the required correction is speeding up the
PRESCALER=DIV8
CORRECT=0
Count enable
PRESCALER=DIV8
CORRECT=4
Count enable
PRESCALER=DIV8
CORRECT=-4
Count enable
Bit 7 6 5 4 3 2 1 0
+0x00 – – – – CORREN PRESCALER[2:0]
Read/Write R R R R R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x01 – – – – – – – SYNCBUSY
Read/Write R R R R R R R R
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x02 – – – – COMPINTLVL[1:0] OVFINTLVL[1:0]
Read/Write R R R R R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x03 – – – – – – COMPIF OVFIF
Read/Write R R R R R R R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x04 TEMP[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x09 CNT[15:8]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x0B PER[15:8]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x0D COMP[15:8]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
18.1 Features
Bidirectional, two-wire communication interface
Phillips I2C compatible
System Management Bus (SMBus) compatible
Bus master and slave operation supported
Slave operation
Single bus master operation
Bus master in multi-master bus environment
Multi-master arbitration
Bridge mode with independent and simultaneous master and slave operation
Flexible slave address match functions
7-bit and general call address recognition in hardware
10-bit addressing supported
Address mask register for dual address match or address range masking
Optional software address recognition for unlimited number of addresses
Slave can operate in all sleep modes, including power-down
Slave address match can wake device from all sleep modes
Up to 1MHz bus frequency support
Slew-rate limited output drivers
Input filter for bus noise and spike suppression
Support arbitration between start/repeated start and data bit (SMBus)
Slave arbitration allows support for address resolve protocol (ARP) (SMBus)
Supports SMBUS Layer 1 timeouts
Configurable timeout values
Independent timeout counters in master and slave (Bridge mode support)
18.2 Overview
The two-wire interface (TWI) is a bidirectional, two-wire communication interface. It is I2C and System Management Bus
(SMBus) compatible. The only external hardware needed to implement the bus is one pull-up resistor on each bus line.
A device connected to the bus must act as a master or a slave. The master initiates a data transaction by addressing a
slave on the bus and telling whether it wants to transmit or receive data. One bus can have many slaves and one or
several masters that can take control of the bus. An arbitration process handles priority if more than one master tries to
transmit data at the same time. Mechanisms for resolving bus contention are inherent in the protocol.
The TWI module supports master and slave functionality. The master and slave functionality are separated from each
other, and can be enabled and configured separately. The master module supports multi-master bus operation and
arbitration. It contains the baud rate generator. All 100kHz, 400kHz, and 1MHz bus frequencies are supported. Quick
command and smart mode can be enabled to auto-trigger operations and reduce software complexity.
The slave module implements 7-bit address match and general address call recognition in hardware. 10-bit addressing is
also supported. A dedicated address mask register can act as a second address match register or as a register for
address range masking. The slave continues to operate in all sleep modes, including power-down mode. This enables
the slave to wake up the device from all sleep modes on TWI address match. It is possible to disable the address
matching to let this be handled in software instead.
The TWI module will detect START and STOP conditions, bus collisions, and bus errors. Arbitration lost, errors, collision,
and clock hold on the bus are also detected and indicated in separate status flags available in both master and slave
modes.
VCC
RS RS RS RS RS RS
SDA
SCL
Note: RS is optional
An unique address is assigned to all slave devices connected to the bus, and the master will use this to address a slave
and initiate a data transaction.
Several masters can be connected to the same bus, called a multi-master environment. An arbitration mechanism is
provided for resolving bus ownership among masters, since only one master device may own the bus at any given time.
A device can contain both master and slave logic, and can emulate multiple slave devices by responding to more than
one address.
A master indicates the start of a transaction by issuing a START condition (S) on the bus. An address packet with a slave
address (ADDRESS) and an indication whether the master wishes to read or write data (R/W) are then sent. After all
data packets (DATA) are transferred, the master issues a STOP condition (P) on the bus to end the transaction. The
receiver must acknowledge (A) or not-acknowledge (A) each byte received.
Figure 18-2 on page 236 shows a TWI transaction.
SDA
Direction
Transaction
The master provides the clock signal for the transaction, but a device connected to the bus is allowed to stretch the low-
level period of the clock to decrease the clock speed.
SDA
SCL
S P
START STOP
Condition Condition
Multiple START conditions can be issued during a single transaction. A START condition that is not directly following a
STOP condition is called a repeated START condition (Sr).
SDA
SCL
DATA Change
Valid Allowed
Combining bit transfers results in the formation of address and data packets. These packets consist of eight data bits
(one byte) with the most-significant bit transferred first, plus a single-bit not-acknowledge (NACK) or acknowledge (ACK)
response. The addressed device signals ACK by pulling the SCL line low during the ninth clock cycle, and signals NACK
by leaving the line SCL high.
18.3.6 Transaction
A transaction is the complete transfer from a START to a STOP condition, including any repeated START conditions in
between. The TWI standard defines three fundamental transaction modes: Master write, master read, and a combined
transaction.
Figure 18-5 on page 237 illustrates the master write transaction. The master initiates the transaction by issuing a START
condition (S) followed by an address packet with the direction bit set to zero (ADDRESS+W).
Transaction
Address Packet Data Packet
N data packets
Assuming the slave acknowledges the address, the master can start transmitting data (DATA) and the slave will ACK or
NACK (A/A) each byte. If no data packets are to be transmitted, the master terminates the transaction by issuing a STOP
condition (P) directly after the address packet. There are no limitations to the number of data packets that can be
Transaction
Address Packet Data Packet
N data packets
Assuming the slave acknowledges the address, the master can start receiving data from the slave. There are no
limitations to the number of data packets that can be transferred. The slave transmits the data while the master signals
ACK or NACK after each data byte. The master terminates the transfer with a NACK before issuing a STOP condition.
Figure 18-7 illustrates a combined transaction. A combined transaction consists of several read and write transactions
separated by repeated START conditions (Sr).
Transaction
Address Packet #1 N Data Packets Address Packet #2 M Data Packets
Direction Direction
SCL
S
Note: 1. Clock stretching is not supported by all I2C slaves and masters.
If a slave device is in sleep mode and a START condition is detected, the clock stretching normally works during the
wake-up period. For AVR XMEGA devices, the clock stretching will be either directly before or after the ACK/NACK bit,
as AVR XMEGA devices do not need to wake up for transactions that are not addressed to it.
A slave device can slow down the bus frequency by stretching the clock periodically on a bit level. This allows the slave
to run at a lower system clock frequency. However, the overall performance of the bus will be reduced accordingly. Both
18.3.8 Arbitration
A master can start a bus transaction only if it has detected that the bus is idle. As the TWI bus is a multi-master bus, it is
possible that two devices may initiate a transaction at the same time. This results in multiple masters owning the bus
simultaneously. This is solved using an arbitration scheme where the master loses control of the bus if it is not able to
transmit a high level on the SDA line. The masters who lose arbitration must then wait until the bus becomes idle (i.e.,
wait for a STOP condition) before attempting to reacquire bus ownership. Slave devices are not involved in the arbitration
procedure.
DEVICE1_SDA
DEVICE2_SDA
SDA
bit 7 bit 6 bit 5 bit 4
(wired-AND)
SCL
S
Figure 18-9 shows an example where two TWI masters are contending for bus ownership. Both devices are able to issue
a START condition, but DEVICE1 loses arbitration when attempting to transmit a high level (bit 5) while DEVICE2 is
transmitting a low level.
Arbitration between a repeated START condition and a data bit, a STOP condition and a data bit, or a repeated START
condition and a STOP condition are not allowed and will require special handling by software.
18.3.9 Synchronization
A clock synchronization algorithm is necessary for solving situations where more than one master is trying to control the
SCL line at the same time. The algorithm is based on the same principles used for the clock stretching previously
described. Figure 18-10 shows an example where two masters are competing for control over the bus clock. The SCL
line is the wired-AND result of the two masters clock outputs.
DEVICE1_SCL
DEVICE2_SCL
SCL
(wired-AND)
A high-to-low transition on the SCL line will force the line low for all masters on the bus, and they will start timing their low
clock period. The timing length of the low clock period can vary among the masters. When a master (DEVICE1 in this
case) has completed its low period, it releases the SCL line. However, the SCL line will not go high until all masters have
released it. Consequently, the SCL line will be held low by the device with the longest low period (DEVICE2). Devices
with shorter low periods must insert a wait state until the clock is released. All masters start their high period when the
SCL line is released by all devices and has gone high. The device which first completes its high period (DEVICE1) forces
the clock line low, and the procedure is then repeated. The result is that the device with the shortest clock period
determines the high period, while the low period of the clock is determined by the device with the longest clock period.
RESET
UNKNOWN
(0b00)
P + Timeout
S
Sr
IDLE BUSY
(0b01) P + Timeout (0b11)
Command P
Arbitration
Write ADDRESS Lost
(S) OWNER
(0b10)
Write
ADDRESS(Sr)
M1 M2 M3 M4
Wait for
SW
IDLE
R/W A SW P IDLE M2
W A SW Sr M3 BUSY M4
SW DATA A/A
SW Driver software
MASTER READ INTERRUPT + HOLD
The master provides data
on the bus
A/A Sr M3
Mn Diagram connections
A/A
R A DATA
The number of interrupts generated is kept to a minimum by automatic handling of most conditions. Quick command and
smart mode can be enabled to auto-trigger operations and reduce software complexity.
18.5.1.1 Case M1: Arbitration Lost or Bus Error during Address Packet
If arbitration is lost during the sending of the address packet, the master write interrupt flag and arbitration lost flag are
both set. Serial data output to the SDA line is disabled, and the SCL line is released. The master is no longer allowed to
perform any operation on the bus until the bus state has changed back to idle.
A bus error will behave in the same way as an arbitration lost condition, but the error flag is set in addition to the write
interrupt and arbitration lost flags.
18.5.1.2 Case M2: Address Packet Transmit Complete - Address not Acknowledged by Slave
If no slave device responds to the address, the master write interrupt flag and the master received acknowledge flag are
set. The clock hold is active at this point, preventing further activity on the bus.
18.5.1.3 Case M3: Address Packet Transmit Complete - Direction Bit Cleared
If the master receives an ACK from the slave, the master write interrupt flag is set and the master received acknowledge
flag is cleared. The clock hold is active at this point, preventing further activity on the bus.
18.5.1.4 Case M4: Address Packet Transmit Complete - Direction Bit Set
If the master receives an ACK from the slave, the master proceeds to receive the next byte of data from the slave. When
the first data byte is received, the master read interrupt flag is set and the master received acknowledge flag is cleared.
The clock hold is active at this point, preventing further activity on the bus.
P S2
S1 S3 A S1 Sr S3
P S2
A S1 Sr S3
SW Driver software
W SW A/A DATA SW A/A
The master provides data
on the bus
Interrupt on STOP
SW
Condition Enabled
Slave provides data on
the bus Collision Release
(SMBus)
SW
Hold S1
Sn Diagram connections
The number of interrupts generated is kept to a minimum by automatic handling of most conditions. Quick command can
be enabled to auto-trigger operations and reduce software complexity.
Promiscuous mode can be enabled to allow the slave to respond to all received addresses.
Figure 18-14.TWI Bus Topology Example when one Device is Enabled in Bridge Mode
Note: RS is optional
SCL
SDA
RP RP RS RS RS RS
VCC
Slave Master
RP RP
TWI DEVICE #1 TWI DEVICE #2 TWI DEVICE #3 TWI DEVICE #N
RS RS RS RS RS RS
SDA
SCL
Note: RS is optional
18.9.1 Overview
Ttimeout
25ms
SCL
STOP
SDA
TTIMEOUT
Tlowsext
25ms
SCL
SDA
18.9.2 Operation
For the operation of SMBUS timeout counters, the 2MHz internal oscillator should be in the oscillator control register,
“CTRL – Oscillator Control Register” on page 104.
Stop condition sent by hardware. The Slave resets the communication and releases the
Ttimeout master is ready to start a new transaction bus. Ready to receive a START condition in no
on the bus. later than TIMEOUT,MAX
Stop condition sent by hardware. The Slave resets the communication after detecting a
Tlowsext master is ready to start a new transaction stop pulse after timeout. Ready to receive a
on the bus. START condition.
Stop condition sent by hardware. The Slave resets the communication after detecting a
Tlowmext master is ready to start a new transaction stop pulse after timeout. Ready to receive a
on the bus. START condition.
Bit 7 6 5 4 3 2 1 0
+0x00 BRIDGEEN SFMPEN SSDAHOLD[1:0] FMPEN SDAHOLD[1:0] EDIEN
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
0 Normal TWI Two-pin interface, slew rate control, and input filter
1 External driver interface Four-pin interface, standard I/O, no slew rate control, and no input filter
Bit 7 6 5 4 3 2 1 0
+0x00 INTLVL[1:0] RIEN WIEN ENABLE – – –
Read/Write R/W R/W R/W R/W R/W R R R
Initial Value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x01 TOIE TMEXTEN TSEXTEN TTOUTEN TIMEOUT[1:0] QCEN SMEN
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
10 100US 100µs
11 200US 200µs
Bit 7 6 5 4 3 2 1 0
+0x02 – – – – – ACKACT CMD[1:0]
Read/Write R R R R R R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
ACKACT Action
0 Send ACK
1 Send NACK
00 NOACT X Reserved
W No operation
10 BYTEREC
R Execute acknowledge action succeeded by a byte receive
Writing a command to the CMD bits will clear the master interrupt flags and the CLKHOLD flag.
Bit 7 6 5 4 3 2 1 0
+0x03 RIF WIF CLKHOLD RXACK ARBLOST BUSERR BUSSTATE[1:0]
Read/Write R/W R/W R R R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
Writing 01 to the BUSSTATE bits forces the bus state logic into the idle state. The bus state logic cannot be forced into
any other state. When the master is disabled, and after reset, the bus state logic is disabled and the bus state is
unknown.
Bit 7 6 5 4 3 2 1 0
+0x04 BAUD[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
The baud rate (BAUD) register defines the relation between the system clock and the TWI bus clock (SCL) frequency.
The frequency relation can be expressed by using the following equation:
f sys
f TWI = --------------------------------------- [Hz] [1]
2(5 + BAUD )
The BAUD register must be set to a value that results in a TWI bus clock frequency (fTWI) equal or less than 100kHz or
400kHz, depending on which standard the application should comply with. The following equation [2] expresses equation
[1] solved for the BAUD value:
f sys
BAUD = -------------- – 5 [2]
2f TWI
The BAUD register should be written only while the master is disabled.
Bit 7 6 5 4 3 2 1 0
+0x05 ADDR[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
When the address (ADDR) register is written with a slave address and the R/W bit while the bus is idle, a START
condition is issued and the 7-bit slave address and the R/W bit are transmitted on the bus. If the bus is already owned
Bit 7 6 5 4 3 2 1 0
+0x06 DATA[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
The data (DATA) register is used when transmitting and receiving data. During data transfer, data are shifted from/to the
DATA register and to/from the bus. This implies that the DATA register cannot be accessed during byte transfers, and
this is prevented by hardware. The DATA register can only be accessed when the SCL line is held low by the master; i.e.,
when CLKHOLD is set.
In master write mode, writing the DATA register will trigger a data byte transfer followed by the master receiving the
acknowledge bit from the slave. WIF and CLKHOLD are set.
In master read mode, RIF and CLKHOLD are set when one byte is received in the DATA register. If smart mode is
enabled, reading the DATA register will trigger the bus operation as set by the ACKACT bit. If a bus error occurs during
reception, WIF and BUSERR are set instead of RIF.
Accessing the DATA register will clear the master interrupt flags and CLKHOLD.
Bit 7 6 5 4 3 2 1 0
+0x00 INTLVL[1:0] DIEN APIEN ENABLE PIEN PMEN SMEN
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x01 TOIE – – TTOUTEN – ACKACT CMD[1:0]
Read/Write R/W R R R/W R R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
ACKACT Action
0 Send ACK
1 Send NACK
00 NOACT X No action
01 X Reserved
1 No operation
Writing the CMD bits will automatically clear the slave interrupt flags and CLKHOLD, and release the SCL line. The
ACKACT bit and CMD bits can be written at the same time, and then the acknowledge action will be updated before the
command is triggered.
Bit 7 6 5 4 3 2 1 0
+0x02 DIF APIF CLKHOLD RXACK COLL BUSERR DIR AP
Read/Write R/W R/W R R R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
AP Description
Bit 7 6 5 4 3 2 1 0
+0x03 ADDR[7:1] ADDR[0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x04 DATA[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
The data (DATA) register is used when transmitting and received data. During data transfer, data are shifted from/to the
DATA register and to/from the bus. This implies that the DATA register cannot be accessed during byte transfers, and
this is prevented by hardware. The DATA register can be accessed only when the SCL line is held low by the slave; i.e.,
when CLKHOLD is set.
When a master is reading data from the slave, data to send must be written to the DATA register. The byte transfer is
started when the master starts to clock the data byte from the slave, followed by the slave receiving the acknowledge bit
from the master. DIF and CLKHOLD are set.
When a master writes data to the slave, DIF and CLKHOLD are set when one byte has been received in the DATA
register. If smart mode is enabled, reading the DATA register will trigger the bus operation as set by the ACKACT bit.
Accessing the DATA register will clear the slave interrupt flags and CLKHOLD. When an address match occurs, the
received address will be stored in the DATA register.
Bit 7 6 5 4 3 2 1 0
+0x05 ADDRMASK[7:1] ADDREN
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x01 TTOUTSSEL[2:0] TMSEXTSEL[1:0] TTOUTMSEL[2:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
+0x01 CTRLB TOIE TMEXTEN TSEXTEN TTOUTEN TIMEOUT[1:0] QCEN SMEN 249
ARBLOS
+0x03 STATUS RIF WIF CLKHOLD RXACK BUSERR BUSSTATE[1:0] 251
T
+0x00 CTRLA INTLVL[1:0] DIEN APIEN ENABLE PIEN PMEN SMEN 254
+0x02 STATUS DIF APIF CLKHOLD RXACK COLL BUSERR DIR AP 256
Table 18-13. TWI Interrupt Vectors and their Word Offset Addresses
19.1 Features
Supports SMBUS Layer 1 timeouts
Configurable timeout values
Independent timeout counters in master and slave (Bridge mode support)
19.3 Overview
Ttimeout
25ms
SCL
STOP
SDA
TTIMEOUT
Tlowsext
25ms
SCL
SDA
19.4 Operation
For the operation of SMBUS timeout counters, the 2MHz internal oscillator should be enabled in the OSC_CTRL register.
Stop condition sent by hardware. The Slave resets the communication and releases the
Ttimeout master is ready to start a new transaction bus. Ready to receive a START condition in no
on the bus. later than TIMEOUT,MAX
Stop condition sent by hardware. The Slave resets the communication after detecting a
Tlowsext master is ready to start a new transaction stop pulse after timeout. Ready to receive a
on the bus. START condition.
Stop condition sent by hardware. The Slave resets the communication after detecting a
Tlowmext master is ready to start a new transaction stop pulse after timeout. Ready to receive a
on the bus. START condition.
Bit 7 6 5 4 3 2 1 0
+0x01 TOIE TMEXTEN TSEXTEN TTOUTEN TIMEOUT[1:0] QCEN SMEN
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x01 TOIE – – TTOUTEN – ACKACT CMD[1:0]
Read/Write R/W R R R/W R R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x01 TTOUTSSEL[2:0] TMSEXTSEL[1:0] TTOUTMSEL[2:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
+0x01 CTRLB TOIE TMEXTEN TSEXTEN TTOUTEN TIMEOUT[1:0] QCEN SMEN 264
20.1 Features
Full-duplex, three-wire synchronous data transfer
Master or slave operation
Lsb first or msb first data transfer
Eight programmable bit rates
Optional double buffered receive
Optional buffered transmit
Optional separate interrupts for:
Receive complete
Transmit complete
Transmit data register empty
Slave Select line pulled low
Data overrun detection
Wake up from idle sleep mode
Double speed master mode
20.2 Overview
The Serial Peripheral Interface (SPI) is a high-speed synchronous data transfer interface using three or four pins. It
allows fast communication between an XMEGA device and peripheral devices or between several microcontrollers. The
SPI supports full-duplex communication.
A device connected to the bus must act as a master or slave.The master initiates and controls all data transactions. The
interconnection between master and slave devices with SPI is shown in Figure 20-1 on page 268. The system consists of
two shift registers and a master clock generator. The SPI master initiates the communication cycle by pulling the slave
select (SS) signal low for the desired slave. Master and slave prepare the data to be sent in their respective shift
registers, and the master generates the required clock pulses on the SCK line to interchange data. Data are always
shifted from master to slave on the master output, slave input (MOSI) line, and from slave to master on the master input,
slave output (MISO) line. After each data packet, the master can synchronize the slave by pulling the SS line high.
MASTER
SLAVE
Transmit Data Register
Transmit Data Register
(DATA)
(DATA)
msb lsb MISO MISO
8-bit Shift Register
MOSI MOSI lsb msb
8-bit Shift Register
SPI CLOCK SCK SCK
GENERATOR
SS SS
Receive Buffer Register
Receive Buffer Register
In SPI slave mode, the control logic will sample the incoming signal on the SCK pin. To ensure correct sampling of this
clock signal, the minimum low and high periods must each be longer than two CPU clock cycles.
SPI - Mode 0
/SS
SCK
sampling
MISO HZ 1 2 3 4 5 6 7 8 HZ
MOSI 1 2 3 4 5 6 7 8
Cycle # 1 2 3 4 5 6 7 8
SPI - Mode 1
/SS
SCK
sampling
MISO HZ 1 2 3 4 5 6 7 8 HZ
MOSI 1 2 3 4 5 6 7 8
Cycle # 1 2 3 4 5 6 7 8
SPI - Mode 2
/SS
SCK
sampling
MISO HZ 1 2 3 4 5 6 7 8 HZ
MOSI 1 2 3 4 5 6 7 8
Cycle # 1 2 3 4 5 6 7 8
SPI - Mode 3
SCK
sampling
MISO HZ 1 2 3 4 5 6 7 8 HZ
MOSI 1 2 3 4 5 6 7 8
Status IF WRCOL - - - - - -
Register RXCI F TXCI F DREI F SSI F - - - BUFOVF
Status IF WRCOL - - - - - -
Register RXCI F TXCI F DREI F TXCI F - - - BUFOVF
IFRXC (SPI to MEM.)
"SPI Trigger Source (offset 0)"
IFDRE (MEM. to SPI)
"SPI Trigger Source (offset 1)"
Buffered SPI Modes
It is possible to use the XMEGA USART in SPI mode and then have EDMA support in master mode. For details, refer to
“USART in Master SPI mode” on page 293.
Bit 7 6 5 4 3 2 1 0
+0x00 CLK2X ENABLE DORD MASTER MODE[1:0] PRESCALER[1:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Table 20-4. Relationship between SCK and the Peripheral Clock (ClkPER) Frequency
0 00 ClkPER/4
0 01 ClkPER/16
0 10 ClkPER/64
0 11 ClkPER/128
1 00 ClkPER/2
1 01 ClkPER/8
1 10 ClkPER/32
1 11 ClkPER/64
Bit 7 6 5 4 3 2 1 0
Unbuffered mode – – – – – –
+0x01 INTLVL[1:0]
Buffer modes RXCIE TXCIE DREIE SSIE – –
Unbuffered mode Read/Write R R R R R R R/W R/W
Buffer modes Read/Write R/W R/W R/W R/W R R R/W R/W
Initial value 0 0 0 0 0 0 0 0
Note: For details on buffer modes, refer to Table 20-5 on page 277.
Bit 7 6 5 4 3 2 1 0
Unbuffered mode IF WRCOL – – – – – –
+0x02
Buffer modes RXCIF TXCIF DREIF SSIF – – – BUFOVF
Unbuffered mode Read/Write R R R R R R R R
Buffer modes Read/Write R/W R/W R/W R/W R R R R/W
Initial value 0 0 0 0 0 0 0 0
Note: For details on buffer modes, refer to Table 20-5 on page 277.
Bit 7 6 5 4 3 2 1 0
+0x03 DATA[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x04 BUFMODE[1:0] – – – SSD – –
Read/Write R/W R/W R R R R/W R R
Initial value 0 0 0 0 0 0 0 0
Unbuffered mode:
00 OFF - 1 buffer in reception, no buffer in transmission
- 1 interrupt flag for both transmission and reception
01 - Reserved
Buffer Mode 1:
- 2 buffers in reception, 1 buffer in transmission
10 BUFMODE1 - Separated interrupt flags for transmission and reception
- 1 SPI transfer must be completed before the data is copied into the shift
register, even after SPI enable (1st data transmitted = dummy byte)
Buffer Mode 2:
- 2 buffers in reception, 1 buffer in transmission
11 BUFMODE2 - Separated interrupt flags for transmission and reception
- Immediate write data into shift register after SPI enable. Then, 1 SPI
transfer must be completed before the data is copied into the shift register.
Table 20-6. SPI Interrupt vectors and their word offset address
21.1 Features
Full-duplex or one-wire half-duplex operation
Asynchronous or synchronous operation
Synchronous clock rates up to 1/2 of the device clock frequency
Asynchronous clock rates up to 1/8 of the device clock frequency
Supports serial frames with:
5, 6, 7, 8, or 9 data bits
Optionally even and odd parity bits
1 or 2 stop bits
Fractional baud rate generator
Can generate desired baud rate from any system clock frequency
No need for external oscillator with certain frequencies
Built-in error detection and correction schemes
Odd or even parity generation and parity check
Data overrun and framing error detection
Noise filtering includes false start bit detection and digital low-pass filter
Separate interrupts for
Transmit complete
Transmit Data Register empty
Receive complete
Multiprocessor communication mode
Addressing scheme to address a specific devices on a multi-device bus
Enable unaddressed devices to automatically ignore all frames
Start Frame detection in UART mode
Master SPI mode
Double buffered operation
Configurable data order
Operation up to 1/2 of the peripheral clock frequency
IRCOM module for IrDA compliant pulse modulation/demodulation
Can be linked with XMEGA Custom Logic (XCL):
Send and receive events from peripheral counter (PEC) to extend frame length
Modulate/demodulate data within the frame by using the glue logic outputs
21.2 Overview
The universal synchronous and asynchronous serial receiver and transmitter (USART) is a fast and flexible serial
communication module. The USART supports full-duplex communication, asynchronous and synchronous operation and
one-wire configurations. The USART can be set in SPI master mode and used for SPI communication.
Communication is frame based, and the frame format can be customized to support a wide range of standards. The
USART is buffered in both directions, enabling continued data transmission without any delay between frames. Separate
interrupts for receive and transmit complete enable fully interrupt driven communication. Frame error and buffer overflow
are detected in hardware and indicated with separate status flags. Even or odd parity generation and parity check can
also be enabled.
A block diagram of the USART and closely related peripheral modules (in grey) is shown in Figure 21-1 on page 280.The
main functional blocks are the clock generator, the transmitter, and the receiver, which are indicated in dashed boxes.
Clock Generator
BSEL[H:L]
OSC
SYNT LOGIC
PIN
XCK
CONTROL
Transmitter
XCL
TX PEC 1
DATA (Transmit)
CONTROL
DATA BUS
PARITY
TxD
GENERATOR PIN
CONTROL
TRANSMIT SHIFT REGISTER
XCL
LUT
OUT1
Receiver
CLOCK RX XCL
RECOVERY CONTROL PEC 0
XCL
LUT
PARITY
DATA (Receive) OUT 0
CHECKER
The clock generator includes a fractional baud rate generator that is able to generate a wide range of USART baud rates
from any system clock frequencies. This removes the need to use an external crystal oscillator with a specific frequency
to achieve a required baud rate. It also supports external clock input in synchronous slave operation.
The transmitter consists of a single write buffer (DATA), a Shift Register and a parity generator. The write buffer allows
continuous data transmission without any delay between frames.
The receiver consists of a two-level receive buffer (DATA) and a Shift Register. Data and clock recovery units ensure
robust synchronization and noise filtering during asynchronous data reception. It includes frame error, buffer overflow,
and parity error detection.
When the USART is set in one-wire mode, the transmitter and the receiver share the same RxD I/O pin.
When the USART is set in master SPI mode, all USART-specific logic is disabled, leaving the transmit and receive
buffers, Shift registers, and baud rate generator enabled. Pin control and interrupt generation are identical in both modes.
The registers are used in both modes, but their functionality differs for some control settings.
An IRCOM module can be enabled for one USART to support IrDA 1.4 physical compliant pulse modulation and
demodulation for baud rates up to 115.2kbps. For details, refer to “IRCOM – IR Communication Module” on page 304.
f OSC
0
DDR_XCK
txclk
PORT_INV
1
Synch Edge 0
Register Detector
XCK
UMSEL[1]
Pin
1
rxclk
0
Operating mode Conditions Baud rate calculation (1) BSEL value calculation
BSCALE ≥ 0
f PER f PER
f PER f BAUD BSEL 1
f BAUD 2 BSCALE
16( BSEL 1) 2 BSCALE
16 f BAUD
Asynchronous Normal
16
Speed mode (CLK2X = 0) BSCALE < 0
f PER 1 f PER
f PER f BAUD BSEL 1
f BAUD BSCALE
BSEL) 1) BSCALE
16
16((2 2 16 f BAUD
BSCALE ≥ 0
f PER f PER
f PER f BAUD BSEL 1
f BAUD 2 BSCALE
8( BSEL 1) 2 BSCALE
8 f BAUD
Asynchronous Double
8
Speed mode (CLK2X = 1) BSCALE < 0
f PER 1 f PER
f PER f BAUD BSEL 1
f BAUD BSCALE
BSEL) 1) BSCALE
8
8((2 2 8 f BAUD
Notes: 1. The baud rate is defined to be the transfer rate bit per second (bps).
For BSEL = 0, all baud rates be achieved by changing BSEL instead of setting BSCALE: BSEL = (2 BSCALE-1).
1 0 0 1
2 0 0 3
3 0 0 7
4 0 0 15
5 0 0 31
6 0 0 63
7 0 0 127
INVEN = 1 XCK
RxD / TxD
Sample
INVEN = 0 XCK
RxD / TxD
Sample
Using the inverted I/O (INVEN) setting for the corresponding XCK port pin, the XCK clock edges used for data sampling
and data change can be selected. If inverted I/O is disabled (INVEN=0), data will be changed at the rising XCK clock
edge and sampled at the falling XCK clock edge. If inverted I/O is enabled (INVEN=1), data will be changed at the falling
XCK clock edge and sampled at the rising XCK clock edge. For more details, see “I/O Ports” on page 139.
The leading edge is the first clock edge of a clock cycle. The trailing edge is the last clock edge of a clock cycle.
INVEN=0 INVEN=1
SPI Mode 1 SPI Mode 3
UCPHA=1
XCK XCK
XCK XCK
FRAME
(IDLE) St 0 1 2 3 4 [5] [6] [7] [8] [P] Sp1 [Sp2] (St / IDLE)
Sample
(U2X = 0) 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 2 3
Sample
(U2X = 1) 0 1 2 3 4 5 6 7 8 1 2
When the clock recovery logic detects a high (idle) to low (start) transition on the RxD line, the start bit detection
sequence is initiated. Sample 1 denotes the first zero-sample, as shown in the figure. The clock recovery logic then uses
samples 8, 9, and 10 for normal mode and samples 4, 5, and 6 for double speed mode to decide if a valid start bit is
received. If two or three samples have a low level, the start bit is accepted. The clock recovery unit is synchronized, and
the data recovery can begin. If two or three samples have a high level, the start bit is rejected as a noise spike, and the
receiver looks for the next high-to-low transition. The process is repeated for each start bit.
RxD BIT n
Sample
(CLK2X = 0) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1
Sample
(CLK2X = 1) 1 2 3 4 5 6 7 8 1
As for start bit detection, an identical majority voting technique is used on the three center samples for deciding of the
logic level of the received bit. The process is repeated for each bit until a complete frame is received. It includes the first
stop bit, but excludes additional ones. If the sampled stop bit is a 0 value, the frame error (FERR) flag will be set. Figure
21-8 shows the sampling of the stop bit in relation to the earliest possible beginning of the next frame's start bit.
Sample
(CLK2X = 0) 1 2 3 4 5 6 7 8 9 10 0/1 0/1 0/1
Sample
(CLK2X = 1) 1 2 3 4 5 6 0/1
A new high-to-low transition indicating the start bit of a new frame can come right after the last of the bits used for
majority voting. For normal speed mode, the first low level sample can be at the point marked (A) in Stop Bit Sampling
and Next Start Bit Sampling. For double speed mode, the first low level must be delayed to point (B). Point (C) marks a
stop bit of full length at nominal baud rate. The early start bit detection influences the operational range of the receiver.
( D 1) S ( D 2) S
Rslow R fast
S 1 D S SF ( D 1) S S M
D Sum of character size and parity size (D = 5 to 10 bit).
S Samples per bit. S = 16 for Normal Speed mode and S = 8 for Double Speed mode.
SF First sample number used for majority voting. SF = 8 for normal speed and SF = 4 for Double Speed mode.
SM Middle sample number used for majority voting. SM = 9 for normal speed and SM = 5 for Double Speed
mode.
Rslow Is the ratio of the slowest incoming data rate that can be accepted in relation to the receiver baud rate.
Rfast Is the ratio of the fastest incoming data rate that can be accepted in relation to the receiver baud rate.
Table 21-3 and Table 21-4 list the maximum receiver baud rate error that can be tolerated. Normal Speed mode has
higher toleration of baud rate variations.
Table 21-3. Recommended Maximum Receiver Baud Rate Error for Normal Speed Mode (CLK2X = 0)
D #(Data + Parity bit) Rslow [%] Rfast [%] Maximum total error [%] Receiver max. receiver error [%]
Table 21-4. Recommended Maximum Receiver Baud Rate Error for Double Speed Mode (CLK2X = 1)
D #(Data + Parity bit) Rslow [%] Rfast [%] Maximum total error [%] Receiver max. receiver error [%]
The recommendations of the maximum receiver baud rate error were made under the assumption that the Receiver and
Transmitter equally divide the maximum total error.
0 x x Standard mode
Note: 1. The SLEEP instruction will not shut down the oscillator if on going communication.
BSEL=0
BSCALE=0
fBAUD=f PER/8
clkBAUD8
BSEL=3
BSCALE=-6
fBAUD=f PER/8.375
clkBAUD8
BSEL=3
BSCALE=-4
fBAUD=f PER/9.5
clkBAUD8
CLK2X = 0 CLK2X = 1
rate (bps)
BSEL BSCALE Error [%] BSEL BSCALE Error [%]
34 2 0.8 34 3 0.8
14.4k
138 0 -0.1 138 1 -0.1
34 1 -0.8 34 2 -0.8
28.8k
137 -1 -0.1 138 0 -0.1
34 0 -0.8 34 1 -0.8
57.6k
135 -2 -0.1 137 -1 -0.1
33 -1 -0.8 34 0 -0.8
115.2k
131 -3 -0.1 135 -2 -0.1
31 -2 -0.8 33 -1 -0.8
230.4k
123 -4 -0.1 131 -3 -0.1
27 -3 -0.8 31 -2 -0.8
460.8k
107 -5 -0.1 123 -4 -0.1
19 -4 -0.8 27 -3 -0.8
921.6k
75 -6 -0.1 107 -5 -0.1
7 -4 0.6 15 -3 0.6
1.382M
57 -7 0.1 121 -6 0.1
3 -5 -0.8 19 -4 -0.8
1.843M
11 -7 -0.1 75 -6 -0.1
3 -2 -0.8
2.304M – – –
47 -6 -0.1
19 -4 0.4
2.5M – – –
77 -7 -0.1
11 -5 -0.8
3.0M – – –
43 -7 -0.2
4.0M – – – 0 0 0.0
XCK
Clock
Control Digital Input Pin
DIRy
Base
OUTy RxD
USART
(*)
LUT0 IN0 Digital Input Pin
Receive OUT0 Δ
Truth
Δ
Shift Table IN1
Register
FSM
IN2 LUT1(*)
Transmit Δ OUT1
Truth
Δ
DIRz
Shift IN3 Table
Register TxD
Input Pin
(*) Belongs to XCL module
Bit 7 6 5 4 3 2 1 0
RXB[7:0]
+0x00
TXB[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
The USART Transmit Data Buffer Register and USART Receive Data Buffer Registers share the same I/O address
referred to as USART Data Register (DATA). The Transmit Data Buffer Register (TXB) will be the destination for data
written to the DATA Register location. Reading the DATA Register location will return the contents of the Receive Data
Buffer Register (RXB).
For 5-, 6-, or 7-bit characters the upper unused bits will be ignored by the Transmitter and set to zero by the Receiver.
The transmit buffer can only be written when the DREIF Flag in the STATUS Register is set. Data written to DATA when
the DREIF Flag is not set, will be ignored by the USART Transmitter. When data is written to the transmit buffer, and the
Transmitter is enabled, the Transmitter will load the data into the Transmit Shift Register when the Shift Register is
empty. The data is then transmitted on the TxD pin.
The receive buffer consists of a two level FIFO. The FIFO and the corresponding flags in the Status Register (STATUS)
will change state whenever the receive buffer is accessed (read). Always read STATUS before DATA in order to get the
correct flags.
Bit 7 6 5 4 3 2 1 0
+0x01 RXCIF TXCIF DREIF FERR BUFOVF PERR RXSIF RXB8/DRIF
Read/Write R/W R/W R/W R/W R/W R/W R R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x02 RXSIE DRIE RXCINTLVL[1:0] TXCINTLVL[1:0] DREINTLVL[1:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x03 ONEWIRE SFDEN – RXEN TXEN CLK2X MPCM TXB8
Read/Write R/W R/W R R/W R/W R/W R R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x04 CMODE[1:0] PMODE[1:0] SBMODE CHSIZE[2:0]
+0x04 (1) CMODE[1:0] – – – UDORD UCPHA –
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 1 1
Note: 1. See “IRCOM – IR Communication Module” on page 304 for full description on using IRCOM mode.
2. See “USART in Master SPI mode” on page 293 for full description of master SPI operation.
00 DISABLED Disabled
01 – Reserved
0 1-bit
1 2-bit
100 – Reserved
101 – Reserved
110 – Reserved
Bit 7 6 5 4 3 2 1 0
+0x05 – – DECTYPE[1:0] LUTACT[1:0] PECACT[1:0]
Read/Write R R R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
01 – Reserved
Bit 7 6 5 4 3 2 1 0
+0x06 BSEL[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x07 BSCALE[3:0] BSEL[11:8]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Table 21-15. USART Interrupt Vectors and their Word Offset Address
22.1 Features
Pulse modulation/demodulation for infrared communication
IrDA compatible for baud rates up to 115.2kbps
Selectable pulse modulation scheme
3/16 of the baud rate period
Fixed pulse period, 8-bit programmable
Pulse modulation disabled
Built-in filtering
Can be connected to and used by any USART
22.2 Overview
XMEGA devices contain an infrared communication module (IRCOM) that is IrDA compatible for baud rates up to
115.2kbps. It can be connected to any USART to enable infrared pulse encoding/decoding for that USART.
RXDxn
USARTxn
TXDxn
IRCOM
.... RXD...
TXD...
encoded RXD USARTD0 RXDD0
Pulse
TXDD0
Decoding
USARTC0 RXDC0
decoded RXD TXDC0
decoded TXD
Pulse
Encoding encoded TXD
The IRCOM is automatically enabled when a USART is set in IRCOM mode. The signals between the USART and the
RX/TX pins are then routed through the module as shown in Figure 22-1. The data on the TX/RX pins are the inverted
value of the transmitted/received infrared pulse. It is also possible to select an event channel from the event system as
input for the IRCOM receiver. This will disable the RX input from the USART pin.
For transmission, three pulse modulation schemes are available:
3/16 of the baud rate period
Fixed programmable pulse time based on the peripheral clock frequency
Pulse modulation disabled
Bit 7 6 5 4 3 2 1 0
+0x00 – – – – EVSEL[3:0]
Read/Write R R R R R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
0000 – None
0001 – (Reserved)
0010 – (Reserved)
0011 – (Reserved)
0100 – (Reserved)
0101 – (Reserved)
0110 – (Reserved)
0111 – (Reserved)
Bit 7 6 5 4 3 2 1 0
+0x01 TXPLCTRL[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x02 RXPLCTRL[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
23.1 Features
Two independent 8-bit timer/counter with:
Period or compare channel for each timer/counter
Input capture for each timer
Serial peripheral data length control for each timer
Timer underflow interrupt/event
Compare match or input capture interrupt/event for each timer
One 16-bit timer/counter by cascading two 8-bit timer/counters with:
Period or compare channel
Input capture
Timer underflow interrupt/event
Compare match or input capture interrupt/event
Programmable lookup table supporting multiple configurations:
Two 2-input units
One 3-input unit
RS configuration
Duplicate input with selectable delay on one input
Connection to external I/O pins or event system
Combinatorial logic functions using programmable truth table:
AND, NAND, OR, NOR, XOR, XNOR, NOT, MUX
Sequential logic functions:
D-Flip-Flop, D Latch, RS Latch
Input sources:
From external pins or the event system
One input source includes selectable delay or synchronization option
Can be shared with selectable USART pin locations
Outputs:
Available on external pins or event system
Includes selectable delay or synchronization option
Can override selectable USART pin locations
Operates in all power modes
23.2 Overview
Atmel AVR XMEGA E devices include the XMEGA Custom Logic (XCL). The module consists of two main sub-units,
timer/counter and glue logic.
The timer/counter includes two 8-bit timer/counters BTCO and BTC1 respectively, allowing up to seven
configuration settings. Both timer/counters can be cascaded to create a 16-bit timer/counter with optional 16-bit
capture.
The glue logic is made of two truth tables with configurable delay elements and sequential logic functions such as
D-type flip-flop or D-latch
An interconnect array enables a large amount of connections between a number of XCL elements and also allows
working with other peripherals such as USART, port pins, or event system.
Event Port
System Pins USART
Interrupts
Periph.Counter
Truth
Interconnect Array
One Shot Table
8-bit T/C
Control Registers
PWM LUT0
Capture
D Q
Normal
BTC0
Interconnect Array
D Q
Normal BTC1
G
8-bit T/C
Capture
PWM LUT1
The timer/counter configuration allows for two 8-bits timer/counter usage. Each timer/counter supports normal, input
capture, continuous and one shot pulse width modulations (PWM), with common flexible clock selections and event
channels. By cascading the two 8-bit timer/counters, the XMEGA custom logic (XCL) offers a 16-bit timer/counter.
In peripheral counter (PEC) configuration, the XCL is directly linked to one of USART modules. The selected USART
controls the counter operation, since the PEC can optionally control the data length within the USART frame.
If the glue logic configuration is enabled, the XCL implements two programmable lookup tables (LUT). Each LUT defines
the truth table corresponding to the logical condition between two inputs. Any combinatorial function logic is possible.
The LUT inputs can be connected to I/O pins or to event system channels. If the LUT is connected to USART or SPI I/O
pin locations (TxD/RxD/XCK or MOSI/MISO/SCK), serial data encoding/decoding is possible. Connecting together the
LUT units, RS Latch or any combinatorial logic between two operands can be enabled.
A delay element (DLY) can be enabled. Each DLY has a 2-stage digital flip-flop. The position of the DLY is software
selectable between either one input or the output. The size of the delay is software selectable, between 0-cycle delay (no
delay), 1-cycle delay or 2-cycle delay configurations.
The LUT works in all sleep modes. Combined with event system and one I/O pin, the LUT can wake-up the system if
condition on LUT inputs is true.
A block diagram of the programmable logic unit with extensions and closely related peripheral modules is shown in
Figure 23-1 on page 309.
23.2.1 Definitions
Table 23-1 on page 310 shows the definitions used throughout the documentation.
Name Description
PEC Peripheral counter. Can work only with the serial peripheral module.
The counter reaches TOP when it becomes equal to the highest value in the count sequence. The TOP value
TOP can be equal to the period (PER) or the compare channel A (CCA) register setting. This is selected by the
waveform generator mode.
The timer/counter signals an update when it reaches BOTTOM or TOP, depending on the waveform generator
UPDATE
mode.
CLEAR External peripheral, event system or CPU forces the (peripheral) timer/counter next value to BOTTOM.
CC Compare or capture.
Delay element, created with a programmable number of flip-flops. Position is selectable by software, between
DLY
one LUT input or LUT output
In general, the term “timer” is used when the timer/counter clock control is handled by an internal source, and the term
“counter” is used when the clock control is handled externally (e.g. counting external events). When the CC channels are
used for compare operations, they are referred to as “compare channels”. When used for capture operations, the CC
channels are referred to as “capture channels”.
BTC0 "count"
Counter BTC0 "underflow"
BTC0 "restart" Counter UNF0IF
BTC1 "count" Control
CNTH CNTL BTC1 "underflow"
BTC1 "restart" Logic UNF1IF
CTRLG
BTC0 "bottom"
I/O Data Bus
=0
=0
BTC1 "bottom" Events
CMPL
Waveform
Generator
OC0 Out
BTC0 INTFLAGS
Compare =
BTC0 "match"
CC0IF
Channel
CMPH
Waveform
Generator
OC1 Out
BTC1 INTFLAGS
Compare =
BTC1 "match"
CC1IF
Channel
Counter
Control Logic
CLKSEL
EVSEL CNT
EVACT (Encoding)
The peripheral clock is fed into the common pre-scaler (common for all timer/counters in a device). A selection of the pre-
scaler outputs is directly available for both timer/counters. In addition the whole range from 1 to 215 times pre-scaling is
available through the event system.
MAX
CNT “reload”
TOP
CNT PERCAPT
BOT
CNT TOP
BOT
(PERCAPT=x) (PERCAPT=y)
PERCAPT (higher than current CNT) (lower than current CNT)
“write”
Event System
CH0 Mux. Event Channel 0 EVSEL Event for capture TC16
CH1 Mux. Event Channel 1 Event for capture BTC0
(EVSEL+1) %(n+1)
Event for capture BTC1
CHn Mux. Event Channel n
Rotate
MAX
CNT
CNT “reload”
BOT
“capture n” “capture n+1” “capture n+2”
Events
Event action: ( [1:0] = b00)
MAX
CNT “reload”
CNT
BOT
“capture n-1” “capture n” “capture n+1”
Events
Event action:
( [1:0] = b01)
Period (t0) Period (t1)
External Signal
The capture result will be the time (t) from the previous timer/counter restart until the event occurred (MAX-PERCAPT).
1
Frequency (f ): f
t
CNT
BOT
“capture n” “capture n+1” “restart” “capture n+2”
“restart”
“restart”
Events
Event action:
( [1:0] = b10) PulseWidth PulseWidth PulseWidth
(pw0) (pw1) (pw2)
External Signal
TOP
CNT
CMP
BOT
OC Out
CNT “reload”
MAX
CNT “match”
TOP
CNT
CMP
BOT
OC Out
Software “restart”
Events
Event action: ( [1:0] = b11)
CNT “reload”
MAX
CNT “match”
TOP
CNT
CMP
BOT
OC Out
“start”
“start”
“start”
“stop”
Software “restart”
Events
Event action: ( [1:0] = b10)
Base Counter
clkPER
Peripheral Length Count
INTFLAGS
PLC
I/O Data Bus
PEC0 "underflow"
PEC0 "count"
PEC0IF
PEC0 "restart" PEC1 "underflow"
PEC1 "count"
PEC1IF
CNTH CNTL Control
PEC1 "restart"
Counter Logic
Rx "count"
Rx "restart"
PEC0 "bottom"
=0 Tx "count"
PEC1 "bottom" Tx "restart"
=0
TxShiftRegclk RxShiftRegclk
In peripheral counter configuration (PEC), the peripheral length control register (PLC) represents the TOP value and the
compare is always done with the BOTTOM.
The data length within serial peripheral frame is defined using formula:
Frame Lenght PLC 1
The count (Rx/Tx ”count”) and restart (Rx/Tx ”restart”) commands are provided by each receiver and transmitter stage of
the selected serial peripheral and all CLKSEL clock settings are ignored in PEC configuration. If only one PEC is used,
the CLKSEL clock selection will be available for the other timer/counter.
While counting, the counter restarts from PLC if the restart command is received. When it reaches the BOTTOM value,
the counter restarts from PLC if restart or count command is received from the serial peripheral.
MAX
PEC “reload”
TOP 11 11 11
10 10
9 9
8
7
6
5
4
x 3
2
1
BOT 0
“count” “count”
“restart” “restart”
Since the commands are provided by the serial peripheral, the event actions are ignored. Only software restart command
is available.
PEC “reload”
MAX
TOP 9 9
8 8
PEC 7
6
7
5 PLC
4
3
2
1
BOT 0
“count” “count”
Rx/Tx“count”
Rx/Tx“restart” (*)
SCK (pin) SPI mode 0
MISO (pin) bit-0 bit-1 bit-2 bit-3 bit-4 bit-5 bit-6 bit-7 bit-8 bit-9 bit-0 bit-1 bit-
MOSI (pin) bit-0 bit-1 bit-2 bit-3 bit-4 bit-5 bit-6 bit-7 bit-8 bit-9 bit-0 bit-1 bit-
( )
* No Rx/Tx“restart”: During PEC initialization for SPI communication, set-up PEC=PLC.
The XCL supports up to two 8-bit peripheral counters, called PEC0 and PEC1 respectively.The receiver stage of serial
peripheral controls PEC0 operation, since the transmitter stage of the serial peripheral controls the PEC1 operation.
The XCL also supports two 4-bit peripheral counters, called PEC20 and PEC21 respectively. Both are mapped in one 8-
bit T/C. The receiver stage of serial peripheral controls PEC20 operation, since the transmitter stage of the serial
peripheral controls the PEC21 operation. This lets the opportunity to control serial frames up to 16 bits in reception and in
transmission, and still to have an 8-bit timer/counter available resource.
Cascading two peripheral counters is not available.
CTRLD
TRUTH0[0]
TRUTH0[1] Delay
TRUTH0[2] Block
OUT0
TRUTH0[3]
Delay Optional
IN0 Block
IN1
CTRLD
TRUTH1[0]
TRUTH1[1] Delay
TRUTH1[2] Block
OUT1
TRUTH1[3]
Delay Optional
IN2 Block
IN3
The combinatorial logic functions can be: AND, NAND, OR, NOR, XOR, XNOR, NOT.
The truth table for these functions is written to the CTRLD register of the LUT. Table 23-2 shows both truth table for 2-
input LUT units.
0 0 TRUTH0[0] 0 0 TRUTH1[0]
0 1 TRUTH0[1] 0 1 TRUTH1[1]
1 0 TRUTH0[2] 1 0 TRUTH1[2]
1 1 TRUTH0[3] 1 1 TRUTH1[3]
Cascading both LUT units, the logic function OUT can be a function of three inputs. Table 23-3 on page 320 shows the
truth table for a 3-input LUT.
=0 TRUTH0[0]
0 0 0 TRUTH1[0]
=1 TRUTH0[1]
=0 TRUTH0[0]
0 0 1 TRUTH1[1]
=1 TRUTH0[1]
=0 TRUTH0[0]
0 1 0 TRUTH1[2]
=1 TRUTH0[1]
=0 TRUTH0[0]
0 1 1 TRUTH1[3]
=1 TRUTH0[1]
=0 TRUTH0[2]
1 0 0 TRUTH1[0]
=1 TRUTH0[3]
=0 TRUTH0[2]
1 0 1 TRUTH1[1]
=1 TRUTH0[3]
=0 TRUTH0[2]
1 1 0 TRUTH1[2]
=1 TRUTH0[3]
=0 TRUTH0[2]
1 1 1 TRUTH1[3]
=1 TRUTH0[3]
DLYnCONF[1:0]
clkPER Logic
DLYSEL[1:0]
1-Cycle Delay
input D Q D Q
2-Cycle Delay output
No Delay
The insertion of a delay unit is selectable for each LUT, on the first of the two inputs or on the output. The insertion is
decided by the application purpose, but some examples are provided:
Delay on input can be used as input synchronizer or as edge detector on input signal
Delay on output can be used to filter glitches or to synchronize the LUT output when both inputs are asynchronous
IN0 Delay
Truth
Delay OUT0
Table 0
IN1 LUT0
IN2 Delay
Truth
Delay OUT1
Table 1
IN3 LUT1
IN0 Delay
Truth
Delay OUT0
Table 0
LUT0
IN2 Delay
Truth
Delay OUT1
Table 1
LUT1
IN0 Delay
Truth
Delay OUT0
Table 0
LUT0
IN2 Delay
Truth
Delay OUT1
Table 1
IN3 LUT1
IN0 Delay
Truth
Delay OUT0
Table 0
IN2 Delay
Truth
Delay OUT1
Table 1
IN3 LUT
IN0 Delay
Delay OUT0
IN1
IN2 Delay
Truth
Delay OUT1
Table 1 Mux.
IN3
& LUT
IN2 Delay
Truth
Delay OUT1
Table 1 D-Latch
IN3
& LUT
IN0 Delay
Truth
Delay OUT0
Table 0
IN2 Delay
Truth
Delay OUT1
Table 1
RS-Latch
LUT
Figure 23-25.One DFF with Data Controlled by Two Independent 2-input LUT (DFF)
IN0 Delay
Truth
D Q OUT0
Delay
Table 0
IN1
clkPER
IN2 Delay
Truth
Delay OUT1
Table 1 DFF
IN3
& LUT
OUTn
D Q D Q To Input Sensing
R R
INn
The LUT outputs are connected to all strobe, asynchronous and synchronous event system data lines, as shown in
Figure 23-7. The connection depends on delay configuration, but it is up to the application to generate the correct
waveform or to use the correct event line.
Truth
No Delay
Table
No Delay
Delay
Truth
Table
Delay
Truth
Table
INxSEL bits in CTRLB register decide the source of each input pin for each LUT0 and LUT1. Table 23-4 on page 324
shows the input selections for the LUT units. PORTSEL bits in CTRLA register select the port associated to LUT0 and
LUT1.
Notes: 1. Figure 23-18 on page 321 to Figure 23-25 on page 322 show the active inputs.
2. In TC16 configuration, IN1 is the 16-bit Waveform Generation (OC0 out).
EVASYSELn bits in CTRLC register decides if the event system channel line selection is the strobe or the asynchronous
event line.
Only the LUT0 output can be connected to I/O pin. LUT0OUTEN bit in CTRLA register allows two LUT0 output pin
locations: PIN0 or PIN4.
Table 23-5 shows the consumers of the LUT outputs.
OUT1 OUT0
Bit 7 6 5 4 3 2 1 0
+0x00 LUT0OUTEN[1:0] PORTSEL[1:0] – LUTCONF[2:0]
Read/Write R/W R/W R/W R/W R R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
11 - Reserved
LUT(s) Port C
00 PC
PEC USARTC0
LUT(s) Port D
01 PD
PEC USARTD0
1x - Reserved
Bit 3 - Reserved
This bit is unused and reserved for future use. For compatibility with future devices, always write this bit to zero
when this register is written.
Bit 2:0 – LUTCONF[2:0]: LUT Configuration
Setting these bits enables the configuration of the glue logic cells, according to Table 23-8 on page 326.
111 DFF One DFF with data controlled by two independent 2-input LUT
Bit 7 6 5 4 3 2 1 0
+0x01 IN3SEL[1:0] IN2SEL [1:0] IN1SEL [1:0] IN0SEL [1:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x02 EVASYSEL1 EVASYSEL0 DLYSEL [1:0] DLY1CONF[1:0] DLY0CONF[1:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
00 DISABLE No delay
11 - Reserved
Note: 1. Figure 23-18 on page 321 to Figure 23-25 on page 322 show possible location of delay elements.
Bit 7 6 5 4 3 2 1 0
+0x04 CMDSEL TCSEL[2:0] CLKSEL[3:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
0 NONE None
011 BTC0PEC1 One 8-bit timer/counter with period and one 8-bit transmitter peripheral counter
100 PEC0BTC1 One 8-bit timer/counter with period and one 8-bit receiver peripheral counter
One 8-bit timer/counter with period and two 4-bit transmitter/receiver peripheral
110 BTC0PEC2
counter
111 - Reserved
Bit 7 6 5 4 3 2 1 0
+0x05 CMDEN[1:0] CMP1 CMP0 CCEN1 CCEN0 MODE[1:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Note: 1. Not supported in PEC01 configuration. Refer to Table 23-13 on page 328 for more details.
Bit 7 6 5 4 3 2 1 0
+0x06 EVACTEN EVACT1[1:0] EVACT0[1:0] EVSEL[2:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
(1)
UNF1IE UNF0IE CC1IE CC0IE
(2)
+0x08 PEC1IE PEC0IE - - UNFINTLVL[1:0] CCINTLVL[1:0]
(3)
PEC21IE - PEC20IE -
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
(1)
UNF1IF UNF0IF CC1IF CC0IF - - - -
(2)
+0x08 PEC1IF PEC0IF - - - - - -
(3)
PEC21IF - PEC20IF - - - - -
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
(1)
PLC[7:0]
+0x09 (2)
– – – – PLC[3:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
(1)
CNT[15:8]
(2)
BCNT1[7:0]
+0x0B
(3)
PCNT1[7:0]
(4)
PCNT21[3:0] PCNT20[3:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 1 1 1 1 1 1 1
Bit 7 6 5 4 3 2 1 0
(1)
CMP[15:8]
+0x0D (2)
BCMP1[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 1 1 1 1 1 1 1 1
Bit 7 6 5 4 3 2 1 0
(1)
PER[7:0]
CAPT[7:0]
+0x0E
(2)
BPER0[7:0]
BCAPT0[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 1 1 1 1 1 1 1 1
(1)
PER[15:8]
CAPT[15:8]
+0x0F
(2)
BPER1[7:0]
BCAPT1[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 1 1 1 1 1 1 1 1
+0x0C Reserved - - - - - - - -
+0x0D Reserved - - - - - - - -
+0x0C Reserved - - - - - - - -
+0x0D Reserved - - - - - - - -
23.8.1.3 T/C in PWM Modes with Period Fixed to MAX (PWM or SSPWM)
+0x09 Reserved - - - - - - - -
+0x0E Reserved - - - - - - - -
+0x0F Reserved - - - - - - - -
+0x0B Reserved - - - - - - - -
+0x0C Reserved - - - - - - - -
+0x0D Reserved - - - - - - - -
+0x0F Reserved - - - - - - - -
+0x0B Reserved - - - - - - - -
+0x0C Reserved - - - - - - - -
+0x0D Reserved - - - - - - - -
+0x0F Reserved - - - - - - - -
+0x0B Reserved - - - - - - - -
+0x0D Reserved - - - - - - - -
+0x0F Reserved - - - - - - - -
+0x0C Reserved - - - - - - - -
+0x09 Reserved - - - - - - - -
+0x0C Reserved - - - - - - - -
+0x0D Reserved - - - - - - - -
23.8.3.3 T/C in PWM Modes with Period Fixed to MAX (PWM or SSPWM)
+0x09 Reserved - - - - - - - -
+0x0E Reserved - - - - - - - -
+0x0F Reserved - - - - - - - -
23.8.4 Register Summary – One 8-bit T/C and one 8-bit Tx PEC (BTC0PEC1)
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Page
+0x07 INTCTRL PEC1IE UNF0IE - CC0IE UNFINTLVL[1:0] CCINTLVL[1:0] 330
+0x09 Reserved - - - - - - - -
+0x0B Reserved - - - - - - - -
+0x0C Reserved - - - - - - - -
+0x0D Reserved - - - - - - - -
+0x0F Reserved - - - - - - - -
+0x0B Reserved - - - - - - - -
+0x0C Reserved - - - - - - - -
+0x0D Reserved - - - - - - - -
+0x0F Reserved - - - - - - - -
+0x0B Reserved - - - - - - - -
+0x0D Reserved - - - - - - - -
+0x0F Reserved - - - - - - - -
+0x0A Reserved - - - - - - - -
+0x0C Reserved - - - - - - - -
+0x0D Reserved - - - - - - - -
+0x0D Reserved - - - - - - - -
+0x0F Reserved - - - - - - - -
23.8.5 Register Summary – One 8-bit T/C and One 8-bit Rx PEC (PEC0BTC1)
Address Name BIt 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 BIt 1 BIt 0 Page
+0x07 INTCTRL UNF1IE PEC0IE CC1IE - UNFINTLVL[1:0] CCINTLVL[1:0] 330
+0x0B Reserved - - - - - - - -
+0x0C Reserved - - - - - - - -
+0x0D Reserved - - - - - - - -
+0x0E Reserved - - - - - - - -
+0x0F Reserved - - - - - - - -
+0x0A Reserved - - - - - - - -
+0x0C Reserved - - - - - - - -
+0x0D Reserved - - - - - - - -
+0x0E Reserved - - - - - - - -
+0x0A Reserved - - - - - - - -
+0x0C Reserved - - - - - - - -
+0x0D Reserved - - - - - - - -
+0x0E Reserved - - - - - - - -
+0x0A Reserved - - - - - - - -
+0x0C Reserved - - - - - - - -
+0x0E Reserved - - - - - - - -
+0x0C Reserved - - - - - - - -
+0x0D Reserved - - - - - - - -
+0x0E Reserved - - - - - - - -
+0x0F Reserved - - - - - - - -
+0x0B Reserved - - - - - - - -
+0x0C Reserved - - - - - - - -
+0x0D Reserved - - - - - - - -
+0x0F Reserved - - - - - - - -
+0x0B Reserved - - - - - - - -
+0x0C Reserved - - - - - - - -
+0x0D Reserved - - - - - - - -
+0x0F Reserved - - - - - - - -
+0x0B Reserved - - - - - - - -
+0x0D Reserved - - - - - - - -
+0x0F Reserved - - - - - - - -
+0x0A Reserved - - - - - - - -
+0x0C Reserved - - - - - - - -
+0x0D Reserved - - - - - - - -
+0x0E Reserved - - - - - - - -
+0x0F Reserved - - - - - - - -
Table 23-19. XCL Interrupt Vectors and their Word Offset Address
23.10 T/C and PEC Register Summary vs. Configuration and Mode
Config.
Mode
Mode
Mode
@Off.
@Off.
@Off.
Register Field Register Field Register Field
PWM & 1SHOT
+0x0A CNTL CNT[7:0] +0x0A CNTL CNT[7:0] +0x0A CNTL CNT[7:0]
NORMAL
CAPT
+0x0C Reserved +0x0C Reserved +0x0C CMPL CMP[7:0]
+0x0D Reserved +0x0D Reserved +0x0D CMPH CMP[15:8]
+0x0E PERCAPTL PER[7:0] +0x0E PERCAPTL CAPT[7:0] +0x0E Reserved
+0x0F PERCAPTH PER[15:8] +0x0F PERCAPTH CAPT[15:8] +0x0F Reserved
PWM & 1SHOT
+0x0A CNTL BCNT0[7:0] +0x0A CNTL BCNT0[7:0] +0x0A CNTL BCNT0[7:0]
NORMAL
PWM & 1SHOT
+0x0A CNTL BCNT0[7:0] +0x0A CNTL BCNT0[7:0] +0x0A CNTL BCNT0[7:0]
NORMAL
CAPT
NORMAL
NORMAL
+0x0C Reserved
+0x0D Reserved
+0x0E Reserved
+0x0F Reserved
NORMAL
24.1 Features
Cyclic redundancy check (CRC) generation and checking for
Communication data
Program or data in flash memory
Data in SRAM and I/O memory space
Integrated with flash memory, EDMA controller, and CPU
Continuous CRC on data going through an EDMA channel
Automatic CRC of the complete or a selectable range of the flash memory
CPU can load data to the CRC generator through the I/O interface
CRC polynomial software selectable to
CRC-16 (CRC-CCITT)
CRC-32 (IEEE 802.3)
Zero remainder detection
24.2 Overview
A cyclic redundancy check (CRC) is an error detection technique test algorithm used to find accidental errors in data, and
it is commonly used to determine the correctness of a data transmission, and data presence in the data and program
memories. A CRC takes a data stream or a block of data as input and generates a 16- or 32-bit output that can be
appended to the data and used as a checksum. When the same data are later received or read, the device or application
repeats the calculation. If the new CRC result does not match the one calculated earlier, the block contains a data error.
The application will then detect the error and may take a corrective action, such as requesting the data to be sent again
or simply not using the incorrect data.
Typically, an n-bit CRC applied to a data block of arbitrary length will detect any single error burst not longer than n bits
(any single alteration that spans no more than n bits of the data), and will detect the fraction 1-2-n of all longer error
bursts. The CRC module in XMEGA devices supports two commonly used CRC polynomials; CRC-16 (CRC-CCITT) and
CRC-32 (IEEE 802.3).
CRC-16:
Polynomial: x16+x12+x5+1
CRC-32:
Polynomial: x32+x26+x23+x22+x16+x12+x11+x10+x8+x7+x5+x4+x2+x+1
24.3 Operation
The data source for the CRC module must be selected in software as either flash memory, the EDMA channels, or the
I/O interface. The CRC module then takes data input from the selected source and generates a checksum based on
these data. The checksum is available in the CHECKSUM registers in the CRC module. When CRC-32 polynomial is
used, the final checksum read is bit reversed and complemented (see Figure 24-1 on page 345).
For the I/O interface or EDMA controller, which CRC polynomial is used is software selectable, but the default setting is
CRC-16. CRC-32 is automatically used if Flash Memory is selected as the source. The CRC module operates on bytes
only.
EDMA Flash
Controller Memory
DATAIN
CTRL
8 16 8 32
CRC-16 CRC-32
crc32
CHECKSUM
bit-reverse +
complement
Checksum read
Bit 7 6 5 4 3 2 1 0
+0x00 RESET[1:0] CRC32 – SOURCE[3:0]
Read/Write R/W R/W R/W R R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
00 NO No reset
01 – Reserved
Bit 7 6 5 4 3 2 1 0
+0x01 – – – – – – ZERO BUSY
Read/Write R R R R R R R R/W
Initial Value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x03 DATAIN[7:0]
Read/Write W W W W W W W W
Initial Value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x05 CHECKSUM[15:8]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x06 CHECKSUM[23:16]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x07 CHECKSUM[31:24]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
+0x02 Reserved – – – – – – – –
25.1 Features
12-bit resolution
Up to 300 thousand samples per second
Down to 2.3μs conversion time with 8-bit resolution
Down to 3.35μs conversion time with 12-bit resolution
Differential and single-ended input
Up to 16 single-ended inputs
16x8 differential input with programmable gain
Built-in differential gain stage
1/2x, 1x, 2x, 4x, 8x, 16x, 32x, and 64x gain options
Single, continuous and scan conversion options
Four internal inputs
Internal temperature sensor
DAC output
AVCC voltage divided by 10
1.1V bandgap voltage
Internal and external reference options
Compare function for accurate monitoring of user defined thresholds
Offset and gain correction
Averaging
oversampling and decimation
Optional event triggered conversion for accurate timing
Optional interrupt/event on compare result
Optional EDMA transfer of conversion results
25.2 Overview
The ADC converts analog signals to digital values. The ADC has 12-bit resolution and is capable of converting up to 300
thousand samples per second (ksps). The input selection is flexible, and both single-ended and differential
measurements can be done. A programmable gain stage is available to increase the dynamic range. In addition, several
internal signal inputs are available. The ADC can provide both signed and unsigned results.
The ADC measurements can either be started by application software or an incoming event from another peripheral in
the device. The ADC measurements can be started with predictable timing, and without software intervention. It is
possible to use EDMA to move ADC results directly to memory or peripherals when conversions are done.
Both internal and external reference voltages can be used. An integrated temperature sensor is available for use with the
ADC. The AVCC/10 and the bandgap voltage can also be measured by the ADC.
The ADC has a compare function for accurate monitoring of user defined thresholds with minimum software intervention
required.
When operation in noisy conditions, the average feature can be enabled to increase the ADC resolution. Up to 1024
samples can be averaged, enabling up to 16-bit resolution results. In the same way, using the oversampling and
decimation mode, the ADC resolution is increased up to 16-bits, which results in up to 4-bit extra LSB resolution. The
ADC includes various calibration options. In addition to standard production calibration, the user can enable the offset
and gain correction to improve the absolute ADC accuracy.
VIN VOUT
S&H Σ 2x
ADC DAC
ADC0
ADC1 2 bits
• CMP
•
•
ADC14 Stage Stage
ADC15
VINP
1 2
< Threshold
2 2
GAINCORR > (Int. Req.)
Internal clkADC
Signals
½x - 64x Adder/Multiplier
G RES
Digital Correction Logic
OFFSETCORR
ADC0 Averaging
•
•
•
VINN
ADC
ADC7 Number of
Correction Samples
Enable
Internal 1.00V
Internal AVCC /1.6 Enable Right Shift
Reference Start
Internal AVCC/2 Action
Voltage Select
AREFA Mode CORRCTRL AVGCTRL
AREFD Resolution
ADC0
ADC1 INPUTMODE = 10
•
•
•
ADC14
ADC15 Gain & Offset
½x - 64x
ADC Error
Correction
ADC0
•
• CORREN
ADC3
GND
INTGND
ADC0
ADC1 INPUTMODE = 11
•
•
•
ADC14
ADC15 Gain & Offset
½x - 64x
ADC Error
Correction
ADC4
•
• CORREN
ADC7
GND
INTGND
ADC0
ADC1
•
•
• Gain & Offset
ADC14
ADC15
1x
ADC Error
Correction
CORREN
In unsigned mode, the negative input is connected to half of the voltage reference (VREF) voltage minus a fixed offset.
The nominal value for the offset is:
V = V REF 0.05
Since the ADC is differential, the input range is VREF to zero for the positive single-ended input. The offset enables the
ADC to measure zero crossing in unsigned mode.
ADC0
ADC1
•
•
• Gain & Offset
ADC14
ADC15 VREF
1x
ADC Error
Correction
− ΔV
2
CORREN
TEMP REF
BANDGAP REF
AVCC SCALED Gain & Offset
DAC 1x
ADC Error
Correction
CORREN
To measure the internal signals in unsigned mode, the negative input is connected to a fixed value given by the formula
below, which is half of the voltage reference (VREF) minus a fixed offset, as it is for single-ended unsigned input. Refer to
Table 25-2 on page 355 for details.
V REF
V INN = -------------- – V
2
TEMP REF
BANDGAP REF
AVCC SCALED Gain & Offset
DAC
VREF
1x
ADC Error
Correction
− ΔV
2
CORREN
VINP and VINN are the positive and negative inputs to the ADC.
For differential measurements, GAIN is software selectable from 1/2 to 64. For single-ended and internal measurements,
GAIN must be set by software to 1x and VINP is the internal ground.
In unsigned mode, only positive results are generated. The TOP value of an unsigned result is 4095, and the results will
be in the range 0 to +4095 (0x0 - 0x0FFF).
The ADC transfer functions can be written as:
V INP – – V
RES = --------------------------------- TOP + 1
V REF
Table 25-1. Signed Differential Input (with Gain), Input Voltage Versus Output Code
VINP Signed
… … …
… … …
VINN 0x0000 0
… … …
… … … … …
… … … … …
In single conversion, a latency of 13 peripheral clock cycles (clkPER) is added for the final conversion result availability.
Since the correction time is always less than propagation delay, in free running mode this latency affects only the first
conversion time. All the other conversions are done within the normal sampling rate.
Offset
-VREF error
Input Voltage
VREF
ADC with
corrected offset
ADC with
uncorrected offset
Gain error
-VREF
Input Voltage
VREF
ADC with
corrected gain
ADC with
uncorrected gain
Notes: 1. GAINCORR precision is 1-bit integer + 11-bit fraction, implies 0.5 ≤ GAINCORR < 2.0.
2. GAINCORR range is from 0x0400 (0.5) up to 0x0FFF (1.99951171875).
3. No gain correction (1x gain) is set when GAINCORR = 0x0800 (1.0).
25.8.3 Averaging
The ADC has inherently 12-bit resolution but it is possible to obtain 16-bit results by averaging up to 1024 samples. The
numbers of samples to be averaged is specified in AVGCTRL register and the averaged output is written to channel
output register.
The number of samples to be averaged is set by the SAMPNUM bits in “ AVGCTRL – Average Control Register” on page
378. A maximum of 1024 samples can be averaged. The final result is rounded off to 16-bit value. After accumulating
programmed number of bits, division is achieved by automatic right shifting and result will be available in channel result
register (RES).
The output is calculated as per following formula:
Output = 2
SAMPNUM
16bitRoundOff >> RIGHTSHIFT
For SAMPNUM > 0, Table 25-3 shows the number of samples which will be accumulated and the automatic number of
right shifts internally performed.
Final result resolution Number of samples Number of automatic right shift for round-off
12-bits 1 0
13-bits 2 0
14-bits 4 0
15-bits 8 0
16-bits 16 0
16-bits 32 1
16-bits 64 2
16-bits 128 3
16-bits 256 4
16-bits 512 5
16-bits 1024 6
Table 25-4. Configuration Required for Averaging Function to Output Corresponding Over-sampled Output
Result resolution Number of samples to average SAMPNUM No. of automatic right shift RIGHTSHIFT
PRESCALER[2:0]
clk ADC
f ADC
SampleRate = ----------------------------------------------------------------------------------------------------------------------------------------
0.5 RESOLUTION + SAMPVAL + GAINFACTOR
1
PropagationDelay = -------------------------------
SampleRate
where
The most-significant bit (msb) of the result is converted first, and the rest of the bits are converted during the next three
(for 8-bit results) or five (for 12-bit results) ADC clock cycles. Converting one bit takes a half ADC clock period. During the
last cycle, the result is prepared before the interrupt flag is set and the result is available in the result register for readout.
clk ADC
START
ADC SAMPLE
IF
Figure 25-12.ADC Timing for One Conversion with Increased Sampling Time (SAMPVAL = 6)
1 2 3 4 5 6 7 8 9 10
clk ADC
START
ADC SAMPLE
IF
clkADC
START
ADC SAMPLE
AMPLIFY
IF
clk ADC
START
ADC SAMPLE
AMPLIFY
IF
Figure 25-15.ADC Timing for One Single Conversion with 64x Gain
1 2 3 4 5 6 7 8 9 10
clk ADC
START
ADC SAMPLE
AMPLIFY
IF
sample
channel switch
Figure 25-17.ADC Input for Differential Measurements and Differential Measurement with Gain
CC CC
sample
channel switch
sample
channel switch
In order to achieve n bits of accuracy, the source output resistance, Rsource, must be less than the ADC input resistance
on a pin:
Ts
R source --------------------------------------------------------
-–R
channel – R switch
C sample In 2 n + 1
where the ADC sample time, TS is one-half the ADC clock cycle given by:
Ts
T s ----------------------
2 f ADC
For details on Rchannel, Rswitch, and Csample, refer to the ADC electrical characteristic in the device datasheet.
Bit 7 6 5 4 3 2 1 0
+0x00 – – – – – START FLUSH ENABLE
Read/Write R R R R R R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x01 – CURRLIMIT[1:0] CONVMODE FREERUN RESOLUTION[1:0] –
Read/Write R R/W R/W R/W R/W R/W R/W R
Initial value 0 0 0 0 0 0 0 0
Bit 7 – Reserved
This bit is unused and reserved for future use. For compatibility with future devices, always write this bit to zero
when this register is written.
Bits 6:5 – CURRLIMIT[1:0]: Current Limitation
These bits can be used to limit the current consumption of the ADC by reducing the maximum ADC sample rate.
The available settings are shown in Table 25-5. The indicated current limitations are nominal values. Refer to the
device datasheet for actual current limitation for each setting.
00 NO No limit
Bit 0 – Reserved
This bit is unused and reserved for future use. For compatibility with future devices, always write this bit to zero
when this register is written.
Bit 7 6 5 4 3 2 1 0
+0x02 – REFSEL[2:0] – – BANDGAP TEMPREF
Read/Write R R/W R/W R/W R R R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 – Reserved
This bit is unused and reserved for future use. For compatibility with future devices, always write this bit to zero
when this register is written.
Bits 6:4 – REFSEL[2:0]: Reference Selection
These bits set the reference settings and conversion range for the ADC according to Table 25-7.
101-111 – Reserved
Bit 7 6 5 4 3 2 1 0
+0x03 – – EVSEL[2:0] EVACT[2:0]
Read/Write R R R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
010 – Reserved
011 – Reserved
100 – Reserved
101 – Reserved
110 SYNCSWEEP The ADC is flushed and restarted for accurate timing
111 – Reserved
Bit 7 6 5 4 3 2 1 0
+0x04 – – – – – PRESCALER[2:0]
Read/Write R R R R R R/W R/W R/W
Initial value 0 0 0 0 0 0 1 0
000 DIV4 4
001 DIV8 8
010 DIV16 16
011 DIV32 32
100 DIV64 64
Bit 7 6 5 4 3 2 1 0
+0x06 – – – – – – – CH0IF
Read/Write R R R R R R R R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x07 TEMP[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x08 – – SAMPVAL[5:0]
Read/Write R R R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
12-bit, left CH0RES[11:4]
+0x11
12-bit, right – – – – CH0RES[11:8]
8-bit – – – – – – – –
Read/Write R R R R R R R R
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x19 CMP[15:8]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x00 START – – GAIN[2:0] INPUTMODE[1:0]
Read/Write R/W R R R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
000 1X 1x
001 2X 2x
010 4X 4x
011 8X 8x
100 16X 16 x
101 32X 32 x
110 64X 64 x
111 DIV2 ½x
10 – Reserved
11 – Reserved
10 DIFFWGAINL Differential input signal with gain, 4 LSB pins available for MUXNEG selection
11 DIFFWGAINH Differential input signal with gain, 4 MSB pins available for MUXNEG selection
Bit 7 6 5 4 3 2 1 0
+0x01 – MUXPOS[3:0] MUXNEG[2:0]
Read/Write R R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 – Reserved
This bit is unused and reserved for future use. For compatibility with future devices, always write this bit to zero
when this register is written.
Bits 6:3 – MUXPOS[3:0]: MUX Selection on Positive ADC Input
These bits define the MUX selection for the positive ADC input. Table 25-14 and Table 25-15 on page 373 shows
the possible input selection for the different input modes.
0100-1111 – Reserved
Note: 1. Depending on the device pin count and feature configuration, the actual number of analog input pins may be less than 16. Refer to the device data-
sheet and pin-out description for details.
Table 25-16. ADC MUXNEG Configuration, INPUTMODE[1:0] = 10 (Differential with Programmable Gain)
100 – Reserved
110 – Reserved
100 – Reserved
101 – Reserved
110 – Reserved
Bit 7 6 5 4 3 2 1 0
+0x02 – – – – INTMODE[1:0] INTLVL[1:0]
Read/Write R R R R R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
10 – Reserved
Bit 7 6 5 4 3 2 1 0
+0x03 – – – – – – – IF
Read/Write R R R R R R R R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
12-bit, left RES[11:4]
+0x05
12-bit, right – – – – RES[11:8]
8-bit – – – – – – – –
Read/Write R R R R R R R R
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x06 INPUTOFFSET[3:0] INPUTSCAN[3:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x07 – – – – – – – CORREN
Read/Write R R R R R R R R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x09 – – – – OFFSETCORR[11:8]
Read/Write R R R R R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x0B – – – – GAINCORR[11:8]
Read/Write R R R R R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x0C – RIGHTSHIFT[2:0] SAMPNUM3:0]
Read/Write R R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
Bit 7 – Reserved
This bit is reserved and will always read as zero. For compatibility with future devices, always write this bit to zero
when this register is written.
Bit 6:4 – RIGHTSHIFT[2:0] – Right Shift
This value is effective only if SAMPNUM > 0. Output value will be in RES 16-bit register. Accumulated value will be
right shifted by the value specified by this bits. Right shift is from 0-shift till 7-shift.
+0x05 Reserved – – – – – – – –
+0x09 Reserved – – – – – – – –
+0x0A Reserved – – – – – – – –
+0x0B Reserved – – – – – – – –
+0x0E Reserved – – – – – – – –
+0x0F Reserved – – – – – – – –
+0x12 Reserved – – – – – – – –
+0x13 Reserved – – – – – – – –
+0x14 Reserved – – – – – – – –
+0x15 Reserved – – – – – – – –
+0x16 Reserved – – – – – – – –
+0x17 Reserved – – – – – – – –
+0x1A Reserved – – – – – – – –
+0x1B Reserved – – – – – – – –
+0x1C Reserved – – – – – – – –
+0x1D Reserved – – – – – – – –
+0x1E Reserved – – – – – – – –
+0x1F Reserved – – – – – – – –
+0x28 Reserved – – – – – – – –
+0x30 Reserved – – – – – – – –
+0x38 Reserved – – – – – – – –
+0x0D Reserved – – – – – – – –
+0x0E Reserved – – – – – – – –
+0x0F Reserved – – – – – – – –
Table 25-20. Analog-to-Digital Convertor Interrupt Vectors and their Word Offset Address
26.1 Features
12-bit resolution
Two independent, continuous-drive output channels
Up to one million samples per second conversion rate per DAC channel
Built-in calibration that removes:
Offset error
Gain error
Multiple conversion trigger sources
On new available data
Events from the event system
High drive capabilities and support for:
Resistive loads
Capacitive loads
Combined resistive and capacitive loads
Internal and external reference options
DAC output available as input to analog comparator and ADC
Low-power mode, with reduced drive strength
Optional EDMA transfer of data
26.2 Overview
The digital-to-analog converter (DAC) converts digital values to voltages. The DAC has two channels, each with12-bit
resolution, and is capable of converting up to one million samples per second (MSPS) on each channel. The built-in
calibration system can remove offset and gain error when loaded with calibration values from software.
Figure 26-1 illustrates the basic functionality of the DAC. Not all functions are shown.
Int. To
Trigger Select Enable driver AC/ADC
AVCC Reference
Internal 1.00V voltage
AREFA CTRLB CTRLA
AREFD Internal Output enable
D
12 A Output
CH1DATA T Driver
A
EDMA req
(Data Empty)
R feedback
26.9 Calibration
For improved accuracy, it is possible to calibrate for gain and offset errors in the DAC.
To get the best calibration result, it is recommended to use the same DAC configuration during calibration as will be used
in the final application. The theoretical transfer function for the DAC was shown in the equation in “Output and Output
Channels” on page 382. Including gain and offset errors, the DAC output value can be expressed as:
To calibrate for offset error, output the DAC channel's middle code (0x800) and adjust the offset calibration value until the
measured output value is as close as possible to the middle value (VREF / 2). The formula for the offset calibration is
given by the Equation 26-2 on page 383, where OCAL is OFFSETCAL and GCAL is GAINCAL.
To calibrate for gain error, output the DAC channel's maximum code (0xFFF) and adjust the gain calibration value until
the measured output value is as close as possible to the top value (VREF x 4095 / 4096). The gain calibration controls
the slope of the DAC characteristic by rotating the transfer function around the middle code. The formula for gain
calibration is given by the Equation 26-3 on page 383.
Including calibration in the equation, the DAC output can be expressed by Equation 26-4 on page 383.
Bit 7 6 5 4 3 2 1 0
+0x00 – – – IDOEN CH1EN CH0EN LPMODE ENABLE
Read/Write R R R R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x01 – CHSEL[1:0] – – – CH1TRIG CH0TRIG
Read/Write R R/W R/W R R R R/W R/W
Initial Value 0 0 0 0 0 0 0 0
Bit 7 – Reserved
This bit is unused and reserved for future use. For compatibility with future devices, always write this bit to zero
when this register is written.
Bit 6:5 – CHSEL[1:0]: Channel Selection
These bits control which DAC channels are enabled and operating. Table 26-1 shows the available selections.
11 – Reserved
Bit 7 6 5 4 3 2 1 0
+0x02 – – – REFSEL[1:0] – – LEFTADJ
Read/Write R R R R/W R/W R R R/W
Initial Value 0 0 0 0 0 0 0 0
01 AVCC AVCC
Bit 7 6 5 4 3 2 1 0
+0x03 – – – – EVSEL[3:0]
Read/Write R R R R R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x05 – – – – – – CH1DRE CH0DRE
Read/Write R R R R R R R/W R/W
Initial Value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x08 CH0GAINCAL[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x09 CH0OFFSETCAL[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x0A CH1GAINCAL[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x0B CH1OFFSETCAL[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
26.10.10.1Right-adjusted
Bit 7:4 – Reserved
These bits are unused and reserved for future use. For compatibility with future devices, always write these bits to
zero when this register is written.
Bit 3:0 – CHDATA[11:8]: Conversion Data Channel 0, Four MSB Bits
These bits are the four msbs of the 12-bit value to convert to channel 0 in right-adjusted mode.
26.10.10.2Left-adjusted
Bits 7:0 –- CHDATA[11:4]: Conversion Data Channel 0, Eight MSB Bits
These bits are the eight msbs of the 12-bit value to convert to channel 0 in left-adjusted mode
Bit 7 6 5 4 3 2 1 0
Right-adjust CHDATA[7:0]
+0x18
Left-adjust CHDATA[3:0] – – – –
Right-adjust Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Left-adjust Read/Write R/W R/W R/W R/W R R R R
Right-adjust Initial Value 0 0 0 0 0 0 0 0
Left-adjust Initial Value 0 0 0 0 0 0 0 0
26.10.11.1Right-adjusted
Bit 7:0 – CHDATA[7:0]: Conversion Data Channel 0, eight LSB Bits
These bits are the eight lsbs of the 12-bit value to convert to channel 0 in right-adjusted mode.
26.10.11.2Left-adjusted
Bit 7:4 – CHDATA[3:0]: Conversion Data Channel 0, four LSB Bits
These bits are the four lsbs of the 12-bit value to convert to channel 0 in left-adjusted mode.
Bit 3:0 – Reserved
These bits are unused and reserved for future use. For compatibility with future devices, always write these bits to
zero when this register is written.
Bit 7 6 5 4 3 2 1 0
Right-adjust – – – – CHDATA[11:8]
+0x1B
Left-adjust CHDATA[11:4]
Right-adjust Read/Write R R R R R/W R/W R/W R/W
Left-adjust Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Right-adjust Initial Value 0 0 0 0 0 0 0 0
Left-adjust Initial Value 0 0 0 0 0 0 0 0
26.10.12.1Right-adjusted
Bit 7:4 – Reserved
These bits are unused and reserved for future use. For compatibility with future devices, always write these bits to
zero when this register is written.
Bit 3:0 – CHDATA[11:8]: Conversion Data Channel 1, four MSB Bits
These bits are the four msbs of the 12-bit value to convert to channel 1 in right-adjusted mode.
26.10.12.2Left-adjusted
Bit 7:0 – CHDATA[11:4]: Conversion Data Channel 1, eight MSB Bits
These bits are the eight msbs of the 12-bit value to convert to channel 1 in left-adjusted mode.
Bit 7 6 5 4 3 2 1 0
Right-adjust CHDATA[7:0]
+0x1A
Left-adjust CHDATA[3:0] – – – –
Right-adjust Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Left-adjust Read/Write R/W R/W R/W R/W R R R R
Right-adjust Initial Value 0 0 0 0 0 0 0 0
Left-adjust Initial Value 0 0 0 0 0 0 0 0
26.10.13.1Right-adjusted
Bit 7:0 – CHDATA[7:0]: Conversion Data Channel 1, eight LSB Bits
These bits are the eight lsbs of the 12-bit value to convert to channel 1 in right-adjusted mode.
26.10.13.2Left-adjusted
Bits 7:4 – CHDATA[3:0]: Conversion Data Channel 1, four LSB Bits
These bits are the four lsbs of the 12-bit value to convert to channel 1 in left-adjusted mode.
Bit 3:0 – Reserved
These bits are unused and reserved for future use. For compatibility with future devices, always write these bits to
zero when this register is written.
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Page
+0x04 Reserved – – – – – – – –
+0x06 Reserved – – – – – – – –
+0x07 Reserved – – – – – – – –
+0x12 Reserved – – – – – – – –
+0x13 Reserved – – – – – – – –
+0x14 Reserved – – – – – – – –
+0x15 Reserved – – – – – – – –
+0x16 Reserved – – – – – – – –
+0x17 Reserved – – – – – – – –
27.1 Features
Selectable hysteresis
None
Small
Large
Analog comparator output available on pin
Flexible input selection
All pins on the port
Output from the DAC
Bandgap reference voltage
A 64-level programmable voltage scaler of the internal AVCC voltage
Interrupt and event generation on:
Rising edge
Falling edge
Toggle
Window function interrupt and event generation on:
Signal above window
Signal inside window
Signal below window
Constant current source with configurable output pin selection
Source of asynchronous event
27.2 Overview
The analog comparator (AC) compares the voltage levels on two inputs and gives a digital output based on this
comparison. The analog comparator may be configured to generate interrupt requests and/or synchronous/
asynchronous events upon several different combinations of input change.
The important property of the analog comparator’s dynamic behavior is the hysteresis. It can be adjusted in order to
achieve the optimal operation for each application.
The input selection includes analog port pins, several internal signals, and a 64-level programmable voltage scaler. The
analog comparator output state can also be output on a pin for use by external devices.
A constant current source can be enabled and output on a selectable pin. This can be used to replace, for example,
external resistors used to charge capacitors in capacitive touch sensing applications.
The analog comparators are always grouped in pairs on each port. These are called analog comparator 0 (AC0) and
analog comparator 1 (AC1). They have identical behavior, but separate control registers. Used as pair, they can be set in
window mode to compare a signal to a voltage range instead of a voltage level.
Pin Input
+
AC0OUT
Pin Input
-
Hysteresis
DAC Enable
Interrupt Interrupts
Interrupt Sensititivity
Voltage Mode Control
Scaler
ACnMUXCTRL ACnCTRL WINCTRL &
Window Events
Function
Enable
Bandgap
Hysteresis
+
Pin Input
AC1OUT
Pin Input
+
AC0
Upper limit of window -
Interrupts
Interrupt
Input signal sensitivity
Events
control
+
AC1
Lower limit of window
-
Bit 7 6 5 4 3 2 1 0
+0x00 / +0x01 INTMODE[1:0] INTLVL[1:0] – HYSMODE[2:0] ENABLE
Read/Write R/W R/W R/W R/W R R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
01 – Reserved
00 NO No hysteresis
11 – Reserved
Bit 7 6 5 4 3 2 1 0
+0x02 / +0x03 – – MUXPOS[2:0] MUXNEG[2:0]
Read/Write R R R/W R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x04 – – – – AC1INVEN AC0INVEN AC1OUT AC0OUT
Read/Write R R R R R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x05 – – SCALEFAC[5:0]
Read/Write R R R/W R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x06 – – – WEN WINTMODE[1:0] WINTLVL[1:0]
Read/Write R R R R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x07 WSTATE[1:0] AC1STATE AC0STATE – WIF AC1IF AC0IF
Read/Write R/W R/W R/W R/W R R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x08 CURRENT CURRMODE – – – – AC1CURR AC0CURR
Read/Write R/W R/W R R R R R/W R/W
Initial Value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x09 – – – – CALIB[3:0]
Read/Write R R R R R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
28.1 Features
Programming
External programming through PDI interface
Minimal protocol overhead for fast operation
Built-in error detection and handling for reliable operation
Boot loader support for programming through any communication interface
Debugging
Non-intrusive, real-time, on-chip debug system
No software or hardware resources required from device except pin connection
Program flow control
Go, Stop, Reset, Step Into, Step Over, Step Out, Run-to-Cursor
Unlimited number of user program breakpoints
Unlimited number of user data breakpoints, break on:
Data location read, write, or both read and write
Data location content equal or not equal to a value
Data location content is greater or smaller than a value
Data location content is within or outside a range
No limitation on device clock frequency
Program and Debug Interface (PDI)
Two-pin interface for external programming and debugging
Uses the Reset pin and a dedicated pin
No I/O pins required during programming or debugging
28.2 Overview
The Program and Debug Interface (PDI) is an Atmel proprietary interface for external programming and on-chip
debugging of a device.
The PDI supports fast programming of nonvolatile memory (NVM) spaces; flash, EEPOM, fuses, lock bits, and the user
signature row. This is done by accessing the NVM controller and executing NVM controller commands, as described in
“Memory Programming” on page 411.
Debug is supported through an on-chip debug system that offers non-intrusive, real-time debug. It does not require any
software or hardware resources except for the device pin connection. Using the Atmel tool chain, it offers complete
program flow control and support for an unlimited number of program and complex data breakpoints. Application debug
can be done from a C or other high-level language source code level, as well as from an assembler and disassembler
level.
Programming and debugging can be done through two physical interfaces. The primary one is the PDI physical layer,
which is available on all devices. This is a two-pin interface that uses the Reset pin for the clock input (PDI_CLK) and one
other dedicated pin for data input and output (PDI_DATA). Any external programmer or on-chip debugger/emulator can
be directly connected to this interface.
OCD
NVM
Controller
VCC
PDI Connector
PDI_CLK
PDI_DATA
GND
The remainder of this section is intended for use only by third parties developing programmers or programming support
for Atmel AVR XMEGA devices.
28.3.1 Enabling
The PDI physical layer must be enabled before use. This is done by first forcing the PDI_DATA line high for a period
longer than the equivalent external reset minimum pulse width (refer to device datasheet for external reset pulse width
data). This will disable the RESET functionality of the Reset pin, if not already disabled by the fuse settings.
Next, continue to keep the PDI_DATA line high for 16 PDI_CLK cycles. The first PDI_CLK cycle must start no later than
100µs after the RESET functionality of the Reset pin is disabled. If this does not occur in time, the enabling procedure
must start over again. The enable sequence is shown in Figure 28-3 on page 402.
PDI_DATA
PDI_CLK
The Reset pin is sampled when the PDI interface is enabled. The reset register is then set according to the state of the
Reset pin, preventing the device from running code after the reset functionality of this pin is disabled.
28.3.2 Disabling
If the clock frequency on PDI_CLK is lower than approximately 10kHz, this is regarded as inactivity on the clock line. This
will automatically disable the PDI. If not disabled by a fuse, the reset function of the Reset (PDI_CLK) pin is enabled
again. This also means that the minimum programming frequency is approximately 10kHz.
FRAME
Three different characters are used, DATA, BREAK, and IDLE. The BREAK character is equal to a 12-bit length of low
level. The IDLE character is equal to a 12-bit length of high level. The BREAK and IDLE characters can be extended
beyond the 12-bit length.
Figure 28-5. Characters and Timing for the PDI Physical Layer
1 DATA character
START 0 1 2 3 4 5 6 7 P STOP
1 BREAK character
BREAK
1 IDLE character
IDLE
PDI_CLK
PDI_DATA
St PDI DATA Receive (RX) P Sp1 Sp2 IDLE bits St PDI DATA Transmit (TX) P Sp1 Sp2
Figure 28-8. Driving Data out on the PDI_DATA using a Bus Keeper
PDI_CLK
Output enable
PDI Output
PDI_DATA
1 0 1 1 0 0 1
If the programmer and the PDI both drive the PDI_DATA line at the same time, drive contention will occur, as illustrated
in Figure 28-9. Every time a bit value is kept for two or more clock cycles, the PDI is able to verify that the correct bit
value is driven on the PDI_DATA line. If the programmer is driving the PDI_DATA line to the opposite bit value to what
the PDI expects, a collision is detected.
Figure 28-9. Drive Contention and Collision Detection on the PDI_DATA Line
PDI_CLK
PDI Output
Programmer
output
PDI_DATA
1 0 X 1 X 1 1
Collision detect
= Collision
As long as the PDI transmits alternating ones and zeros, collisions cannot be detected, because the PDI output driver will
be active all the time, preventing polling of the PDI_DATA line. However, the two stop bits should always be transmitted
as ones within a single frame, enabling collision detection at least once per frame.
Exceptions are signaled to the PDI controller. All ongoing operations are then aborted, and the PDI is put in ERROR
state. The PDI will remain in ERROR state until a BREAK is sent from the external programmer, and this will bring the
PDI back to its default RX state.
Due to this mechanism, the programmer can always synchronize the protocol by transmitting two successive BREAK
characters.
28.4.5.2 STS - Store Data to PDIBUS Data Space using Direct Addressing
The STS instruction is used to store data that are serially shifted into the physical layer shift register to locations within
the PDIBUS data space. The STS instruction is based on direct addressing, which means that the address must be given
as an argument to the instruction. Even though the protocol is based on byte-wise communication, the ST instruction
supports multiple-bytes addresses and data access. Four different address/data sizes are supported: single-byte, word
(two bytes), three-byte, and long (four bytes). Multiple-byte access is broken down internally into repeated single-byte
accesses, but this reduces protocol overhead. When using the STS instruction, the address byte(s) must be transmitted
before the data transfer.
28.4.5.3 LD - Load Data from PDIBUS Data Space using Indirect Addressing
The LD instruction is used to load data from the PDIBUS data space into the physical layer shift register for serial read
out. The LD instruction is based on indirect addressing (pointer access), which means that the address must be stored in
the pointer register prior to the data access. Indirect addressing can be combined with pointer increment. In addition to
reading data from the PDIBUS data space, the LD instruction can read the pointer register. Even though the protocol is
based on byte-wise communication, the LD instruction supports multiple-byte addresses and data access. Four different
address/data sizes are supported: single-byte, word (two bytes), three-byte, and long (four bytes). Multiple-byte access is
broken down internally into repeated single-byte accesses, but this reduces the protocol overhead.
28.4.5.5 LDCS - Load Data from PDI Control and Status Register Space
The LDCS instruction is used to load data from the PDI control and status registers into the physical layer shift register
for serial read out. The LDCS instruction supports only direct addressing and single-byte access.
28.4.5.6 STCS - Store Data to PDI Control and Status Register Space
The STCS instruction is used to store data that are serially shifted into the physical layer shift register to locations within
the PDI control and status registers. The STCS instruction supports only direct addressing and single-byte access.
LD 0 0 1 0
Size A - Address size (direct access)
0 0 Byte
0 1 Word (2 Bytes)
ST 0 1 1 0
1 0 3 Bytes
1 1 Long (4 Bytes)
CS Address
Ptr - Pointer access (indirect access)
0 0 *(ptr)
LDCS 1 0 0 0
0 1 *(ptr++)
1 0 ptr
STCS
1 1 ptr++ - Reserved
1 1 0 0
Bit 7 6 5 4 3 2 1 0
+0x00 – – – – – – NVMEN –
Read/Write R R R R R R R/W R
Initial Value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x01 RESET[7:0]
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
+0x02 – – – – – GUARDTIME[2:0]
Read/Write R R R R R R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
000 128
001 64
010 32
011 16
100 8
101 4
110 2
111 2
+0x03 Reserved – – – – – – – –
29.1 Features
Read and write access to all memory spaces from
External programmers
Application software self-programming
Self-programming and boot loader support
Any communication interface can be used for program upload/download
External programming
Support for in-system and production programming
Programming through serial PDI interface
High security with separate boot lock bits for:
External programming access
Boot loader section access
Application section access
Application table access
Reset fuse to select reset vector address to the start of the:
Application section, or
Boot loader section
29.2 Overview
This section describes how to program the nonvolatile memory (NVM) in Atmel AVR XMEGA devices, and covers both
self-programming and external programming. The NVM consists of the flash program memory, user signature and
production signature rows, fuses and lock bits, and EEPROM data memory. For details on the actual memories, how
they are organized, and the register description for the NVM controller used to access the memories, refer to “Memories”
on page 20.
The NVM can be accessed for read and write from application software through self-programming and from an external
programmer. Accessing the NVM is done through the NVM controller, and for the flash memory the two methods of
programming are similar. Memory access is done by loading address and/or data to the selected memory or NVM
controller and using a set of commands and triggers that make the NVM controller perform specific tasks on the
nonvolatile memory.
From external programming, all memory spaces can be read and written, except for the production signature row, which
can only be read. The device can be programmed in-system and is accessed through the PDI using the PDI physical
interface. “External Programming” on page 424 describes PDI in detail.
Self-programming and boot loader support allows application software in the device to read and write the flash, user
signature row and EEPROM, write the lock bits to a more secure setting, and read the production signature row and
fuses. When programming, the CPU is halted, waiting for the flash operation to complete. “Self-programming and Boot
Loader Support” on page 415 describes this in detail.
For both self-programming and external programming, it is possible to run a CRC check on the flash or a section of the
flash to verify its content after programming.
The device can be locked to prevent reading and/or writing of the NVM. There are separate lock bits for external
programming access and self-programming access to the boot loader section, application section, and application table
section.
Section being addressed during programming Section that can be read during programming CPU halted?
PAGEEND
FLASHEND
configuration
Data register
Description
CPU halted
NVM busy
CMD[6:0]
Address
Change
Trigger
pointer
Group
0x00 NO_OPERATION No operation / read flash -/(E)LPM -/N N -/N -/ Z-pointer -/Rd
Flash
0x2F ERASE_WRITE_FLASH_PAGE Erase and write flash page SPM N/Y(2) Y Y Z-pointer -
(3) (1)
0x3A FLASH_RANGE_CRC Flash range CRC CMDEX Y Y Y DATA/ADDR DATA
Application Section
0x25 ERASE_WRITE_APP_PAGE Erase and write application section page SPM N Y Y Z-pointer -
0x2D ERASE_WRITE_BOOT_PAGE Erase and write boot loader section page SPM Y Y Y Z-pointer -
Notes: 1. The flash range CRC command used byte addressing of the flash.
2. Will depend on the flash section (application or boot loader) that is actually addressed.
3. This command is qualified with the lock bits, and requires that the boot lock bits are unprogrammed.
4. When using a command that changes the normal behavior of the LPM command; READ_USER_SIG_ROW and READ_CALIB_ROW; it is recommended to
disable interrupts to ensure correct execution of the LPM instruction.
5. For consistency the name Calibration Row has been renamed to Production Signature Row throughout the document.
29.11.2.9 Erase and Write Application Section / Boot Loader Section Page
The erase and write application section page and erase and write boot loader section page commands are used to erase
one flash page and then write the flash page buffer into that flash page in the application section or boot loader section in
one atomic operation.
1. Load the Z-pointer with the flash page to write. The page address must be written to FPAGE. Other bits in the Z-
pointer will be ignored during this operation.
2. Load the NVM CMD register with the erase and write application section/boot loader section page command.
3. Execute the SPM instruction. This requires the timed CCP sequence during self-programming.
The BUSY flag in the NVM STATUS register will be set until the operation is finished. The FBUSY flag is set as long as
the flash is busy, and the application section cannot be accessed.
An invalid page address in the Z-pointer will abort the NVM command. The erase and write application section command
requires that the Z-pointer addresses the application section, and the erase and write boot section page command
requires that the Z-pointer addresses the boot loader section.
01 01
02 02
E2END E2PAGEEND
Loading a data byte into the EEPROM page buffer can be performed through direct or indirect store instructions. Only the
least-significant bits of the EEPROM address are used to determine locations within the page buffer, but the complete
memory mapped EEPROM address is always required to ensure correct address mapping. Reading from the EEPROM
can be done directly using direct or indirect load instructions. When an EEPROM page buffer load operation is
performed, the CPU is halted for two cycles before the next instruction is executed.
EEPROM
FLASH_BASE = 0x0800000
EPPROM_BASE = 0x08C0000
FUSE_BASE = 0x08F0020
DATAMEM_BASE = 0x1000000
DATAMEM
16 MB
APP_BASE = FLASH_BASE (mapped IO/SRAM)
BOOT_BASE = FLASH_BASE + SIZE_APPL
PROD_SIGNATURE_BASE = 0x008E0200
USER_SIGNATURE_BASE = 0x008E0400
0x1000000
FUSES
0x08F0020
SIGNATURE ROW
0x08E0200
0x08C1000
EEPROM
0x08C0000
BOOT SECTION
APPLICATION
SECTION
0x0800000 16 MB
0x0000000
1 BYTE
0x00 No operation - - -
Flash
Application Section
0x2D Erase and write boot loader section page PDI write N Y
EEPROM
FMULSU Rd,Rr Fractional Multiply Signed with Unsigned R1:R0 Rd x Rr<<1 (SU) Z,C 2
Branch instructions
PC(15:0) Z,
IJMP Indirect Jump to (Z) None 2
PC(21:16) 0
PC(15:0) Z,
EIJMP Extended Indirect Jump to (Z) None 2
PC(21:16) EIND
PC(15:0) Z,
ICALL Indirect Call to (Z) None 2 / 3(1)
PC(21:16) 0
PC(15:0) Z,
EICALL Extended Indirect Call to (Z) None 3(1)
PC(21:16) EIND
SBIS A, b Skip if Bit in I/O Register Set If (I/O(A,b) =1) PC PC + 2 or 3 None 2/3/4
LDS Rd, k Load Direct from data space Rd (k) None 2(1)(2)
Rd (X)
LD Rd, X+ Load Indirect and Post-Increment None 1(1)(2)
X X+1
X X - 1, X-1
LD Rd, -X Load Indirect and Pre-Decrement None 2(1)(2)
Rd (X) (X)
Rd (Y)
LD Rd, Y+ Load Indirect and Post-Increment None 1(1)(2)
Y Y+1
Y Y-1
LD Rd, -Y Load Indirect and Pre-Decrement None 2(1)(2)
Rd (Y)
Rd (Z),
LD Rd, Z+ Load Indirect and Post-Increment None 1(1)(2)
Z Z+1
Z Z - 1,
LD Rd, -Z Load Indirect and Pre-Decrement None 2(1)(2)
Rd (Z)
(X) Rr,
ST X+, Rr Store Indirect and Post-Increment None 1(1)
X X+1
X X - 1,
ST -X, Rr Store Indirect and Pre-Decrement None 2(1)
(X) Rr
(Y) Rr,
ST Y+, Rr Store Indirect and Post-Increment None 1(1)
Y Y+1
Y Y - 1,
ST -Y, Rr Store Indirect and Pre-Decrement None 2(1)
(Y) Rr
(Z) Rr
ST Z+, Rr Store Indirect and Post-Increment None 1(1)
Z Z+1
Rd (Z),
LPM Rd, Z+ Load Program Memory and Post-Increment None 3
Z Z+1
(RAMPZ:Z) R1:R0,
SPM Z+ Store Program Memory and Post-Increment by 2 None -
Z Z+2
Temp Rd,
XCH Z, Rd Exchange RAM location Rd (Z), None 2
(Z) Temp
Temp Rd,
LAS Z, Rd Load and Set RAM location Rd (Z), None 2
(Z) Temp v (Z)
Temp Rd,
LAC Z, Rd Load and Clear RAM location Rd (Z), None 2
(Z) ($FFh – Rd) (Z)
Temp Rd,
LAT Z, Rd Load and Toggle RAM location Rd (Z), None 2
(Z) Temp (Z)
Rd(n+1) Rd(n),
LSL Rd Logical Shift Left Rd(0) 0, Z,C,N,V,H 1
C Rd(7)
Rd(n) Rd(n+1),
LSR Rd Logical Shift Right Rd(7) 0, Z,C,N,V 1
C Rd(0)
Rd(0) C,
ROL Rd Rotate Left Through Carry Rd(n+1) Rd(n), Z,C,N,V,H 1
C Rd(7)
Rd(7) C,
ROR Rd Rotate Right Through Carry Rd(n) Rd(n+1), Z,C,N,V 1
C Rd(0)
Notes: 1. Cycle times for data memory accesses assume internal memory accesses, and are not valid for accesses via the external RAM interface.
2. One extra cycle must be added when accessing Internal SRAM.
4. Added note on initial value for production signature rows in Section 4.15 “Register Description – Production
Signature Row” on page 36.
2. In Table 12-7 on page 154 the value for RTCOUT[1:0] on the last line has been changed from 1x to 11.
3. In Table 12-9 on page 155 PORTE in the last line has been changed to PORTR (there is no PORTE in XMEGA E
devices).
5. Changed Vcc to AVcc in the section“AC – Analog Comparator” on page 391 and onwards, and in “Voltage Reference
Selection” on page 353.
6. Changed footnote text from BCT0 toBTC0 and BCT1 to BTC1 in tables in Section 23.7 “Register Description” on
page 325.
7. Added footnote on AVcc and Vcc power supply to Table 2-1 on page 4.
2. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1 Block Diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
4. Memories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.2 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.3 Flash Program Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.4 Fuses and Lockbits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.5 Data Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.6 Internal SRAM. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.7 EEPROM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.8 I/O Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.9 Data Memory and Bus Arbitration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.10 Memory Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.11 Device ID and Revision. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.12 I/O Memory Protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.13 Register Description – NVM Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.14 Register Descriptions – Fuses and Lock Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.15 Register Description – Production Signature Row . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.16 Register Description – General Purpose I/O Memory. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
4.17 Register Descriptions – MCU Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
4.18 Register Summary – NVM Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
4.19 Register Summary – Fuses and Lockbits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
4.20 Register Summary – Production Signature Row . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
4.21 Register Summary – General Purpose I/O Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
4.22 Register Summary – MCU Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
4.23 Interrupt Vector Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
XMEGA E MANUAL i
Atmel-8201E-AVR-XMEGA E Manual_11/2014
5. EDMA – Enhanced Direct Memory Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
5.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
5.2 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
5.3 EDMA Transaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
5.4 Transfer Triggers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
5.5 Addressing and Transfer Count . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
5.6 Priority Between Channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
5.7 Double Buffering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
5.8 Data Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
5.9 Error Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.10 Software Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.11 Protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
5.12 Interrupts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
5.13 Register Description – EDMA Controller. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
5.14 Register Description – Peripheral Channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
5.15 Register Description – Standard Channel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
5.16 Register Summary – EDMA Controller in PER0123 Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . 75
5.17 Register Summary – EDMA Controller in STD0 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
5.18 Register Summary – EDMA Controller in STD2 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
5.19 Register Summary – EDMA Controller in STD02 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
5.20 Register Summary – EDMA Peripheral Channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
5.21 Register Summary – EDMA Standard Channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
5.22 Interrupt Vector Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
6. Event System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
6.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
6.2 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
6.3 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
6.4 Signalling Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
6.5 Data Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
6.6 Peripheral Clock Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
6.7 Software Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
6.8 Event Routing Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
6.9 Event Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
6.10 Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
6.11 Quadrature Decoder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
6.12 Register Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
6.13 Register Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
XMEGA E MANUAL ii
Atmel-8201E-AVR-XMEGA E Manual_11/2014
7.12 Register Summary - Clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
7.13 Register Summary - Oscillator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
7.14 Register Summary – DFLL32M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
7.15 Interrupt Vector Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
XMEGA E MANUAL iv
Atmel-8201E-AVR-XMEGA E Manual_11/2014
16.2 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
16.3 Timer/counter Considerations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
16.4 Faults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
16.5 Register Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
16.6 Register Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
XMEGA E MANUAL v
Atmel-8201E-AVR-XMEGA E Manual_11/2014
20.3 Master Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
20.4 Slave Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
20.5 Buffer Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
20.6 Data Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
20.7 Interrupts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
20.8 EDMA Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
20.9 Register Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
20.10 Register Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
20.11 Interrupt Vector Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
XMEGA E MANUAL vi
Atmel-8201E-AVR-XMEGA E Manual_11/2014
24.2 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344
24.3 Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344
24.4 CRC on Flash Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
24.5 CRC on EDMA Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
24.6 CRC using the I/O Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
24.7 Register Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
24.8 Register Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
Table of Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i
Atmel®, Atmel logo and combinations thereof, AVR®, Enabling Unlimited Possibilities®, QTouch®, XMEGA®, and others are registered trademarks or trademarks of
Atmel Corporation in U.S. and other countries. Other terms and product names may be trademarks of others.
DISCLAIMER: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right
is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN THE ATMEL TERMS AND CONDITIONS OF SALES LOCATED ON THE
ATMEL WEBSITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT
SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES
FOR LOSS AND PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this
document and reserves the right to make changes to specifications and products descriptions at any time without notice. Atmel does not make any commitment to update the information
contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be used in, automotive applications. Atmel products are not intended,
authorized, or warranted for use as components in applications intended to support or sustain life.
SAFETY-CRITICAL, MILITARY, AND AUTOMOTIVE APPLICATIONS DISCLAIMER: Atmel products are not designed for and will not be used in connection with any applications where
the failure of such products would reasonably be expected to result in significant personal injury or death (“Safety-Critical Applications”) without an Atmel officer's specific written
consent. Safety-Critical Applications include, without limitation, life support devices and systems, equipment or systems for the operation of nuclear facilities and weapons systems.
Atmel products are not designed nor intended for use in military or aerospace applications or environments unless specifically designated by Atmel as military-grade. Atmel products are
not designed nor intended for use in automotive applications unless specifically designated by Atmel as automotive-grade.