The Atmel® | SMART™ SAM D21 is a series of low-power microcontrollers using the 32-bit
®
ARM
Cortex®-M0+ processor, and ranging from 32- to 64-pins with up to 256KB Flash and
32KB of SRAM. The SAM D21 devices operate at a maximum frequency of 48MHz and reach
2.46 CoreMark/MHz. They are designed for simple and intuitive migration with identical
peripheral modules, hex compatible code, identical linear address map and pin compatible
migration paths between all devices in the product series. All devices include intelligent and
flexible peripherals, Atmel Event System for inter-peripheral signaling, and support for capacitive
touch button, slider and wheel user interfaces.
The Atmel SAM D21 devices provide the following features: In-system programmable Flash,
twelve-channel direct memory access (DMA) controller, 12 channel Event System,
programmable interrupt controller, up to 52 programmable I/O pins, 32-bit real-time clock and
calendar, up to five 16-bit Timer/Counters (TC) and three 24-bit Timer/Counters for Control
(TCC), where each TC can be configured to perform frequency and waveform generation,
accurate program execution timing or input capture with time and frequency measurement of
digital signals. The TCs can operate in 8- or 16-bit mode, selected TCs can be cascaded to form
a 32-bit TC, and three timer/counters have extended functions optimized for motor, lighting and
other control applications. The series provide one full-speed USB 2.0 embedded host and device
interface; up to six Serial Communication Modules (SERCOM) that each can be configured to act
as an USART, UART, SPI, I
interface; up to twenty-channel 350ksps 12-bit ADC with programmable gain and optional
oversampling and decimation supporting up to 16-bit resolution, one 10-bit 350ksps DAC, two
analog comparators with window mode, Peripheral Touch Controller supporting up to 256
buttons, sliders, wheels and proximity sensing; programmable Watchdog Timer, brown-out
detector and power-on reset and two-pin Serial Wire Debug (SWD) program and debug interface.
2
C up to 3.4MHz, SMBus, PMBus, and LIN slave; two-channel I2S
SMART
All devices have accurate and low-power external and internal oscillators. All oscillators can be
used as a source for the system clock. Different clock domains can be independently configured
to run at different frequencies, enabling power saving by running each peripheral at its optimal
clock frequency, and thus maintaining a high CPU frequency while reducing power consumption.
The SAM D21 devices have two software-selectable sleep modes, idle and standby. In idle mode
the CPU is stopped while all other functions can be kept running. In standby all clocks and
functions are stopped expect those selected to continue running. The device supports
SleepWalking. This feature allows the peripheral to wake up from sleep based on predefined
conditions, and thus allows the CPU to wake up only when needed, e.g. when a threshold is
crossed or a result is ready. The Event System supports synchronous and asynchronous events,
allowing peripherals to receive, react to and send events even in standby mode.
The Flash program memory can be reprogrammed in-system through the SWD interface. The
same interface can be used for non-intrusive on-chip debug of application code. A boot loader
running in the device can use any communication interface to download and upgrade the
application program in the Flash memory.
The Atmel SAM D21 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
.
Atmel-42181G–SAM-D21_Datasheet–09/2015
Features
z Processor
z ARM Cortex-M0+ CPU running at up to 48MHz
z Single-cycle hardware multiplier
z Micro Trace Buffer (MTB)
z Memories
z 32/64/128/256KB in-system self-programmable Flash
z 4/8/16/32KB SRAM Memory
z System
z Power-on reset (POR) and brown-out detection (BOD)
z Internal and external clock options with 48MHz Digital Frequency Locked Loop (DFLL48M) and 48MHz to 96MHz Fractional
Digital Phase Locked Loop (FDPLL96M)
z External Interrupt Controller (EIC)
z 16 external interrupts
z One non-maskable interrupt
z Two-pin Serial Wire Debug (SWD) programming, test and debugging interface
z Low Power
z Idle and standby sleep modes
z SleepWalking peripherals
z Peripherals
z 12-channel Direct Memory Access Controller (DMAC)
z 12-channel Event System
z Up to five 16-bit Timer/Counters (TC), configurable as either:
z One 16-bit TC with compare/capture channels
z One 8-bit TC with compare/capture channels
z One 32-bit TC with compare/capture channels, by using two TCs
z Three 24-bit Timer/Counters for Control (TCC), with extended functions:
z Up to four compare channels with optional complementary output
z Generation of synchronized pulse width modulation (PWM) pattern across port pins
z Deterministic fault protection, fast decay and configurable dead-time between complementary output
z Dithering that increase resolution with up to 5 bit and reduce quantization error
z 32-bit Real Time Counter (RTC) with clock/calendar function
z Watchdog Timer (WDT)
z CRC-32 generator
z One full-speed (12Mbps) Universal Serial Bus (USB) 2.0 interface
z Embedded host and device function
z Eight endpoints
z Up to six Serial Communication Interfaces (SERCOM), each configurable to operate as either:
z USART with full-duplex and single-wire half-duplex configuration
2
z I
C up to 3.4MHz
z SPI
z LIN slave
z One two-channel Inter-IC Sound (I
z One 12-bit, 350ksps Analog-to-Digital Converter (ADC) with up to 20 channels
z Differential and single-ended input
z 1/2x to 16x programmable gain stage
z Automatic offset and gain error compensation
z Oversampling and decimation in hardware to support 13-, 14-, 15- or 16-bit resolution
z 10-bit, 350ksps Digital-to-Analog Converter (DAC)
z Two Analog Comparators (AC) with window compare function
z Peripheral Touch Controller (PTC)
z 256-Channel capacitive touch and proximity sensing
z I/O
z Up to 52 programmable I/O pins
z Drop in compatible with SAM D20
z Packages
z 64-pin TQFP, QFN, UFBGA
z 48-pin TQFP, QFN, WLCSP
z 32-pin TQFP, QFN, WLCSP
The following table gives details on signal names classified by peripheral.
Signal NameFunctionTypeActive Level
Analog Comparators - AC
AIN[3:0]AC Analog InputsAnalog
CMP[:0]AC Comparator OutputsDigital
Analog Digital Converter - ADC
AIN[19:0]ADC Analog InputsAnalog
VREFAADC Voltage External Reference AAnalog
VREFBADC Voltage External Reference BAnalog
Digital Analog Converter - DAC
VOUTDAC Voltage outputAnalog
VREFADAC Voltage External ReferenceAnalog
External Interrupt Controller
EXTINT[15:0]External InterruptsInput
NMIExternal Non-Maskable InterruptInput
Generic Clock Generator - GCLK
GCLK_IO[7:0]Generic Clock (source clock or generic clock generator output)I/O
Inter-IC Sound Controller - I2S
MCK[1..0]Master ClockI/O
SCK[1..0]Serial ClockI/O
FS[1..0]I2S Word Select or TDM Frame SyncI/O
SD[1..0]Serial Data Input or Output I/O
Power Manager - PM
RESETNResetInputLow
Serial Communication Interface - SERCOMx
PAD[3:0]SERCOM I/O PadsI/O
System Control - SYSCTRL
XINCrystal InputAnalog/ Digital
XIN3232kHz Crystal InputAnalog/ Digital
XOUTCrystal OutputAnalog
XOUT3232kHz Crystal OutputAnalog
Timer Counter - TCx
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
19
Signal NameFunctionTypeActive Level
WO[1:0]Waveform OutputsOutput
Timer Counter - TCCx
WO[1:0]Waveform OutputsOutput
Peripheral Touch Controller - PTC
X[15:0]PTC Input Analog
Y[15:0]PTC InputAnalog
General Purpose I/O - PORT
PA25 - PA00Parallel I/O Controller I/O Port AI/O
PA28 - PA27Parallel I/O Controller I/O Port AI/O
PA31 - PA30Parallel I/O Controller I/O Port AI/O
PB17 - PB00Parallel I/O Controller I/O Port BI/O
PB23 - PB22Parallel I/O Controller I/O Port BI/O
PB31 - PB30Parallel I/O Controller I/O Port BI/O
Universal Serial Bus - USB
DPDP for USBI/O
DMDM for USBI/O
SOF 1kHzUSB Start of FrameI/O
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
20
Atmel-42181G–SAM-D21_Datasheet–09/2015
[DATASHEET]
21
6.I/O Multiplexing and Considerations
6.1Multiplexed Signals
Each pin is by default controlled by the PORT as a general purpose I/O and alternatively it can be assigned to one of the peripheral functions A, B, C,
D, E, F, G or H. To enable a peripheral function on a pin, the Peripheral Multiplexer Enable bit in the Pin Configuration register corresponding to that pin
(PINCFGn.PMUXEN, n = 0-31) in the PORT must be written to one. The selection of peripheral function A to H is done by writing to the Peripheral
Multiplexing Odd and Even bits in the Peripheral Multiplexing register (PMUXn.PMUXE/O) in the PORT.
Table 5-1 on page 11 describes the peripheral signals multiplexed to the PORT I/O pins.
Table 6-1. PORT Function Multiplexing
(1)
Pin
SAMD21E SAMD21GSAMD21JEICREFADCACPTCDAC SERCOM
111PA0 0VDDANA EXTINT[0]
222PA0 1VDDANAEXTINT[1]
333PA02VDDANAEXTINT[2]AIN[0]Y[0]VOUT
444PA03VDDANAEXTINT[3]
711PB08VDDANAEXTINT[8]AIN[2]Y[14]
812PB09 VDDANAEXTINT[9]AIN[3]Y[15]
5913PA0 4VDDANAEXTINT[4]
61014PA 05VDDANAEXTINT[5]AIN[5]AIN[1]Y[3]
71115PA 06VDDANAEXTINT[6]AIN[6]AIN[2]Y[4]
81216PA 07VDDANAEXTINT[7]AIN[7]AIN[3]Y[5]
111317PA 08VDDIOI2CNMIAIN[16]X[0]
121418PA0 9VDDIOI2CEXTINT[9]AIN[17]X[1]
131519PA1 0VDDIOEXTINT[10]AIN[18]X[2]
141620PA11VDDIOEXTINT[11]AIN[19]X[3]
I/O Pin Supply Typ e
5PB04VDDANAEXTINT[4]AIN[12]Y[10]
6PB05VDDANAEXTINT[5]AIN[13]Y[11]
9PB06VDDANAEXTINT[6]AIN[14]Y[12]
10PB07VDDANAEXTINT[7]AIN[15]Y[13]
AB
ADC/VREFA
DAC/VREFA
ADC/VREFB
(2)(3)
AIN[1]Y[1]
AIN[4]AIN[0]Y[2]
CDEFGH
SERCOM0/
PAD [0]
SERCOM0/
PAD [1]
SERCOM0/
PAD [2]
SERCOM0/
PAD [3]
(2)(3)
SERCOM-
ALT
SERCOM1/
PAD [0]
SERCOM1/
PAD [1]
SERCOM4/
PAD [0]
SERCOM4/
PAD [1]
SERCOM0/
PAD [0]
SERCOM0/
PAD [1]
SERCOM0/
PAD [2]
SERCOM0/
PAD [3]
SERCOM2/
PAD [0]
SERCOM2/
PAD [1]
SERCOM2/
PAD [2]
SERCOM2/
PAD [3]
(4)
TC
/TCCTCCCOMAC/GCLK
TCC2/WO[0]
TCC2/WO[1]
TC4/WO[0]
TC4/WO[1]
TCC0/WO[0]
TCC0/WO[1]
TCC1/WO[0]
TCC1/WO[1]I2S/SD[0]
TCC0/WO[0]
TCC0/WO[1]
TCC1/WO[0]
TCC1/WO[1]
TCC1/
WO[2]
TCC1/
WO[3]
TCC0/
WO[2]
TCC0/
WO[3]
I2S/SD[1]
I2S/
MCK[0]
I2S/
SCK[0]
I2S/FS[0] GCLK_IO[5]
GCLK_IO[4]
Atmel-42181G–SAM-D21_Datasheet–09/2015
[DATASHEET]
22
Table 6-1. PORT Function Multiplexing (Continued)
(1)
Pin
SAMD21E SAMD21GSAMD21JEICREFADCACPTCDAC SERCOM
1923PB10VDDIOEXTINT[10]
2024PB11VDDIOEXTINT[11]
2129PA 12VDDIOI2CEXTINT[12]
2230PA 13VDDIOI2CEXTINT[13]
152331PA1 4VDDIOEXTINT[14]
162432PA1 5VDDIOEXTINT[15]
172535PA1 6VDDIOI2CEXTINT[0]X[4]
182636PA1 7VDDIOI2CEXTINT[1]X[5]
192737PA1 8VDDIOEXTINT[2]X[6]
202838PA1 9VDDIOEXTINT[3]X[7]
2941PA 20VDDIOEXTINT[4]X[8]
3042PA 21VDDIOEXTINT[5]X[9]
213143PA2 2VDDIOI2CEXTINT[6]X[10]
223244PA2 3VDDIOI2CEXTINT[7]X[11]
233345PA2 4VDDIOEXTINT[12]
243446PA2 5VDDIOEXTINT[13]
I/O Pin Supply Typ e
25PB12VDDIOI2CEXTINT[12]X[12]
26PB13VDDIOI2CEXTINT[13]X[13]
27PB14VDDIOEXTINT[14]X[14]
28PB15VDDIOEXTINT[15]X[15]
39PB16VDDIOI2CEXTINT[0]
40PB17VDDIOI2CEXTINT[1]
AB
(2)(3)
CDEFGH
SERCOM4/
PAD [0]
SERCOM4/
PAD [1]
SERCOM4/
PAD [2]
SERCOM4/
PAD [3]
SERCOM2/
PAD [0]
SERCOM2/
PAD [1]
SERCOM2/
PAD [2]
SERCOM2/
PAD [3]
SERCOM1/
PAD [0]
SERCOM1/
PAD [1]
SERCOM1/
PAD [2]
SERCOM1/
PAD [3]
SERCOM5/
PAD [0]
SERCOM5/
PAD [1]
SERCOM5/
PAD [2]
SERCOM5/
PAD [3]
SERCOM3/
PAD [0]
SERCOM3/
PAD [1]
SERCOM3/
PAD [2]
SERCOM3/
PAD [3]
(2)(3)
SERCOM-
ALT
SERCOM4/
PAD [2]
SERCOM4/
PAD [3]
SERCOM4/
PAD [0]
SERCOM4/
PAD [1]
SERCOM4/
PAD [2]
SERCOM4/
PAD [3]
SERCOM3/
PAD [0]
SERCOM3/
PAD [1]
SERCOM3/
PAD [2]
SERCOM3/
PAD [3]
SERCOM3/
PAD [2]
SERCOM3/
PAD [3]
SERCOM5/
PAD [0]
SERCOM5/
PAD [1]
SERCOM5/
PAD [2]
SERCOM5/
PAD [3]
(4)
TC
/TCCTCCCOMAC/GCLK
TC5/WO[0]
TC5/WO[1]
TC4/WO[0]
TC4/WO[1]
TC5/WO[0]GCLK_IO[0]
TC5/WO[1]GCLK_IO[1]
TCC2/WO[0]
TCC2/WO[1]
TC3/WO[0]
TC3/WO[1]
TCC2/WO[0] TCC0/WO[6]GCLK_IO[2]
TCC2/WO[1] TCC0/WO[7]GCLK_IO[3]
TC3/WO[0]
TC3/WO[1]
TC6/WO[0]
TC6/WO[1]
TC7/WO[0]
TC7/WO[1]
TC4/WO[0]
TC4/WO[1]
TC5/WO[0]
TC5/WO[1]
TCC0/
WO[4]
TCC0/
WO[5]
TCC0/
WO[6]
TCC0/
WO[7]
TCC0/
WO[6]
TCC0/
WO[7]
TCC0/
WO[4]
TCC0/
WO[5]
TCC0/
WO[2]
TCC0/
WO[3]
TCC0/
WO[4]
TCC0/
WO[5]
TCC0/
WO[6]
TCC0/
WO[7]
TCC0/
WO[4]
TCC0/
WO[5]
TCC1/
WO[2]
TCC1/
WO[3]
I2S/
I2S/
I2S/
I2S/
1kHz
GCLK_IO[4]
GCLK_IO[5]
GCLK_IO[7]
AC/CMP[0]
AC/CMP[1]
GCLK_IO[0]
GCLK_IO[1]
AC/CMP[0]
GCLK_IO[3]
GCLK_IO[4]
GCLK_IO[6]
GCLK_IO[7]
MCK[1]
SCK[1]
I2S/FS[1] GCLK_IO[6]
I2S/SD[0] AC/CMP[1]
I2S/SD[1] GCLK_IO[2]
MCK[0]
SCK[0]
I2S/FS[0] GCLK_IO[5]
USB/SOF
USB/DM
USB/DP
Table 6-1. PORT Function Multiplexing (Continued)
(1)
Pin
SAMD21E SAMD21GSAMD21JEICREFADCACPTCDAC SERCOM
3749PB22VDDIOEXTINT[6]
3850PB23VDDIOEXTINT[7]
253951PA2 7VDDIOEXTINT[15]GCLK_IO[0]
274153PA2 8VDDIOEXTINT[8]GCLK_IO[0]
314557PA3 0VDDIOEXTINT[10]
324658PA3 1VDDIOEXTINT[11]
4763PB02 VDDANAEXTINT[2]AIN[10]Y[8]
4864PB03 VDDANAEXTINT[3]AIN[11]Y[9]
Notes:1. Use the SAMD21J pinout muxing for WLCSP45 package.
2. All analog pin functions are on peripheral function B. Peripheral function B must be selected to disable the digital control of the pin.
3. Only some pins can be used in SERCOM I
characteristics.
4. Note that TC6 and TC7 are not supported on the SAM D21E and G devices. Refer to “Configuration Summary” on page 3 for details.
5. This function is only activated in the presence of a debugger.
I/O Pin Supply Typ e
59PB30VDDIOI2CEXTINT[14]
60PB31VDDIOI2CEXTINT[15]
61PB00 VDDANAEXTINT[0]AIN[8]Y[6]
62PB01 VDDANAEXTINT[1]AIN[9]Y[7]
2
C mode. See the Type column for using a SERCOM pin in I2C mode. Refer to “Electrical Characteristics” on page 935 for details on the I2C pin
AB
(2)(3)
CDEFGH
SERCOM-
(2)(3)
ALT
SERCOM5/
PAD [2]
SERCOM5/
PAD [3]
SERCOM1/
PAD [2]
SERCOM1/
PAD [3]
SERCOM5/
PAD [0]
SERCOM5/
PAD [1]
SERCOM5/
PAD [2]
SERCOM5/
PAD [3]
SERCOM5/
PAD [0]
SERCOM5/
PAD [1]
(4)
TC
/TCCTCCCOMAC/GCLK
TC7/WO[0]GCLK_IO[0]
TC7/WO[1]GCLK_IO[1]
TCC1/WO[0]SWCLK GCLK_IO[0]
TCC1/WO[1]SWDIO
TCC0/WO[0]
TCC0/WO[1]
TC7/WO[0]
TC7/WO[1]
TC6/WO[0]
TC6/WO[1]
TCC1/
WO[2]
TCC1/
WO[3]
(5)
Atmel-42181G–SAM-D21_Datasheet–09/2015
[DATASHEET]
23
6.2Other Functions
6.2.1Oscillator Pinout
The oscillators are not mapped to the normal PORT functions and their multiplexing are controlled by registers in the
System Controller (SYSCTRL).
OscillatorSupplySignalI/O Pin
XOSCVDDIO
XOSC32KVDDANA
6.2.2Serial Wire Debug Interface Pinout
Only the SWCLK pin is mapped to the normal PORT functions. A debugger cold-plugging or hot-plugging detection will
automatically switch the SWDIO port to the SWDIO function.
SignalSupplyI/O Pin
SWCLKVDDIOPA30
SWDIOVDDIOPA31
XINPA1 4
XOUTPA1 5
XIN32PA0 0
XOUT32PA01
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
24
7.Power Supply and Start-Up Considerations
VOLTAGE
REGULATOR
VDDIN
VDDCORE
GND
ADC
AC
DAC
PTC
XOSC32K
OSC32K
VDDANA
GNDANA
PA[7:2]
PB[9:0]
PA[1:0]
Digital Logic
(CPU, peripherals)
DFLL48M
VDDIO
OSC8M
XOSC
OSCULP32K
PA[31:16]
PB[31:10]
PA[15:14]
BOD33
POR
PA[13:8]
BOD12
FDPLL96M
7.1Power Domain Overview
7.2Power Supply Considerations
7.2.1Power Supplies
The Atmel® SAM D21 has several different power supply pins:
zVDDIO: Powers I/O lines, OSC8M and XOSC. Voltage is 1.62V to 3.63V.
zVDDIN: Powers I/O lines and the internal regulator. Voltage is 1.62V to 3.63V.
zVDDANA: Powers I/O lines and the ADC, AC, DAC, PTC, OSCULP32K, OSC32K, XOSC32K. Voltage is 1.62V to
3.63V.
zVDDCORE: Internal regulated voltage output. Powers the core, memories, peripherals, DFLL48M and
FDPLL96M. Voltage is 1.2V.
The same voltage must be applied to both VDDIN, VDDIO and VDDANA. This common voltage is referred to as V
the datasheet.
DD
in
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
25
The ground pins, GND, are common to VDDCORE, VDDIO and VDDIN. The ground pin for VDDANA is GNDANA.
(1.62V — 3.63V)
Main Supply
VDDIO
VDDANA
VDDIN
VDDCORE
GND
GNDANA
SAM D21
For decoupling recommendations for the different power supplies, refer to the schematic checklist.
Refer to “Schematic Checklist” on page 1008 for details.
7.2.2Voltage Regulator
The SAM D21 voltage regulator has two different modes:
zNormal mode: To be used when the CPU and peripherals are running
zLow Power (LP) mode: To be used when the regulator draws small static current. It can be used in standby mode
7.2.3Typical Powering Schematics
The SAM D21 uses a single supply from 1.62V to 3.63V.
The following figure shows the recommended power supply connection.
Figure 7-1. Power Supply Connection
7.2.4Power-Up Sequence
7.2.4.1 Minimum Rise Rate
7.2.4.2 Maximum Rise Rate
The integrated power-on reset (POR) circuitry monitoring the VDDANA power supply requires a minimum rise rate. Refer
to the “Electrical Characteristics” on page 935 for details.
The rise rate of the power supply must not exceed the values described in Electrical Characteristics. Refer to the
“Electrical Characteristics” on page 935 for details.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
26
7.3Power-Up
This section summarizes the power-up sequence of the SAM D21. The behavior after power-up is controlled by the
Power Manager. Refer to “PM – Power Manager” on page 117 for details.
7.3.1Starting of Clocks
After power-up, the device is set to its initial state and kept in reset, until the power has stabilized throughout the device.
Once the power has stabilized, the device will use a 1MHz clock. This clock is derived from the 8MHz Internal Oscillator
(OSC8M), which is divided by eight and used as a clock source for generic clock generator 0. Generic clock generator 0
is the main clock for the Power Manager (PM).
Some synchronous system clocks are active, allowing software execution.
Refer to the “Clock Mask Register” section in “PM – Power Manager” on page 117 for the list of default peripheral clocks
running. Synchronous system clocks that are running are by default not divided and receive a 1MHz clock through
generic clock generator 0. Other generic clocks are disabled except GCLK_WDT, which is used by the Watchdog Timer
(WDT).
7.3.2I/O Pins
After power-up, the I/O pins are tri-stated.
7.3.3Fetching of Initial Instructions
After reset has been released, the CPU starts fetching PC and SP values from the reset address, which is 0x00000000.
This address points to the first executable address in the internal flash. The code read from the internal flash is free to
configure the clock system and clock sources. Refer to “PM – Power Manager” on page 117, “GCLK – Generic Clock
Controller” on page 95 and “SYSCTRL – System Controller” on page 148 for details. Refer to the ARM Architecture
Reference Manual for more information on CPU startup (http://www.arm.com).
7.4Power-On Reset and Brown-Out Detector
The SAM D21 embeds three features to monitor, warn and/or reset the device:
zPOR: Power-on reset on VDDANA
zBOD33: Brown-out detector on VDDANA
zBOD12: Voltage Regulator Internal Brown-out detector on VDDCORE. The Voltage Regulator Internal BOD is
calibrated in production and its calibration configuration is stored in the NVM User Row. This configuration should
not be changed if the user row is written to assure the correct behavior of the BOD12.
7.4.1Power-On Reset on VDDANA
POR monitors VDDANA. It is always activated and monitors voltage at startup and also during all the sleep modes. If
VDDANA goes below the threshold voltage, the entire chip is reset.
7.4.2Brown-Out Detector on VDDANA
BOD33 monitors VDDANA. Refer to “SYSCTRL – System Controller” on page 148 for details.
7.4.3Brown-Out Detector on VDDCORE
Once the device has started up, BOD12 monitors the internal VDDCORE.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
27
8.Product Mapping
Code
SRAM
Undefined
Peripherals
Reserved
Undefined
Global Memory Space
0x00000000
0x20000000
0x20008000
0x40000000
0x43000000
0x60000000
Internal SRAM
SRAM
AHB-APB
Bridge A
AHB-APB
Bridge B
AHB-APB
Bridge C
AHB-APB
Internal Flash
Reserved
Code
0x00000000
0x00040000
0x1FFFFFFF
0x20000000
0x20007FFF
0x40000000
0x41000000
0x42000000
0x42FFFFFF
Reserved
PAC0
PM
SYSCTRL
GCLK
WDT
RTC
EIC
AHB-APB Bridge A
0x40000000
0x40000400
0x40000800
0x40000C00
0x40001000
0x40001400
0x40001800
0x40FFFFFF
0x40001C00
AHB-APB Bridge B
Reserved
PAC1
DSU
NVMCTRL
PORT
0x41000000
0x41002000
0x41004000
0x41004400
0x41FFFFFF
0x41007000
SERCOM5
PAC2
EVSYS
SERCOM0
SERCOM1
SERCOM2
SERCOM3
SERCOM4
AHB-APB Bridge C
TC7
TCC0
TCC1
TCC2
TC3
TC4
TC5
TC6
ADC
AC
0x42000000
0x42000400
0x42000800
0x42000C00
0x42001000
0x42001400
0x42001800
0x42002000
0x42001C00
0x42003000
0x42003400
0x42003800
0x42003C00
0x42004000
0x42004400
0x42004800
Reserved
0x42FFFFFF
0x60000200
0xFFFFFFFF
Reserved
System
0xE0000000
DAC
0x42004C00
0x42002400
0x42002800
0x42002C00
PTC
0x42005400
0x42005000
I2S
DMAC
USB
MTB
0x41004800
0x41005000
0x41006000
0xE0000000
0xE000E000
0xE000F000
0xE00FF000
0xE0100000
0xFFFFFFFF
System
Reserved
SCS
Reserved
ROMTable
Reserved
Internal Flash
0x00000000
0x00400000
0x1FFFFFFF
Internal
RWW section
Device Variant A
Device Variant B
Figure 8-1. Atmel | SMART SAM D21 Product Mapping
This figure represents the full configuration of the Atmel® SAM D21 with maximum flash and SRAM capabilities and a full
set of peripherals. Refer to the “Configuration Summary” on page 3 for details.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
28
9.Memories
9.1Embedded Memories
zInternal high-speed flash with Read-While-Write (RWW) capability on section of the array (Device Variant B).
zInternal high-speed flash
zInternal high-speed RAM, single-cycle access at full speed
9.2Physical Memory Map
The High-Speed bus is implemented as a bus matrix. All High-Speed bus addresses are fixed, and they are never
remapped in any way, even during boot. The 32-bit physical address space is mapped as follow:
Notes: 1. x = G, J or E. Refer to “Ordering Information” on page 5 for details.
2. Only applicable for Device Variant B.
Table 9-2.Flash memory parameters
DeviceFlash sizeNumber of pagesPage size
SAMD21x18256Kbytes409664 bytes
SAMD21x17128Kbytes204664 bytes
(1)
SAMD21x1664Kbytes102464 bytes
SAMD21x1532Kbytes51264 bytes
Note:1.x = G, J or E. Refer to “Ordering Information” on page 5 for details.
2. The number of pages (NVMP) and page size (PSZ) can be read from the NVM Pages and Page Size bits in
the NVM Parameter register in the NVMCTRL (PARAM.NVMP and PARAM.PSZ, respectively). Refer to
PARAM for details.
Table 9-3.RWW section parameters
DeviceFlash size Number of pagesPage size
SAMD21x16B2Kbytes3264 bytes
SAMD21x15B1Kbytes1664 bytes
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
29
9.3NVM Calibration and Auxiliary Space
0x00800000
AUX0 offset address
Automatic calibration
row
Calibration and auxiliary
space address offset
AUX0 – NVM User
Row
AUX1
0x00804000
0x00806000
AUX1 offset address
0x00806000
Area 3 offset ad
Area 1: Reserved (64 bits)
Area 2: Device configuration
area (64 bits)
Area 1 address
Area 2 offset ad
Area 3: Reserved
(128bits)
Area 4: Software
calibration area (256bits)
0x00806008
0x00806010
0x00806020
Area 4 offset add
AUX1
0x00806040
000000
NVM base address
+ NVM size
NVM main address
space
NVM Base Address
Calibration and
auxiliary space
NVM base address +
0x00800000
The device calibration data are stored in different sections of the NVM calibration and auxiliary space presented in Figure
9-1.
Figure 9-1. Calibration and Auxiliary Space
The values from the automatic calibration row are loaded into their respective registers at startup.
9.3.1NVM User Row Mapping
The NVM User Row contains calibration data that are automatically read at device power on.
The NVM User Row can be read at address 0x804000.
To write the NVM User Row refer to “NVMCTRL – Non-Volatile Memory Controller” on page 355.
Note that when writing to the user row the values do not get loaded by the other modules on the device until a device
reset occurs.
Atmel | SMART SAM D21 [DATASHEET]
30
Atmel-42181G–SAM-D21_Datasheet–09/2015
Table 9-4.NVM User Row Mapping
Bit PositionNameUsage
2:0BOOTPROT
3Reserved
6:4EEPROM
7Reserved
13:8BOD33 Level
14BOD33 EnableBOD33 Enable at power on . Refer to BOD33 register. Default value = 1.
16:15BOD33 ActionBOD33 Action at power on. Refer to BOD33 register. Default value = 1.
24:17Reserved
25WDT Enable
26WDT Always-On
30:27WDT Period
34:31WDT Window
Used to select one of eight different bootloader sizes. Refer to “NVMCTRL –
Non-Volatile Memory Controller” on page 355. Default value = 7.
Used to select one of eight different EEPROM sizes. Refer to “NVMCTRL –
Non-Volatile Memory Controller” on page 355. Default value = 7.
BOD33 Threshold Level at power on. Refer to BOD33 register.
Default value = 7.
Voltage Regulator Internal BOD (BOD12) configuration. These bits are written
in production and must not be changed. Default value = 0x70.
WDT Enable at power on. Refer to WDT CTRL register.
Default value = 0.
WDT Always-On at power on. Refer to WDT CTRL register.
Default value = 0.
WDT Period at power on. Refer to WDT CONFIG register.
Default value = 0x0B.
WDT Window mode time-out at power on. Refer to WDT CONFIG register.
Default value = 0x05.
38:35WDT EWOFFSET
39WDT WEN
40BOD33 Hysteresis
41Reserved
47:42Reserved
63:48LOCK
9.3.2NVM Software Calibration Area Mapping
The NVM Software Calibration Area contains calibration data that are measured and written during production test.
These calibration values should be read by the application software and written back to the corresponding register.
The NVM Software Calibration Area can be read at address 0x806020.
The NVM Software Calibration Area can not be written.
WDT Early Warning Interrupt Time Offset at power on. Refer to WDT
EWCTRL register. Default value = 0x0B.
WDT Timer Window Mode Enable at power on. Refer to WDT CTRL register.
Default value = 0.
BOD33 Hysteresis configuration at power on. Refer to BOD33 register.
Default value = 0.
Voltage Regulator Internal BOD(BOD12) configuration. This bit is written in
production and must not be changed. Default value = 0.
NVM Region Lock Bits. Refer to “NVMCTRL – Non-Volatile Memory
Controller” on page 355.
Default value = 0xFFFF.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
31
Table 9-5.NVM Software Calibration Area Mapping
Bit PositionName Description
2:0Reserved
14:3Reserved
26:15Reserved
34:27ADC LINEARITYADC Linearity Calibration. Should be written to CALIB register.
37:35ADC BIASCALADC Bias Calibration. Should be written to CALIB register.
44:38OSC32K CALOSC32KCalibration. Should be written to OSC32K register.
49:45USB TRANSNUSB TRANSN calibration value. Should be written to PADCAL register.
54:50USB TRANSPUSB TRANSP calibration value. Should be written to PADCAL register.
57:55USB TRIMUSB TRIM calibration value. Should be written to the PADCAL register.
63:58DFLL48M COARSE CALDFLL48M Coarse calibration value. Should be written to DFLLVAL register.
73:64DFLL48M FINE CALDFLL48M Fine calibration value. Should be written to DFLLVAL register.
127:74Reserved
9.3.3Serial Number
Each device has a unique 128-bit serial number which is a concatenation of four 32-bit words contained at the following
addresses:
Word 0: 0x0080A00C
Word 1: 0x0080A040
Word 2: 0x0080A044
Word 3: 0x0080A048
The uniqueness of the serial number is guaranteed only when using all 128 bits.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
32
10.Processor And Architecture
10.1Cortex M0+ Processor
The Atmel | SMART SAM D21 implements the ARM® Cortex™-M0+ processor, based on the ARMv6 Architecture and
Thumb®-2 ISA. The Cortex M0+ is 100% instruction set compatible with its predecessor, the Cortex-M0 core, and
upward compatible to Cortex-M3 and M4 cores. The ARM Cortex-M0+ implemented is revision r0p1. For more
information refer to www.arm.com.
10.1.1 Cortex M0+ Configuration
Table 10-1. Cortex M0+ Configuration
FeaturesConfigurable option
InterruptsExternal interrupts 0-3228
Data endiannessLittle-endian or big-endianLittle-endian
SysTick timerPresent or absentPresent
Number of watchpoint comparators0, 1, 22
Number of breakpoint comparators0, 1, 2, 3, 44
Halting debug supportPresent or absentPresent
Atmel | SMART SAM D21
configuration
MultiplierFast or smallFast (single cycle)
Single-cycle I/O portPresent or absentPresent
Wake-up interrupt controllerSupported or not supportedNot supported
Vector Table Offset RegisterPresent or absentPresent
Unprivileged/Privileged supportPresent or absentAbsent
Memory Protection UnitNot present or 8-regionNot present
Reset all registersPresent or absentAbsent
Instruction fetch width16-bit only or mostly 32-bit32-bit
Note:1.All software run in privileged mode only.
The ARM Cortex-M0+ core has two bus interfaces:
zSingle 32-bit AMBA-3 AHB-Lite system interface that provides connections to peripherals and all system
memory, which includes flash and RAM.
zSingle 32-bit I/O port bus interfacing to the PORT with 1-cycle loads and stores.
10.1.2 Cortex-M0+ Peripherals
zSystem Control Space (SCS)
zThe processor provides debug through registers in the SCS. Refer to the Cortex-M0+ Technical Reference
Manual for details (www.arm.com).
zSystem Timer (SysTick)
zThe System Timer is a 24-bit timer that extends the functionality of both the processor and the NVIC. Refer
to the Cortex-M0+ Technical Reference Manual for details (www.arm.com).
(1)
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
33
zNested Vectored Interrupt Controller (NVIC)
zExternal interrupt signals connect to the NVIC, and the NVIC prioritizes the interrupts. Software can set the
priority of each interrupt. The NVIC and the Cortex-M0+ processor core are closely coupled, providing low
latency interrupt processing and efficient processing of late arriving interrupts. Refer to “Nested Vector
Interrupt Controller” on page 34 and the Cortex-M0+ Technical Reference Manual for details
(www.arm.com).
zSystem Control Block (SCB)
zThe System Control Block provides system implementation information, and system control. This includes
configuration, control, and reporting of the system exceptions. Refer to the Cortex-M0+ Devices Generic
User Guide for details (www.arm.com).
zMicro Trace Buffer (MTB)
zThe CoreSight MTB-M0+ (MTB) provides a simple execution trace capability to the Cortex-M0+ processor.
Refer to section “Micro Trace Buffer” on page 36 and the CoreSight MTB-M0+ Technical Reference Manual
for details (www.arm.com).
0x41006000 (see also “Product Mapping” on page 28)Micro Trace Buffer (MTB)
10.1.4 I/O Interface
10.1.4.1 Overview
Because accesses to the AMBA® AHB-Lite™ and the single cycle I/O interface can be made concurrently, the CortexM0+ processor can fetch the next instructions while accessing the I/Os. This enables single cycle I/O accesses to be
sustained for as long as needed. Refer to “CPU Local Bus” on page 381 for more information.
10.1.4.2 Description
Direct access to PORT registers.
10.2Nested Vector Interrupt Controller
10.2.1 Overview
The Nested Vectored Interrupt Controller (NVIC) in the SAM D21 supports 32 interrupt lines with four different priority
levels. For more details, refer to the Cortex-M0+ Technical Reference Manual (www.arm.com).
10.2.2 Interrupt Line Mapping
Each of the 28 interrupt lines is connected to one peripheral instance, as shown in the table below. Each peripheral can
have one or more interrupt flags, located in the peripheral’s Interrupt Flag Status and Clear (INTFLAG) register. The
interrupt flag is set when the interrupt condition occurs. Each interrupt in the peripheral can be individually enabled by
writing a one to the corresponding bit in the peripheral’s Interrupt Enable Set (INTENSET) register, and disabled by
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
34
writing a one to the corresponding bit in the peripheral’s Interrupt Enable Clear (INTENCLR) register. An interrupt request
is generated from the peripheral when the interrupt flag is set and the corresponding interrupt is enabled. The interrupt
requests for one peripheral are ORed together on system level, generating one interrupt request for each peripheral. An
interrupt request will set the corresponding interrupt pending bit in the NVIC interrupt pending registers
(SETPEND/CLRPEND bits in ISPR/ICPR). For the NVIC to activate the interrupt, it must be enabled in the NVIC interrupt
enable register (SETENA/CLRENA bits in ISER/ICER). The NVIC interrupt priority registers IPR0-IPR7 provide a priority
field for each interrupt.
Table 10-3. Interrupt Line Mapping
Peripheral SourceNVIC Line
EIC NMI – External Interrupt ControllerNMI
PM – Power Manager0
SYSCTRL – System Control1
WDT – Watchdog Timer2
RTC – Real Time Counter3
EIC – External Interrupt Controller4
NVMCTRL – Non-Volatile Memory Controller5
DMAC - Direct Memory Access Controller6
USB - Universal Serial Bus7
EVSYS – Event System8
SERCOM0 – Serial Communication Interface 09
SERCOM1 – Serial Communication Interface 110
SERCOM2 – Serial Communication Interface 211
SERCOM3 – Serial Communication Interface 312
SERCOM4 – Serial Communication Interface 413
SERCOM5 – Serial Communication Interface 514
TCC0 – Timer Counter for Control 015
TCC1 – Timer Counter for Control 116
TCC2 – Timer Counter for Control 217
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
35
Table 10-3. Interrupt Line Mapping (Continued)
Peripheral SourceNVIC Line
TC3 – Timer Counter 318
TC4 – Timer Counter 419
TC5 – Timer Counter 520
TC6 – Timer Counter 621
TC7 – Timer Counter 722
ADC – Analog-to-Digital Converter23
AC – Analog Comparator24
DAC – Digital-to-Analog Converter25
PTC – Peripheral Touch Controller26
I2S - Inter IC Sound27
10.3Micro Trace Buffer
10.3.1 Features
zProgram flow tracing for the Cortex-M0+ processor
zMTB SRAM can be used for both trace and general purpose storage by the processor
zThe position and size of the trace buffer in SRAM is configurable by software
zCoreSight compliant
10.3.2 Overview
When enabled, the MTB records changes in program flow, reported by the Cortex-M0+ processor over the execution
trace interface shared between the Cortex-M0+ processor and the CoreSight MTB-M0+. This information is stored as
trace packets in the SRAM by the MTB. An off-chip debugger can extract the trace information using the Debug Access
Port to read the trace information from the SRAM. The debugger can then reconstruct the program flow from this
information.
The MTB simultaneously stores trace information into the SRAM, and gives the processor access to the SRAM. The
MTB ensures that trace write accesses have priority over processor accesses.
The execution trace packet consists of a pair of 32-bit words that the MTB generates when it detects the processor PC
value changes non-sequentially. A non-sequential PC change can occur during branch instructions or during exception
entry. See the CoreSight MTB-M0+ Technical Reference Manual for more details on the MTB execution trace packet
format.
Tracing is enabled when the MASTER.EN bit in the Master Trace Control Register is 1. There are various ways to set the
bit to 1 to start tracing, or to 0 to stop tracing. See the CoreSight Cortex-M0+ Technical Reference Manual for more
details on the Trace start and stop and for a detailed description of the MTB’s MASTER register. The MTB can be
programmed to stop tracing automatically when the memory fills to a specified watermark level or to start or stop tracing
by writing directly to the MASTER.EN bit. If the watermark mechanism is not being used and the trace buffer overflows,
then the buffer wraps around overwriting previous trace packets.
The base address of the MTB registers is 0x41006000; this address is also written in the CoreSight ROM Table. The
offset of each register from the base address is fixed and as defined by the CoreSight MTB-M0+ Technical Reference
Manual. The MTB has 4 programmable registers to control the behavior of the trace features:
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
36
zPOSITION: Contains the trace write pointer and the wrap bit,
zMASTER: Contains the main trace enable bit and other trace control fields,
zFLOW: Contains the WATERMARK address and the AUTOSTOP and AUTOHALT control bits,
zBASE: Indicates where the SRAM is located in the processor memory map. This register is provided to enable
auto discovery of the MTB SRAM location, by a debug agent.
See the CoreSight MTB-M0+ Technical Reference Manual for a detailed description of these registers.
10.4High-Speed Bus System
10.4.1 Features
High-Speed Bus Matrix has the following features:
zSymmetric crossbar bus switch implementation
zAllows concurrent accesses from different masters to different slaves
z32-bit data bus
zOperation at a one-to-one clock frequency with the bus masters
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
37
10.4.2 Configuration
CM0+0
DSU1
High-Speed Bus SLAVES
Internal Flash
0
AHB-APB Bridge A
1
AHB-APB Bridge B
2
AHB-APB Bridge C
3
MTB
Multi-Slave
MASTERS
USB
DMAC WB
DMAC Fetch
CM0+
4
DMAC Data
DSU
6
SRAM
DSU1
MTB
USB
DMAC WB
DMAC Fetch
Priviledged SRAM-access
MASTERS
DSU2
DMAC Data
4
5
0123
65
SLAVE ID
SRAM PORT ID
MASTER ID
Table 10-4. Bus Matrix Masters
Bus Matrix MastersMaster ID
CM0+ - Cortex M0+ Processor0
DSU - Device Service Unit1
DMAC - Direct Memory Access Controller / Data Access2
Table 10-5. Bus Matrix Slaves
Bus Matrix SlavesSlave ID
Internal Flash Memory0
AHB-APB Bridge A1
AHB-APB Bridge B2
AHB-APB Bridge C3
SRAM Port 4 - CM0+ Access4
SRAM Port 5 - DMAC Data Access5
SRAM Port 6 - DSU Access6
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
38
Table 10-6. SRAM Port Connection
SRAM Port ConnectionPort IDConnection Type
MTB - Micro Trace Buffer0Direct
USB - Universal Serial Bus1Direct
DMAC - Direct Memory Access Controller - Write-Back Access2Direct
DMAC - Direct Memory Access Controller - Fetch Access3Direct
CM0+ - Cortex M0+ Processor4Bus Matrix
DMAC - Direct Memory Access Controller - Data Access5Bus Matrix
DSU - Device Service Unit6Bus Matrix
10.4.3 SRAM Quality of Service
To ensure that masters with latency requirements get sufficient priority when accessing RAM, the different masters can
be configured to have a given priority for different type of access.
The Quality of Service (QoS) level is independently selected for each master accessing the RAM. For any access to the
RAM the RAM also receives the QoS level. The QoS levels and their corresponding bit values for the QoS level
configuration is shown in Table 10-7.
Table 10-7. Quality of Service
ValueNameDescription
00DISABLE Background (no sensitive operation)
01LOWSensitive Bandwidth
10MEDIUMSensitive Latency
11HIGHCritical Latency
If a master is configured with QoS level 0x00 or 0x01 there will be minimum one cycle latency for the RAM access.
The priority order for concurrent accesses are decided by two factors. First the QoS level for the master and then a static
priority given by table nn-mm (table: SRAM port connection) where the lowest port ID has the highest static priority.
The MTB has fixed QoS level 3 and the DSU has fixed QoS level 1.
The CPU QoS level can be written/read at address 0x41007110, bits [1:0]. Its reset value is 0x0.
Refer to different master QOSCTRL registers for configuring QoS for the other masters (USB, DMAC).
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
39
10.5AHB-APB Bridge
T0T1T2T3
Addr 1
Data 1
PADDR
PWRITE
PCLK
PSEL
PENABLE
PWDATA
PREADY
T0T1T2T3
Addr 1
Data 1
PADDR
PWRITE
PCLK
PSEL
PENABLE
PWDATA
PREADY
T4T5
Wait statesNo wait states
The AHB-APB bridge is an AHB slave, providing an interface between the high-speed AHB domain and the low-power
APB domain. It is used to provide access to the programmable control registers of peripherals (see “Product Mapping” on
page 28).
AHB-APB bridge is based on AMBA APB Protocol Specification V2.0 (ref. as APB4) including:
z Wait state support
z Error reporting
z Transaction protection
z Sparse data transfer (byte, half-word and word)
Additional enhancements:
z Address and data cycles merged into a single cycle
z Sparse data transfer also apply to read access
to operate the AHB-APB bridge, the clock (CLK_HPBx_AHB) must be enabled. See “PM – Power Manager” on page 117
for details.
Figure 10-1. APB Write Access.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
40
Figure 10-2. APB Read Access.
T0T1T2T3
Addr 1
Data 1
PADDR
PWRITE
PCLK
PSEL
PENABLE
PRDATA
PREADY
T0T1T2T3
Addr 1
Data 1
PADDR
PWRITE
PCLK
PSEL
PENABLE
PRDATA
PREADY
T4T5
Wait statesNo wait states
10.6PAC – Peripheral Access Controller
10.6.1 Overview
There is one PAC associated with each AHB-APB bridge. The PAC can provide write protection for registers of each
peripheral connected on the same bridge.
The PAC peripheral bus clock (CLK_PACx_APB) can be enabled and disabled in the Power Manager. CLK_PAC0_APB
and CLK_PAC1_APB are enabled are reset. CLK_PAC2_APB is disabled at reset. Refer to “PM – Power Manager” on
page 117 for details. The PAC will continue to operate in any sleep mode where the selected clock source is running.
Write-protection does not apply for debugger access. When the debugger makes an access to a peripheral, writeprotection is ignored so that the debugger can update the register.
Write-protect registers allow the user to disable a selected peripheral’s write-protection without doing a read-modify-write
operation. These registers are mapped into two I/O memory locations, one for clearing and one for setting the register
bits. Writing a one to a bit in the Write Protect Clear register (WPCLR) will clear the corresponding bit in both registers
(WPCLR and WPSET) and disable the write-protection for the corresponding peripheral, while writing a one to a bit in the
Write Protect Set (WPSET) register will set the corresponding bit in both registers (WPCLR and WPSET) and enable the
write-protection for the corresponding peripheral. Both registers (WPCLR and WPSET) will return the same value when
read.
If a peripheral is write-protected, and if a write access is performed, data will not be written, and the peripheral will return
an access error (CPU exception).
The PAC also offers a safety feature for correct program execution, with a CPU exception generated on double writeprotection or double unprotection of a peripheral. If a peripheral n is write-protected and a write to one in WPSET[n] is
detected, the PAC returns an error. This can be used to ensure that the application follows the intended program flow by
always following a write-protect with an unprotect, and vice versa. However, in applications where a write-protected
peripheral is used in several contexts, e.g., interrupts, care should be taken so that either the interrupt can not happen
while the main application or other interrupt levels manipulate the write-protection status, or when the interrupt handler
needs to unprotect the peripheral, based on the current protection status, by reading WPSET.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
41
10.6.2 Register Description
Atomic 8-, 16- and 32-bit accesses are supported. In addition, the 8-bit quarters and 16-bit halves of a 32-bit register, and
the 8-bit halves of a 16-bit register can be accessed directly.
Refer to “Product Mapping” on page 28for PAC locations.
10.6.2.1 PAC0 Register Description
Write Protect Clear
Name:WPCLR
Offset:0x00
Reset:0x00000000
Property:-
Bit3130292827262524
AccessRRRRRRRR
Reset00000000
Bit2322212019181716
AccessRRRRRRRR
Reset00000000
Bit151413121110 9 8
AccessRRRRRRRR
Reset00000000
Bit76543210
EICRTCWDTGCLKSYSCTRLPM
AccessRR/WR/WR/WR/WR/WR/WR
Reset00000000
zBits 31:7 – 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. These bits will always return zero when read.
Writing a one to these bits will clear the Write Protect bits for the corresponding peripherals.
zBit 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. This bit will always return zero when read.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
42
Write Protect Set
Name:WPSET
Offset:0x04
Reset:0x00000000
Property:-
Bit 3130292827262524
AccessRRRRRRRR
Reset00000000
Bit 2322212019181716
AccessRRRRRRRR
Reset00000000
Bit15141312111098
AccessRRRRRRRR
Reset00000000
Bit76543210
EICRTCWDTGCLKSYSCTRLPM
AccessRR/WR/WR/WR/WR/WR/WR
Reset00000000
zBits 31:7 – 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. These bits will always return zero when read.
Writing a one to these bits will set the Write Protect bit for the corresponding peripherals.
zBit 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. This bit will always return zero when read.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
43
10.6.2.2 PAC1 Register Description
Write Protect Clear
Name:WPCLR
Offset:0x00
Reset:0x00000002
Property:-
Bit3130292827262524
AccessRRRRRRRR
Reset00000000
Bit2322212019181716
AccessRRRRRRRR
Reset00000000
Bit151413121110 9 8
AccessRRRRRRRR
Reset00000000
Bit76543210
MTBUSBDMACPORTNVMCTRLDSU
AccessRR/WR/WR/WR/WR/WR/WR
Reset00000010
zBits 31:7 – 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. These bits will always return zero when read.
Writing a one to these bits will clear the Write Protect bit for the corresponding peripherals.
zBit 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. This bit will always return zero when read.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
44
Write Protect Set
Name:WPSET
Offset:0x04
Reset:0x00000002
Property:-
Bit 3130292827262524
AccessRRRRRRRR
Reset00000000
Bit 2322212019181716
AccessRRRRRRRR
Reset00000000
Bit15141312111098
AccessRRRRRRRR
Reset00000000
Bit76543210
MTBUSBDMACPORTNVMCTRLDSU
AccessRR/WR/WR/WR/WR/WR/WR
Reset00000010
zBits 31:7 – 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. These bits will always return zero when read.
Writing a one to these bits will set the Write Protect bit for the corresponding peripherals.
zBit 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. This bit will always return zero when read.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
45
10.6.2.3 PAC2 Register Description
Write Protect Clear
Name:WPCLR
Offset:0x00
Reset:0x00800000
Property:-
Bit3130292827262524
AccessRRRRRRRR
Reset00000000
Bit2322212019181716
AC1I2SPTCDACACADC
AccessRRR/WR/WR/WR/WR/WR/W
Reset10000000
Bit151413121110 9 8
TC7TC6TC5TC4TC3TCC2TCC1TCC0
AccessR/WR/WR/WR/WR/WR/WR/WR/W
Reset00000000
Bit76543210
SERCOM5SERCOM4SERCOM3SERCOM2SERCOM1SERCOM0EVSYS
AccessR/WR/WR/WR/WR/WR/WR/WR
Reset00000000
zBits 31:21 – Reserved
These bits are unused and reserved for future use. For compatibility with future devices, always write these bits to
reset value when this register is written. These bits will always return reset value when read.
Writing a one to these bits will clear the Write Protect bit for the corresponding peripherals.
zBit 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. This bit will always return zero when read.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
46
Write Protect Set
Name:WPSET
Offset:0x04
Reset:0x00800000
Property:-
Bit3130292827262524
AccessRRRRRRRR
Reset00000000
Bit2322212019181716
AC1I2SPTCDACACADC
AccessRRR/WR/WR/WR/WR/WR/W
Reset10000000
Bit151413121110 9 8
TC7TC6TC5TC4TC3TCC2TCC1TCC0
AccessR/WR/WR/WR/WR/WR/WR/WR/W
Reset00000000
Bit76543210
SERCOM5SERCOM4SERCOM3SERCOM2SERCOM1SERCOM0EVSYS
AccessR/WR/WR/WR/WR/WR/WR/WR
Reset00000000
zBits 31:21 – Reserved
These bits are unused and reserved for future use. For compatibility with future devices, always write these bits to
reset value when this register is written. These bits will always return reset value when read.
Writing a one to these bits will set the Write Protect bit for the corresponding peripherals.
zBit 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. This bit will always return zero when read.
The Device Service Unit (DSU) provides a means to detect debugger probes. This enables the ARM Debug Access Port
(DAP) to have control over multiplexed debug pads and CPU reset. The DSU also provides system-level services to
debug adapters in an ARM debug system. It implements a CoreSight Debug ROM that provides device identification as
well as identification of other debug components in the system. Hence, it complies with the ARM Peripheral Identification
specification. The DSU also provides system services to applications that need memory testing, as required for
IEC60730 Class B compliance, for example. The DSU can be accessed simultaneously by a debugger and the CPU, as
it is connected on the High-Speed Bus Matrix. For security reasons, some of the DSU features will be limited or
unavailable when the device is protected by the NVMCTRL security bit (refer to “Security Bit” on page 361).
12.2Features
z CPU reset extension
z Debugger probe detection (Cold- and Hot-Plugging)
z Chip-Erase command and status
z 32-bit cyclic redundancy check (CRC32) of any memory accessible through the bus matrix
z ARM
z Two debug communications channels
z Debug access port security filter
z Onboard memory built-in self-test (MBIST)
®
CoreSight™ compliant device identification
12.3Block Diagram
Figure 12-1. DSU Bock Diagram
LK
WDI
ET
AP
HB-A
D
INTERFACE
DAP SECURITY FILTER
HT R
RC-32
MBI
HIP ERAS
ebugger_presen
pu_reset_extensio
CP
NVMCTRL
DB
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
50
12.4 Signal Description
Signal NameTypeDescription
RESETDigital InputExternal reset
SWCLKDigital InputSW clock
SWDIODigital I/OSW bidirectional data pin
Refer to “I/O Multiplexing and Considerations” on page 21 for details on the pin mapping for this peripheral.
12.5Product Dependencies
In order to use this peripheral, other parts of the system must be configured correctly, as described below.
12.5.1 I/O Lines
The SWCLK pin is by default assigned to the DSU module to allow debugger probe detection and the condition to stretch
the CPU reset phase. For more information, refer to “Debugger Probe Detection” on page 52. The Hot-Plugging feature
depends on the PORT configuration. If the SWCLK pin function is changed in the PORT or if the PORT_MUX is disabled,
the Hot-Plugging feature is disabled until a power-reset or an external reset.
12.5.2 Power Management
The DSU will continue to operate in any sleep mode where the selected source clock is running.
Refer to “PM – Power Manager” on page 117 for details on the different sleep modes.
12.5.3 Clocks
The DSU bus clocks (CLK_DSU_APB and CLK_DSU_AHB) can be enabled and disabled in the Power Manager. For
more information on the CLK_DSU_APB and CLK_DSU_AHB clock masks, refer to “PM – Power Manager” on page
117.
12.5.4 DMA
Not applicable.
12.5.5 Interrupts
Not applicable.
12.5.6 Events
Not applicable.
12.5.7 Register Access Protection
All registers with write access are optionally write-protected by the Peripheral Access Controller (PAC), except the
following registers:
zDebug Communication Channel 0 register (DCC0)
zDebug Communication Channel 1 register (DCC1)
Write-protection is denoted by the Write-Protection property in the register description.
Write-protection does not apply for accesses through an external debugger. Refer to “PAC – Peripheral Access
Controller” on page 41 for details.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
51
12.5.8 Analog Connections
Clear
SWCLK
CPU reset
extension
CPU_STATE
reset
running
T
Not applicable.
12.6Debug Operation
12.6.1 Principle of Operation
The DSU provides basic services to allow on-chip debug using the ARM Debug Access Port and the ARM processor
debug resources:
zCPU reset extension
zDebugger probe detection
For more details on the ARM debug components, refer to the ARM Debug Interface v5Architecture Specification.
12.6.2 CPU Reset Extension
“CPU reset extension” refers to the extension of the reset phase of the CPU core after the external reset is released. This
ensures that the CPU is not executing code at startup while a debugger connects to the system. It is detected on a
RESET
debugger if SWCLK is left unconnected. When the CPU is held in the reset extension phase, the CPU Reset Extension
bit (CRSTEXT) of the Status A register (STATUSA.CRSTEXT) is set. To release the CPU, write a one to
STATUSA.CRSTEXT. STATUSA.CRSTEXT will then be set to zero. Writing a zero to STATUSA.CRSTEXT has no
effect. For security reasons, it is not possible to release the CPU reset extension when the device is protected by the
NVMCTRL security bit (refer to “Security Bit” on page 361). Trying to do so sets the Protection Error bit (PERR) of the
Status A register (STATUSA.PERR).
release event when SWCLK is low. At startup, SWCLK is internally pulled up to avoid false detection of a
Figure 12-2. Typical CPU Reset Extension Set and Clear Timing Diagram
RESE
12.6.3 Debugger Probe Detection
12.6.3.1 Cold-Plugging
Cold-Plugging is the detection of a debugger when the system is in reset. Cold-Plugging is detected when the CPU reset
extension is requested, as described above.
12.6.3.2 Hot-Plugging
Hot-Plugging is the detection of a debugger probe when the system is not in reset. Hot-Plugging is not possible under
reset because the detector is reset when POR or RESET
edge is detected. The SWCLK pad is multiplexed with other functions and the user must ensure that its default function is
assigned to the debug system. If the SWCLK function is changed, the Hot-Plugging feature is disabled until a power-
are asserted. Hot-Plugging is active when a SWCLK falling
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
52
reset or external reset occurs. Availability of the Hot-Plugging feature can be read from the Hot-Plugging Enable bit of the
The presence of a debugger probe is detected when either Hot-Plugging or Cold-Plugging is detected. Once detected,
the Debugger Present bit of the Status B register (STATUSB.DBGPRES) is set. For security reasons, Hot-Plugging is not
available when the device is protected by the NVMCTRL security bit (refer to “Security Bit” on page 361).
This detection requires that pads are correctly powered. Thus, at cold startup, this detection cannot be done until POR is
released. If the device is protected, Cold-Plugging is the only way to detect a debugger probe, and so the external reset
timing must be longer than the POR timing. If external reset is deasserted before POR release, the user must retry the
procedure above until it gets connected to the device.
12.7Chip-Erase
Chip-Erase consists of removing all sensitive information stored in the chip and clearing the NVMCTRL security bit (refer
to “Security Bit” on page 361). Hence, all volatile memories and the flash array (including the EEPROM emulation area)
will be erased. The flash auxiliary rows, including the user row, will not be erased. When the device is protected, the
debugger must reset the device in order to be detected. This ensures that internal registers are reset after the protected
state is removed. The Chip-Erase operation is triggered by writing a one to the Chip-Erase bit in the Control register
(CTRL.CE). This command will be discarded if the DSU is protected by the Peripheral Access Controller (PAC). Once
issued, the module clears volatile memories prior to erasing the flash array. To ensure that the Chip-Erase operation is
completed, check the Done bit of the Status A register (STATUSA.DONE). The Chip-Erase operation depends on clocks
and power management features that can be altered by the CPU. For that reason, it is recommended to issue a ChipErase after a Cold-Plugging procedure to ensure that the device is in a known and safe state.
The recommended sequence is as follows:
1.Issue the Cold-Plugging procedure (refer to “Cold-Plugging” on page 52). The device then:
1. Detects the debugger probe
2. Holds the CPU in reset
2.Issue the Chip-Erase command by writing a one to CTRL.CE. The device then:
1. Clears the system volatile memories
2. Erases the whole flash array (including the EEPROM emulation area, not including auxiliary rows)
3. Erases the lock row, removing the NVMCTRL security bit protection
3.Check for completion by polling STATUSA.DONE (read as one when completed).
4.Reset the device to let the NVMCTRL update fuses.
12.8Programming
Programming of the flash or RAM memories is available when the device is not protected by the NVMCTRL security bit
(refer to “Security Bit” on page 361).
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
53
1.At power up, RESET is driven low by a debugger. The on-chip regulator holds the system in a POR state until the
input supply is above the POR threshold (refer to “Power-On Reset (POR) Characteristics” on page 952). The system continues to be held in this static state until the internally regulated supplies have reached a safe operating
state.
2.The PM starts, clocks are switched to the slow clock (Core Clock, System Clock, Flash Clock and any Bus Clocks
that do not have clock gate control). Internal resets are maintained due to the external reset.
3.The debugger maintains a low level on SWCLK. Releasing RESET
procedure.
4.The debugger generates a clock signal on the SWCLK pin, the Debug Access Port (DAP) receives a clock.
5.The CPU remains in reset due to the Cold-Plugging procedure; meanwhile, the rest of the system is released.
6.A Chip-Erase is issued to ensure that the flash is fully erased prior to programming.
7.Programming is available through the AHB-AP.
8.After operation is completed, the chip can be restarted either by asserting RESET
to the Status A register CPU Reset Phase Extension bit (STATUSA.CRSTEXT). Make sure that the SWCLK pin is
high when releasing RESET
to prevent extending the CPU reset.
12.9Intellectual Property Protection
Intellectual property protection consists of restricting access to internal memories from external tools when the device is
protected, and is accomplished by setting the NVMCTRL security bit (refer to “Security Bit” on page 361). This protected
state can be removed by issuing a Chip-Erase (refer to “Chip-Erase” on page 53). When the device is protected,
read/write accesses using the AHB-AP are limited to the DSU address range and DSU commands are restricted.
The DSU implements a security filter that monitors the AHB transactions generated by the ARM AHB-AP inside the DAP.
If the device is protected, then AHB-AP read/write accesses outside the DSU external address range are discarded,
causing an error response that sets the ARM AHB-AP sticky error bits (refer to the ARM Debug Interface v5 Architecture
Specification on http://www.arm.com).
The DSU is intended to be accessed either:
zInternally from the CPU, without any limitation, even when the device is protected
zExternally from a debug adapter, with some restrictions when the device is protected
For security reasons, DSU features have limitations when used from a debug adapter. To differentiate external accesses
from internal ones, the first 0x100 bytes of the DSU register map have been replicated at offset 0x100:
zThe first 0x100 bytes form the internal address range
zThe next 0x100 bytes form the external address range
When the device is protected, the DAP can only issue MEM-AP accesses in the DSU address range limited to the 0x1000x2000 offset range.
The DSU operating registers are located in the 0x00-0xFF area and remapped in 0x100-0x1FF to differentiate accesses
coming from a debugger and the CPU. If the device is protected and an access is issued in the region 0x100-0x1FF, it is
subject to security restrictions. For more information, refer to Table 12-1.
results in a debugger Cold-Plugging
, toggling power or writing a one
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
54
Figure 12-4. APB Memory Mapping
0x0000
0x00FC
0x0100
0x01FD
0x1000
0x1FFC
DSU operating
registers
Replicated
DSU operating
registers
Empty
DSU CoreSight
ROM
Internal address range
(cannot be accessed from debug tools when the device is
protected by the NVMCTRL security bit)
External address range
(can be accessed from debug tools with some restrictions)
Some features not activated by APB transactions are not available when the device is protected:
Table 12-1. Feature Availability Under Protection
FeaturesAvailability When the Device is Protected
CPU reset extensionYes
Debugger Cold-PluggingYes
Debugger Hot-PluggingNo
12.10 Device Identification
Device identification relies on the ARM CoreSight component identification scheme, which allows the chip to be identified
as an ATMEL device implementing a DSU. The DSU contains identification registers to differentiate the device.
12.10.1 CoreSight Identification
A system-level ARM CoreSight ROM table is present in the device to identify the vendor and the chip identification
method. Its address is provided in the MEM-AP BASE register inside the ARM Debug Access Port. The CoreSight ROM
implements a 64-bit conceptual ID composed as follows from the PID0 to PID7 CoreSight ROM Table registers:
Figure 12-5. Conceptual 64-Bit Peripheral ID
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
55
Table 12-2. Conceptual 64-Bit Peripheral ID Bit Descriptions
FieldSizeDescriptionLocation
JEP-106 CC code4Atmel continuation code: 0x0PID4
JEP-106 ID code7Atmel device ID: 0x1FPID1+PID2
4KB count4Indicates that the CoreSight component is a ROM: 0x0PID4
RevAnd4Not used; read as 0PID3
CUSMOD4Not used; read as 0PID3
PARTNUM12Contains 0xCD0 to indicate that DSU is presentPID0+PID1
DSU revision (starts at 0x0 and increments by 1 at both major and minor
REVISION4
revisions). Identifies DSU identification method variants. If 0x0, this
indicates that device identification can be completed by reading the
Device Identification register (DID)
For more information, refer to the ARM Debug Interface Version 5 Architecture Specification.
12.10.2 DSU Chip Identification Method:
The DSU DID register identifies the device by implementing the following information:
zProcessor identification
zProduct family identification
zProduct series identification
zDevice select
PID3
12.11 Functional Description
12.11.1 Principle of Operation
The DSU provides memory services such as CRC32 or MBIST that require almost the same interface. Hence, the
Address, Length and Data registers are shared. They must be configured first; then a command can be issued by writing
the Control register. When a command is ongoing, other commands are discarded until the current operation is
completed. Hence, the user must wait for the STATUSA.DONE bit to be set prior to issuing another one.
12.11.2 Basic Operation
12.11.2.1 Initialization
The module is enabled by enabling its clocks. For more details, refer to “Clocks” on page 51. The DSU registers can be
write-protected. Refer to “PAC – Peripheral Access Controller” on page 41.
12.11.2.2 Operation from a debug adapter
Debug adapters should access the DSU registers in the external address range 0x100 – 0x2000. If the device is
protected by the NVMCTRL security bit (refer to “Security Bit” on page 361), accessing the first 0x100 bytes causes the
system to return an error (refer to “Intellectual Property Protection” on page 54).
12.11.2.3 Operation from the CPU
There are no restrictions when accessing DSU registers from the CPU. However, the user should access DSU registers
in the internal address range (0x0 – 0x100) to avoid external security restrictions (refer to “Intellectual Property
Protection” on page 54).
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
56
12.11.3 32-bit Cyclic Redundancy Check (CRC32)
The DSU unit provides support for calculating a cyclic redundancy check (CRC32) value for a memory area (including
flash and AHB RAM).
When the CRC32 command is issued from:
zThe internal range, the CRC32 can be operated at any memory location
zThe external range, the CRC32 operation is restricted; DATA, ADDR and LENGTH values are forced (see below)
Table 12-3. AMOD Bit Descriptions when Operating CRC32
AMOD[1:0]Short NameExternal Range Restrictions
0ARRAY
1EEPROM
2-3Reserved
The algorithm employed is the industry standard CRC32 algorithm using the generator polynomial 0xEDB88320
(reversed representation).
12.11.3.1 Starting CRC32 Calculation
CRC32 calculation for a memory range is started after writing the start address into the Address register (ADDR) and the
size of the memory range into the Length register (LENGTH). Both must be word-aligned.
The initial value used for the CRC32 calculation must be written to the Data register. This value will usually be
0xFFFFFFFF, but can be, for example, the result of a previous CRC32 calculation if generating a common CRC32 of
separate memory blocks.
Once completed, the calculated CRC32 value can be read out of the Data register. The read value must be
complemented to match standard CRC32 implementations or kept non-inverted if used as starting point for subsequent
CRC32 calculations.
If the device is in protected state by the NVMCTRL security bit (refer to “Security Bit” on page 361), it is only possible to
calculate the CRC32 of the whole flash array when operated from the external address space. In most cases, this area
will be the entire onboard non-volatile memory. The Address, Length and Data registers will be forced to predefined
values once the CRC32 operation is started, and values written by the user are ignored. This allows the user to verify the
contents of a protected device.
The actual test is started by writing a one in the 32-bit Cyclic Redundancy Check bit of the Control register (CTRL.CRC).
A running CRC32 operation can be canceled by resetting the module (writing a one to CTRL.SWRST).
CRC32 is restricted to the full flash array area (EEPROM emulation area not included)
DATA forced to 0xFFFFFFFF before calculation (no seed)
CRC32 of the whole EEPROM emulation area
DATA forced to 0xFFFFFFFF before calculation (no seed)
12.11.3.2 Interpreting the Results
The user should monitor the Status A register. When the operation is completed, STATUSA.DONE is set. Then the Bus
Error bit of the Status A register (STATUSA.BERR) must be read to ensure that no bus error occurred.
12.11.4 Debug Communication Channels
The Debug Communication Channels (DCCO and DCC1) consist of a pair of registers with associated handshake logic,
accessible by both CPU and debugger even if the device is protected by the NVMCTRL security bit (refer to “Security Bit”
on page 361). The registers can be used to exchange data between the CPU and the debugger, during run time as well
as in debug mode. This enables the user to build a custom debug protocol using only these registers. The DCC0 and
DCC1 registers are accessible when the protected state is active. When the device is protected, however, it is not
possible to connect a debugger while the CPU is running (STATUSA.CRSTEXT is not writable and the CPU is held
under reset). Dirty bits in the status registers indicate whether a new value has been written in DCC0 or DCC1. These
bits,DCC0D and DCC1D, are located in the STATUSB registers. They are automatically set on write and cleared on
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
57
read. The DCC0 and DCC1 registers are shared with the onboard memory testing logic (MBIST). Accordingly, DCC0 and
DCC1 must not be used while performing MBIST operations.
12.11.5 Testing of Onboard Memories (MBIST)
The DSU implements a feature for automatic testing of memory also known as MBIST. This is primarily intended for
production test of onboard memories. MBIST cannot be operated from the external address range when the device is
protected by the NVMCTRL security bit (refer to “Security Bit” on page 361). If a MBIST command is issued when the
device is protected, a protection error is reported in the Protection Error bit in the Status A register (STATUSA.PERR).
1.Algorithm
The algorithm used for testing is a type of March algorithm called "March LR". This algorithm is able to detect a
wide range of memory defects, while still keeping a linear run time. The algorithm is:
1. Write entire memory to 0, in any order.
2. Bit for bit read 0, write 1, in descending order.
3. Bit for bit read 1, write 0, read 0, write 1, in ascending order.
4. Bit for bit read 1, write 0, in ascending order.
5. Bit for bit read 0, write 1, read 1, write 0, in ascending order.
6. Read 0 from entire memory, in ascending order.
The specific implementation used has a run time of O(14n) where n is the number of bits in the RAM. The detected
faults are:
zAddress decoder faults
zStuck-at faults
zTransition faults
zCoupling faults
zLinked Coupling faults
zStuck-open faults
2.Starting MBIST
To test a memory, you need to write the start address of the memory to the ADDR.ADDR bit group, and the size of
the memory into the Length register. See “Physical Memory Map” on page 29 to know which memories are available, and which address they are at.
For best test coverage, an entire physical memory block should be tested at once. It is possible to test only a subset of a memory, but the test coverage will then be somewhat lower.
The actual test is started by writing a one to CTRL.MBIST. A running MBIST operation can be canceled by writing
a one to CTRL.SWRST.
3.Interpreting the Results
The tester should monitor the STATUSA register. When the operation is completed, STATUSA.DONE is set.
There are three different modes:
zADDR.AMOD=0: exit-on-error (default)
In this mode, the algorithm terminates either when a fault is detected or on successful completion. In both cases,
STATUSA.DONE is set. If an error was detected, STATUSA.FAIL will be set. User then can read the DATA and
ADDR registers to locate the fault. Refer to “Locating Errors” on page 58.
zADDR.AMOD=1: pause-on-error
In this mode, the MBIST algorithm is paused when an error is detected. In such a situation, only STATUSA.FAIL is
asserted. The state machine waits for user to clear STATUSA.FAIL by writing a one in STATUSA.FAIL to resume.
Prior to resuming, user can read the DATA and ADDR registers to locate the fault. Refer to “Locating Errors” on
page 58.
4.Locating Errors
If the test stops with STATUSA.FAIL set, one or more bits failed the test. The test stops at the first detected error.
The position of the failing bit can be found by reading the following registers:
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
58
zADDR: Address of the word containing the failing bit.
zDATA: contains data to identify which bit failed, and during which phase of the test it failed. The DATA
register will in this case contains the following bit groups:
Table 12-4. DATA bits Description When MBIST Operation Returns An Error
Bit3130292827262524
Bit2322212019181716
Bit151413121110 9 8
phase
Bit76543210
bit_index
zbit_index: contains the bit number of the failing bit
zphase: indicates which phase of the test failed and the cause of the error. See Table 12-5 on page 59.
Table 12-5. MBIST Operation Phases
PhaseTest A c t i o n s
0Write all bits to zero. This phase cannot fail.
1Read 0, write 1, increment address
2Read 1, write 0
3Read 0, write 1, decrement address
4Read 1, write 0, decrement address
5Read 0, write 1
6Read 1, write 0, decrement address
7Read all zeros. bit_index is not used
12.11.6 System Services Availability When Accessed Externally
External access: Access performed in the DSU address offset 0x200-0x1FFF range.
Internal access: Access performed in the DSU address offset 0x0-0x100 range.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
59
Table 12-6. Available Features When Operated From The External Address Range and Device is Protected
Availability From The External Address Range and Device is Protected
Features
Chip-Erase command and statusYes
CRC32Yes, only full array or full EEPROM
CoreSight Compliant Device identificationYe s
Debug communication channelsYe s
Testing of onboard memories (MBIST)Ye s
STATUSA.CRSTEXT clearingNo (STATUSA.PERR is set when attempting to do so)
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
60
12.12 Register Summary
Table 12-7. Register Summary
Bit
OffsetName
0x0000CTRL7:0CEMBISTCRCSWRST
0x0001STATUSA7:0
0x0002STATUSB7:0
0x0003Reserved
0x0004
0x000515:8ADDR[13:6]
0x000623:16ADDR[21:14]
0x000731:24ADDR[29:22]
0x0008
0x000915:8LENGTH[13:6]
0x000A23:16LENGTH[21:14]
0x000B31:24LENGTH[29:22]
0x000C
0x000D15:8DATA[15:8]
0x000E23:16DATA[23:16]
0x000F31:24DATA[31:24]
0x0010
0x001115:8DATA[15:8]
0x001223:16DATA[23:16]
0x001331:24DATA[31:24]
0x0014
0x001515:8DATA[15:8]
0x001623:16DATA[23:16]
0x001731:24DATA[31:24]
0x0018
0x001915:8DIE[3:0]REVISION[3:0]
0x001A23:16FAMILY
0x001B31:24PROCESSOR[3:0]FAMILY[4:1]
0x001C
...
0x00FF
0x0100
...
0x01FF
0x0200
...
0x0FFF
0x1000
0x100115:8ADDOFF[3:0]
0x100223:16ADDOFF[11:4]
0x100331:24ADDOFF[19:12]
ADDR
LENGTH
DATA
DCC0
DCC1
DID
Reserved
Reserved
ENTRY0
Pos.
PERRFAILBERRCRSTEXTDONE
HPEDCCD1DCCD0DBGPRESPROT
7:0ADDR[5:0]
7:0LENGTH[5:0]
7:0DATA[7:0]
7:0DATA[7:0]
7:0DATA[7:0]
7:0DEVSEL[7:0]
SERIES[5:0]
External address range:
Replicates the 0x00:0xFF address range,
Gives access to the same resources but with security restrictions when the device is protected.
This address range is the only one accessible externally (using the ARM DAP) when the device is protected.
7:0FMTEPRES
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
61
Bit
OffsetName
0x1004
0x100515:8ADDOFF[3:0]
0x100623:16ADDOFF[11:4]
0x100731:24ADDOFF[19:12]
0x1008
0x100915:8END[15:8]
0x100A23:16END[23:16]
0x100B31:24END[31:24]
0x100C
...
0x1FCB
0x1FCC
0x1FCD15:8
0x1FCE23:16
0x1FCF31:24
0x1FD0
0x1FD115:8
0x1FD223:16
0x1FD331:24
0x1FD4
...
0x1FDF
0x1FE0
0x1FE115:8
0x1FE223:16
0x1FE331:24
0x1FE4
0x1FE515:8
0x1FE623:16
0x1FE731:24
0x1FE8
0x1FE915:8
0x1FEA23:16
0x1FEB31:24
0x1FEC
0x1FED15:8
0x1FEE23:16
0x1FEF31:24
0x1FF0
0x1FF115:8
0x1FF223:16
0x1FF331:24
ENTRY1
END
Reserved
MEMTYPE
PID4
Reserved
PID0
PID1
PID2
PID3
CID0
Pos.
7:0FMTEPRES
7:0END[7:0]
7:0SMEMP
7:0FKBC[3:0]JEPCC[3:0]
7:0PARTNBL[7:0]
7:0JEPIDCL[3:0]PARTNBH[3:0]
7:0REVISION[3:0]JEPUJEPIDCH[2:0]
7:0REVAND[3:0]CUSMOD[3:0]
7:0PREAMBLEB0[7:0]
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
62
Bit
OffsetName
0x1FF4
0x1FF515:8
0x1FF623:16
0x1FF731:24
0x1FF8
0x1FF915:8
0x1FFA23:16
0x1FFB31:24
0x1FFC
0x1FFD15:8
0x1FFE23:16
0x1FFF31:24
CID1
CID2
CID3
Pos.
7:0CCLASS[3:0]PREAMBLE[3:0]
7:0PREAMBLEB2[7:0]
7:0PREAMBLEB3[7:0]
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
63
12.13 Register Description
Registers can be 8, 16 or 32 bits wide. Atomic 8-, 16- and 32-bit accesses are supported. In addition, the 8-bit quarters
and 16-bit halves of a 32-bit register and the 8-bit halves of a 16-bit register can be accessed directly.
Some registers are optionally write-protected by the Peripheral Access Controller (PAC). Write protection is denoted by
the Write-Protected property in each individual register description. Refer to “Register Access Protection” on page 51 for
details.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
64
12.13.1 Control
Name:CTRL
Offset:0x0000
Reset:0x00
Property:Write-Protected
Bit 76543210
AccessRRRWWWRW
Reset00000000
zBits 7:5 – 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. These bits will always return zero when read.
zBit 4 – CE: Chip Erase
Writing a zero to this bit has no effect.
Writing a one to this bit starts the Chip-Erase operation.
zBit 3 – MBIST: Memory Built-In Self-Test
Writing a zero to this bit has no effect.
Writing a one to this bit starts the memory BIST algorithm.
CEMBISTCRCSWRST
zBit 2 – CRC: 32-bit Cyclic Redundancy Check
Writing a zero to this bit has no effect.
Writing a one to this bit starts the cyclic redundancy check algorithm.
zBit 1 – 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. This bit will always return zero when read.
zBit 0 – SWRST: Software Reset
Writing a zero to this bit has no effect.
Writing a one to this bit resets the module.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
65
12.13.2 Status A
Name:STATUSA
Offset:0x0001
Reset:0x00
Property:Write-Protected
Bit 76543210
AccessRRRR/WR/WR/WR/WR/W
Reset00000000
zBits 7:5 – 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. These bits will always return zero when read.
zBit 4 – PERR: Protection Error
Writing a zero to this bit has no effect.
Writing a one to this bit clears the Protection Error bit.
This bit is set when a command that is not allowed in protected state is issued.
zBit 3 – FAIL: Failure
Writing a zero to this bit has no effect.
Writing a one to this bit clears the Failure bit.
This bit is set when a DSU operation failure is detected.
PERRFAILBERRCRSTEXTDONE
zBit 2 – BERR: Bus Error
Writing a zero to this bit has no effect.
Writing a one to this bit clears the Bus Error bit.
This bit is set when a bus error is detected.
zBit 1 – CRSTEXT: CPU Reset Phase Extension
Writing a zero to this bit has no effect.
Writing a one to this bit clears the CPU Reset Phase Extension bit.
This bit is set when a debug adapter Cold-Plugging is detected, which extends the CPU reset phase.
zBit 0 – DONE: Done
Writing a zero to this bit has no effect.
Writing a one to this bit clears the Done bit.
This bit is set when a DSU operation is completed.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
66
12.13.3 Status B
Name:STATUSB
Offset:0x0002
Reset:0x1X
Property:Write-Protected
Bit 76543210
AccessRRRRRRRR
Reset000100XX
zBits 7:5 – 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. These bits will always return zero when read.
zBit 4 – HPE: Hot-Plugging Enable
Writing a zero to this bit has no effect.
Writing a one to this bit has no effect.
This bit is set when Hot-Plugging is enabled.
This bit is cleared when Hot-Plugging is disabled. This is the case when the SWCLK function is changed. Only a
power-reset or a external reset can set it again.
HPEDCCD1DCCD0DBGPRESPROT
zBits 3:2 – DCCDx [x=1..0]: Debug Communication Channel x Dirty
Writing a zero to this bit has no effect.
Writing a one to this bit has no effect.
This bit is set when DCCx is written.
This bit is cleared when DCCx is read.
zBit 1 – DBGPRES: Debugger Present
Writing a zero to this bit has no effect.
Writing a one to this bit has no effect.
This bit is set when a debugger probe is detected.
This bit is never cleared.
zBit 0 – PROT: Protected
Writing a zero to this bit has no effect.
Writing a one to this bit has no effect.
This bit is set at powerup when the device is protected.
This bit is never cleared.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
67
12.13.4 Address
Name:ADDR
Offset:0x0004
Reset:0x00000000
Property:Write-Protected
Bit 3130292827262524
AccessR/WR/WR/WR/WR/WR/WR/WR/W
Reset00000000
Bit 2322212019181716
AccessR/WR/WR/WR/WR/WR/WR/WR/W
Reset00000000
Bit 15141312 1110 9 8
ADDR[29:22]
ADDR[21:14]
ADDR[13:6]
AccessR/WR/WR/WR/WR/WR/WR/WR/W
Reset00000000
Bit 76543210
ADDR[5:0]
AccessR/WR/WR/WR/WR/WR/W RR
Reset00000000
zBits 31:2 – ADDR[29:0]: Address
Initial word start address needed for memory operations.
zBits 1: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. These bits will always return zero when read.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
68
12.13.5 Length
Name:LENGTH
Offset:0x0008
Reset:0x00000000
Property:Write-Protected
Bit 3130292827262524
AccessR/WR/WR/WR/WR/WR/WR/WR/W
Reset00000000
Bit 2322212019181716
AccessR/WR/WR/WR/WR/WR/WR/WR/W
Reset00000000
Bit 15141312 1110 9 8
LENGTH[29:22]
LENGTH[21:14]
LENGTH[13:6]
AccessR/WR/WR/WR/WR/WR/WR/WR/W
Reset00000000
Bit 76543210
LENGTH[5:0]
AccessR/WR/WR/WR/WR/WR/W RR
Reset00000000
zBits 31:2 – LENGTH[29:0]: Length
Length in words needed for memory operations.
zBits 1: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. These bits will always return zero when read.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
69
12.13.6 Data
Name:DATA
Offset:0x000C
Reset:0x00000000
Property:Write-Protected
Bit 3130292827262524
AccessR/WR/WR/WR/WR/WR/WR/WR/W
Reset00000000
Bit 2322212019181716
AccessR/WR/WR/WR/WR/WR/WR/WR/W
Reset00000000
Bit 15141312 1110 9 8
DATA[31:24]
DATA[23:16]
DATA[15:8]
AccessR/WR/WR/WR/WR/WR/WR/WR/W
Reset00000000
Bit 76543210
DATA[7:0]
AccessR/WR/WR/WR/WR/WR/WR/WR/W
Reset00000000
zBits 31:0 – DATA[31:0]: Data
Memory operation initial value or result value.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
70
12.13.7 Debug Communication Channel n
Name:DCCn
Offset:0x0010+n*0x4 [n=0..1]
Reset:0x00000000
Property:-
Bit 3130292827262524
AccessR/WR/WR/WR/WR/WR/WR/WR/W
Reset00000000
Bit 2322212019181716
AccessR/WR/WR/WR/WR/WR/WR/WR/W
Reset00000000
Bit 15141312 1110 9 8
DATA[31:24]
DATA[23:16]
DATA[15:8]
AccessR/WR/WR/WR/WR/WR/WR/WR/W
Reset00000000
Bit 76543210
DATA[7:0]
AccessR/WR/WR/WR/WR/WR/WR/WR/W
Reset00000000
zBits 31:0 – DATA[31:0]: Data
Data register.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
71
12.13.8 Device Identification
The information in this register is related to the ordering code. Refer to the “Ordering Information” on page 5 for details.
Name:DID
Offset:0x0018
Reset:-
Property:Write-Protected
Bit 3130292827262524
AccessRRRRRRRR
Reset00000000
Bit 2322212019181716
PROCESSOR[3:0]FAMILY[4:1]
FAMILY
AccessRRRRRRRR
Reset00000000
Bit 15141312 1110 9 8
DIE[3:0]REVISION[3:0]
AccessRRRRRRRR
Reset00000000
Bit 76543210
DEVSEL[7:0]
AccessRRRRRRRR
Reset00000000
zBits 31:28 – PROCESSOR[3:0]: Processor
SERIES[5:0]
The value of this field defines the processor used on the device. For this device, the value of this field is 0x1, corresponding to the ARM Cortex-M0+ processor.
zBits 27:23 – FAMILY[4:0]: Product Family
The value of this field corresponds to the Product Family part of the ordering code. For this device, the value of this
field is 0x0, corresponding to the SAM D family of base line microcontrollers.
zBit 22 – 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. This bit will always return zero when read.
zBits 21:16 – SERIES[5:0]: Product Series
The value of this field corresponds to the Product Series part of the ordering code. For this device, the value of this
field is 0x01, corresponding to a product with the Cortex-M0+ processor with DMA and USB features.
zBits 15:12 – DIE[3:0]: Die Identification
Identifies the die in the family.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
72
zBits 11:8 – REVISION[3:0]: Revision
Identifies the die revision number.
zBits 7:0 – DEVSEL[7:0]: Device Select
DEVSEL is used to identify a device within a product family and product series. The value corresponds to the
Flash memory density, pin count and device variant parts of the ordering code. Refer to “Ordering Information” on
page 5 for details.
Table 12-8. Device Selection
DEVSELDeviceFlashRAMPincount
0x0SAMD21J18A256KB32KB64
0x1SAMD21J17A128KB16KB64
0x2SAMD21J16A64KB8KB64
0x3SAMD21J15A32KB4KB64
0x4Reserved
0x5SAMD21G18A256KB32KB48
0x6SAMD21G17A128KB16KB48
0x7SAMD21G16A64KB8KB48
0x8SAMD21G15A32KB4KB48
0x0 - 0xB0x9Reserved
0xASAMD21E18A256KB32KB32
0xBSAMD21E17A128KB16KB32
0xCSAMD21E16AL64KB8KB32
0xDSAMD21E15AL32KB4KB32
0xE - 0xFFReserved
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
73
12.13.9 Coresight ROM Table Entry n
Name:ENTRYn
Offset:0x1000+n*0x4 [n=0..1]
Reset:0xXXXXX00X
Property:Write-Protected
Bit 3130292827262524
AccessRRRRRRRR
ResetXXXXXXXX
Bit 2322212019181716
AccessRRRRRRRR
ResetXXXXXXXX
Bit 15141312 1110 9 8
ADDOFF[19:12]
ADDOFF[11:4]
ADDOFF[3:0]
AccessRRRRRRRR
ResetXXXX0000
Bit 76543210
FMTEPRES
AccessRRRRRRRR
Reset0000001X
zBits 31:12 – ADDOFF[19:0]: Address Offset
The base address of the component, relative to the base address of this ROM table.
zBits 11:2 – 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. These bits will always return zero when read.
zBit 1 – FMT: Format
Always read as one, indicates a 32-bit ROM table.
zBit 0 – EPRES: Entry Present
This bit indicates whether an entry is present at this location in the ROM table.
This bit is set at powerup if the device is not protected indicating that the entry is not present.
This bit is cleared at powerup if the device is not protected indicating that the entry is present.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
74
12.13.10Coresight ROM Table End
Name:END
Offset:0x1008
Reset:0x00000000
Property:-
Bit 3130292827262524
AccessRRRRRRRR
Reset00000000
Bit 2322212019181716
AccessRRRRRRRR
Reset00000000
Bit 15141312 1110 9 8
END[31:24]
END[23:16]
END[15:8]
AccessRRRRRRRR
Reset00000000
Bit 76543210
END[7:0]
AccessRRRRRRRR
Reset00000000
zBits 31:0 – END[31:0]: End Marker
Indicates the end of the CoreSight ROM table entries.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
75
12.13.11Coresight ROM Table Memory Type
Name:MEMTYPE
Offset:0x1FCC
Reset:0x0000000X
Property:-
Bit 3130292827262524
AccessRRRRRRRR
Reset00000000
Bit 2322212019181716
AccessRRRRRRRR
Reset00000000
Bit 15141312 1110 9 8
AccessRRRRRRRR
Reset00000000
Bit 76543210
SMEMP
AccessRRRRRRRR
Reset0000000X
zBits 31:1 – 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. These bits will always return zero when read.
zBit 0 – SMEMP: System Memory Present
This bit indicates whether system memory is present on the bus that connects to the ROM table.
This bit is set at powerup if the device is not protected indicating that the system memory is accessible from a
debug adapter.
This bit is cleared at powerup if the device is protected indicating that the system memory is not accessible from a
debug adapter.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
76
12.13.12Peripheral Identification 4
Name:PID4
Offset:0x1FD0
Reset:0x00000000
Property:-
Bit 3130292827262524
AccessRRRRRRRR
Reset00000000
Bit 2322212019181716
AccessRRRRRRRR
Reset00000000
Bit 15141312 1110 9 8
AccessRRRRRRRR
Reset00000000
Bit 76543210
FKBC[3:0]JEPCC[3:0]
AccessRRRRRRRR
Reset00000000
zBits 31:8 – 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. These bits will always return zero when read.
zBits 7:4 – FKBC[3:0]: 4KB Count
These bits will always return zero when read, indicating that this debug component occupies one 4KB block.
zBits 3:0 – JEPCC[3:0]: JEP-106 Continuation Code
These bits will always return zero when read, indicating a Atmel device.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
77
12.13.13Peripheral Identification 0
Name:PID0
Offset:0x1FE0
Reset:0x000000D0
Property:-
Bit 3130292827262524
AccessRRRRRRRR
Reset00000000
Bit 2322212019181716
AccessRRRRRRRR
Reset00000000
Bit 15141312 1110 9 8
AccessRRRRRRRR
Reset00000000
Bit 76543210
PARTNBL[7:0]
AccessRRRRRRRR
Reset11010000
zBits 31:8 – 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. These bits will always return zero when read.
zBits 7:0 – PARTNBL[7:0]: Part Number Low
These bits will always return 0xD0 when read, indicating that this device implements a DSU module instance.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
78
12.13.14Peripheral Identification 1
Name:PID1
Offset:0x1FE4
Reset:0x000000FC
Property:-
Bit 3130292827262524
AccessRRRRRRRR
Reset00000000
Bit 2322212019181716
AccessRRRRRRRR
Reset00000000
Bit 15141312 1110 9 8
AccessRRRRRRRR
Reset00000000
Bit 76543210
JEPIDCL[3:0]PARTNBH[3:0]
AccessRRRRRRRR
Reset11111100
zBits 31:8 – 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. These bits will always return zero when read.
zBits 7:4 – JEPIDCL[3:0]: Low part of the JEP-106 Identity Code
These bits will always return 0xF when read, indicating a Atmel device (Atmel JEP-106 identity code is 0x1F).
zBits 3:0 – PARTNBH[3:0]: Part Number High
These bits will always return 0xC when read, indicating that this device implements a DSU module instance.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
79
12.13.15Peripheral Identification 2
Name:PID2
Offset:0x1FE8
Reset:0x00000009
Property:-
Bit 3130292827262524
AccessRRRRRRRR
Reset00000000
Bit 2322212019181716
AccessRRRRRRRR
Reset00000000
Bit 15141312 1110 9 8
AccessRRRRRRRR
Reset00000000
Bit 76543210
REVISION[3:0]JEPUJEPIDCH[2:0]
AccessRRRRRRRR
Reset00001001
zBits 31:8 – 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. These bits will always return zero when read.
zBits 7:4 – REVISION[3:0]: Revision Number
Revision of the peripheral. Starts at 0x0 and increments by one at both major and minor revisions.
zBit 3 – JEPU: JEP-106 Identity Code is used
This bit will always return one when read, indicating that JEP-106 code is used.
zBits 2:0 – JEPIDCH[2:0]: JEP-106 Identity Code High
These bits will always return 0x1 when read, indicating an Atmel device (Atmel JEP-106 identity code is 0x1F).
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
80
12.13.16Peripheral Identification 3
Name:PID3
Offset:0x1FEC
Reset:0x00000000
Property:-
Bit 3130292827262524
AccessRRRRRRRR
Reset00000000
Bit 2322212019181716
AccessRRRRRRRR
Reset00000000
Bit 15141312 1110 9 8
AccessRRRRRRRR
Reset00000000
Bit 76543210
REVAND[3:0]CUSMOD[3:0]
AccessRRRRRRRR
Reset00000000
zBits 31:8 – 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. These bits will always return zero when read.
zBits 7:4 – REVAND[3:0]: Revision Number
These bits will always return 0x0 when read.
zBits 3:0 – CUSMOD[3:0]: ARM CUSMOD
These bits will always return 0x0 when read.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
81
12.13.17Component Identification 0
Name:CID0
Offset:0x1FF0
Reset:0x0000000D
Property:-
Bit 3130292827262524
AccessRRRRRRRR
Reset00000000
Bit 2322212019181716
AccessRRRRRRRR
Reset00000000
Bit 15141312 1110 9 8
AccessRRRRRRRR
Reset00000000
Bit 76543210
PREAMBLEB0[7:0]
AccessRRRRRRRR
Reset00001101
zBits 31:8 – 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. These bits will always return zero when read.
zBits 7:0 – PREAMBLEB0[7:0]: Preamble Byte 0
These bits will always return 0xD when read.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
82
12.13.18Component Identification 1
Name:CID1
Offset:0x1FF4
Reset:0x00000010
Property:-
Bit 3130292827262524
AccessRRRRRRRR
Reset00000000
Bit 2322212019181716
AccessRRRRRRRR
Reset00000000
Bit 15141312 1110 9 8
AccessRRRRRRRR
Reset00000000
Bit 76543210
CCLASS[3:0]PREAMBLE[3:0]
AccessRRRRRRRR
Reset00010000
zBits 31:8 – 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. These bits will always return zero when read.
zBits 7:4 – CCLASS[3:0]: Component Class
These bits will always return 0x1 when read indicating that this ARM CoreSight component is ROM table (refer to
the ARM Debug Interface v5 Architecture Specification at http://www.arm.com).
zBits 3:0 – PREAMBLE[3:0]: Preamble
These bits will always return 0x0 when read.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
83
12.13.19Component Identification 2
Name:CID2
Offset:0x1FF8
Reset:0x00000005
Property:-
Bit 3130292827262524
AccessRRRRRRRR
Reset00000000
Bit 2322212019181716
AccessRRRRRRRR
Reset00000000
Bit 15141312 1110 9 8
AccessRRRRRRRR
Reset00000000
Bit 76543210
PREAMBLEB2[7:0]
AccessRRRRRRRR
Reset00000101
zBits 31:8 – 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. These bits will always return zero when read.
zBits 7:0 – PREAMBLEB2[7:0]: Preamble Byte 2
These bits will always return 0x05 when read.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
84
12.13.20Component Identification 3
Name:CID3
Offset:0x1FFC
Reset:0x000000B1
Property:-
Bit 3130292827262524
AccessRRRRRRRR
Reset00000000
Bit 2322212019181716
AccessRRRRRRRR
Reset00000000
Bit 15141312 1110 9 8
AccessRRRRRRRR
Reset00000000
Bit 76543210
PREAMBLEB3[7:0]
AccessRRRRRRRR
Reset10110001
zBits 31:8 – 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. These bits will always return zero when read.
zBits 7:0 – PREAMBLEB3[7:0]: Preamble Byte 3
These bits will always return 0xB1 when read.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
85
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
86
13.Clock System
0
x
0
z
0
A
s
_
C
96M
This chapter only aims to summarize the clock distribution and terminology in the SAM D21 device. It will not explain
every detail of its configuration. For in-depth documentation, see the referenced module chapters.
13.1Clock Distribution
Figure 13-1. Clock distribution
YSCTRL
OS
DPLL
2K
M
LK
GCLK Generator
LK Generator 1
LK Generator
GCLK Multiplexer
(DFLL48M Reference)
LK Multiplexer 1
GCLK Multiplexer y
Peripheral
eneric
locks
Peripheral
Synchronous Clock
ontroller
HB/APB System Clock
The clock system on the SAM D21 consists of:
zClock sources, controlled by SYSCTRL
zA Clock source is the base clock signal used in the system. Example clock sources are the internal 8MHz
oscillator (OSC8M), External crystal oscillator (XOSC) and the Digital frequency locked loop (DFLL48M).
zGeneric Clock Controller (GCLK) which controls the clock distribution system, made up of:
zGeneric Clock generators: A programmable prescaler, that can use any of the system clock sources as its
source clock. The Generic Clock Generator 0, also called GCLK_MAIN, is the clock feeding the Power
Manager used to generate synchronous clocks.
zGeneric Clocks: Typically the clock input of a peripheral on the system. The generic clocks, through the
Generic Clock Multiplexer, can use any of the Generic Clock generators as its clock source. Multiple
instances of a peripheral will typically have a separate generic clock for each instance. The DFLL48M clock
input (when multiplying another clock source) is generic clock 0.
zPower Manager (PM)
zThe PM controls synchronous clocks on the system. This includes the CPU, bus clocks (APB, AHB) as well
as the synchronous (to the CPU) user interfaces of the peripherals. It contains clock masks that can turn
on/off the user interface of a peripheral as well as prescalers for the CPU and bus clocks.
Figure 13-2 shows an example where SERCOM0 is clocked by the DFLL48M in open loop mode. The DFLL48M is
enabled, the Generic Clock Generator 1 uses the DFLL48M as its clock source, and the generic clock 20, also called
GCLK_SERCOM0_CORE, that is connected to SERCOM0 uses generator 1 as its source. The SERCOM0 interface,
clocked by CLK_SERCOM0_APB, has been unmasked in the APBC Mask register in the PM.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
87
Figure 13-2. Example of SERCOM clock
SYSCTRL
DFLL48M
1
20
SERCOM 0
Synchronous Clock
Controller
PM
CLK_SERCOM0_APB
GCLK_SERCOM0_CORE
GCLK
eneric Clock
enerator
eneric Clock
Multiplexer
13.2Synchronous and Asynchronous Clocks
As the CPU and the peripherals can be clocked from different clock sources, possibly with widely different clock speeds,
some peripheral accesses by the CPU needs to be synchronized between the different clock domains. In these cases the
peripheral includes a SYNCBUSY status flag that can be used to check if a sync operation is in progress. As the nature
of the synchronization might vary between different peripherals, detailed description for each peripheral can be found in
the sub-chapter “synchronization” for each peripheral where this is necessary.
In the datasheet references to synchronous clocks are referring to the CPU and bus clocks, while asynchronous clocks
are clock generated by generic clocks.
13.3Register Synchronization
There are two different register synchronization schemes implemented on this device: some modules use a common
synchronizer register synchronization scheme, while other modules use a distributed synchronizer register
synchronization scheme.
The modules using a common synchronizer register synchronization scheme are: GCLK, WDT, RTC, EIC, TC, ADC, AC,
DAC.
The modules using a distributed synchronizer register synchronization scheme are: SERCOM USART, SERCOM SPI,
SERCOM I2C, I2S, TCC, USB.
13.3.1 Common Synchronizer Register Synchronization
13.3.1.1 Overview
All peripherals are composed of one digital bus interface, which is connected to the APB or AHB bus and clocked using a
corresponding synchronous clock, and one core clock, which is clocked using a generic clock. Access between these
clock domains must be synchronized. As this mechanism is implemented in hardware the synchronization process takes
place even if the different clocks domains are clocked from the same source and on the same frequency. All registers in
the bus interface are accessible without synchronization. All core registers in the generic clock domain must be
synchronized when written. Some core registers must be synchronized when read. Registers that need synchronization
has this denoted in each individual register description. Two properties are used: write-synchronization and readsynchronization.
A common synchronizer is used for all registers in one peripheral, as shown in Figure 13-3. Therefore, only one register
per peripheral can be synchronized at a time.
Atmel | SMART SAM D21 [DATASHEET]
88
Atmel-42181G–SAM-D21_Datasheet–09/2015
Figure 13-3. Synchronization
Non Synced reg
INTFLAG
STATUS
READREQ
Write-Synced reg
Write-Synced reg
R/W-Synced reg
Synchronizer
Sync
SYNCBUSY
Synchronous Domain
(CLK_APB)
Asynchronous Domain
(generic clock)
Peripheral bus
13.3.1.2 Write-Synchronization
The write-synchronization is triggered by a write to any generic clock core register. The Synchronization Busy bit in the
Status register (STATUS.SYNCBUSY) will be set when the write-synchronization starts and cleared when the writesynchronization is complete. Refer to “Synchronization Delay” on page 91 for details on the synchronization delay.
When the write-synchronization is ongoing (STATUS.SYNCBUSY is one), any of the following actions will cause the
peripheral bus to stall until the synchronization is complete:
zWriting a generic clock core register
zReading a read-synchronized core register
zReading the register that is being written (and thus triggered the synchronization)
Core registers without read-synchronization will remain static once they have been written and synchronized, and can be
read while the synchronization is ongoing without causing the peripheral bus to stall. APB registers can also be read
while the synchronization is ongoing without causing the peripheral bus to stall.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
89
13.3.1.3 Read-Synchronization
Reading a read-synchronized core register will cause the peripheral bus to stall immediately until the readsynchronization is complete. STATUS.SYNCBUSY will not be set. Refer to “Synchronization Delay” on page 91 for
details on the synchronization delay. Note that reading a read-synchronized core register while STATUS.SYNCBUSY is
one will cause the peripheral bus to stall twice; first because of the ongoing synchronization, and then again because
reading a read-synchronized core register will cause the peripheral bus to stall immediately.
13.3.1.4 Completion of synchronization
The user can either poll STATUS.SYNCBUSY or use the Synchronisation Ready interrupt (if available) to check when
the synchronization is complete. It is also possible to perform the next read/write operation and wait, as this next
operation will be started once the previous write/read operation is synchronized and/or complete.
13.3.1.5 Read Request
The read request functionality is only available to peripherals that have the Read Request register (READREQ)
implemented. Refer to the register description of individual peripheral chapters for details.
To avoid forcing the peripheral bus to stall when reading read-synchronized core registers, the read request mechanism
can be used.
Basic Read Request
Writing a one to the Read Request bit in the Read Request register (READREQ.RREQ) will request readsynchronization of the register specified in the Address bits in READREQ (READREQ.ADDR) and set
STATUS.SYNCBUSY. When read-synchronization is complete, STATUS.SYNCBUSY is cleared. The readsynchronized value is then available for reading without delay until READREQ.RREQ is written to one again.
The address to use is the offset to the peripheral's base address of the register that should be synchronized.
Continuous Read Request
Writing a one to the Read Continuously bit in READREQ (READREQ.RCONT) will force continuous readsynchronization of the register specified in READREQ.ADDR. The latest value is always available for reading without
stalling the bus, as the synchronization mechanism is continuously synchronizing the given value.
SYNCBUSY is set for the first synchronization, but not for the subsequent synchronizations. If another synchronization is
attempted, i.e. by executing a write-operation of a write-synchronized register, the read request will be stopped, and will
have to be manually restarted.
Note that continuous read-synchronization is paused in sleep modes where the generic clock is not running. This means
that a new read request is required if the value is needed immediately after exiting sleep.
13.3.1.6 Enable Write-Synchronization
Writing to the Enable bit in the Control register (CTRL.ENABLE) will also trigger write-synchronization and set
STATUS.SYNCBUSY. CTRL.ENABLE will read its new value immediately after being written. The Synchronisation
Ready interrupt (if available) cannot be used for Enable write-synchronization.
When the enable write-synchronization is ongoing (STATUS.SYNCBUSY is one), attempt to do any of the following will
cause the peripheral bus to stall until the enable synchronization is complete:
zWriting a core register
zWriting an APB register
zReading a read-synchronized core register
APB registers can be read while the enable write-synchronization is ongoing without causing the peripheral bus to stall.
13.3.1.7 Software Reset Write-Synchronization
Writing a one to the Software Reset bit in CTRL (CTRL.SWRST) will also trigger write-synchronization and set
STATUS.SYNCBUSY. When writing a one to the CTRL.SWRST bit it will immediately read as one. CTRL.SWRST and
STATUS.SYNCBUSY will be cleared by hardware when the peripheral has been reset. Writing a zero to the
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
90
CTRL.SWRST bit has no effect. The Synchronisation Ready interrupt (if available) cannot be used for Software Reset
5 P
GCLK
⋅2 P
APB
⋅+D6 P
GCLK
⋅3 P
APB
⋅+<<
P
GCLK
P
APB
2 P
APB
⋅
write-synchronization.
When the software reset is in progress (STATUS.SYNCBUSY and CTRL.SWRST are one), attempt to do any of the
following will cause the peripheral bus to stall until the Software Reset synchronization and the reset is complete:
zWriting a core register
zWriting an APB register
zReading a read-synchronized register
APB registers can be read while the software reset is being write-synchronized without causing the peripheral bus to
stall.
13.3.1.8 Synchronization Delay
The synchronization will delay the write or read access duration by a delay D, given by the equation:
Where is the period of the generic clock and is the period of the peripheral bus clock. A normal peripheral
bus register access duration is .
All peripherals are composed of one digital bus interface, which is connected to the APB or AHB bus and clocked using a
corresponding synchronous clock, and one core clock, which is clocked using a generic clock. Access between these
clock domains must be synchronized. As this mechanism is implemented in hardware the synchronization process takes
place even if the different clocks domains are clocked from the same source and on the same frequency. All registers in
the bus interface are accessible without synchronization. All core registers in the generic clock domain must be
synchronized when written. Some core registers must be synchronized when read. Registers that need synchronization
has this denoted in each individual register description.
13.3.2.2 General Write synchronization
Inside the same module, each core register, denoted by the Write-Synchronized property, use its own synchronization
mechanism so that writing to different core registers can be done without waiting for the end of synchronization of
previous core register access.
To write again to the same core register in the same module, user must wait for the end of synchronization or the write
will be discarded.
For each core register, that can be written, a synchronization status bit is associated
Example:
REGA, REGB are 8-bit core registers. REGC is 16-bit core register.
OffsetRegister
0x00REGA
0x01REGB
0x02
0x03
REGC
Since synchronization is per register, user can write REGA (8-bit access) then immediately write REGB (8-bit access)
without error.
User can write REGC (16-bit access) without affecting REGA or REGB. But if user writes REGC in two consecutives 8-bit
accesses, second write will be discarded and generate an error.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
91
When user makes a 32-bit access to offset 0x00, all registers are written but REGA, REGB, REGC can be updated at a
5 P
GCLK
⋅2 P
APB
⋅+D6 P
GCLK
⋅3 P
APB
⋅+<<
P
GCLK
P
APB
2 P
APB
⋅
different time because of independent write synchronization
13.3.2.3 General read synchronization
Before any read of a core register, the user must check that the related bit in SYNCBUSY register is cleared.
Read access to core register is always immediate but the return value is reliable only if a synchonization of this core
register is not going.
13.3.2.4 Completion of synchronization
The user can either poll SYNCBUSY register or use the Synchronisation Ready interrupt (if available) to check when the
synchronization is complete.
13.3.2.5 Enable Write-Synchronization
Writing to the Enable bit in the Control register (CTRL.ENABLE) will also trigger write-synchronization and set
SYNCBUSY.ENABLE. CTRL.ENABLE will read its new value immediately after being written. The Synchronisation
Ready interrupt (if available) cannot be used for Enable write-synchronization.
13.3.2.6 Software Reset Write-Synchronization
Writing a one to the Software Reset bit in CTRL (CTRL.SWRST) will also trigger write-synchronization and set
SYNCBUSY.SWRST. When writing a one to the CTRL.SWRST bit it will immediately read as one. CTRL.SWRST and
SYNCBUSY.SWRST will be cleared by hardware when the peripheral has been reset. Writing a zero to the
CTRL.SWRST bit has no effect. The Synchronisation Ready interrupt (if available) cannot be used for Software Reset
write-synchronization.
13.3.2.7 Synchronization Delay
The synchronization will delay the write or read access duration by a delay D, given by the equation:
Where is the period of the generic clock and is the period of the peripheral bus clock. A normal peripheral
bus register access duration is .
13.4Enabling a Peripheral
To enable a peripheral clocked by a generic clock, the following parts of the system needs to be configured:
zA running clock source.
zA clock from the Generic Clock Generator must be configured to use one of the running clock sources, and the
generator must be enabled.
zThe generic clock, through the Generic Clock Multiplexer, that connects to the peripheral needs to be configured
with a running clock from the Generic Clock Generator, and the generic clock must be enabled.
zThe user interface of the peripheral needs to be unmasked in the PM. If this is not done the peripheral registers will
read as all 0’s and any writes to the peripheral will be discarded.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
92
13.5On-demand, Clock Requests
DFLL48M
Clock request
Clock request
iph
l
Clock request
ENABLE
RUNSTDBY
ONDEMAND
CLKEN
RUNSTDBY
ENABLE
RUNSTDBY
GENEN
Figure 13-4. Clock request routing
eneric Clock
enerator
eneric Clock
ultiplexer
er
era
All the clock sources in the system can be run in an on-demand mode, where the clock source is in a stopped state when
no peripherals are requesting the clock source. Clock requests propagate from the peripheral, via the GCLK, to the clock
source. If one or more peripheral is using a clock source, the clock source will be started/kept running. As soon as the
clock source is no longer needed and no peripheral have an active request the clock source will be stopped until
requested again. For the clock request to reach the clock source, the peripheral, the generic clock and the clock from the
Generic Clock Generator in-between must be enabled. The time taken from a clock request being asserted to the clock
source being ready is dependent on the clock source startup time, clock source frequency as well as the divider used in
the Generic Clock Generator. The total startup time from a clock request to the clock is available for the peripheral is:
Delay_start_max = Clock source startup time + 2 * clock source periods + 2 * divided clock source periods
Delay_start_min = Clock source startup time + 1 * clock source period + 1 * divided clock source period
The delay for shutting down the clock source when there is no longer an active request is:
Delay_stop_min = 1 * divided clock source period + 1 * clock source period
Delay_stop_max = 2 * divided clock source periods + 2 * clock source periods
The On-Demand principle can be disabled individually for each clock source by clearing the ONDEMAND bit located in
each clock source controller. The clock is always running whatever is the clock request. This has the effect to remove the
clock source startup time at the cost of the power consumption.
In standby mode, the clock request mechanism is still working if the modules are configured to run in standby mode
(RUNSTDBY bit).
13.6Power Consumption vs Speed
Due to the nature of the asynchronous clocking of the peripherals there are some considerations that needs to be taken
if either targeting a low-power or a fast-acting system. If clocking a peripheral with a very low clock, the active power
consumption of the peripheral will be lower. At the same time the synchronization to the synchronous (CPU) clock
domain is dependent on the peripheral clock speed, and will be longer with a slower peripheral clock; giving lower
response time and more time waiting for the synchronization to complete.
13.7Clocks after Reset
On any reset the synchronous clocks start to their initial state:
zOSC8M is enabled and divided by 8
zGCLK_MAIN uses OSC8M as source
zCPU and BUS clocks are undivided
On a power reset the GCLK starts to their initial state:
zAll generic clock generators disabled except:
zthe generator 0 (GCLK_MAIN) using OSC8M as source, with no division
zthe generator 2 using OSCULP32K as source, with no division
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
93
zAll generic clocks disabled except:
zthe WDT generic clock using the generator 2 as source
On a user reset the GCLK starts to their initial state, except for:
zgeneric clocks that are write-locked (WRTLOCK is written to one prior to reset or the WDT generic clock if the
WDT Always-On at power on bit set in the NVM User Row)
zThe generic clock dedicated to the RTC if the RTC generic clock is enabled
On any reset the clock sources are reset to their initial state except the 32KHz clock sources which are reset only by a
power reset.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
94
14.GCLK – Generic Clock Controller
O
r
K
&
er
k
e
r
S
R
N
OSC
L
14.1Overview
Several peripherals may require specific clock frequencies to operate correctly. The Generic Clock Controller consists of
number of generic clock generators and generic clock multiplexers that can provide a wide range of clock frequencies.
The generic clock generators can be set to use different external and internal clock sources. The selected clock can be
divided down in the generic clock generator. The outputs from the generic clock generators are used as clock sources for
the generic clock multiplexers, which select one of the sources to generate a generic clock (GCLK_PERIPHERAL), as
shown in Figure 14-2. The number of generic clocks, m, depends on how many peripherals the device has.
14.2Features
z Provides generic clocks
z Wide frequency range
z Clock source for the generator can be changed on the fly
14.3Block Diagram
The Generic Clock Controller can be seen in the clocking diagram, which is shown in Figure 14-1 .
Figure 14-1. Device Clocking Diagram
ENERIC CLOCK CONTROLLE
YSCTRL
X
ULP32K
32K
32
FLL48M
FDPLL96M
LK_I
eneric Clock Generato
lock
ivider
k
The Generic Clock Controller block diagram is shown in Figure 14-2.
Note:1.If the GENCTRL.SRC=GCLKIN the GCLK_IO is set as an input.
LK_MAIN
LK_IO[0
(I/O output
Clock
at
LK_IO[1
I/O output
Clock
at
GCLK_IO[n
I/O output
lock
at
14.4Signal Description
Table 14-1. Signal Description
Signal NameTypeDescription
GCLK_IO[7:0]Digital I/O
Refer to “I/O Multiplexing and Considerations” on page 21 for details on the pin mapping for this peripheral. One signal
can be mapped on several pins.
14.5Product Dependencies
In order to use this peripheral, other parts of the system must be configured correctly, as described below.
14.5.1 I/O Lines
Using the Generic Clock Controller’s I/O lines requires the I/O pins to be configured. Refer to “PORT” on page 379 for
details.
14.5.2 Power Management
The Generic Clock Controller can operate in all sleep modes, if required. Refer to Table 15-4 for details on the different
sleep modes.
Source clock when input
Generic clock when output
14.5.3 Clocks
The Generic Clock Controller bus clock (CLK_GCLK_APB) can be enabled and disabled in the Power Manager, and the
default state of CLK_GCLK_APB can be found in the Peripheral Clock Masking section in APBAMASK.
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
96
14.5.4 DMA
Not applicable.
14.5.5 Interrupts
Not applicable.
14.5.6 Events
Not applicable.
14.5.7 Debug Operation
Not applicable.
14.5.8 Register Access Protection
All registers with write-access are optionally write-protected by the Peripheral Access Controller (PAC).
Write-protection is denoted by the Write-Protection property in the register description.
When the CPU is halted in debug mode or the CPU reset is extended, all write-protection is automatically disabled.
Write-protection does not apply for accesses through an external debugger. Refer to “PAC – Peripheral Access
Controller” on page 41 for details.
14.5.9 Analog Connections
Not applicable.
14.6Functional Description
14.6.1 Principle of Operation
The GCLK module is comprised of eight generic clock generators sourcing m generic clock multiplexers.
A clock source selected as input to one of the generic clock generators can be used directly, or it can be prescaled in the
generic clock generator before the generator output is used as input to one or more of the generic clock multiplexers.
A generic clock multiplexer provides a generic clock to a peripheral (GCLK_PERIPHERAL). A generic clock can act as
the clock to one or several of peripherals.
14.6.2 Basic Operation
14.6.2.1 Initialization
Before a generic clock is enabled, the clock source of its generic clock generator should be enabled. The generic clock
must be configured as outlined by the following steps:
1.The generic clock generator division factor must be set by performing a single 32-bit write to the Generic Clock
Generator Division register (GENDIV):
zThe generic clock generator that will be selected as the source of the generic clock must be written to the ID
bit group (GENDIV.ID).
zThe division factor must be written to the DIV bit group (GENDIV.DIV)
Refer to GENDIV register for details.
2.The generic clock generator must be enabled by performing a single 32-bit write to the Generic Clock Generator
Control register (GENCTRL):
zThe generic clock generator that will be selected as the source of the generic clock must be written to the ID
bit group (GENCTRL.ID)
zThe generic clock generator must be enabled by writing a one to the GENEN bit (GENCTRL.GENEN)
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
97
Refer to GENCTRL register for details.
R
k
e
]
s
L
V
C
C
3.The generic clock must be configured by performing a single 16-bit write to the Generic Clock Control register
(CLKCTRL):
zThe generic clock that will be configured must be written to the ID bit group (CLKCTRL.ID)
zThe generic clock generator used as the source of the generic clock must be written to the GEN bit group
(CLKCTRL.GEN)
Refer to CLKCTRL register for details.
14.6.2.2 Enabling, Disabling and Resetting
The GCLK module has no enable/disable bit to enable or disable the whole module.
The GCLK is reset by writing a one to the Software Reset bit in the Control register (CTRL.SWRST). All registers in the
GCLK will be reset to their initial state except for generic clocks and associated generators that have their Write Lock bit
written to one. Refer to “Configuration Lock” on page 100 for details.
14.6.2.3 Generic Clock Generator
Each generic clock generator (GCLKGEN) can be set to run from one of eight different clock sources except
GCLKGEN[1] which can be set to run from one of seven sources. GCLKGEN[1] can act as source to the other generic
clock generators but can not act as source to itself.
Each generic clock generator GCLKGEN[x] can be connected to one specific GCLK_IO[x] pin. The GCLK_IO[x] can be
set to act as source to GCLKGEN[x] or GCLK_IO[x] can be set up to output the clock generated by GCLKGEN[x].
The selected source (GCLKGENSRC see Figure 14-3) can optionally be divided. Each generic clock generator can be
independently enabled and disabled.
Each GCLKGEN clock can then be used as a clock source for the generic clock multiplexers. Each generic clock is
allocated to one or several peripherals.
GCLKGEN[0], is used as GCLK_MAIN for the synchronous clock controller inside the Power Manager.
Refer to “PM – Power Manager” on page 117 for details on the synchronous clock generation.
Figure 14-3. Generic Clock Generator
lock Source
LK_IO[x]
ENCTRL.SR
14.6.2.4 Enabling a Generic Clock Generator
A generic clock generator is enabled by writing a one to the Generic Clock Generator Enable bit in the Generic Clock
Generator Control register (GENCTRL.GENEN).
14.6.2.5 Disabling a Generic Clock Generator
A generic clock generator is disabled by writing a zero to GENCTRL.GENEN. When GENCTRL.GENEN is read as zero,
the GCLKGEN clock is disabled and clock gated.
LKGENSR
IVIDE
GENCTRL.DIVSE
ENDIV.DI
loc
at
ENCTRL.GENEN
LKGEN[x
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
98
14.6.2.6 Selecting a Clock Source for the Generic Clock Generator
k
e
]
[n]
Each generic clock generator can individually select a clock source by writing to the Source Select bit group in
GENCTRL (GENCTRL.SRC). Changing from one clock source, A, to another clock source, B, can be done on the fly. If
clock source B is not ready, the generic clock generator will continue running with clock source A. As soon as clock
source B is ready, however, the generic clock generator will switch to it. During the switching, the generic clock generator
holds clock requests to clock sources A and B and then releases the clock source A request when the switch is done.
The available clock sources are device dependent (usually the crystal oscillators, RC oscillators, PLL and DFLL clocks).
GCLKGEN[1] can be used as a common source for all the generic clock generators except generic clock generator 1.
14.6.2.7 Changing Clock Frequency
The selected generic clock generator source, GENCLKSRC can optionally be divided by writing a division factor
in the Division Factor bit group in the Generic Clock Generator Division register (GENDIV.DIV). Depending on the value
of the Divide Selection bit in GENCTRL (GENCTRL.DIVSEL), it can be interpreted in two ways by the integer divider.
Note that the number of DIV bits for each generic clock generator is device dependent.
Refer to Table 14-11 for details.
14.6.2.8 Duty Cycle
When dividing a clock with an odd division factor, the duty-cycle will not be 50/50. Writing a one to the Improve Duty
Cycle bit in GENCTRL (GENCTRL.IDC) will result in a 50/50 duty cycle.
14.6.2.9 Generic Clock Output on I/O Pins
Each Generic Clock Generator's output can be directed to a GCLK_IO pin. If the Output Enable bit in GENCTRL
(GENCTRL.OE) is one and the generic clock generator is enabled (GENCTRL.GENEN is one), the generic clock
generator requests its clock source and the GCLKGEN clock is output to a GCLK_IO pin. If GENCTRL.OE is zero,
GCLK_IO is set according to the Output Off Value bit. If the Output Off Value bit in GENCTRL (GENCTRL.OOV) is zero,
the output clock will be low when generic clock generator is turned off. If GENCTRL.OOV is one, the output clock will be
high when generic clock generator is turned off.
In standby mode, if the clock is output (GENCTRL.OE is one), the clock on the GCLK_IO pin is frozen to the OOV value
if the Run In Standby bit in GENCTRL (GENCTRL.RUNSTDBY) is zero. If GENCTRL.RUNSTDBY is one, the GCLKGEN
clock is kept running and output to GCLK_IO.
14.6.3 Generic Clock
Figure 14-4. Generic Clock Multiplexer
14.6.3.1 Enabling a Generic Clock
Before a generic clock is enabled, one of the generic clock generators must be selected as the source for the generic
clock by writing to CLKCTRL.GEN. The clock source selection is individually set for each generic clock.
GCLKGEN[0
LKGEN[1]
LKGEN[2]
GCLKGEN
LKCTRL.GEN
loc
at
LKCTRL.CLKEN
GCLK_PERIPHERAL
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
99
When a generic clock generator has been selected, the generic clock is enabled by writing a one to the Clock Enable bit
L
L
i
j
L
]
L
in CLKCTRL (CLKCTRL.CLKEN). The CLKCTRL.CLKEN bit must be synchronized to the generic clock domain.
CLKCTRL.CLKEN will continue to read as its previous state until the synchronization is complete.
14.6.3.2 Disabling a Generic Clock
A generic clock is disabled by writing a zero to CLKCTRL.CLKEN. The SYNCBUSY bit will be cleared when this writesynchronization is complete. CLKCTRL.CLKEN will continue to read as its previous state until the synchronization is
complete. When the generic clock is disabled, the generic clock is clock gated.
14.6.3.3 Selecting a Clock Source for the Generic Clock
When changing a generic clock source by writing to CLKCTRL.GEN, the generic clock must be disabled before being reenabled with the new clock source setting. This prevents glitches during the transition:
1.Write a zero to CLKCTRL.CLKEN
2.Wait until CLKCTRL.CLKEN reads as zero
3.Change the source of the generic clock by writing CLKCTRL.GEN
4.Re-enable the generic clock by writing a one to CLKCTRL.CLKEN
14.6.3.4 Configuration Lock
The generic clock configuration is locked for further write accesses by writing the Write Lock bit (WRTLOCK) in the
CLKCTRL register. All writes to the CLKCTRL register will be ignored. It can only be unlocked by a power reset.
The generic clock generator sources of a locked generic clock are also locked. The corresponding GENCTRL and
GENDIV are locked, and can be unlocked only by a power reset.
There is one exception concerning the GCLKGEN[0]. As it is used as GCLK_MAIN, it can not be locked. It is reset by any
reset to startup with a known configuration.
The SWRST can not unlock the registers.
14.6.4 Additional Features
14.6.4.1 Indirect Access
The Generic Clock Generator Control and Division registers (GENCTRL and GENDIV) and the Generic Clock Control
register (CLKCTRL) are indirectly addressed as shown in Figure 14-5.
Figure 14-5. GCLK Indirect Access
ser Interface
GENCTR
ENDIV
LKCTR
Writing these registers is done by setting the corresponding ID bit group.
To read a register, the user must write the ID of the channel, i, in the corresponding register. The value of the register for
the corresponding ID is available in the user interface by a read access.
ENCTRL.ID=
ENDIV.ID=i
CLKCTRL.ID=
eneric Clock Generator [i
GENCTR
ENDIV
eneric Clock[j]
LKCTR
Atmel | SMART SAM D21 [DATASHEET]
Atmel-42181G–SAM-D21_Datasheet–09/2015
100
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.