Upload
others
View
17
Download
0
Embed Size (px)
Citation preview
AVR 8-bit Microcontrollers
ATtiny417 ATtiny814 ATtiny816 ATtiny817
DATASHEET ADVANCE INFORMATION
Introduction
The Atmelreg ATtiny417814816817 is a series of microcontrollers using the8-bit AVRreg processor with hardware multiplier running at up to 20MHz withup to 8KB Flash 512 bytes of SRAM and 128 bytes of EEPROM in a 14-20- and 24-pin package The series uses the latest technologies from Atmelwith a flexible and low power architecture including Event System andSleepWalking accurate analog features and advanced peripheralsCapacitive touch interfaces with driven shield are supported with theintegrated QTouchreg peripheral touch controller
Features
bull CPUndash Atmelreg AVRreg 8-bit CPUndash Running at up to 20MHzndash Single cycle IO accessndash Two-level interrupt controllerndash Two-cycle hardware multiplier
bull Memoriesndash 48KB In-system self-programmable Flash memoryndash 128B EEPROMndash 256512B SRAM
bull Systemndash Power-on Reset (POR)ndash Brown-out Detection (BOD)ndash Clock options
bull Fusible 1620MHz low power internal RC oscillator withndash plusmn3 accuracy over full temp and voltage rangendash plusmn15 drift over limited temp and full voltage range
bull 32768kHz Ultra Low Power (ULP) internal RC oscillatorwith plusmn10 accuracy plusmn2 calibration step size
bull 32768kHz external crystal oscillatorbull External clock input
Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
ndash Single pin Unified Program Debug Interface (UPDI)ndash Three sleep modes
bull Idle with all peripherals running and mode for immediate wake up timebull Standby
ndash Configurable operation of selected peripheralsndash SleepWalking peripherals
bull Power Down with limited wake-up functionalitybull Peripherals
ndash One 16-bit TimerCounter type A with dedicated period register 3 compare channels (TCA)ndash One 16-bit TimerCounter type B with input capture (TCB)ndash One 12-bit TimerCounter type D optimized for control applications (TCD)ndash One 16-bit Real Time Counter (RTC) running from external crystal or internal RC oscillatorndash One USART with fractional baud rate generator autobaud and start-of-frame detectionndash Masterslave Serial Peripheral Interface (SPI)ndash Masterslave I2C with dual address match
bull Standard mode (Sm 100kHz)bull Fast mode (Fm 400kHz)bull Fast mode plus (Fm+ 1MHz)
ndash Configurable Custom Logic (CCL) with two programmable Lookup Tables (LUT)ndash Analog Comparator (AC) with fast propagation delayndash 10-bit 150ksps Analog to Digital Converter (ADC)ndash 8-bit Digital to Analog Converter (DAC)ndash Five selectable internal voltage references 055V 11V 15V 25V and 43Vndash Automated CRC memory scanndash Watchdog Timer (WDT) with Window Mode with separate on-chip oscillatorndash Peripheral Touch Controller (PTC)(1)
bull Capacitive touch buttons sliders and wheelsbull Wake-up on touchbull Driven shield for improved moisture and noise handling performancebull Six self-capacitance and nine mutual-capacitance channels
ndash External interrupt on all general purpose pinsbull IO and Packages
ndash 12 to 22 programmable IO linesndash 14-pin SOIC150ndash 20-pin QFN 3x3 and SOIC300ndash 24-pin QFN 4x4
bull Temperature Ranges -40degC to 105degC within specificationndash Some device variants -40degC to 125degC with reduced spec
bull Speed Gradesndash 0-5MHz 18V ndash 55Vndash 0-10MHz 27V ndash 55Vndash 0-20MHz 45V ndash 55V
Note 1 Only available in devices with 8KB Flash
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
2
Table of Contents
Introduction1
Features 1
1 Configuration Summary10
2 Ordering Information 1121 ATtiny81x 1122 ATtiny41x12
3 Block Diagram 13
4 Pinout1441 24-pin QFN1442 20-pin QFN1543 20-pin SOIC1644 14-pin SOIC17
5 IO Multiplexing and Considerations1851 Multiplexed Signals18
6 Memories2061 Overview2062 Memory Map2163 In-System Reprogrammable Flash Program Memory2164 SRAM Data Memory2265 EEPROM Data Memory 2266 User Row2367 IO Memory2368 FUSES - Configuration and User Fuses23
7 Peripherals and Architecture 3871 Peripheral Module Address Map 3872 Interrupt Vector Mapping 39
8 SYSCFG - System Configuration 4181 Overview4182 Functional Description4183 Register Summary - SYSCFG4484 Register Description 44
9 AVR CPU 4791 Overview4792 Features 4793 Architecture 4794 ALU - Arithmetic Logic Unit 49
95 Functional Description5096 Register Summary5597 Register Description 55
10 NVMCTRL - Non Volatile Memory Controller 59101 Overview59102 Features 59103 Block Diagram 60104 Product Dependencies 60105 Functional Description61106 Register Summary - NVMCTRL 67107 Register Description 67
11 CLKCTRL - Clock Controller75111 Overview75112 Features 75113 Block Diagram - CLKCTRL76114 Signal Description77115 Functional Description77116 Register Summary81117 Register Description 81
12 SLPCTRL - Sleep Controller 92121 Overview92122 Features 92123 Block Diagram 92124 Product Dependencies 92125 Functional Description93126 Register Summary96127 Register Description 96
13 RSTCTRL - Reset Controller98131 Overview98132 Features 98133 Block Diagram 98134 Signal Description99135 Functional Description99136 Register Summary - RSTCTRL101137 Register Description 101
14 CPUINT - CPU Interrupt Controller 104141 Overview104142 Features 104143 Block Diagram 105144 Signal Description105145 Product Dependencies 105146 Functional Description106147 Register Summary - CPUINT111148 Register Description111
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
4
15 EVSYS - Event System116151 Overview116152 Features116153 Block Diagram 117154 Signal Description118155 Product Dependencies 118156 Functional Description 119157 Register Summary - EVSYS121158 Register Description 121
16 PORTMUX - Port Multiplexer134161 Overview134162 Signal Description134163 Register Summary135164 Register Description 135
17 PORT - IO Pin Controller140171 Overview140172 Features 140173 Block Diagram 141174 Signal Description141175 Product Dependencies 142176 Functional Description142177 Register Summary - PORT146178 Register Description - Ports146179 Register Summary - VPORT 1581710 Register Description - Virtual Ports 158
18 BOD - Brownout Detector163181 Overview163182 Features 163183 Block Diagram 163184 Product Dependencies 164185 Functional Description165186 Register Summary167187 Register Description 167
19 VREF - Voltage Reference 174191 Overview174192 Features 174193 Block Diagram 174194 Functional Description175195 Register Summary176196 Register Description 176
20 WDT - Watchdog Timer 179201 Overview179202 Features 179
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
5
203 Block Diagram 180204 Signal Description180205 Product Dependencies 180206 Functional Description181207 Register Summary185208 Register Description 185
21 TCA - 16-bit TimerCounter Type A 189211 Overview189212 Features 189213 Block Diagram 190214 Signal Description191215 Product Dependencies 191216 Functional Description192217 Register Summary - Normal Mode (CTRLDSPLITM=0) 201218 Register Description - Normal Mode 202219 Register Summary - Split Mode (CTRLDSPLITM=1) 2222110 Register Description - Split Mode222
22 TCB - 16-bit TimerCounter Type B 238221 Overview238222 Features 238223 Block Diagram 239224 Signal Description239225 Product Dependencies 239226 Functional Description240227 Register Summary250228 Register Description 250
23 TCD - 12-bit TimerCounter Type D262231 Overview262232 Features 262233 Block Diagram 263234 Signal Description263235 Product Dependencies 263236 Functional Description265237 Register Summary286238 Register Description 287
24 RTC - Real Time Counter 312241 Overview312242 Features 312243 Block Diagram 313244 Signal Description313245 Product Dependencies 313246 RTC Functional Description314247 PIT Functional Description 315248 Events316249 Interrupts 317
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
6
2410 Sleep Mode Operation 3172411 Synchronization3172412 Configuration Change Protection 3182413 Register Summary - RTC3192414 Register Description319
25 USART - Universal Synchronous and Asynchronous Receiver and Transmitter 336251 Overview336252 Features 336253 Block Diagram 338254 Signal Description338255 Product Dependencies 339256 Functional Description340257 Register Summary354258 Register Description 354
26 SPI - Serial Peripheral Interface 373261 Overview373262 Features 373263 Block Diagram 373264 Signal Description374265 Product Dependencies 374266 Functional Description375267 Register Summary379268 Register Description 379
27 TWI - Two Wire Interface388271 Overview388272 Features 388273 Block Diagram 389274 Signal Description389275 Product Dependencies 389276 Functional Description391277 Register Summary - TWI402278 Register Description 402
28 CRCSCAN - Cyclic Redundancy Check Memory Scan 420281 Overview420282 Features 420283 Block Diagram 421284 Product Dependencies 421285 Functional Description422286 Register Summary425287 Register Description 425
29 CCL ndash Configurable Custom Logic 430291 Overview430292 Features 430293 Block Diagram 431
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
7
294 Signal Description431295 Product Dependencies 431296 Functional Description432297 Register Summary - CCL 440298 Register Description 440
30 AC ndash Analog Comparator 449301 Overview449302 Features 449303 Block Diagram 450304 Signal Description450305 Product Dependencies 450306 Functional Description451307 Register Summary - AC454308 Register Description 454
31 ADC - Analog to Digital Converter460311 Overview460312 Features 460313 Block Diagram 461314 Signal Description461315 Product Dependencies 461316 Functional Description462317 Register Summary472318 Register Description 472
32 DAC - Digital to Analog Converter491321 Overview491322 Features 491323 Block Diagram 491324 Signal Description491325 Product Dependencies 491326 Functional Description493327 Register Summary495328 Register Description 495
33 PTC - Peripheral Touch Controller498331 Overview498332 Features 498333 Block Diagram 499334 Signal Description499335 Product Dependencies 500336 Functional Description501
34 UPDI - Unified Program and Debug Interface 502341 Overview502342 Features 502343 Block Diagram 503344 Product Dependencies 503
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
8
345 Functional Description505346 Register Summary522347 Register Description 522
35 Instruction Set Summary 537
36 Electrical Characteristics 544361 Disclaimer544362 Absolute Maximum Ratings 544363 General Operating Ratings 545364 Voltage Protection 546
37 Typical Characteristics548371 Power Consumption 548
38 Package Drawings554381 WARNING 554382 14-pin SOIC150555383 20-pin SOIC300556384 20-pin VQFN557385 24-pin QFN558
39 Datasheet Revision History 559391 RevA - 092016559
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
9
1 Configuration SummaryTable 1-1 Configuration Summary
ATtiny417 ATtiny817 ATtiny816 ATtiny814
Pins 24 20 14
SRAM 256512B 512B 512B
Flash 48KB 8KB 8KB
EEPROM 128B 128B 128B
Max frequency 20MHz 20MHz 20MHz
16-bit TimerCounter type A (TCA) 1 1 1
16-bit TimerCounter type B (TCB) 1 1 1
12-bit TimerCounter type D (TCD) 1 1 1
Real Time Counter (RTC) 1 1 1
USART 1 1 1
SPI 1 1 1
TWI (I2C) 1 1 1
ADC 1 1 1
ADC channels 12 12 10
DAC 1 1 1
AC 1 1 1
AC inputs 2p2n 2p2n 1p1n
Peripheral Touch Controller (PTC)(1) No Yes(2) Yes(2) Yes(2)
PTC number of self-capacitance channels(1) 6 6 6
PTC number of mutual-capacitance channels(1) 9 9 9
Custom Logic 1 1 1
Window Watchdog 1 1 1
Event System channels 6 6 6
General purpose IO 22 18 12
External interrupts 22 18 12
CRCSCAN 1 1 1
Note 1 PTC is only available in devices with 8KB Flash (ATtiny817 ATtiny816 and ATtiny814)2 The PTC serves as input to the ADC
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
10
2 Ordering Information
21 ATtiny81xTable 2-1 ATtiny817 Ordering Codes
Ordering Code(1) Flash Package Type Leads Power Supply Operational Range Carrier Type
ATtiny817-MNRES(2)
8KB QFN 4x4 24 18V - 55V Industrial (-40degC+105degC)
Tape amp Reel
ATtiny817-MNR 8KB QFN 4x4 24 18V - 55V Industrial (-40degC+105degC)
Tape amp Reel
ATtiny817-MFR 8KB QFN 4x4 24 18V - 55V Industrial (-40degC+125degC)
Tape amp Reel
Table 2-2 ATtiny816 Ordering Codes
Ordering Code(1) Flash Package Type Leads Power Supply Operational Range Carrier Type
ATtiny816-MNRES(2)
8KB QFN 3x3 20 18V - 55V Industrial (-40degC+105degC)
Tape amp Reel
ATtiny816-MNR 8KB QFN 3x3 20 18V - 55V Industrial (-40degC+105degC)
Tape amp Reel
ATtiny816-MFR 8KB QFN 3x3 20 18V - 55V Industrial (-40degC+125degC)
Tape amp Reel
ATtiny816-SNR 8KB SOIC300 20 18V - 55V Industrial (-40degC+105degC)
Tape amp Reel
ATtiny816-SFR 8KB SOIC300 20 18V - 55V Industrial (-40degC+125degC)
Tape amp Reel
Table 2-3 ATtiny814 Ordering Codes
Ordering Code(1) Flash PackageType
Leads Power Supply Operational Range Carrier Type
ATtiny814-SSNRES(2)
8KB SOIC150 14 18V - 55V Industrial (-40degC+105degC)
Tape amp Reel
ATtiny814-SSNR 8KB SOIC150 14 18V - 55V Industrial (-40degC+105degC)
Tape amp Reel
ATtiny814-SSFR 8KB SOIC150 14 18V - 55V Industrial (-40degC+125degC)
Tape amp Reel
Note 1 Pb-free packaging complies to the European Directive for Restriction of Hazardous Substances
(RoHS directive) Also Halide free and fully Green2 Engineering samples
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
11
22 ATtiny41xTable 2-4 ATtiny417 Ordering Codes
Ordering Code(1) Flash Package Type Leads Power Supply Operational Range Carrier Type
ATtiny417-MNR 4KB QFN 4x4 24 18V - 55V Industrial (-40degC+105degC)
Tape amp Reel
ATtiny417-MFR 4KB QFN 4x4 24 18V - 55V Industrial (-40degC+125degC)
Tape amp Reel
1 Pb-free packaging complies to the European Directive for Restriction of Hazardous Substances(RoHS directive) Also Halide free and fully Green
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
12
3 Block Diagram
Oscillators Clock generation
BUS Matrix
CPU
USART
SPI
TWI
CCL
DAC
AC
PTC ADC
TCD
TCA
TCB
AINN[10]AINP[10]
OUT
ADC[150]X[150]Y[150]
PDS[10]
OC[20]
OC[10]
RxTx
XCK
MISOMOSISCK_SS
SDASCL
PORTS
EVSYS
System Management
SLEEPCTRL
RSTCTRL
CLKCTRL
EVENT
SYSTEM
DATABUS
UPDICRC
GPIOR
SRAM
NVM Controller
Flash
EEPROM
UPDIphy
System Interface
System info
OSC20M
OSC32K
XOSC32K
EXTCLK
Detectors
BOD
POR BG
WindowWDT
RTC
VCC
GND
INTCTRL
M M
S
MS
S S
OCD
SINGLE
CYCLE
DATABUS
UPDI
ResetRST12V
EVOUT
CPUINT
TOSC2
TOSC1
S
Bridge Bridge
OC[20]
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
13
4 Pinout
41 24-pin QFN
PA0
PA1
PC3
PC2
PA2
PA3
PA4
PA5
PA7
PA6
PC5
PC4
PC0
PC1
GND
VDDPB
4
PB5
PB6
PB7
PB0
PB1
PB3
PB2
1
23
4
56
7 8 9 10 11 12
13
14
15
16
17
18
192021222324
Analog
ClockXOSCRESETProg
Digital
Input SupplyGround
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
14
42 20-pin QFN
PA0
PA1
PA4
PA7
PA6
PB0
PB1
PB3PB
4
PB5
PC2
PC3
PA5
GND
VDD
PA3
PB2
PA2 PC0
PC1
123
4
5
6 7 8 9 10
11
12
13
1415
1617181920
Analog
ClockXOSCRESETProg
Digital
Input SupplyGround
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
15
43 20-pin SOIC
VCC GND
PA0
PA1
PA2
PA3PA4
PA5
PA7
PA6
PB0
PB3
PB2
PB1
PB4
PB5
PC0
PC2
PC3
PC1
1
2
34
5
6
7
8
9
10 11
12
13
14
15
16
17
18
19
20
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
16
44 14-pin SOIC
VCC GND
PA0
PA1
PA2
PA3PA4
PA5
PA7
PA6
PB0
PB1
PB3
PB2
1
2
34
5
6
7 8
9
10
11
1213
14
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
17
5 IO Multiplexing and Considerations
51 Multiplexed SignalsTable 5-1 PORT Function Multiplexing
QFN24-pin
QFN20-pin
SOIC20-pin
SOIC14-pin
PinName (1)
Event(5) OtherSpecial
EXTINTn(2)
ADC0 PTC(3)
AC0 DAC USART0 SPI0 TWI0 TCA0 TCB0 TCD0 CCL
23 19 16 10 PA0 EVINA0 EVINS0 RESET
UPDI
S AIN0 LUT0-IN0
24 20 17 11 PA1 EVINA0 EVINS0
S AIN1 TXD MOSI SDA LUT0-IN1
1 1 18 12 PA2 EVINA0 EVINS0 EVOUT0
A AIN2 RxD MISO SCL LUT0-IN2
2 2 19 13 PA3 EVINA0 EVINS0
CLKI S AIN3 XCK SCK W03
3 3 20 14 GND4 4 1 1 VDD5 5 2 2 PA4 EVINA0
EVINS0S AIN4 X0Y0 XDIR SS W04 TCDOUTA LUT0-
OUT6 6 3 3 PA5 EVINA0
EVINS0S AIN5 X1Y1 ACOUT W05 W0 TCDOUTB
7 7 4 4 PA6 EVINA0 EVINS0
A AIN6 X2Y2 N0 OUT
8 8 5 5 PA7 EVINA0 EVINS0
S AIN7 X3Y3 P0 LUT1-OUT
9 PB7 EVINA1 EVINS1
S
10 PB6 EVINA1 EVINS1
A
11 9 6 PB5 EVINA1 EVINS1
CLKOUT S AIN8 P1 W02
12 10 7 PB4 EVINA1 EVINS1
S AIN9 DS1 N1 W01 LUT0-OUT
13 11 8 6 PB3 EVINA1 EVINS1 EVOUT1
TOSC1S RxD W00
14 12 9 7 PB2 EVINA1 EVINS1
TOSC2 A DS0 TxD W02
15 13 10 8 PB1 EVINA1 EVINS1
S AIN10 X4Y4 XCK SDA W01
16 14 11 9 PB0 EVINA1 EVINS1
S AIN11 X5Y5 XDIR SCL W00
17 15 12 PC0 EVINA2 EVINS0
S SCK W0 TCDOUTC
18 16 13 PC1 EVINA2 EVINS0
S MISO TCDOUTD LUT1-OUT
19 17 14 PC2 EVINA2 EVINS0 EVOUT2
A MOSI
20 18 15 PC3 EVINA2 EVINS0
S SS W03 LUT1-IN0
21 PC4 EVINA2 EVINS0
S W04 LUT1-IN1
22 PC5 EVINA2 EVINS0
RESET S W05 LUT1-IN2
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
18
Note 1 Pins PAn are configured by PORT instance A pins PBn are configured by PORT B etc2 S Detection = Synchronous and limited asynchronous A Detection = Synchronous and full
asynchronous3 PTC is only available in devices with 8KB Flash (ATtiny817 ATtiny816 ATtiny814) Every PTC line
can be configured as X-line or Y-line4 Default pin assignment of signals are in regular font Signals on alternative pin locations are in
italic5 EVINA Event input for asynchronous channel EVINS Event input for synchronous channel
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
19
6 Memories
61 OverviewThe main memories are SRAM data memory EEPROM data memory and Flash program memory Inaddition the peripheral registers are located in the IO memory space
Table 6-1 Physical Properties of EEPROM
Property ATtiny817816814 ATtiny417
Size 128B 128B
Page size 32B 32B
Number of pages 4 4
Start address 0x1400 0x1400
Table 6-2 Physical Properties of SRAM
Property ATtiny817816814 ATtiny417
Size 512B 256B
Start address 0x3E00 0x3F00
Table 6-3 Physical Properties of Flash Memory
Property ATtiny817816814 ATtiny417
Size 8KB 4KB
Page size 64B 64B
Number of pages 128 64
Start address 0x8000 0x8000
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
20
62 Memory MapFigure 6-1 Memory Map
(Reserved)
(Reserved)
NVM IO Registers and data
64 IO Registers
960 Ext IO Registers
0x0000 ndash 0x003F
0x0040 ndash 0x0FFF
0x1400 - 0x1480EEPROM128B
Flash code
0x1000 ndash 0x13FF
Internal SRAM256512B
0x3F000x3E00
48KB 0x8000 - 0x8FFF0x9FFF
0x3FFF
Flash code48KB
0x0000
CPU Code space PDICPU Data space
63 In-System Reprogrammable Flash Program MemoryThe ATtiny417814816817 contains 48KB On-Chip In-System Reprogrammable Flash memory forprogram storage Since all AVR instructions are 16 or 32 bits wide the Flash is organized as 4K x 16 Forwrite protection the Flash Program memory space can be divided into three sections Boot Loadersection Application code section and Application data section with restricted access rights among them
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
21
The program counter is 1211 bits wide to address the whole program memory The procedure for writingFlash memory is described in detail in the documentation of the Non-Volatile Memory Controller(NVMCTRL) peripheral
The entire Flash memory is mapped in the memory space and is accessible with normal LDSTinstructions as well as the LPM instruction For LDST instructions the Flash is mapped from address0x8000 For the LPM instruction the Flash start address is 0x0000
The ATtiny417814816817 also has a CRC module that acts a master on the bus If the CRC isconfigured to run in the background it will read the Flash memory and can modify the program timing
Related LinksConfiguration Summary on page 10NVMCTRL - Non Volatile Memory Controller on page 59Flash Write Protection on page 64
64 SRAM Data MemoryThe 512B SRAM is used for data storage and stack
Related LinksAVR CPU on page 47Stack and Stack Pointer on page 51
65 EEPROM Data MemoryThe ATtiny417814816817 contains 128 bytes of data EEPROM memory see Memory Map TheEEPROM memory supports single byte read and write The EEPROM is controlled by the Non-VolatileMemory Controller (NVMCTRL)
Preventing EEPROM CorruptionDuring periods of low VDD the EEPROM data can be corrupted because the supply voltage is too low forthe CPU and the EEPROM to operate properly These issues are the same as for board level systemsusing EEPROM and the same design solutions should be applied
An EEPROM data corruption can be caused by two situations when the voltage is too low First a regularwrite sequence to the EEPROM requires a minimum voltage to operate correctly Also the CPU itself canexecute instructions incorrectly when the supply voltage is too low
EEPROM data corruption can easily be avoided by these measures
Keep the AVR RESET active (low) during periods of insufficient power supply voltage This is done byenabling the internal Brown-Out Detector (BOD)
If the detection levels of the internal BOD does not match the required detection level an external low-VDD-reset protection circuit can be used If a Reset occurs while a write operation is ongoing the writeoperation will be completed provided that the power supply voltage is sufficient
Related LinksMemory Map on page 21NVMCTRL - Non Volatile Memory Controller on page 59BOD - Brownout Detector on page 163
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
22
66 User RowIn addition to the EEPROM the ATtiny417814816817 contains one extra page of EEPROM memorythat can be used for firmware settings the User Row (USERROW) This memory supports single byteread and write as the normal EEPROM The CPU can write this memory as normal EEPROM and theUPDI can write it as a normal EEPROM memory if the part is unlocked The User Row can also be writtenby the UPDI when the part is locked with a special key USERROW is not affected by a chip erase
Related LinksMemory Map on page 21NVMCTRL - Non Volatile Memory Controller on page 59UPDI - Unified Program and Debug Interface on page 502
67 IO MemoryAll ATtiny417814816817 IOs and peripherals are located in the IO space All IO locations can beaccessed by the LDLDSLDD and STSTSSTD instructions transferring data between the 32 generalpurpose working registers and the IO space
IO Registers within the address range 0x00 - 0x1F are directly bit-accessible using the SBI and CBIinstructions In these registers the value of single bits can be checked by using the SBIS and SBICinstructions Refer to the Instruction Set section for more details
The IO specific commands IN and OUT can access the IO addresses 0x00 - 0x3F
The IO address range from 0x00 to 0x3F can be accessed in single cycle using IN and OUT instructionsFor the Extended IO space from 0x0040 - 0x0FFF only the STSTSSTD and LDLDSLDD instructionscan be used
For compatibility with future devices reserved bits should be written to zero if accessed Reserved IOmemory addresses should never be written
Some of the Status Flags are cleared by writing a 1 to them Note that on ATtiny417814816817devices the CBI and SBI instructions will only operate on the specified bit and can therefore be used onregisters containing such Status Flags The CBI and SBI instructions work with registers 0x00 - 0x1F only
General Purpose IO RegistersThe ATtiny417814816817 devices provide four General Purpose IO Registers These registers can beused for storing any information and they are particularly useful for storing global variables and StatusFlags
Related LinksMemory Map on page 21Instruction Set Summary on page 537
68 FUSES - Configuration and User Fuses
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
23
681 Signature Row Summary - SIGROW
Offset Name Bit Pos
0x00 DEVICEID0 70 DEVICEID[70]
0x01 DEVICEID1 70 DEVICEID[70]
0x02 DEVICEID2 70 DEVICEID[70]
0x03 SERNUM0 70 SERNUM[70]
0x04 SERNUM1 70 SERNUM[70]
0x05 SERNUM2 70 SERNUM[70]
0x06 SERNUM3 70 SERNUM[70]
0x07 SERNUM4 70 SERNUM[70]
0x08 SERNUM5 70 SERNUM[70]
0x09 SERNUM6 70 SERNUM[70]
0x0A SERNUM7 70 SERNUM[70]
0x0B SERNUM8 70 SERNUM[70]
0x0C SERNUM9 70 SERNUM[70]
0x0D
0x1F
Reserved
0x20 TEMPSENSE0 70 TEMPSENSE[70]
0x21 TEMPSENSE1 70 TEMPSENSE[70]
682 Signature Row Description
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
24
6821 Device ID n
Name DEVICEIDnOffset 0x00 + n0x01 [n=02]Reset [Device ID]Property
-
Bit 7 6 5 4 3 2 1 0 DEVICEID[70]
Access R R R R R R R R Reset 0 0 0 0 0 0 0 0
Bits 70 ndash DEVICEID[70] Byte n of the Device ID
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
25
6822 Serial Number Byte n
Name SERNUMnOffset 0x03 + n0x01 [n=09]Reset [device serial number]Property
-
Bit 7 6 5 4 3 2 1 0 SERNUM[70]
Access R R R R R R R R Reset 0 0 0 0 0 0 0 0
Bits 70 ndash SERNUM[70] Serial Number n [n=09]Each device has an individual serial number representing a unique ID This can be used to identify aspecific device in the field The serial number consists of ten bytes
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
26
6823 Temperature Sensor Calibration n
Name TEMPSENSEnOffset 0x20 + n0x01 [n=01]Reset [Temperature sensor calibration value]Property
-
Bit 7 6 5 4 3 2 1 0 TEMPSENSE[70]
Access R R R R R R R R Reset 0 0 0 0 0 0 0 0
Bits 70 ndash TEMPSENSE[70] Temperature Sensor Calibration ByteTBD
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
27
683 Fuse Summary - FUSE
Offset Name Bit Pos
0x00 WDTCFG 70 WINDOW[30] PERIOD[30]
0x01 BODCFG 70 LVL[20] SAMPLFREQ ACTIVE[10] SLEEP[10]
0x02 OSCCFG 70 OSCLOCK FREQSEL[10]
0x03 Reserved
0x04 TCD0CFG 70 CMPD CMPC CMPB CMPA CMPD CMPC CMPB CMPA
0x05 SYSCFG0 70CRCBOOTDI
SCRCAPPDIS RSTPINCFG[10] EESAVE
0x06 SYSCFG1 70 SUT[20]
0x07 APPEND 70 APPEND[70]
0x08 BOOTEND 70 BOOTEND[70]
0x09 Reserved
0x0A LOCKBIT 70 LOCKBIT[70]
684 Fuse Description
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
28
6841 Watchdog Configuration
Name WDTCFGOffset 0x00Reset -Property
-
Bit 7 6 5 4 3 2 1 0 WINDOW[30] PERIOD[30]
Access R R R R R R R R Reset 0 0 0 0 0 0 0 0
Bits 74 ndash WINDOW[30] Watchdog Window Timeout PeriodThis value is loaded into the WINDOW bit field of the Watchdog Control A register (WDTCTRLA) at theend of the startup sequence
Bits 30 ndash PERIOD[30] Watchdog Timeout PeriodThis value is loaded into the PERIOD bit field of the Watchdog Control A register (WDTCTRLA) at theend of the startup sequence
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
29
6842 BOD Configuration
Name BODCFGOffset 0x01Reset -Property
-
Bit 7 6 5 4 3 2 1 0 LVL[20] SAMPLFREQ ACTIVE[10] SLEEP[10]
Access R R R R R R R R Reset 0 0 0 0 0 0 0 0
Bits 75 ndash LVL[20] BOD LevelThis value is loaded into the LVL bit field of the BOD Control B register (BODCTRLB) at the end of thestartup sequence
Bit 4 ndash SAMPLFREQ BOD Sample FrequencyThis value is loaded into the SAMPLEFREQ bit of the BOD Control A register (BODCTRLA) at the end ofthe startup sequence
Value Description0x0 Sample frequency is 1kHz
0x1 Sample frequency is 125Hz
Bits 32 ndash ACTIVE[10] BOD Operation Mode in Active and IdleThis value is loaded into the ACTIVE bit field of the BOD Control A register (BODCTRLA) at the end ofthe startup sequence
Value Description0x0 Disabled
0x1 Enabled
0x2 Sampled
0x3 Enabled with wake-up halted until BOD is ready
Bits 10 ndash SLEEP[10] BOD Operation Mode in SleepThis value is loaded into the SLEEP bit field of the BOD Control A register (BODCTRLA) at the end ofthe startup sequence
Value Description0x0 Disabled
0x1 Enabled
0x2 Sampled
0x3 Reserved
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
30
6843 Oscillator Configuration
Name OSCCFGOffset 0x02Reset -Property
-
Bit 7 6 5 4 3 2 1 0 OSCLOCK FREQSEL[10]
Access R R R Reset 0 0 0
Bit 7 ndash OSCLOCK Oscillator LockThis fuse bit is written to LOCKEN in CLKCTRLMCLKLOCK at startup
Value Description0 Calibration registers of the main oscillator are accessible
1 Calibration registers of the main oscillator are locked
Bits 10 ndash FREQSEL[10] Frequency SelectThese bits selects the operation frequency of the 1620MHz internal oscillator (OSC20M) and determinethe respective calibration value to be written to CAL20M in CLKCTRLOSC20MCALIBA
Value Description0x1 Run at 16MHz with corresponding factory calibration
0x2 Run at 20MHz with corresponding factory calibration
Other Reserved
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
31
6844 Timer Counter Type D ConfigurationThe bit values of this fuse register are written to the corresponding bits in the TCDFAULTCTRL registerof the TCD0
Name TCD0CFGOffset 0x04Reset -Property
-
Bit 7 6 5 4 3 2 1 0 CMPD CMPC CMPB CMPA CMPD CMPC CMPB CMPA
Access R R R R R R R R Reset 0 0 0 0 0 0 0 0
Bits 4 5 6 7 ndash CMPA CMPB CMPC CMPD Compare x Enable
Value Description0 Compare x output on Pin is disabled
1 Compare x output on Pin is enabled
Bits 0 1 2 3 ndash CMPA CMPB CMPC CMPD Compare xThis bit selects the default state of Compare x after Reset or when entering debug if FAULTDET is 1
Value Description0 Compare x default state is 0
1 Compare x default state is 1
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
32
6845 System Configuration 0
Name SYSCFG0Offset 0x05Reset -Property
-
Bit 7 6 5 4 3 2 1 0 CRCBOOTDIS CRCAPPDIS RSTPINCFG[10] EESAVE
Access R R R R R Reset 0 0 0 0 0
Bit 7 ndash CRCBOOTDIS CRC of Boot Section in Reset DisableSee CRC description for more information about the functionality
Value Description0 Boot section undergoing a CRC before Reset releases
1 No CRC of the boot section before Reset releases
Bit 6 ndash CRCAPPDIS CRC of Application Code Section in Reset DisableSee CRC description for more information about the functionality
Value Description0 Application code section undergoing a CRC before Reset releases
1 No CRC of the application code section before Reset releases
Bits 32 ndash RSTPINCFG[10] Reset Pin ConfigurationThese bits select the ResetUPDI pin configuration
Value Description0x0 GPIO
0x1 UPDI
0x2 RESET
0x3 Reserved
Bit 0 ndash EESAVE EEPROM Save during chip eraseNote If the device is locked the EEPROM is always erased by a chip erase regardless of this bit
Value Description0 EEPROM erased during chip erase
1 EEPROM not erased under chip erase
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
33
6846 System Configuration 1
Name SYSCFG1Offset 0x06Reset -Property
-
Bit 7 6 5 4 3 2 1 0 SUT[20]
Access R R R Reset 0 0 0
Bits 20 ndash SUT[20] Start Up Time SettingThese bits selects the start-up time
Value Description0x0 0ms
0x1 1ms
0x2 2ms
0x3 4ms
0x4 8ms
0x5 16ms
0x6 32ms
0x7 64ms
other Reserved
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
34
6847 Application Code End
Name APPENDOffset 0x07Reset -Property
-
Bit 7 6 5 4 3 2 1 0 APPEND[70]
Access R R R R R R R R Reset 0 0 0 0 0 0 0 0
Bits 70 ndash APPEND[70] Application Code Section EndThese bits set the end of the application code section in blocks of 256 bytes The end of the applicationcode section should be set as BOOT size + application code size A value of 0x00 defines the wholeFlash as application code sectionNote When both FUSEAPPEND and FUSEBOOTEND are 0x00 the entire Flash is application codesection
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
35
6848 Boot End
Name BOOTENDOffset 0x08Reset -Property
-
Bit 7 6 5 4 3 2 1 0 BOOTEND[70]
Access R R R R R R R R Reset 0 0 0 0 0 0 0 0
Bits 70 ndash BOOTEND[70] Boot Section EndThese bits set the end of the boot section in blocks of 256 bytes A value of 0x00 defines the whole Flashas BOOT sectionNote When both FUSEAPPEND and FUSEBOOTEND are 0x00 the entire Flash is application codesection
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
36
6849 Lock Bits
Name LOCKBITOffset 0x0AReset -Property
-
Bit 7 6 5 4 3 2 1 0 LOCKBIT[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash LOCKBIT[70] Lock Bits
Value Description0xC5 The device is open
other The device is locked
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
37
7 Peripherals and Architecture
71 Peripheral Module Address MapThe address map show the base address for each peripheral For complete register description andsummary for each peripheral module refer to the respective module chapters
Table 7-1 Peripheral Module Address Map
Base Address Name Description
0x0000 VPORTA Virtual Port A
0x0004 VPORTB Virtual Port B
0x0008 VPORTC Virtual Port C
0x001C GPIO General Purpose IO registers
0x0030 CPU CPU
0x0040 RSTCTRL Reset Controller
0x0050 SLPCTRL Sleep Controller
0x0060 CLKCTRL Clock Controller
0x0080 BOD Brown-Out Detector
0x00A0 VREF Voltage Reference
0x0100 WDT Watchdog Timer
0x0110 CPUINT Interrupt Controller
0x0120 CRCSCAN Cyclic Redundancy Check Memory Scan
0x0140 RTC Real Time Counter
0x0180 EVSYS Event System
0x01C0 CCL Configurable Custom Logic
0x0200 PORTMUX Port Multiplexer
0x0400 PORTA Port A Configuration
0x0420 PORTB Port B Configuration
0x0440 PORTC Port C Configuration
0x0600 ADC0 Analog to Digital ConverterPeripheral Touch Controller
0x0670 AC0 Analog Comparator
0x0680 DAC0 Digital to Analog Converter
0x0800 USART0 Universal Synchronous Asynchronous Receiver Transmitter
0x0810 TWI0 Two Wire Interface
0x0820 SPI0 Serial Peripheral Interface
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
38
Base Address Name Description
0x0A00 TCA0 TimerCounter Type A
0x0A40 TCB0 TimerCounter Type B 0
0x0A80 TCD0 TimerCounter Type D
0x0F00 SYSCFG System Configuration
0x1000 NVMCTRL Non Volatile Memory Controller
0x1100 SIGROW Signature Row
0x1280 FUSES Device specific fuses
0x1300 USERROW User Row
72 Interrupt Vector MappingEach of the 26 interrupt vectors is connected to one peripheral instance as shown in the table below Aperipheral can have one or more interrupt sources see the Interrupt section in the FunctionalDescription of the respective peripheral for more details on the available interrupt sources
When the interrupt condition occurs an Interrupt Flag (nameIF) is set in the Interrupt Flags register of theperipheral (peripheralINTFLAGS)
An interrupt is enabled or disabled by writing to the corresponding Interrupt Enable bit (nameIE) in theperipherals Interrupt Control register (peripheralINTCTRL)
An interrupt request is generated when the corresponding interrupt is enabled and the Interrupt Flag isset The interrupt request remains active until the Interrupt Flag is cleared See the peripheralsINTFLAGS register for details on how to clear Interrupt Flags
Note Interrupts must be enabled globally for interrupt requests to be generated
Table 7-2 Interrupt Vector Mapping
Vector Number Base Address Peripheral source
0 0x00 RESET
1 0x02 NMI - Non-Maskable Interruptfrom CRC
2 0x04 VLM - Voltage Level Monitor
3 0x06 PORTA - Port A
4 0x08 PORTB - Port B
5 0x0A PORTC - Port C
6 0x0C RTC - Real Time Counter
7 0x0E PIT - Periodic Interrupt Timer (inRTC peripheral)
8 0x10 TCA0 - Timer Counter Type A
13 0x1A TCB0 - Timer Counter Type B
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
39
Vector Number Base Address Peripheral source
14 0x1C TCD0 - Timer Counter Type D
16 0x20 AC0 ndash Analog Comparator
17 0x22 ADC0 ndash Analog-to-DigitalConverter
19 0x26 TWI0 - Two Wire Interface I2C
21 0x2A SPI0 - Serial Peripheral Interface
22 0x2C USART0 - UniversalAsynchronous Receiver-Transmitter
25 0x32 NVM - Non Volatile Memory
Related LinksNVMCTRL - Non Volatile Memory Controller on page 59PORT - IO Pin Controller on page 140RTC - Real Time Counter on page 312SPI - Serial Peripheral Interface on page 373USART - Universal Synchronous and Asynchronous Receiver and Transmitter on page 336TWI - Two Wire Interface on page 388CRCSCAN - Cyclic Redundancy Check Memory Scan on page 420TCA - 16-bit TimerCounter Type A on page 189TCB - 16-bit TimerCounter Type B on page 238TCD - 12-bit TimerCounter Type D on page 262AC ndash Analog Comparator on page 449ADC - Analog to Digital Converter on page 460
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
40
8 SYSCFG - System Configuration
81 OverviewThe System Configuration blocks (SYSCFG) contain various device-specific registers
82 Functional Description
821 External BreakThe External Break feature makes it possible to connect several devices through one PIN on eachdevice and control the debug start and stop (RUN and BREAK) flow from a debugger connected to oneof the parts Enabling this feature is done through writing the ENABLE bit in SYSCFGEXTBRK Note thatwriting this bit is protected and requires setting the correct CPUCCP signature before it can be writtenThe External Break feature can be described from the perspective of a master and slave point of viewmeaning that the master device initiates HALTRESTART commands to another device and a slavereceives HALTRESTART commands from another device
After the ENABLE bit in SYSCFGEXTBRK is written it is possible to send HALT and RESTARTcommands to an external device through the EXTBREAK output It is recommended that all devices thatis part of the debug chain is set up with OCD mode enabled See section on Enabling of KEY ProtectedInterfaces for details on enabling the OCD features To set up a device for slave mode operation with thepossibility to start and stop the CPU based on the External Debug inputs the must be written
Related LinksEnabling of KEY Protected Interfaces on page 517
8211 Sending HALT and RESTART commandsWhen the External Break feature is enabled through EXTBRKENABLE it is possible to HALT (BREAK)and RESTART (RUN) another device through the External Break Pin This operation works as follows
bull The user writes to the HALT bit in SYSCFGEXTBRK This bit is not protected with CCP signatureand can be written at any time This bit can be written independent of the state of the device that ismaster in this operation meaning that the master device can be in RUN mode and request theconnected device to BREAK
bull The CPU of the master device is enabled in OCD mode and hits a breakpoint or is stopped bywriting the OCD_STOP bit in UPDIASI_OCD_CTRLA
Sending the RESTART commands to an external device is done in the same manner as for the HALTcommands
bull The user writes to the RESTART bit in EXTBRK bit This bit is not protected with CCP signatureand can be written at any time
bull The CPU of the master device is in OCD Stopped mode and receives a restart command forinstance by writing the OCD_RUN bit in UPDIASI_OCD_CTRLA
8212 External BREAK ProtocolThe External BREAK output (EXTBREAK) is in the RUN state when it is pulled low If the device does notsupport internal pull-down the line can be actively driven low from the master device or have an externalpull-down resistor connected Figure 8-1 shows the External BREAK output signal level during stop andrestart requests A transition from low to high level on the EXTBREAK output signalizes that either aninternal or external debug stop condition has occurred while a high to low level transition signalizes theoccurrence of an internal or external restart condition
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
41
Figure 8-1 External BREAK output signal level on internal stop and restart request
Inte rna l Debug s top reques t
Inte rna l Debug res ta rt reques t
EXTBREAK
A stop request can be sent on the EXTBREAK output by writing to the HALT bit in SYSCFGEXTBRKThis is effectively the same as sending a BREAK command to any connected slave device from themaster Figure 8-2 gives an example of sending a HALT commandFigure 8-2 External BREAK output signal level when sending HALT command
Inte rna l Debug res ta rt reques t
EXTBREAK
HALT
A restart request can be sent on the EXTBREAK output by writing a 1 to the RESTART bit inSYSCFGEXTBRK This is the same as sending a RUN command to any connected slave device fromthe master Figure 8-3 shows a combined example where a HALT command is followed by a RESTARTcommandFigure 8-3 External BREAK output signal level when sending HALT followed by RESTART command
EXTBREAK
HALT
RESTART
822 Configuration Change ProtectionThis peripheral has registers that are under Configuration Change Protection (CCP) In order to write tothese a certain key must be written to the CPUCCP register first followed by a write access to theprotected bits within four CPU instructions
It is possible to try writing to these registers any time but the values are not altered
The following registers are under CCP
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
42
Table 8-1 SYSCFG - Registers under Configuration Change Protection
Register Key
SYSCFGEXTBRK IOREG
List of bitsregisters protected by CCP
bull External Break Enable (ENABLE) in External Break register (SYSCFGEXTBRK)
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
43
83 Register Summary - SYSCFG
Offset Name Bit Pos
0x01 REVID 70 REVID[70]
0x02 EXTBRK 70 RESTART HALT ENABLE
84 Register Description
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
44
841 Device Revision ID RegisterThis register is read only and give the device revision ID
Name REVIDOffset 0x01Reset [revision ID]Property
-
Bit 7 6 5 4 3 2 1 0 REVID[70]
Access R R R R R R R R Reset
Bits 70 ndash REVID[70] Revision IDThese bits contain the device revision 0x00 = A 0x01 = B and so on
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
45
842 External Break RegisterEnables external break
Name EXTBRKOffset 0x02Reset 0x00Property
Configuration Change Protection
Bit 7 6 5 4 3 2 1 0 RESTART HALT ENABLE
Access W W W Reset 0 0 0
Bit 2 ndash RESTART External Break Restart CommandWill send a restart command to external break pin This bit has no Configuration Change Protection
Bit 1 ndash HALT External Break Halt CommandWill send a halt command to external break pin This bit has no Configuration Change Protection
Bit 0 ndash ENABLE External Break EnableEnables external break
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
46
9 AVR CPU
91 OverviewAll Atmel AVR devices use the 8-bit AVR CPU The main function of the CPU is to execute the code andperform all calculations The CPU is able to access memories perform calculations control peripheralsand execute instructions in the program memory Interrupt handling is described in a separate section
Related LinksMemories on page 20NVMCTRL - Non Volatile Memory Controller on page 59CPUINT - CPU Interrupt Controller on page 104
92 Featuresbull 8-bit high-performance Atmel AVR RISC CPU
ndash 135 instructionsndash Hardware multiplier
bull 32x8-bit registers directly connected to the ALUbull Stack in RAMbull Stack pointer accessible in IO memory spacebull Direct addressing of up to 64KB of unified memory
ndash Entire Flash accessible with all LDST instructionsbull True 16-bit access to 16-bit IO registersbull Efficient support for 8- 16- and 32-bit arithmeticbull Configuration Change Protection for system-critical featuresbull Native OCD support
ndash 2 hardware breakpointsndash Change of flow interrupt and software breakpointsndash Runtime readout of Stack Pointer register program counter (PC) and Status registerndash Register file read- and writable in stopped mode
93 ArchitectureIn order to maximize performance and parallelism the AVR CPU uses a Harvard architecture withseparate buses for program and data Instructions in the program memory are executed with single-levelpipelining While one instruction is being executed the next instruction is pre-fetched from the programmemory This enables instructions to be executed on every clock cycle
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
47
Figure 9-1 AVR CPU Architecture
The Arithmetic Logic Unit (ALU) supports arithmetic and logic operations between registers or between aconstant and a register Single-register operations can also be executed in the ALU After an arithmeticoperation the status register is updated to reflect information about the result of the operation
The ALU is directly connected to the fast-access register file The 32x8-bit general purpose workingregisters all have single clock cycle access time allowing single-cycle arithmetic logic unit operation
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
48
between registers or between a register and an immediate Six of the 32 registers can be used as three16-bit address pointers for program and data space addressing enabling efficient address calculations
The program memory bus is connected to Flash and the first program memory Flash address is 0x0000
The data memory space is divided into IO registers SRAM EEPROM and Flash
All IO status and control registers reside in the lowest 4KB addresses of the data memory This isreferred to as the IO memory space The lowest 64 addresses are accessed directly with single cycleINOUT instructions or as the data space locations from 0x00 to 0x3F These addresses can also beaccessed using load (LDLDSLDD) and store (STSTSSTD) instructions The lowest 32 addresses caneven be accessed with single cycle SBICBI instructions and SBISSBIC instructions The rest is theextended IO memory space ranging from 0x0040 to 0x0FFF IO registers here must be accessed asdata space locations using load and store instructions
Data addresses 0x1000 to 0x1800 are reserved for memory mapping of fuses the NVM controller andEEPROM The addresses from 0x1800 to 0x7FFF are reserved for other memories such as SRAM
The Flash is mapped in the data space from 0x8000 and above The Flash can be accessed with all loadand store instructions by using addresses above 0x8000 The LPM instruction accesses the Flash as inthe code space where the Flash starts at address 0x0000
For a summary of all AVR instructions refer to the Instruction Set Summary For details of all AVRinstructions refer to httpwwwatmelcomavr
Related LinksInstruction Set Summary on page 537NVMCTRL - Non Volatile Memory Controller on page 59Memories on page 20
94 ALU - Arithmetic Logic UnitThe Arithmetic Logic Unit supports arithmetic and logic operations between registers or between aconstant and a register Single-register operations can also be executed
The ALU operates in direct connection with all 32 general purpose registers Arithmetic operationsbetween general purpose registers or between a register and an immediate are executed in a single clockcycle and the result is stored in the register file After an arithmetic or logic operation the Status register(CPUSREG) is updated to reflect information about the result of the operation
ALU operations are divided into three main categories ndash arithmetic logical and bit functions Both 8- and16-bit arithmetic is supported and the instruction set allows for efficient implementation of 32-bitarithmetic The hardware multiplier supports signed and unsigned multiplication and fractional format
941 Hardware MultiplierThe multiplier is capable of multiplying two 8-bit numbers into a 16-bit result The hardware multipliersupports different variations of signed and unsigned integer and fractional numbers
bull Multiplication of unsigned integersbull Multiplication of signed integersbull Multiplication of a signed integer with an unsigned integerbull Multiplication of unsigned fractional numbersbull Multiplication of signed fractional numbersbull Multiplication of a signed fractional number with an unsigned one
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
49
A multiplication takes two CPU clock cycles
95 Functional Description
951 Program FlowAfter Reset the CPU starts to execute instructions from the lowest address in the Flash program memory0x0000 The program counter (PC) addresses the next instruction to be fetched
Program flow is provided by conditional and unconditional jump and call instructions capable ofaddressing the whole address space directly Most AVR instructions use a 16-bit word format while alimited number use a 32-bit format
During interrupts and subroutine calls the return address PC is stored on the stack as a word pointerThe stack is allocated in the general data SRAM and consequently the stack size is only limited by thetotal SRAM size and the usage of the SRAM After Reset the stack pointer (SP) points to the highestaddress in the internal SRAM The SP is readwrite accessible in the IO memory space enabling easyimplementation of multiple stacks or stack areas The data SRAM can easily be accessed through the fivedifferent addressing modes supported in the AVR CPU
952 Instruction Execution TimingThe AVR CPU is clocked by the CPU clock CLK_CPU No internal clock division is applied The Figurebelow shows the parallel instruction fetches and instruction executions enabled by the Harvardarchitecture and the fast-access register file concept This is the basic pipelining concept enabling up to1MIPSMHz performance with high efficiency
Figure 9-2 The Parallel Instruction Fetches and Instruction Executions
The following Figure shows the internal timing concept for the register file In a single clock cycle an ALUoperation using two register operands is executed and the result is stored back to the destinationregister
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
50
Figure 9-3 Single Cycle ALU Operation
953 Status RegisterThe Status register (CPUSREG) contains information about the result of the most recently executedarithmetic or logic instruction This information can be used for altering program flow in order to performconditional operationsNote CPUSREG is updated after all ALU operations as specified in the Instruction Set Summary
This will in many cases remove the need for using the dedicated compare instructions resulting in fasterand more compact code
CPUSREG is not automatically storedrestored when enteringreturning from an interrupt service routineMaintaining the status register between context switches must therefore be handled by user definedsoftware
CPUSREG is accessible in the IO memory space
Related LinksInstruction Set Summary on page 537
954 Stack and Stack PointerThe Stack is used for storing return addresses after interrupts and subroutine calls It can also be used forstoring temporary data The Stack Pointer (SP) always point to the top of the Stack The SP is defined bythe Stack Pointer bits (SP) in the Stack Pointer register (CPUSP) CPUSP is implemented as two 8-bitregisters that are accessible in the IO memory space
Data is pushed and popped from the Stack using the PUSH and POP instructions The Stack grows fromhigher to lower memory locations This implies that pushing data onto the Stack decreases the SP andpopping data off the Stack increases the SP The Stack Pointer is automatically set to the highest addressof the internal SRAM after Reset If the Stack is changed it must be set to point above address 0x2000and it must be defined before both any subroutine calls are executed and before interrupts are enabled
During interrupts or subroutine calls the return address is automatically pushed on the Stack as a wordpointer The return address consists of two bytes and the least significant byte is pushed on the Stack first(at the higher address) The return address is popped off the Stack when returning from interrupts usingthe RETI instruction and from subroutine calls using the RET instruction The return address is saved onthe Stack as a word pointer As example a byte pointer return address of 0x0006 is saved on the Stackas 0x0003 (shifted one bit to the right) pointing to the fourth 16-bit instruction word in the programmemory
The SP is decremented by 1 when data is pushed on the Stack with the PUSH instruction andincremented by 1 when data is popped off the Stack using the POP instruction
To prevent corruption when updating the Stack pointer from software a write to SPL will automaticallydisable interrupts for up to four instructions or until the next IO memory write
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
51
955 Register FileThe register file consists of 32x 8-bit general purpose working registers with single clock cycle accesstime The register file supports the following inputoutput schemes
bull One 8-bit output operand and one 8-bit result inputbull Two 8-bit output operands and one 8-bit result inputbull Two 8-bit output operands and one 16-bit result inputbull One 16-bit output operand and one 16-bit result input
Six of the 32 registers can be used as three 16-bit address register pointers for data space addressingenabling efficient address calculations One of these address pointers can also be used as an addresspointer for lookup tables in Flash program memory
Figure 9-4 AVR CPU General Purpose Working Registers
7 0R0R1R2
R13R14R15R16R17
R26R27R28R29R30R31
Addr0x000x010x02
0x0D0x0E0x0F0x100x11
0x1A0x1B0x1C0x1D0x1E0x1F
X-register Low ByteX-register High ByteY-register Low ByteY-register High ByteZ-register Low ByteZ-register High Byte
The register file is located in a separate address space so the registers are not accessible as datamemory
9551 The X- Y- and Z- RegistersRegisters R26R31 have added functions besides their general-purpose usage
These registers can form 16-bit address pointers for addressing data memory These three addressregisters are called the X-register Y-register and Z-register The Z-register can also be used as anaddress pointer to read from andor write to the Flash program memory signature and user rows fusesand lock bits
Figure 9-5 The X- Y- and Z-registersBit (individually)
X-register
Bit (X-register)
7 0 7 0
15 8 7 0
R27 R26
XH XL
Bit (individually)
Y-register
Bit (Y-register)
7 0 7 0
15 8 7 0
R29 R28
YH YL
Bit (individually)
Z-register
Bit (Z-register)
7 0 7 0
15 8 7 0
R31 R30
ZH ZL
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
52
The lowest register address holds the least-significant byte (LSB) and the highest register address holdsthe most-significant byte (MSB) In the different addressing modes these address registers function asfixed displacement automatic increment and automatic decrement
Related LinksInstruction Set Summary on page 537
956 Accessing 16-bit RegistersThe AVR data bus is 8 bits wide and so accessing 16-bit registers requires atomic operations Theseregisters must be byte-accessed using two read or write operations 16-bit registers are connected to the8-bit bus and a temporary register using a 16-bit bus
For a write operation the low byte of the 16-bit register must be written before the high byte The low byteis then written into the temporary register When the high byte of the 16-bit register is written thetemporary register is copied into the low byte of the 16-bit register in the same clock cycle
For a read operation the low byte of the 16-bit register must be read before the high byte When the lowbyte register is read by the CPU the high byte of the 16-bit register is copied into the temporary registerin the same clock cycle as the low byte is read When the high byte is read it is then read from thetemporary register
This ensures that the low and high bytes of 16-bit registers are always accessed simultaneously whenreading or writing the register
Interrupts can corrupt the timed sequence if an interrupt is triggered and accesses the same 16-bitregister during an atomic 16-bit readwrite operation To prevent this interrupts can be disabled whenwriting or reading 16-bit registers
The temporary registers can also be read and written directly from user software
957 CCP - Configuration Change ProtectionSystem critical IO register settings are protected from accidental modification Flash self-programming(via store to NVM controller) is protected from accidental execution This is handled globally by theconfiguration change protection (CCP) register
Changes to the protected IO registers or bits or execution of protected instructions are only possibleafter the CPU writes a signature to the CCP register The different signatures are listed in the descriptionof the CCP register (CPUCCP)
There are two modes of operation one for protected IO registers and one for the protected self-programming
Related LinksCCP on page 56
9571 Sequence for Write Operation to Configuration Change Protected IO RegistersIn order to write to registers protected by CCP these steps are required
1 The application code writes the signature that enables change of protected IO registers to the CCPbit field in the CPUCCP register
2 Within four instructions the application code must write the appropriate data to the protectedregisterNote Most protected registers also contain a write enablechange enablelock bit This bit must bewritten to 1 in the same operation as the data are written
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
53
The protected change is immediately disabled if the CPU performs write operations to the IOregister or data memory if load or store accesses to Flash NVMCTRL EEPROM are conducted orif the SLEEP instruction is executed
9572 Sequence for Execution of Self-ProgrammingIn order to execute self-programming (the execution of writes to the NVM controllers command register)these steps are required
1 The application code temporary enables self-programming by writing the SPM signature to the CCPregister (CPUCCP)
2 Within four instructions the application code must execute the appropriate instruction Theprotected change is immediately disabled if the CPU performs accesses to the Flash NVMCTRLor EEPROM or if the SLEEP instruction is executed
Once the correct signature is written by the CPU interrupts will be ignored for the duration of theconfiguration change enable period Any interrupt request (including non-maskable interrupts) during theCCP period will set the corresponding interrupt flag as normal and the request is kept pending After theCCP period is completed any pending interrupts are executed according to their level and priority
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
54
96 Register Summary
Offset Name Bit Pos
0x04 CCP 70 CCP[70]
0x05
0x0C
Reserved
0x0DSP
70 SP[70]
0x0E 158 SP[158]
0x0F SREG 70 I T H S V N Z C
97 Register Description
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
55
971 Configuration Change Protection
Name CCPOffset 0x04Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 CCP[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash CCP[70] Configuration Change ProtectionWriting the correct signature to this bit field allows changing protected IO registers or executing protectedinstructions within the next four CPU instructions
All interrupts are ignored during these cycles After these cycles interrupts will automatically be handledagain by the CPU and any pending interrupts will be executed according to their level and priority
When the protected IO register signature is written CCP[0] will read as 1 as long as the CCP feature isenabled
When the protected self-programming signature is written CCP[1] will read as 1 as long as the CCPfeature is enabled
CCP[72] will always read as zero
Value Name Description0x9D SPM Allow Self-Programming
0xD8 IOREG Un-protect protected IO registers
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
56
972 Stack PointerThe CPUSP holds the Stack Pointer (SP) that points to the top of the Stack After Reset the StackPointer points to the highest internal SRAM address
Only the number of bits required to address the available data memory including external memory (up to64KB) is implemented for each device Unused bits will always read as zero
The CPUSPL and CPUSPH register pair represents the 16-bit value CPUSP The low byte [70] (suffixL) is accessible at the original offset The high byte [158] (suffix H) can be accessed at offset + 0x01 Formore details on reading and writing 16-bit registers refer to Accessing 16-bit RegistersNote To prevent corruption when updating the Stack Pointer from software a write to CPUSPL willautomatically disable interrupts for the next four instructions or until the next IO memory write
Name SPOffset 0x0DReset 0xxxxxProperty
-
Bit 15 14 13 12 11 10 9 8 SP[158]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0 SP[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 158 ndash SP[158] Stack Pointer high byteThese bits hold the MSB of the 16-bit register
Bits 70 ndash SP[70] Stack Pointer low byteThese bits hold the LSB of the 16-bit register
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
57
973 Status RegisterThe Status register contains information about the result of the most recently executed arithmetic or logicinstruction For details about the bits in this register and how they are affected by the differentinstructions see the Instruction Set Summary
Name SREGOffset 0x0FReset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 I T H S V N Z C
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bit 7 ndash I Global Interrupt EnableWriting a 1 to this bit enable interrupts on the device
Writing a 0 to this bit disables interrupts on the device independent of the individual interrupt enablesettings of the peripherals
This bit is not cleared by hardware after an interrupt has occurred
This bit can be set and cleared by the application with the SEI and CLI instructions
Changing the I flag through the IO-register result in a one-cycle wait state on the access
Bit 6 ndash T Bit Copy StorageThe bit copy instructions bit load (BLD) and bit store (BST) use the T bit as source or destination for theoperated bit
A bit from a register in the register file can be copied into this bit by the BST instruction and this bit can becopied into a bit in a register in the register file by the BLD instruction
Bit 5 ndash H Half Carry FlagThis bit indicates a half carry in some arithmetic operations Half carry is useful in BCD arithmetic
Bit 4 ndash S Sign Bit S = N oplus VThe sign bit (S) is always an exclusive or (xor) between the negative flag (N) and the tworsquos complementoverflow flag (V)
Bit 3 ndash V Tworsquos Complement Overflow FlagThe tworsquos complement overflow flag (V) supports tworsquos complement arithmetic
Bit 2 ndash N Negative FlagThe negative flag (N) indicates a negative result in an arithmetic or logic operation
Bit 1 ndash Z Zero FlagThe zero flag (Z) indicates a zero result in an arithmetic or logic operation
Bit 0 ndash C Carry FlagThe carry flag (C) indicates a carry in an arithmetic or logic operation
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
58
10 NVMCTRL - Non Volatile Memory Controller
101 OverviewThe NVM Controller (NVMCTRL) is the interface between the device the Flash and the EEPROM TheFlash and EEPROM are reprogrammable memory blocks that retain their values even with power off TheFlash is mainly used for program storage but can also be used for data storage The EEPROM is usedfor data storage and can be programmed while the CPU is running the program from the Flash
102 Featuresbull Unified memorybull In-system programmablebull Self-programming and boot loader supportbull Interface to Sleep Controller for power-down of Flash blocks in sleep modesbull Configurable sections for write protection
ndash Boot section for boot loader code or application codendash Application code section for application codendash Application data section for application code or data storage
bull Signature row for factory-programmed datandash ID for each device typendash Serial number for each devicendash Calibration bytes for factory calibrated peripherals
bull User Row for application datandash 32 bytes in sizendash Can be read and written from softwarendash Can be written from UPDI on locked devicendash Content is kept after chip erase
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
59
103 Block DiagramFigure 10-1 NVMCTRL Block Diagram
Flash
EEPROM
NVM
Blo
ck
NVMCTRL
Bus matrix
CPU PDI
104 Product DependenciesIn order to use this peripheral other parts of the system must be configured correctly as described below
Table 10-1 NVMCTRL Product Dependencies
Dependency Applicable Peripheral
Clocks Yes CLKCTRL
IO Lines and Connections No -
Interrupts Yes CPUINT
Events No -
Debug Yes UPDI
Related LinksClocks on page 61Interrupts on page 61Debug Operation on page 61
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
60
1041 ClocksThis peripheral always runs on the NVM clock (CLK_NVM) It will request this clock also in sleep modes ifa writeerase is ongoing
Note On this device CLK_CPU CLK_NVM and CLK_PER share the prescaler setting and hencealways have the same frequency
Related LinksCLKCTRL - Clock Controller on page 75
1042 IO Lines and ConnectionsNot applicable
1043 InterruptsUsing the interrupts of this peripheral requires the Interrupt Controller to be configured first
Related LinksCPUINT - CPU Interrupt Controller on page 104SREG on page 58Interrupts on page 144
1044 EventsNot applicable
1045 Debug OperationWhen run-time debugging this peripheral will continue normal operation Halting the CPU in debuggingmode will halt normal operation of the peripheral
If the peripheral is configured to require periodical service by the CPU through interrupts or similarimproper operation or data loss may result during halted debugging
Related LinksUPDI - Unified Program and Debug Interface on page 502
105 Functional Description
1051 FlashEEPROM Memory OrganizationThe Flash and EEPROM are divided into a set of pages A page is the basic unit addressed whenprogramming the Flash and EEPROM
For the Flash it is only possible to write or erase a whole page at a time while for the EEPROM it ispossible to write and erase one byte at a time A page consists of several words The Flash can bedivided into three sections of up to 256 pages for different security
Related LinksFlash Write Protection on page 64
1052 User PageThe User Page is an additional page outside the regular FlashEEPROM array This page can be used tostore various data such as calibration data and serial numbers This page is not erased by regular chiperase The User Page is written as normal EEPROM but there is a special mode to write this page withthe UPDI on a locked device
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
61
1053 ReadReading of the Flash and EEPROM is done by using the normal load instructions with the correct addressas shown in the memory map Reading of the arrays while a write or erase is already ongoing will result ina wait on the bus and the instruction will hang until the ongoing operation is complete
1054 Write OperationAll write operations to Flash and EEPROM must go through an internal buffer called the page buffer Thepage buffer contains the same number of bytes as an NVM page The page buffer can be cleared with acommand in the NVM control register and it is automatically cleared after each write command Whenthe page buffer is cleared all bits are set and all further writes to the page buffer will do an AND operationwith the byte and the current contents of the page buffer
When writing to an address in the Flash EEPROM or extra rows the write goes to the correct address inthe page buffer The address in the page buffer will be set by the least significant bits in the address Afterall writes are done to the page buffer the content of the page buffer can be written to the array with awrite command The page buffer will be automatically cleared after each write command so it is readyfor the next data
The page buffer is shared between the EEPROM and Flash so if the page buffer is written with oneaddress in Flash and another in EEPROM a following write command will only clear the page bufferand set the Write Error flag (WRERROR) in the Status register (NVMCTRLSTATUS)
Procedure for Page Writesbull Fill the page buffer by writing to the corresponding page address in the memory-mapped data
spacebull Write the page buffer to memory with the erase-write page command
ndash Alternatively issue an erase page command first then fill the page buffer and then use thewrite page command
bull The Flash Busy flag (FBUSY) or EEPROM Busy flag (EEBUSY) in NVMCTRLSTATUS will be 1while the programming is in progress All access to the array will be stalled
10541 Write FlashAll writes go through the page buffer To write to the page buffer write to the wanted Flash address in thememory map and the data will go to the page buffer The least significant bits of the address are used toselect the correct byte in the page buffer When the page buffer is filled with the correct data the contentsof the page buffer can be written to the Flash with the command bits in the control register The pagebuffer will be automatically cleared after a write command When writing Flash the whole page in theFlash will be writtenerased when the writeerase command is executed not just the bytes written
If data is written outside the current page the address will wrap around and the content of the pagebuffer will be an AND operation of the two writes to the same address
10542 EEPROM WriteAll write operations to EEPROM must go through the page buffer When writing to the EEPROMaddresses the data will go to the page buffer The least significant bits of the address will be used toselect which byte in the page buffer to write to When the wanted number of bytes are written they can bewritten to the EEPROM with a write command For the EEPROM only the bytes changed in the pagebuffer will be changed in the array
If writing to an address outside the wanted page the content of the page buffer will be a logical ANDbetween the two writes
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
62
EEREADY Interrupt The peripheral provides an EEPROM Ready interrupt (EEREADY) with thecorresponding EEREADY flag in the Interrupt Flags register (NVMCTRLINTFLAGS) This flag is setwhen the EEPROM is ready for new writeerase operations
The interrupt is enabled by writing a 1 to the EEREADY bit in the Interrupt Control register(NVMCTRLINTCTRL) When the EEREADY interrupt is enabled it will immediately request an interruptand it will continue to request interrupts continuously - even if no EEPROM writes are initiated
To use the EEREADY interrupt feature the EEPROM interrupt must be enabled immediately after anEEPROM write is initiated and then disabled again
1055 CommandsReading of the FlashEEPROM and writing of the page buffer is handled with normal loadstoreinstructions Other operations such as writing and erasing the memory arrays are handled by commandsin the NVM
To execute a command in the NVM1 Write the NVM command unlock to the Configuration Change Protection register in the CPU
(CPUCCP)2 Write the desired command value to the CMD bits in the Control A register (NVMCTRLCTRLA)
within the next 4 cycles
10551 Write CommandThe write command of the Flash controller writes the content of the page buffer to the Flash orEEPROM The address used for this operation is stored in the Address register (NVMCTRLADDR) Thisregister will be automatically updated with each page write The higher bits of the address are used toselect which page to write to The lower bits of the address are used to decode the location inside thepage
If the write is to the Flash the CPU will stop executing code as long as the Flash is busy with the writeoperation If the write is to the EEPROM the CPU can continue executing code while the operation isongoing
The page buffer will be automatically cleared after the operation
If writing the Flash the memory sections have to be set up correctly prior to self-programming the Flashhas to be divided into two or three sections using with the FUSEBOOTEND and FUSEAPPEND fusessince only code in the BOOT section can write to the Application code section and code in the BOOT andApplication sections can write to Application Data
Related LinksFlash Write Protection on page 64
10552 Erase CommandThe erase command erases the current page There must be one byte written in the page buffer so theerase command can take effect
For erasing the Flash first write to one address in the desired page then execute the command Thewhole page in the Flash will then be erased The CPU will be halted while the erase is ongoing
For the EEPROM only the bytes written in the page buffer will be erased when the command isexecuted To erase a specific byte write to its corresponding address before executing the commandThe CPU can continue running code while the operation is ongoing
The page buffer will be automatically cleared after the operation is finished
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
63
10553 Erase-Write OperationThe erase-write command is a combination of the erase and write command but without clearingthe page buffer after the erase command The erase-write operation first erases the selected pagethen it writes the content of the page buffer to the same page
When executed on the Flash the CPU will be halted when the operations are ongoing When executedon EEPROM the CPU can continue executing code
The page buffer will be automatically cleared after the operation
10554 Page Buffer Clear CommandThe page buffer clear command clears the page buffer The contents of the page buffer will be all-ones after the operation The CPU will be halted when the operation executes (7 CPU cycles)
10555 Chip Erase CommandThe chip erase command erases the Flash and the EEPROM The EEPROM is unaltered if theEEPROM Save During Chip Erase (EESAVE) in FUSESYSCFG0 is set The memory will be all-onesafter the operation
10556 EEPROM Erase CommandThe EEPROM erase command erases the EEPROM The EEPROM will be all-ones after the operationThe CPU will be halted while the EEPROM is being erased
10557 Fuse Write CommandThe fuse write command writes the fuses It can only be used by the UPDI the CPU cannot start thiscommand
Follow this procedure to use this commandbull Write the address of the fuse to the Address register (NVMCTRLADDR)bull Write the data to be written to the fuse to the Data register (NVMCTRLDATA)bull Execute the fuse write commandbull After the fuse is written a Reset is required for the updated value to take effect
1056 Flash Write ProtectionThe Flash array can be divided into three different sections for write protection The three differentsections are BOOT application code (APPCODE) and application data (APPDATA)
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
64
Figure 10-2 Flash Sections
FLAS HSTART 0x8000
BOOTENDgt0 0x8000+BOOTEND256
BOOT
APP ENDgt0 0x8000+APP END256
AP PLICATION CODE
AP PLICATION DATA
Section SizesThe sizes of these sections are set by the Boot Section End fuse (FUSEBOOTEND) and ApplicationCode Section End fuse (FUSEAPPEND)
The fuses select the section sizes in blocks of 256 bytes As shown in Figure 10-2 the BOOT sectionstretches from the start of the Flash until BOOTEND The APPCODE section runs from right afterBOOTEND until APPEND The remaining area is the APPDATA section If one of the fuses is written to0x00 the entire Flash becomes the according section When both fuses are written to 0x00 the entireFlash becomes BOOT Section
Inter-Section Write ProtectionBetween the three Flash sections a directional write protection is implemented
bull Code in the BOOT section can write to APPCODE and APPDATAbull Code in APPCODE can write to APPDATAbull Code in APPDATA cannot write to Flash or EEPROM
Boot Section Lock and Application Code Section Write ProtectionThe two lock bits (APCWP and BOOTLOCK in NVMCTRLCTRLB) can be set to lock further updates ofthe respective APPCODE or BOOT section until the next ResetNote The CPU can never write to the BOOT section BOOTLOCK in NVMCTRLCTRLB prevents readsand execution of code from the BOOT section
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
65
1057 InterruptsTable 10-2 Available Interrupt Vectors and Sources
Offset Name Vector Description Conditions
0x00 EEREADY NVM The EEPROM is ready for new writeerase operations
When an interrupt condition occurs the corresponding Interrupt Flag is set in the Interrupt Flags registerof the peripheral (peripheralINTFLAGS)
An interrupt source is enabled or disabled by writing to the corresponding bit in the peripherals InterruptEnable register (peripheralINTEN)
An interrupt request is generated when the corresponding interrupt source is enabled and the InterruptFlag is set The interrupt request remains active until the Interrupt Flag is cleared See the peripheralsINTFLAGS register for details on how to clear Interrupt Flags
Note Interrupt requests are only generated when Interrupts are enabled globally
1058 Sleep Mode OperationIf there is no ongoing write operation the NVMCTRL will enter sleep mode when the system enters sleepmode
If a write operation is ongoing when the system is issued to enter a sleep mode the NVM block the NVMController and the system clock will remain on until the write is finished This is valid for all sleep modesincluding Power Down sleep mode
The EEPROM Ready interrupt will wake up the device only from Idle sleep mode
1059 Configuration Change ProtectionThis peripheral has registers that are under Configuration Change Protection (CCP) In order to write tothese a certain key must be written to the CPUCCP register first followed by a write access to theprotected bits within four CPU instructions
It is possible to try writing to these registers any time but the values are not altered
The following registers are under CCP
Table 10-3 NVMCTRL - Registers under Configuration Change Protection
Register Key
NVMCTRLCTRLA SPM
Related LinksSequence for Execution of Self-Programming on page 54
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
66
106 Register Summary - NVMCTRL
Offset Name Bit Pos
0x00 CTRLA 70 CMD[20]
0x01 CTRLB 70 BOOTLOCK APCWP
0x02 STATUS 70 WRERROR EEBUSY FBUSY
0x03 INTCTRL 70 EEREADY
0x04 INTFLAGS 70 EEREADY
0x05 Reserved
0x06DATA
70 DATA[70]
0x07 158 DATA[158]
0x08ADDR
70 ADDR[70]
0x09 158 ADDR[158]
107 Register Description
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
67
1071 Control A
Name CTRLAOffset 0x00Reset 0x00Property
Configuration Change Protection
Bit 7 6 5 4 3 2 1 0 CMD[20]
Access RW RW RW Reset 0 0 0
Bits 20 ndash CMD[20] CommandWrite this bit field to issue a command The Configuration Change Protection key for self-programming(SPM) has to be written within four instructions before this write
Value Name Description0x0 - No command
0x1 WP Write page buffer to memory (NVMCTRLADDR selects which memory)
0x2 ER Erase page (NVMCTRLADDR selects which memory)
0x3 ERWP Erase and write page (NVMCTRLADDR selects which memory)
0x4 PBC Page buffer clear
0x5 CHER Chip erase erase Flash and EEPROM (unless EESAVE in FUSESYSCFG is 1)
0x6 EEER EEPROM Erase
0x7 WFU Write fuse (only accessible through UPDI)
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
68
1072 Control B
Name CTRLBOffset 0x01Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 BOOTLOCK APCWP
Access RW RW Reset 0 0
Bit 1 ndash BOOTLOCK Boot Section LockWriting a 1 to this bit locks the boot section from read and instruction fetch
If this bit is 1 a read from the boot section will return 0 A fetch from the boot section will also return 0as instruction
This bit can only be written from the boot section It can only be cleared to 0 by a Reset
This bit will only take effect when the boot section is left the first time after the bit is written
Bit 0 ndash APCWP Application Code Section Write ProtectionWriting a 1 to this bit protects the application code section from further writes
This bit can only be written to 1 it is cleared to 0 only by Reset
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
69
1073 Status
Name STATUSOffset 0x02Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 WRERROR EEBUSY FBUSY
Access RW RW RW Reset 0 0 0
Bit 2 ndash WRERROR Write ErrorThis bit will read 1 when a write error has happened A write error could be writing to different addressesbefore doing a page write or writing to a protected area This bit is valid for the last operation
Bit 1 ndash EEBUSY EEPROM BusyThis bit will read 1 when the EEPROM is busy with a command
Bit 0 ndash FBUSY Flash BusyThis bit will read 1 when the Flash is busy with a command
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
70
1074 Interrupt Control
Name INTCTRLOffset 0x03Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 EEREADY
Access RW Reset 0
Bit 0 ndash EEREADY EEPROM Ready InterruptWriting a 1 to this bit enables the interrupt which indicates that the EEPROM is ready for new writeeraseoperations
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
71
1075 Interrupt Flags
Name INTFLAGSOffset 0x04Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 EEREADY
Access RW Reset 0
Bit 0 ndash EEREADY EEREADY Interrupt FlagInterrupt flag for the EEPROM interrupt This bit is cleared by writing a 1 to it
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
72
1076 DataThe NVMCTRLDATAL and NVMCTRLDATAH register pair represents the 16-bit valueNVMCTRLDATA The low byte [70] (suffix L) is accessible at the original offset The high byte [158](suffix H) can be accessed at offset + 0x01 For more details on reading and writing 16-bit registers referto Accessing 16-bit Registers
Name DATAOffset 0x06Reset 0x00Property
-
Bit 15 14 13 12 11 10 9 8 DATA[158]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0 DATA[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 150 ndash DATA[150] Data RegisterData register shared between read of FlashEEPROMNVM registers and fuse write
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
73
1077 AddressThe NVMCTRLADDRL and NVMCTRLADDRH register pair represents the 16-bit valueNVMCTRLADDR The low byte [70] (suffix L) is accessible at the original offset The high byte [158](suffix H) can be accessed at offset + 0x01 For more details on reading and writing 16-bit registers referto Accessing 16-bit Registers
Name ADDROffset 0x08Reset 0x00Property
-
Bit 15 14 13 12 11 10 9 8 ADDR[158]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0 ADDR[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 150 ndash ADDR[150] AddressAddress used for page writeerase and fuse write The address is automatically updated with each pagebuffer write
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
74
11 CLKCTRL - Clock Controller
111 OverviewThe Clock Controller peripheral (CLKCTRL) controls distributes and prescales the clock signals from theavailable oscillators The CLKCTRL supports internal and external clock sources
The Main Clock (CLK_MAIN) is used by the CPU RAM and all peripherals connected to the IO bus TheMain Clock source can be selected and prescaled Some peripherals can share the same clock source asthe Main Clock or run asynchronously to the Main Clock domain
112 Featuresbull All clocks and clock sources are automatically enabled when requested by peripheralsbull Internal oscillators
ndash Fusible 1620MHz oscillator (OSC20M)ndash 32KHz Ultra Low Power oscillator (OSCULP32K)
bull External clock optionsndash 32768kHz crystal oscillator (XOSC32K)ndash External clock
bull Main clock featuresndash Safe run-time switchingndash Prescaler with 1x to 64x division in 12 different settings
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
75
113 Block Diagram - CLKCTRLFigure 11-1 CLKCTRL Block Diagram
CPURAMNVM TCDBODRTC
1620MHzint Oscillator
WDT
32KHz ULPInt Oscillator
32768kHzext Crystal Osc
DIV32
TOSC2 TOSC1
RTCCLKSEL
CLK_RTCCLK_PER
CLK_MAIN
CLK_WDT CLK_BOD CLK_TCD
TCDCLKCSEL
Main Clock Prescaler
Main Clock Switch
CLKI
INTPRESCALER
XOSC32KSEL
CLK_CPU
CLK_NVM
OtherPeripherals
CLKOUT
OSC20M
XOSC32K
EXTCLK
OSC32KULP
The clock system consists of the Main Clock and other asynchronous clocksbull Main Clock
This clock is used by the CPU RAM Flash the IO bus and all peripherals connected to the IO busIt is always running in Active and Idle sleep mode and can be running in Standby sleep mode ifrequested
The main clock CLK_MAIN is prescaled and distributed by the Clock Controllerbull CLK_CPU is used by the CPU and SRAMbull CLK_NVM is used by the NVMCTRL peripheral to access the non-volatile memorybull CLK_PER is used by all peripherals that are not listed under asynchronous clocksbull Note On this device CLK_CPU CLK_NVM and CLK_PER share the prescaler setting and
hence always have the same frequencybull Clocks running asynchronously to the Main Clock domain
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
76
ndash CLK_RTC is used by the RTCPIT It will be requested when the RTCPIT is enabled Theclock source for CLK_RTC should only be changed if the peripheral is disabled
ndash CLK_WDT is used by the WDT It will be requested when the WDT is enabledndash CLK_BOD is used by the BOD It will be requested when the BOD is enabled in Sampled
Modendash CLK_TCD is used by the TCD It will be requested when the TCD is enabled The clock
source can only be changed if the peripheral is disabled
The clock source for the for the Main Clock domain is configured by writing to the Clock Select bits(CKSEL) in the Main Clock Control A register (CLKCTRLMCLKCTRLA) The asynchronous clocksources are configured by registers in the respective peripheral
114 Signal Description
Signal Type Description
CLKOUT Digital output CLK_PER output
Related LinksIO Multiplexing and Considerations on page 18
115 Functional Description
1151 Principle of OperationThe Clock Controller is based on an automatic clock request system implemented in all peripherals onthe device The peripherals will automatically request the clocks needed If multiple clock sources areavailable the request is routed to the correct clock source
1152 Sleep Mode OperationWhen a clock source is not usedrequested it will turn off It is possible to request an clock source directlyby writing a 1 to the Run Standby bit (RUNSTDBY) in the respective oscillators Control A register(CLKCTRL[osc]CTRLA) This will cause the oscillator to run constantly except for Power Down sleepmode Additionally when this bit is written to 1 the oscillator startup time is eliminated when the clocksource is requested by a peripheral
The Main Clock will always run in Active and Idle sleep mode In Standby sleep mode the Main Clock willonly run if any peripheral is requesting it and the Run in Standby bit (RUNSTDBY) in the respectiveoscillators Control A register (CLKCTRL[osc]CTRLA) is written to 1
In Power Down sleep mode the Main Clock will stop after all NVM operations are completed
1153 Main Clock Selection and PrescalerAll internal oscillators can be used as the Main Clock source for CLK_MAIN The Main Clock source isselectable from software and can be safely changed during normal operation
Built-in hardware protection prevents unsafe clock switching
Upon selection of an external clock source a switch to the chosen clock source will only occur if edgesare detected indicating it is stable If the new clock is not stable the switch will not occur and it will not bepossible to change to another clock source again without executing a Reset
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
77
An ongoing clock source switch is indicated by the System Oscillator Changing flag (SOSC) in the MainClock Status register (CLKCTRLMCLKSTATUS) The stability of the external clock sources is indicatedby the respective status flags (EXTS and XOSC32KS in CLKCTRLMCLKSTATUS)
Caution If an external clock source fails while used as CLK_MAIN source only the WDT canprovide a mechanism to switch back via System Reset
CLK_MAIN is fed into a prescaler before it is used by the peripherals (CLK_PER) in the device Theprescaler has only one stage and can divide CLK_MAIN by a factor from 1 to 64
Figure 11-2 Main Clock and Prescaler
(Div 1 2 4 8 16 32 64 6 10 24 48)
20MHz Osc
32KHz Osc
32KHz crystal Osc
External clock
CLK_MAIN CLK_PERMain Clock Prescaler
The Main Clock and Prescaler configuration registers (CLKCTRLMCLKCTRLACLKCTRLMCLKCTRLB) are protected by the Configuration Change Protection Mechanism employing atimed write procedure for changing these registers
Note On this device CLK_CPU CLK_NVM and CLK_PER share the prescaler setting and hencealways have the same frequency
Related LinksCCP - Configuration Change Protection on page 53
1154 Main Clock after Reset
After any Reset CLK_MAIN is provided by the 1620MHz oscillator (OSC20M) and with a Prescalerdivision factor of 6 Since the actual frequency of the OSC20M is determined by the Frequency Select bits(FREQSEL) of the Oscillator Configuration fuse (FUSEOSCCFG) these frequencies are possible afterResetTable 11-1 Peripheral Clock Frequencies after Reset
CLK_MAINas per FREQSEL in FUSEOSCCFG
Resulting CLK_PER
16MHz 266MHz
20MHz 333MHz
See the OSC20M description for further details
Related Links1620MHz Oscillator (OSC20M) on page 79
1155 Clock SourcesAll internal clock sources are enabled automatically when they are requested by a peripheral The crystaloscillator based on an external crystal must be enabled by writing a 1 to the ENABLE bit in the 32KHzCrystal Oscillator Control A register (CLKCTRLXOSC32KCTRLA) before it can serve as clock source
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
78
The respective Oscillator Status bits in the Main Clock Status register (CLKCTRLMCLKSTATUS) indicatewhether the clock source is running and stable
Related LinksFUSES - Configuration and User Fuses on page 23CCP - Configuration Change Protection on page 53
11551 Internal OscillatorsThe internal oscillators do not require any external components to run See the related links for accuracyand electrical characteristics
Related LinksElectrical Characteristics on page 544
1620MHz Oscillator (OSC20M)This oscillator can operate at multiple frequencies selected by the value of the Frequency Select bits(FREQSEL) in the Oscillator Configuration fuse (FUSEOSCCFG) The center frequencies are
bull 16MHzbull 20MHz
After a System Reset FUSEOSCCFG determines the initial frequency of CLK_MAIN
The OSC20M is calibrated at startup It has two different calibration bit fields The Calibration bit field(CAL20M) in the Calibration A register (CLKCTRLOSC20MCALIBA) enables calibration around thecurrent center frequency The Oscillator Temperature Coefficient Calibration bit field (TEMPCAL20M) inthe Calibration B register (CLKCTRLOSC20MCALIBB) enables adjustment of the slope of thetemperature drift compensation
The oscillator calibration can be locked by the Oscillator Lock (OSCLOCK) fuse (FUSEOSCCFG) Whenthis fuse is 1 it is not possible to change the calibration The calibration is also locked if this oscillator isused as Main Clock source and the Lock Enable bit (LOCKEN) in the Control B register(CLKCTRLOSC20MCALIBB) is 1
The calibration bits are also protected by the Configuration Change Protection Mechanism requiring atimed write procedure for changing the Main Clock and Prescaler settings
The startup time of this oscillator is analog startup time plus 4 oscillator cycles
Related LinksElectrical Characteristics on page 544FUSES - Configuration and User Fuses on page 23Configuration Change Protection on page 80Main Clock after Reset on page 78
32KHz Oscillator (OSCULP32K)The 32KHz oscillator is optimized for Ultra Low Power (ULP) operation Power consumption is decreasedat the cost of decreased accuracy compared to an external crystal oscillator
This oscillator also provides the 1KHz signal for the Real Time Counter (RTC) the Watchdog Timer(WDT) and the Brownout Detector (BOD)
Related LinksElectrical Characteristics on page 544BOD - Brownout Detector on page 163WDT - Watchdog Timer on page 179
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
79
RTC - Real Time Counter on page 312
11552 External Clock SourcesThese external clock sources are available
bull The CLKI pin can be used as input for an external clock signal (EXTCLK)bull The TOSC1 and TOSC2 pins are dedicated to driving a 32768kHz crystal oscillator (XOSC32K)bull Instead of a crystal oscillator TOSC1 can be configured to accept an external clock source running
at 32KHz
32768kHz Crystal Oscillator (XOSC32K)This oscillator supports two input options Either a crystal is connected to the pins TOSC1 and TOSC2 oran external clock running at 32KHz is connected to TOSC1 The input option must be configured bywriting the Source Select bit (SEL) in the XOSC32K Control A register (CLKCTRLXOSC32KCTRLA)
The XOSC32K is enabled by writing a 1 to its ENABLE bit in CLKCTRLXOSC32KCTRLA Whenenabled the configuration of the GPIO pins used by the XOSC32K is overridden as TOSC1 TOSC2 pinsThe Enable bit needs to be set for the oscillator to start running when requested
The startup time of a given crystal oscillator can be accommodated by writing to the Crystal Startup Timebits (CSUT) in CLKCTRLXOSC32KCTRLA
When XOSC32K is configured to use an external clock on TOSC1 the startup time is fixed to 2 cycles
Note The XOSC32K does not have any calibration mechanism
External Clock (EXTCLK)The External Clock uses the input pin CLKI This GPIO pin is automatically configured for EXTCLK if anyperipheral is requesting this clock
This clock source has a startup time of 2 cycles when first requested
1156 Configuration Change ProtectionThis peripheral has registers that are under Configuration Change Protection (CCP) In order to write tothese a certain key must be written to the CPUCCP register first followed by a write access to theprotected bits within four CPU instructions
It is possible to try writing to these registers any time but the values are not altered
The following registers are under CCP
Table 11-2 CLKCTRL - Registers under Configuration Change Protection
Register Key
CLKCTRLMCLKCTRLB IOREG
CLKCTRLMCLKLOCK IOREG
Related LinksSequence for Write Operation to Configuration Change Protected IO Registers on page 53
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
80
116 Register Summary
Offset Name Bit Pos
0x00 MCLKCTRLA 70 CLKOUT CKSEL[10]
0x01 MCLKCTRLB 70 PDIV[30] PEN
0x02 MCLKLOCK 70 LOCKEN
0x03 MCLKSTATUS 70 EXTS XOSC32KS OSC32KS OSC20MS SOSC
0x04
0x0F
Reserved
0x10 OSC20MCTRLA 70 RUNSTDBY
0x11 OSC20MCALIBA 70 CAL20M[50]
0x12 OSC20MCALIBB 70 LOCK TEMPCAL20M[30]
0x13
0x17
Reserved
0x18 OSC32KCTRLA 70 RUNSTDBY
0x19
0x1B
Reserved
0x1C XOSC32KCTRLA 70 CSUT[10] SEL RUNSTDBY ENABLE
117 Register Description
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
81
1171 Main Clock Control A
Name MCLKCTRLAOffset 0x00Reset 0x00Property
Configuration Change Protection
Bit 7 6 5 4 3 2 1 0 CLKOUT CKSEL[10]
Access RW R R R R R RW RW Reset 0 0 0 0 0 0 0 0
Bit 7 ndash CLKOUT System Clock OutWhen this bit is set the system clock is output to CLKOUT pin
Bits 10 ndash CKSEL[10] Clock SelectThis bit field selects the source for the Main Clock (CLK_MAIN)
Value Name Description0x0 OSC20M 1620MHz internal oscillator
0x1 OSCULP32K 32KHz internal Ultra Low Power oscillator
0x2 XOSC32K 32768kHz external crystal oscillator
0x3 EXTCLK External clock
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
82
1172 Main Clock Control B
Name MCLKCTRLBOffset 0x01Reset 0x11Property
Configuration Change Protection
Bit 7 6 5 4 3 2 1 0 PDIV[30] PEN
Access R R R RW RW RW RW RW Reset 0 0 0 1 0 0 0 1
Bits 41 ndash PDIV[30] Prescaler DivisionIf the Prescaler Enable (PEN) bit is written to 1 these bits define the division ratio of the Main Clockprescaler
These bits can be written during run-time to vary the clock frequency of the system to suit the applicationrequirements
User software must ensure a correct configuration of input frequency (CLK_MAIN) and Prescaler settingssuch that the resulting frequency of CLK_PER never exceeds the allowed maximum (see ElectricalCharacteristics)
Value Description0x0 2
0x1 4
0x2 8
0x3 16
0x4 32
0x5 64
0x8 6
0x9 10
0xA 12
0xB 24
0xC 48
other 64
Bit 0 ndash PEN Prescaler EnableThis bit must be written 1 to enable the prescaler When enabled the division ratio is selected by thePDIV bit field
When this bit is written to 0 the Main Clock will pass through undivided (CLK_PER=CLK_MAIN)regardless of the value of PDIV
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
83
1173 Main Clock Lock
Name MCLKLOCKOffset 0x02Reset From FUSEOSCCFGProperty
Configuration Change Protection
Bit 7 6 5 4 3 2 1 0 LOCKEN
Access R R R R R R R RW Reset 0 0 0 0 0 0 0 0
Bit 0 ndash LOCKEN Lock EnableWriting this bit to 1 will lock the CLKCTRLMCLKCTRLA and CLKCTRLMCLKCTRLB registers and ifapplicable the calibration settings for the current Main Clock source from further software updates Oncelocked the CLKCTRLMCLKLOCK registers cannot be accessed until the next hardware Reset
This provides protection for the CLKCTRLMCLKCTRLA and CLKCTRLMCLKCTRLB registers andcalibration settings for the Main Clock source from unintentional modification by software
The Reset value of this bit is determined by the Oscillator Lock bit (OSCLOCK) in the OscillatorConfiguration fuse (FUSEOSCCFG)
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
84
1174 Main Clock Status
Name MCLKSTATUSOffset 0x03Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 EXTS XOSC32KS OSC32KS OSC20MS SOSC
Access R R R R R R R R Reset 0 0 0 0 0 0 0 0
Bit 7 ndash EXTS External Clock Status
Value Description0 EXTCLK on pin CLKI is not stable
1 EXTCLK on pin CLKI is stable
Bit 6 ndash XOSC32KS XOSC32K Status
Value Description0 XOSC32K is not stable
1 XOSC32K is stable
Bit 5 ndash OSC32KS OSCULP32K Status
Value Description0 OSCULP32K is not stable
1 OSCULP32K is stable
Bit 4 ndash OSC20MS OSC20M Status
Value Description0 OSC20M is not stable
1 OSC20M is stable
Bit 0 ndash SOSC System Oscillator Changing
Value Description0 The clock source for CLK_MAIN will change as soon as the new source is stable
1 The clock source for CLK_MAIN is not undergoing a switch
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
85
1175 1620MHz Oscillator Control A
Name OSC20MCTRLAOffset 0x10Reset 0x00Property
Configuration Change Protection
Bit 7 6 5 4 3 2 1 0 RUNSTDBY
Access R R R R R R RW R Reset 0 0 0 0 0 0 0 0
Bit 1 ndash RUNSTDBY Run StandbyThis bit enables the oscillator in Active Idle and Standby sleep modes
When not requested by peripherals no oscillator output is provided
It takes two cycles to open the clock gate after a request When this bit is written to 1 the oscillatorstartup time will be removed when the device wakes from Standby Sleep mode
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
86
1176 1620MHz Oscillator Calibration A
Name OSC20MCALIBAOffset 0x11Reset 0x9FProperty
Configuration Change Protection
Bit 7 6 5 4 3 2 1 0 CAL20M[50]
Access RW RW RW RW RW RW Reset 0 0 0 0 0 0
Bits 50 ndash CAL20M[50] CalibrationThese bits change the frequency around the current center frequency of the OSC20M for fine tuning
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
87
1177 1620MHz Oscillator Calibration B
Name OSC20MCALIBBOffset 0x12Reset From FUSEOSCCFGProperty
Configuration Change Protection
Bit 7 6 5 4 3 2 1 0 LOCK TEMPCAL20M[30]
Access R R R RW RW RW RW Reset 0 0 0 0 0 0 0
Bit 7 ndash LOCK Oscillator Calibration Locked by FuseWhen this bit is set the calibration settings in CLKCTRLOSC20MCALIBA andCLKCTRLOSC20MCALIBB cannot be changedThe Reset value of this bit is determined by the OSCLOCK bit in the Oscillator Configuration fuse(FUSEOSCCFG)
Bits 30 ndash TEMPCAL20M[30] Oscillator Temperature Coefficient CalibrationThese bits tune the slope of the temperature compensation
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
88
1178 32KHz Oscillator Control A
Name OSC32KCTRLAOffset 0x18Reset 0x00Property
Configuration Change Protection
Bit 7 6 5 4 3 2 1 0 RUNSTDBY
Access R R R R R R RW R Reset 0 0 0 0 0 0 0 0
Bit 1 ndash RUNSTDBY Run StandbyThis bit enables the oscillator in Active Idle and Standby sleep modes
The output of the OSCULP32K is not sent to other peripherals if not requested
When not requested by peripherals no oscillator output is provided
It takes two cycles to open the clock gate after a request When this bit is written to 1 the oscillatorstartup time will be removed when the device wakes from Standby Sleep mode
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
89
1179 32768kHz Crystal Oscillator Control ANote The SEL and CSUT bits cannot be changed as long as the ENABLE bit is set or the XOSC32KStable bit (XOSC32KS) in CLKCTRLMCLKSTATUS is highTo change settings in a safe way write a 0 to the ENABLE bit and wait until XOSC32KS is 0 before re-enabling the XOSC32K with new settings
Name XOSC32KCTRLAOffset 0x1CReset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 CSUT[10] SEL RUNSTDBY ENABLE
Access R R RW RW R RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 54 ndash CSUT[10] Crystal Start-Up TimeThese bits select the startup time for the XOSC32K It is write protected when the oscillator is enabled(ENABLE=1)
If SEL=1 the startup time will not be applied
Value Name Description0x0 1K 1k cycles
0x1 16K 16k cycles
0x2 32K 32k cycles
0x3 64K 64k cycles
Bit 2 ndash SEL Source SelectThis bit select the external source type It is write protected when the oscillator is enabled (ENABLE=1)
Value Description0 External crystal
1 External clock on TOSC1 pin
Bit 1 ndash RUNSTDBY Run StandbyWriting this bit to 1 enables the oscillator in Active Idle and Standby sleep modes When this bit is 0the oscillator is only enabled when requested
The output of the OSCULP32K is not sent to other peripherals if not requested
It takes two cycles to open the clock gate after a request but the oscillator startup time will be removed
This bit is IO protected to prevent unintentional enabling of the oscillator
Bit 0 ndash ENABLE EnableWhen this bit is written to 1 the configuration of the respective input pins is overridden to TOSC1 andTOSC2 Also the Source Select bit (SEL) and Crystal Start-Up Time (CSUT) become read-only
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
90
Depending on the on RUNSTBY bit the oscillator will be turned on all the time if the device is in ActiveIdle or Standby sleep mode or only be enabled when requested
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
91
12 SLPCTRL - Sleep Controller
121 OverviewSleep modes are used to shut down peripherals and clock domains in the device in order to save powerThe Sleep Controller (SLPCTRL) controls and handles the transitions between active modes and sleepmodes
In Active mode the CPU is executing application code In addition to Active mode there are these sleepmodes Idle Standby and Power Down
When the device enters a sleep mode program execution is stopped and depending on the enteredsleep mode different peripherals and clock domains are turned off
122 Featuresbull Three sleep modes
ndash Idlendash Standbyndash Power Down
bull Configurable Standby sleep mode where peripherals can be configured as on or offbull SleepWalking in Standby sleep mode where the PTC can start running on an Event without waking
up the device
123 Block DiagramFigure 12-1 Sleep Controller in System
SLEEPCTRL CPU
Sleep instruction
Interrupt request
Peripheral
Interrupt request
Sleep state
124 Product DependenciesIn order to use this peripheral other parts of the system must be configured correctly as described below
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
92
Table 12-1 SLEEPCTRL Product Dependencies
Dependency Applicable Peripheral
Clocks Yes CLKCTRL
IO Lines and Connections No -
Interrupts no -
Events No -
Debug Yes UPDI
1241 ClocksThis peripheral depends on the peripheral clock
Related LinksCLKCTRL - Clock Controller on page 75Product Dependencies on page 105
1242 IO Lines and ConnectionsNot applicable
1243 InterruptsNot applicable
1244 EventsNot applicable
1245 Debug OperationWhen run-time debugging this peripheral will continue normal operation The SLPCTRL is only affectedby a break in debug operation If the SLPCTRL is in a sleep mode when a break occurs the device willwake up and the CLPCTRL will go to active mode even if there are no pending interrupt requests
If the peripheral is configured to require periodical service by the CPU through interrupts or similarimproper operation or data loss may result during halted debugging
125 Functional Description
1251 Principle of OperationTo enter a sleep mode the SLPCTRL must be enabled and the desired sleep mode must be stated Theapplication code decides when to enter that sleep mode by using a dedicated sleep instruction (SLEEP)
To wake up the device from sleep Interrupts are used The available Interrupt wake-up sources aredependent on the configured sleep mode When an interrupt occurs the device will wake up and executethe interrupt service routine before continuing normal program execution from the first instruction after thesleep instruction Any Reset will also take the device out of a sleep mode
1252 Sleep ModesIn addition to Active mode there are three different sleep modes with decreasing power consumptionand decreasing functionality
Idle The CPU stops executing code no peripherals are disabled
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
93
All interrupt sources can wake up the deviceStandby The user can configure peripherals to be enabled or not using the respective RUNSTBY bit
This means that the power consumption is highly dependent on what functionality is enabledThe current consumption may vary between the Idle value and close to the Power DownconsumptionSleepWalking is available for the PTC moduleThe wake-up sources are Pin interrupts TWI address match USART Start-of-Frameinterrupt (USART is enabled to run in Standby) PTC window interrupt (PTC enabled to run inStandby) RTC interrupt (RTC enabled to run in Standby) and TCB interrupt
PowerDown
Only the WDT is enabledThe only wake-up sources are the pin change interrupt and TWI address match
Table 12-2 Sleep Mode Overview
Active clock domain Oscillators Wake-up Sources
Sleep Mode CPUclock
Peripheralclock
WDTclock
RTCclock
TCBclock
ADCPTCclock
CLK_CPU
CLK_PER
CLK_WDT
CLK_RTC
CLK_PER
CLK_PER
MainClocksource
WDToscillator
RTCclocksource
INTnandpinchange
TWIaddressmatch
USARTstartofframe
PTCwindow
RTCinterrupt
TCB Allotherinterrupts
Idle X X X X X X X X X X X X X X X
Standby X X X X X X X X X X X X X
Power Down X X X X
Note X means active X indicates that the RUNSTBY bit of the corresponding peripheral must be set toenter active state
Note On this device CLK_CPU CLK_NVM and CLK_PER share the prescaler setting and hencealways have the same frequency
1253 Basic Operation
12531 InitializationTo put the device into a sleep mode follow these steps
bull Configure and enable the interrupts that should wake up the device from sleep Also enable globalinterrupts
Warning If there are no interrupts enabled when going to sleep the device can notwake up again
bull Select the sleep mode to be entered and enable the Sleep Controller by writing to the Sleep Modebits (SMODE) and the Enable bit (SEN) in the Control A register (SLPCTRLCTRLA)
12532 Wake-Up TimeThe normal wake-up time for the device is 6 Main Clock cycles (CLK_PER) plus the time it takes to startup the Main Clock source
bull In Idle sleep mode the Main Clock source is kept running so it will not be any extra wake-up time
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
94
bull In Standby sleep mode the Main Clock might be running so it depends on the peripheralconfiguration
bull In Power Down sleep mode only the ULP 32KHz oscillator may be running if it is used by the BODor WDT All other clock sources will be off
The startup time for the different clock sources is described in the Clock Controller (CLKCTRL) section
In addition to the normal wake-up time it is possible to make the device wait until the BOD is ready beforeexecuting code This is done by writing 0x3 to the BOD Operation Mode in Active and Idle bits (ACTIVE)in the BOD Configuration fuse (FUSEBODCFG) If the BOD is ready before the normal wake-up time thenet wake-up time will be the same If the BOD takes longer than the normal wake-up time the wake-uptime will be extended until the BOD is ready This is ensures correct supply voltage whenever code isexecuted
1254 Configuration Change ProtectionNot applicable
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
95
126 Register Summary
Offset Name Bit Pos
0x00 CTRLA 70 SMODE[10] SEN
127 Register Description
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
96
1271 Control A
Name CTRLAOffset 0x00Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 SMODE[10] SEN
Access R R R R R RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 21 ndash SMODE[10] Sleep ModeWriting these bits selects the sleep mode entered when the Sleep Enable bit (SEN) is written to 1 andthe SLEEP instruction is executed
Value Name Description0x0 IDLE Idle sleep mode enabled
0x1 STANDBY Standby sleep mode enabled
0x2 PDOWN Power Down sleep mode enabled
other - Reserved
Bit 0 ndash SEN Sleep EnableThis bit must be written to 1 before the SLEEP instruction is executed to make the MCU enter theselected sleep mode
To avoid unintentional entering of sleep modes it is recommended to write SEN=1 just before executingthe SLEEP instruction and to write SEN=0 immediately after waking up
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
97
13 RSTCTRL - Reset Controller
131 OverviewThe Reset Controller (RSTCTRL) manages the Reset of the device It issues a device Reset sets thedevice to its initial state and allows the Reset source to be identified by software
132 Featuresbull Reset the device and set it to an initial statebull Reset Flag register for identifying the Reset source by application codebull Multiple Reset sources
ndash Power supply Reset sources Brownout Detect (BOD) Power On Reset (POR)ndash User Reset sources External Reset pin Watchdog Reset software Reset UPDI reset
133 Block DiagramFigure 13-1 Reset System Overview
RESET SOURCES
POR
BOD
WDT
CPU (SW)
RESET
RESET CONTROLLER
UPDI
UPDI
All otherPeripherals
TCD pin override fuses
Note The UPDI and some registers containing fuse values such as the TCD pin override fuses are notreset by all Reset sources
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
98
134 Signal Description
Signal Description Type
RESET External Reset (active low) Digital input
135 Functional Description
1351 Principle of OperationThe Reset controller combines the different Reset sources and routes the generated Reset on the device
1352 Basic Operation
13521 InitializationThe Reset Controller (RSTCTRL) is always enabled but the some of the Reset sources must be enabled(either by fuses or by software) before they can request a Reset
After any Reset the Reset source that caused the Reset is found in the Reset Flag register(RSTCTRLRSTFR)
After a Power-On Reset only the POR flag will be set
The flags are kept until they are cleared by writing a 1 to them
After Reset from any source all registers that are loaded from fuses are reloaded
13522 Reset SourcesThere are two kind of sources for Resets
bull Power supply Resets are caused by changes in the power supply voltage Power-on Reset (POR)and Brownout Detector (BOD)
bull User Resets are issued by the application by debug or by pin changes (Software Reset WatchdogReset UPDI Reset and external Reset pin RESET)
Power-On Reset (POR)The Power-on Reset detector is always enabled and is not configurable It triggers a Reset when thesupply voltage is too low for the device to function
This Reset source will reset everything on the entire device
Brownout Detector (BOD) Reset SourceThe BOD has a similar functionality like the POR but can be configured to check the supply voltage indifferent ranges than the POR See the BOD documentation for details on how to configure it
A BOD Reset request will reset the entire device except the BOD setting (given by fuses) and the TCDpin override settings
Related LinksBOD - Brownout Detector on page 163
Software ResetA software Reset is generated by the CPU by writing a 1 to the Software Reset Enable bit (SWRE) in theSoftware Reset register (RSTCTRLSWRR)
The software Reset will keep the device in Reset for the next cycle of CLK_PER and resets the entiredevice except the UPDI TCD pin override settings and BOD settings that are loaded from fuses
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
99
External ResetThe External Reset is enabled by fuse (see fuse map) If both UPDI and External Reset are enabled theExternal Reset will be moved to an alternative pin
When enabled the External Reset requests a Reset as long as the RESET pin is low The device will stayin Reset until RESET is high again The UPDI will not be affected by an external Reset
Related LinksFUSES - Configuration and User Fuses on page 23
Watchdog ResetThe Watchdog Reset is generated by the Watchdog Timer (WDT) See the WDT documentation fordetails on configuration
The WDT Reset request resets the entire device except the PDI
Related LinksWDT - Watchdog Timer on page 179
Universal Program Debug Interface (UPDI) ResetThe UPDI Reset request resets the entitre device except the UPDI itself See PDI documentation on howto generate a UPDI Reset request
Related LinksUPDI - Unified Program and Debug Interface on page 502
1353 Sleep Mode OperationThe Reset Controller continues to operate in all active and sleep modes
1354 Configuration Change ProtectionThis peripheral has registers that are under Configuration Change Protection (CCP) In order to write tothese a certain key must be written to the CPUCCP register first followed by a write access to theprotected bits within four CPU instructions
It is possible to try writing to these registers any time but the values are not altered
The following registers are under CCP
Table 13-1 RSTCTRL - Registers under Configuration Change Protection
Register Key
RSTCTRLSWRR IOREG
Related LinksSequence for Write Operation to Configuration Change Protected IO Registers on page 53
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
100
136 Register Summary - RSTCTRL
Offset Name Bit Pos
0x00 RSTFR 70 PDIRF SWRF WDRF EXTRF BORF PORF
0x01 SWRR 70 SWRE
137 Register Description
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
101
1371 Reset Flag RegisterAll flags are cleared by writing a 1 to them They are also cleared by a Power-on Reset with theexception of the Power-On Reset Flag (PORF)
Name RSTFROffset 0x00Reset 0xXXProperty
-
Bit 7 6 5 4 3 2 1 0 PDIRF SWRF WDRF EXTRF BORF PORF
Access R R RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bit 5 ndash PDIRF UPDI Reset FlagThis bit is set if a UPDI Reset occurs
Bit 4 ndash SWRF Software Reset FlagThis bit is set if a Software Reset occurs
Bit 3 ndash WDRF Watchdog Reset FlagThis bit is set if a Watchdog Reset occurs
Bit 2 ndash EXTRF External Reset FlagThis bit is set if an External reset occurs
Bit 1 ndash BORF Brownout Reset FlagThis bit is set if a Brownout Reset occurs
Bit 0 ndash PORF Power-On Reset FlagThis bit is set if a Power-on Reset occurs
This flag is only cleared by writing a 1 it
Note After a POR only the POR flag is set all other flags are cleared No other flag can be set before afull system boot is run after the POR
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
102
1372 Software Reset Register
Name SWRROffset 0x01Reset 0x00Property
Configuration Change Protection
Bit 7 6 5 4 3 2 1 0 SWRE
Access R R R R R R R RW Reset 0 0 0 0 0 0 0 0
Bit 0 ndash SWRE Software Reset EnableWhen this bit is written to 1 a software reset will occur
Note that this bit will always read 0 because it is reset when a Reset is issued
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
103
14 CPUINT - CPU Interrupt Controller
141 OverviewAn interrupt request signals a change of state inside a peripheral and can be used to alter programexecution Peripherals can have one or more interrupts and all are individually enabled and configured
When an interrupt is enabled and configured it will generate an interrupt request when the interruptcondition occurs
The CPU Interrupt Controller (CPUINT) handles and prioritizes interrupt requests When an interruptrequest is acknowledged by the CPUINT the program counter is set to point to the interrupt vector andthe interrupt handler can be executed
By default all peripherals are priority level 0 User can set one single interrupt vector to the higher prioritylevel 1 Interrupts are prioritized according to their priority level and their interrupt vector address Prioritylevel 1 interrupts will interrupt level 0 interrupt handlers Among priority level 0 interrupts the priority isdetermined from the interrupt vector address where the lowest interrupt vector address has the highestinterrupt priority
Optionally a round-robin scheduling scheme can be enabled for priority level 0 interrupts This ensuresthat all interrupts are serviced within a certain amount of time
Non-maskable interrupts (NMI) are also supported and can be used for system critical functions
142 Featuresbull Short and predictable interrupt response timebull Separate interrupt configuration and vector address for each interruptbull Interrupt prioritizing by level and vector addressbull Two interrupt priority levels 0 (normal) and 1 (high)bull Higher priority for one interruptbull Optional round-robin priority scheme for priority level 0 interruptsbull Non-maskable interrupts (NMI) for critical functionsbull Interrupt vectors optionally placed in the application section or the boot loader sectionbull Selectable compact vector table
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
104
143 Block DiagramFigure 14-1 CPUINT Block Diagram
INT REQ
INT LEVEL
INT ACK
Peripheral 1
Peripheral n
Interrupt Controller
SleepController
CPU
PriorityDecoder
STATUS
CPUREG
INT REQ
INT REQ
GlobalInterruptEnable
CPU RETICPU INT ACK
CPU INT REQ
Wake-upLVL0PRLVL1VEC
144 Signal DescriptionNot applicable
145 Product DependenciesIn order to use this peripheral other parts of the system must be configured correctly as described below
Table 14-1 CPUINT Product Dependencies
Dependency Applicable Peripheral
Clocks Yes CLKCTRL
IO Lines and Connections No -
Interrupts No -
Events No -
Debug Yes UPDI
Related LinksClocks on page 93Debug Operation on page 106
1451 ClocksThis peripheral depends on the peripheral clock
Related LinksCLKCTRL - Clock Controller on page 75Product Dependencies on page 105
1452 IO Lines and ConnectionsNot applicable
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
105
1453 InterruptsNot applicable
1454 EventsNot applicable
1455 Debug OperationWhen run-time debugging this peripheral will continue normal operation Halting the CPU in debuggingmode will halt normal operation of the peripheral
If the peripheral is configured to require periodical service by the CPU through interrupts or similarimproper operation or data loss may result during halted debugging
Related LinksProduct Dependencies on page 105UPDI - Unified Program and Debug Interface on page 502
146 Functional Description
1461 Principle of OperationInterrupt generation must be globally enabled by writing a 1 to the Global Interrupt Enable bit (I) in theCPU Status register (CPUSREG) This bit is not cleared when an interrupt is acknowledged
When an interrupt is enabled and the interrupt condition occurs the CPUINT will receive the interruptrequest Based on the interrupts priority level and the priority level of any ongoing interrupts the interruptrequest is either acknowledged or kept pending until it has priority
When the interrupt request is acknowledged the program counter is updated to point to the interruptvector The interrupt vector is normally a jump to the interrupt handler (ie the software routine thathandles the interrupt) After returning from the interrupt handler program execution continues from whereit was before the interrupt occurred One instruction is always executed before any pending interrupt isserved
The CPUINT Status register (CPUINTSTATUS) contains state information that ensures that the CPUINTreturns to the correct interrupt level when the RETI (interrupt return) instruction is executed at the end ofan interrupt handler Returning from an interrupt will return the CPUINT to the state it had before enteringthe interrupt CPUINTSTATUS is not saved automatically upon an interrupt requestNote The RET (subroutine return) instruction cannot be used when returning from the interrupt handlerroutine as this will not return the CPUINT to its correct state
1462 Basic Operation
14621 InitializationAn interrupt must be initialized in the following order
1 Configure the CPUINT if the default configuration is not adequate (optional)ndash Vector handling is configured by writing to the respective bits (IVSEL and CVT) in the Control
A register (CPUINTCTRLA)ndash Vector prioritizing by round-robin is enabled by writing a 1 to the Round-Robin Priority Enable
bit (LVL0RR) in CPUINTCTRLAndash Select the priority level 1 vector by writing its address to the Interrupt Vector (LVL1VEC) in the
Level 1 Priority register (CPUINTLVL1VEC)
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
106
2 Configure the interrupt conditions within the peripheral and enable the peripherals interrupt3 Enable interrupts globally by writing a 1 to the Global Interrupt Enable bit (I) in the CPU Status
register (CPUSREG)
14622 Enabling Disabling and ResettingGlobal enabling of interrupts is done by writing a 1 to the Global Interrupt Enable bit (I) in the CPU Statusregister (CPUSREG) To disable interrupts globally write a 0 to the I bit in CPUSREG
The desired interrupt lines must also be enabled in the respective peripheral by writing to the peripheralsInterrupt Control register ([peripheral]INTCTRL)
Interrupt flags are not automatically cleared after the interrupt is executed The respective INTFLAGSregister descriptions provide information on how to clear specific flags
14623 Interrupt Vector LocationsThe table below shows Reset addresses and Interrupt vector placement dependent on the value ofInterrupt Vector Select bit (IVSEL) in the Control A register (CPUINTCTRLA)
If the program never enables an interrupt source the Interrupt Vectors are not used and regular programcode can be placed at these locations
Table 14-2 Reset and Interrupt Vector Placement
IVSEL Reset address Interrupt vectors start address
0 0x0000 Application start address +Interrupt vector offset address
1 0x0000 Interrupt vector offset address(1)
Note 1 If boot section is defined it will be placed before application section
14624 Interrupt Response TimeThe minimum interrupt response time for all enabled interrupts is three CPU clock cycles one cycle tofinish the ongoing instruction and two cycles to store the program counter to the stack After the programcounter is pushed on the stack the program vector for the interrupt is executed
The jump to the interrupt handler takes three clock cycles If an interrupt occurs during execution of amulticycle instruction this instruction is completed before the interrupt is served
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
107
Figure 14-2 Interrupt Execution of a Multicycle Instruction
1463 Interrupt Priority
14631 NMI - Non-Maskable InterruptsAn NMI will be executed regardless of the setting of the I bit in CPUSREG and it will never change the Ibit No other interrupt can interrupt a NMI handler If more than one NMI is requested at the same timepriority is static according to the interrupt vector address where the lowest address has highest priority
Which interrupts are non-maskable is device-dependent and not subject to configuration Non-maskableinterrupts must be enabled before they can be used Refer to the Interrupt Line Mapping of the device foravailable NMI lines
Related LinksInterrupt Vector Mapping on page 39
14632 Static PriorityInterrupt vectors (IVEC) are located at fixed addresses For static priority the interrupt vector addressdecides the priority within normal interrupt level where the lowest interrupt vector address has the highestpriority Refer to the Interrupt Line Mapping of the device for available interrupt lines and their baseaddress offset
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
108
Figure 14-3 Static Priority
Lowest Priority
Highest PriorityIVEC 0
IVEC x
IVEC x+1
IVEC n
Lowest Address
Highest Address
Related LinksInterrupt Vector Mapping on page 39
14633 Round-Robin SchedulingTo avoid starvation for priority level 0 (LVL0) interrupt requests with static priority ie some interruptsmight never be served the CPUINT offers round-robin scheduling for LVL0 interrupts
Round-robin scheduling for LVL0 interrupt requests is enabled by writing a 1 to the Round-Robin PriorityEnable bit (LVL0RR) in the Control A register (CPUINTCTRLA)
When round-robin scheduling is enabled the interrupt vector address for the last acknowledged LVL0interrupt will have the lowest priority the next time one or more LVL0 interrupts are requested asillustrated in the figure below
Figure 14-4 Round-Robin Scheduling
IVEC x last acknowledgeinterrupt
IVEC x+1 last acknowledgeinterrupt
IVEC 0
IVEC x
IVEC x+1
IVEC n
IVEC x+2
IVEC x+1
IVEC x
IVEC 0
IVEC n
Lowest Priority
Highest PriorityLowest Priority
Highest Priority
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
109
14634 Compact Vector TableThe Compact Vector Table (CVT) is a feature to allow for writing of compact code
When CVT is enabled by writing a 1 to the CVT bit in the Control A register (CPUINTCTRLA) the vectortable contains these three interrupt vectors
1 The non-maskable interrupts (NMI) at vector address 12 The priority level 1 (LVL1) interrupt at vector address 23 All priority level 0 (LVL0) interrupts share vector address 3
This feature is most suitable for applications using a small number of interrupt generators
1464 EventsNot applicable
1465 Sleep Mode OperationNot applicable
1466 Configuration Change ProtectionThis peripheral has registers that are under Configuration Change Protection (CCP) In order to write tothese a certain key must be written to the CPUCCP register first followed by a write access to theprotected bits within four CPU instructions
It is possible to try writing to these registers any time but the values are not altered
The following registers are under CCP
Table 14-3 INTCTRL - Registers under Configuration Change Protection
Register Key
IVSEL in CPUINTCTRLA IOREG
CVT in CPUINTCTRLA IOREG
Related LinksSequence for Write Operation to Configuration Change Protected IO Registers on page 53
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
110
147 Register Summary - CPUINT
Offset Name Bit Pos
0x00 CTRLA 70 IVSEL CVT LVL0RR
0x01 STATUS 70 NMIEX LVL1EX LVL0EX
0x02 LVL0PRI 70 LVL0PRI[70]
0x03 LVL1VEC 70 LVL1VEC[70]
148 Register Description
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
111
1481 Control A
Name CTRLAOffset 0x00Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 IVSEL CVT LVL0RR
Access RW RW RW Reset 0 0 0
Bit 6 ndash IVSEL Interrupt Vector SelectIf boot section is defined it will be placed before application section The actual start address of theapplication section is determined by the BOOTEND Fuse
This bit is protected by the Configuration Change Protection mechanism
Value Description0 Interrupt vectors are placed at the start of the application section of the Flash
1 Interrupt vectors are placed at the start of the boot section of the Flash
Bit 5 ndash CVT Compact Vector TableThis bit is protected by the Configuration Change Protection mechanism
Value Description0 Compact Vector Table function is disabled
1 Compact Vector Table function is enabled
Bit 0 ndash LVL0RR Round-Robin Priority Enable
Value Description0 Priority is fixed for priority level 0 interrupt requests The lowest interrupt vector address has
highest priority
1 Round Robin priority scheme is enabled for low-level interrupts
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
112
1482 Status
Name STATUSOffset 0x01Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 NMIEX LVL1EX LVL0EX
Access R R R Reset 0 0 0
Bit 7 ndash NMIEX Non-Maskable Interrupt ExecutingThis flag is set if a non-maskable interrupt is executing The flag is cleared when returning (RETI) fromthe interrupt handler
Bit 1 ndash LVL1EX Level 1 Interrupt ExecutingThis flag is set when a priority level 1 interrupt is executing or when the interrupt handler has beeninterrupted by an NMI The flag is cleared when returning (RETI) from the interrupt handler
Bit 0 ndash LVL0EX Level 0 Interrupt ExecutingThis flag is set when a priority level 0 interrupt is executing or when the interrupt handler has beeninterrupted by a priority level 1 interrupt or an NMI The flag is cleared when returning (RETI) from theinterrupt handler
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
113
1483 Interrupt Priority Level 0
Name LVL0PRIOffset 0x02Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 LVL0PRI[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash LVL0PRI[70] Interrupt Priority Level 0When Round Robin is enabled (LVL0RR bit in CPUINTCTRLA is 1) this bit field stores the vector of thelast acknowledged priority level 0 (LVL0) interrupt The stored vector will have the lowest priority next timeone or more LVL0 interrupts are pending
If Round Robin is disabled (LVL0RR in CPUINTCTRLA is 0) the vector address based priority scheme(lowest address has highest priority) is governing the priorities of LVL0 interrupt requests
This bit field can be written to change the priority queue If a system Reset is asserted the lowestinterrupt vector address will have highest priority within the LVL0
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
114
1484 Interrupt Vector with Priority Level 1
Name LVL1VECOffset 0x03Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 LVL1VEC[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash LVL1VEC[70] Interrupt Vector with Priority Level 1This bit field contains the address of the single vector with increased priority level 1 (LVL1)
If this bit field has the value 0x00 no vector has LVL1 Consequently the LVL1 interrupt is disabled
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
115
15 EVSYS - Event System
151 Overviewhe Event System (EVSYS) enables direct peripheral-to-peripheral signaling It allows a change in oneperipheral (the Event Generator) to trigger actions in other peripherals (the Event Users) without using theCPU It is designed to provide short and predictable response times between peripherals allowing forautonomous peripheral control and interaction and also for synchronized timing of actions in severalperipheral modules It is thus a powerful tool for reducing the complexity size and execution time ofapplication code
A change of the Event Generators state is referred to as an Event and usually corresponds to one of theperipherals interrupt conditions Events can be directly forwarded to other peripherals using thededicated Event routing network The routing of each channel is configured in software including eventgeneration and use
The Event System can directly connect analog and digital converters analog comparators IO port pinsthe real-time counter timercounters and the configurable custom logic peripheral Events can also begenerated from software and the peripheral clock
152 Featuresbull System for direct peripheral-to-peripheral signalingbull Peripherals can directly produce use and react to peripheral eventsbull Short and guaranteed response timebull Up to six parallel Event channels available 4 asynchronous- and 2 synchronousbull Channels can be configured to have one triggering peripheral action and multiple peripheral usersbull Peripherals can directly trigger and react to Events from other peripheralsbull Events can be sent andor received by most peripherals clock system and softwarebull Works in active mode and standby sleep mode
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
116
153 Block DiagramFigure 15-1 Block Diagram
Sync user x
Async user y
Sync user 0
EVSEL
Sync event channel rdquokrdquo
Async event channel rdquolrdquo
Sync event channel 0
Async event channel 0
Sync source 0Sync source 1
Sync source n
Async source 0Async source 1
Async source m
EVSRC SWEVT
Async user 0
EVSEL
EVSRC SWEVT
To sync user
To async user
Figure 15-2 Example of Event Source Generator User and Action
|Event
RoutingNetwork Single
Conversion
Channel SweepCompare Match
Over-Underflow
Error
Event Generator Event User
Event Source Event Action
Event Action Selection
TimerCounter ADC
Note 1 For an overview of peripherals supporting Events also the Block Diagram of the device2 For a list of Event Generators refer to the Channel n Input Selection registers (EVSYSSYNCCH
and EVSYSASYNCCH)3 For a list of Event Users refer to the User Channel n Selection registers (EVSYSSYNCUSER and
EVSYSASYNCUSER)
Related LinksBlock Diagram on page 13SYNCCH0 SYNCCH1 on page 127ASYNCCH0 ASYNCCH1 ASYNCCH2 ASYNCCH3 on page 124SYNCUSER0 SYNCUSER1 on page 133
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
117
ASYNCUSER0 ASYNCUSER1 ASYNCUSER2 ASYNCUSER3 ASYNCUSER4 ASYNCUSER5ASYNCUSER6 ASYNCUSER7 ASYNCUSER8 ASYNCUSER9 ASYNCUSER10 on page 129
154 Signal DescriptionThe Event signaling can either happen synchronously to the main clock (CLK_MAIN) or asynchronouslyto it
Depending on the underlying event the Event signal can be a pulse with a duration of 1 clock cycle or alevel signal (similar to a status flag)
Related LinksBlock Diagram - CLKCTRL on page 76
155 Product DependenciesIn order to use this peripheral other parts of the system must be configured correctly as described below
Table 15-1 EVSYS Product Dependencies
Dependency Applicable Peripheral
Clocks Yes CLKCTRL
IO Lines and Connections No -
Interrupts No -
Events No -
Debug Yes UPDI
Related LinksClocks on page 118Debug Operation on page 118
1551 ClocksThe EVSYS uses the peripheral clock for IO registers and strobes When set up correctly the routingnetwork can be used also in sleep modes without any clock Strobe registers will not work in sleep modeswhere the peripheral clock is halted
Related LinksCLKCTRL - Clock Controller on page 75
1552 IO Lines and ConnectionsNot applicable
1553 InterruptsNot applicable
1554 EventsNot applicable
1555 Debug OperationThis peripheral is unaffected by entering debug mode
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
118
Note When the CPU is halted the strobe registers are not cleared automatically
Related LinksUPDI - Unified Program and Debug Interface on page 502
156 Functional Description
1561 Principle of OperationThe Event System consists of several channels which each route Events triggered from one peripheralsource (Event generators) to other peripherals or IO pins (Event users) Only one trigger from an Eventgenerator peripheral can be routed on each channel but multiple channels can use the same generatorsource Multiple peripherals can use events from the same channel
A channel path can be either asynchronous or synchronous to the main clock The mode must beselected based on the requirements of the application
1562 Basic Operation
15621 InitializationBefore enabling Events within the device the Event Users Multiplexer and Event Channels must beconfigured
Related LinksEvent User Multiplexer Setup on page 119Event System Channel on page 119
15622 Event User Multiplexer SetupThe Event User multiplexer defines the channel to be connected to which Event User Each Event Usermultiplexer is dedicated to one Event User Each Event User multiplexer is connected to the supportedEvent channel outputs and can be configured to select one of these channels
Event Users which support asynchronous Events also support synchronous Events There are also EventUsers that support only synchronous Events The Event User multiplexers are configured by writing to thecorresponding registers
bull Event Users supporting synchronous and asynchronous Events are configured by writing to therespective asynchronous User Channel Input Selection n register (EVSYSASYNCUSERn)
bull The users of synchronous-only Events are configured by writing to the respective SynchronousUser Channel Input Selection n register (EVSYSSYNCUSERn)
Default setup of all user multiplexers is Off
15623 Event System ChannelAn Event channel can be connected to one of the Event generators Event channels either supportasynchronous generators or synchronous generators
The source for each asynchronous Event channel is configured by writing to the respective AsynchronousChannel n Input Selection register (EVSYSASYNCCHn)
The source for each synchronous Event channel is configured by writing to the respective SynchronousChannel n Input Selection register (EVSYSSYNCCHn)
15624 Event GeneratorsEach Event channel can receive the Events from several Event generators For details on Eventgeneration refer to the documentation of the corresponding peripheral
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
119
For each Event channel there are several possible Event generators only one of which can be selectedat a time The Event generator trigger is selected for each channel by writing to the respective channelregisters (EVSYSASYNCCHn EVSYSSYNCCHn) By default the channels are not connected to anyEvent generator
Note Some Event generators are available for several Event channels
15625 Software EventIn a Software Event the CPU can override an Event channel line by writing to the respective stroberegister location The write to the strobe register will invert the current value on the Event channel for onesystem clock cycle
A Software Event can be triggered on a channel by writing a 1 to the respective Strobe bit in theappropriate Channel Strobe register
bull Software Events on asynchronous channel m are initiated by writing a 1 to the ASYNCSTROBEmbit in the Asynchronous Channel Strobe register (EVSYSASYNCSTROBE)
bull Software Events on synchronous channel n are initiated by writing a 1 to the SYNCSTROBEn bitin the Synchronous Channel Strobe register (EVSYSSYNCSTROBE)
Software Events are no different to those produced by Event generator peripherals with respect to Eventusers when the bit is written to 1 an Event will be generated on the respective channel and receivedand processed by the Event User
Note To guarantee a positive pulse set the channel to OFF (SYNCCHn=0x00 or ASYNCCHn=0x00 inEVSYSSYNCCH or EVSYSASYNCCH respectively) before writing to the strobe register
1563 InterruptsNot applicable
1564 Sleep Mode OperationWhen configured the Event System will work in all sleep modes One exception are software Eventswhich require a system clock
1565 SynchronizationAsynchronous Events are synchronized and handled by the compatible Event users Event Userperipherals not compatible with asynchronous Events can only be configured to listen to synchronousEvent channels
1566 Configuration Change ProtectionNot applicable
Related LinksSequence for Write Operation to Configuration Change Protected IO Registers on page 53
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
120
157 Register Summary - EVSYS
Offset Name Bit Pos
0x00 ASYNCSTROBE 70 ASYNCSTROBE[70]
0x01 SYNCSTROBE 70 SYNCSTROBE[70]
0x02 ASYNCCH0 70 ASYNCCH[70]
0x03 ASYNCCH1 70 ASYNCCH[70]
0x04 ASYNCCH2 70 ASYNCCH[70]
0x05 ASYNCCH3 70 ASYNCCH[70]
0x06
0x09
Reserved
0x0A SYNCCH0 70 SYNCCH[70]
0x0B SYNCCH1 70 SYNCCH[70]
0x0C
0x11
Reserved
0x12 ASYNCUSER0 70 ASYNCUSER[70]
0x13 ASYNCUSER1 70 ASYNCUSER[70]
0x14 ASYNCUSER2 70 ASYNCUSER[70]
0x15 ASYNCUSER3 70 ASYNCUSER[70]
0x16 ASYNCUSER4 70 ASYNCUSER[70]
0x17 ASYNCUSER5 70 ASYNCUSER[70]
0x18 ASYNCUSER6 70 ASYNCUSER[70]
0x19 ASYNCUSER7 70 ASYNCUSER[70]
0x1A ASYNCUSER8 70 ASYNCUSER[70]
0x1B ASYNCUSER9 70 ASYNCUSER[70]
0x1C ASYNCUSER10 70 ASYNCUSER[70]
0x1D
0x21
Reserved
0x22 SYNCUSER0 70 SYNCUSER[70]
0x23 SYNCUSER1 70 SYNCUSER[70]
158 Register Description
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
121
1581 Asynchronous Channel Strobe
Name ASYNCSTROBEOffset 0x00Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 ASYNCSTROBE[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash ASYNCSTROBE[70] Asynchronous Channel StrobeIf the strobe register location is written each Event channel will be inverted for one system clock cycleie a single Event is generated
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
122
1582 Synchronous Channel Strobe
Name SYNCSTROBEOffset 0x01Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 SYNCSTROBE[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash SYNCSTROBE[70] Synchronous Channel StrobeIf the strobe register location is written each Event channel will be inverted for one system clock cycleie a single event is generated
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
123
1583 Asynchronous Channel n Generator Selection
Name ASYNCCH0 ASYNCCH1 ASYNCCH2 ASYNCCH3Offset 0x02 + n0x01 [n=03]Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 ASYNCCH[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash ASYNCCH[70] Asynchronous Channel Generator SelectionTable 15-2 ASYNCCH0
Value Description
0x00 OFF
0x01 CCL_LUT0
0x02 CCL_LUT1
0x03 AC0_OUT
0x04 TCD0_CMPBCLR
0x05 TCD0_CMPASET
0x06 TCD0_CMPBSET
0x07 TCD0_PROGEV
0x08 RTC_OVF
0x09 RTC_CMP
0x0A PORTA0
0x0B PORTA1
0x0C PORTA2
0x0D PORTA3
0x0E PORTA4
0x0F PORTA5
0x10 PORTA6
0x11 PORTA7
0x12 UPDI
Other Reserved
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
124
Table 15-3 ASYNCCH1
Value Description
0x00 OFF
0x01 CCL_LUT0
0x02 CCL_LUT1
0x03 AC0_OUT
0x04 TCD0_CMPBCLR
0x05 TCD0_CMPASET
0x06 TCD0_CMPBSET
0x07 TCD0_PROGEV
0x08 RTC_OVF
0x09 RTC_CMP
0x0A PORTB0
0x0B PORTB1
0x0C PORTB2
0x0D PORTB3
0x0E PORTB4
0x0F PORTB5
0x10 PORTB6
0x11 PORTB7
Other Reserved
Table 15-4 ASYNCCH2
Value Description
0x00 OFF
0x01 CCL_LUT0
0x02 CCL_LUT1
0x03 AC0_OUT
0x04 TCD0_CMPBCLR
0x05 TCD0_CMPASET
0x06 TCD0_CMPBSET
0x07 TCD0_PROGEV
0x08 RTC_OVF
0x09 RTC_CMP
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
125
Value Description
0x0A PORTC0
0x0B PORTC1
0x0C PORTC2
0x0D PORTC3
0x0E PORTC4
0x0F PORTC5
Other Reserved
Table 15-5 ASYNCCH3
Value Description
0x00 OFF
0x01 CCL_LUT0
0x02 CCL_LUT1
0x03 AC0_OUT
0x04 TCD0_CMPBCLR
0x05 TCD0_CMPASET
0x06 TCD0_CMPBSET
0x07 TCD0_PROGEV
0x08 RTC_OVF
0x09 RTC_CMP
0x0A PIT_DIV8192
0x0B PIT_DIV4096
0x0C PIT_DIV2048
0x0D PIT_DIV1024
0x0E PIT_DIV512
0x0F PIT_DIV256
0x10 PIT_DIV128
0x11 PIT_DIV64
Other Reserved
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
126
1584 Synchronous Channel n Generator Selection
Name SYNCCH0 SYNCCH1Offset 0x0A + n0x01 [n=01]Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 SYNCCH[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash SYNCCH[70] Synchronous Channel Generator SelectionTable 15-6 SYNCCH0
Value Description
0x00 OFF
0x01 TCB0
0x02 TCA0_OVF_LUNF
0x03 TCA0_HUNF
0x04 TCA0_CMP0
0x05 TCA0_CMP1
0x06 TCA0_CMP2
0x07 PORTC0
0x08 PORTC1
0x09 PORTC2
0x0A PORTC3
0x0B PORTC4
0x0C PORTC5
0x0D PORTA0
0x0E PORTA1
0x0F PORTA2
0x10 PORTA3
0x11 PORTA4
0x12 PORTA5
0x13 PORTA6
0x14 PORTA7
Other Reserved
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
127
Table 15-7 SYNCCH1
Value Description
0x00 OFF
0x01 TCB0
0x02 TCA0_OVF_LUNF
0x03 TCA0_HUNF
0x04 TCA0_CMP0
0x05 TCA0_CMP1
0x06 TCA0_CMP2
0x07 Reserved
0x08 PORTB0
0x09 PORTB1
0x0A PORTB2
0x0B PORTB3
0x0C PORTB4
0x0D PORTB5
0x0E PORTB6
0x0F PORTB7
Other Reserved
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
128
1585 Asynchronous User Channel n Input Selection
Name ASYNCUSER0 ASYNCUSER1 ASYNCUSER2 ASYNCUSER3 ASYNCUSER4ASYNCUSER5 ASYNCUSER6 ASYNCUSER7 ASYNCUSER8 ASYNCUSER9ASYNCUSER10
Offset 0x12 + n0x01 [n=010]Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 ASYNCUSER[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash ASYNCUSER[70] Asynchronous User Channel SelectionTable 15-8 ASYNCUSER0 - TCB0
Value Description
0x0 OFF
0x1 SYNCCH0
0x2 SYNCCH1
0x3 ASYNCCH0
0x4 ASYNCCH1
0x5 ASYNCCH2
0x6 ASYNCCH3
Table 15-9 ASYNCUSER1 - ADC0
Value Description
0x0 OFF
0x1 SYNCCH0
0x2 SYNCCH1
0x3 ASYNCCH0
0x4 ASYNCCH1
0x5 ASYNCCH2
0x6 ASYNCCH3
Table 15-10 ASYNCUSER2 - CCL LUT0 Event 0
Value Description
0x0 OFF
0x1 SYNCCH0
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
129
Value Description
0x2 SYNCCH1
0x3 ASYNCCH0
0x4 ASYNCCH1
0x5 ASYNCCH2
0x6 ASYNCCH3
Table 15-11 ASYNCUSER3 - CCL LUT1 Event 0
Value Description
0x0 OFF
0x1 SYNCCH0
0x2 SYNCCH1
0x3 ASYNCCH0
0x4 ASYNCCH1
0x5 ASYNCCH2
0x6 ASYNCCH3
Table 15-12 ASYNCUSER4 - CCL LUT0 Event 1
Value Description
0x0 OFF
0x1 SYNCCH0
0x2 SYNCCH1
0x3 ASYNCCH0
0x4 ASYNCCH1
0x5 ASYNCCH2
0x6 ASYNCCH3
Table 15-13 ASYNCUSER5 - CCL LUT1 Event 1
Value Description
0x0 OFF
0x1 SYNCCH0
0x2 SYNCCH1
0x3 ASYNCCH0
0x4 ASYNCCH1
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
130
Value Description
0x5 ASYNCCH2
0x6 ASYNCCH3
Table 15-14 ASYNCUSER6 - TCD0 Event 0
Value Description
0x0 OFF
0x1 SYNCCH0
0x2 SYNCCH1
0x3 ASYNCCH0
0x4 ASYNCCH1
0x5 ASYNCCH2
0x6 ASYNCCH3
Table 15-15 ASYNCUSER7 - TCD0 Event 1
Value Description
0x0 OFF
0x1 SYNCCH0
0x2 SYNCCH1
0x3 ASYNCCH0
0x4 ASYNCCH1
0x5 ASYNCCH2
0x6 ASYNCCH3
Table 15-16 ASYNCUSER8 - EVOUT0
Value Description
0x0 OFF
0x1 SYNCCH0
0x2 SYNCCH1
0x3 ASYNCCH0
0x4 ASYNCCH1
0x5 ASYNCCH2
0x6 ASYNCCH3
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
131
Table 15-17 ASYNCUSER9 - EVOUT1
Value Description
0x0 OFF
0x1 SYNCCH0
0x2 SYNCCH1
0x3 ASYNCCH0
0x4 ASYNCCH1
0x5 ASYNCCH2
0x6 ASYNCCH3
Table 15-18 ASYNCUSER10 - EVOUT2
Value Description
0x0 OFF
0x1 SYNCCH0
0x2 SYNCCH1
0x3 ASYNCCH0
0x4 ASYNCCH1
0x5 ASYNCCH2
0x6 ASYNCCH3
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
132
1586 Synchronous User Channel n Input Selection
Name SYNCUSER0 SYNCUSER1Offset 0x22 + n0x01 [n=01]Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 SYNCUSER[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash SYNCUSER[70] Synchronous User Channel SelectionTable 15-19 SYNCUSER0 - TCA0
Value Description
0x0 OFF
0x1 SYNCCH0
0x2 SYNCCH1
Table 15-20 SYNCUSER1 - USART0
Value Description
0x0 OFF
0x1 SYNCCH0
0x2 SYNCCH1
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
133
16 PORTMUX - Port Multiplexer
161 OverviewThe Port Multiplexer (PORTMUX) can either enable or disable functionality of pins or change betweendefault and alternative pin positions This depends on the actual pin and property and is described indetail in the register map of this peripheral
162 Signal Description
Signal Type Description
EVOUT[20] Digital output Event output
Related LinksIO Multiplexing and Considerations on page 18
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
134
163 Register Summary
Offset Name Bit Pos
0x00 CTRLA 70 EXTBRK LUT1 LUT0 EVOUT2 EVOUT1 EVOUT0
0x01 CTRLB 70 TWI0 SPI0 USART0
0x02 CTRLC 70 TCA05 TCA04 TCA03 TCA02 TCA01 TCA00
0x03 CTRLD 70 TCB0
164 Register Description
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
135
1641 Control A
Name CTRLAOffset 0x00Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 EXTBRK LUT1 LUT0 EVOUT2 EVOUT1 EVOUT0
Access RW RW RW RW RW RW Reset 0 0 0 0 0 0
Bit 7 ndash EXTBRK External Break PinWrite this bit to 1 to select alternative output pin for external break
Bit 5 ndash LUT1 CCL LUT 1 outputWrite this bit to 1 to select alternative output pin for CCL LUT 1
Bit 4 ndash LUT0 CCL LUT 0 outputWrite this bit to 1 to select alternative output pin for CCL LUT 0
Bit 2 ndash EVOUT2 Event Output 2Write this bit to 1 to enable event output 2
Bit 1 ndash EVOUT1 Event Output 1Write this bit to 1 to enable event output 1
Bit 0 ndash EVOUT0 Event Output 0Write this bit to 1 to enable event output 0
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
136
1642 Control B
Name CTRLBOffset 0x01Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 TWI0 SPI0 USART0
Access RW RW RW Reset 0 0 0
Bit 4 ndash TWI0 TWI 0 communicationWrite this bit to 1 to select alternative communication pins for TWI 0
Bit 2 ndash SPI0 SPI 0 communicationWrite this bit to 1 to select alternative communication pins for SPI 0
Bit 0 ndash USART0 USART 0 communicationWrite this bit to 1 to select alternative communication pins for USART 0
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
137
1643 Control C
Name CTRLCOffset 0x02Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 TCA05 TCA04 TCA03 TCA02 TCA01 TCA00
Access RW RW RW RW RW RW Reset 0 0 0 0 0 0
Bit 5 ndash TCA05 TCA0 Waveform output 5Write this bit to 1 to select alternative output pin for TCA0 waveform output 5 in split modeNote Not applicable when TCA in normal mode
Bit 4 ndash TCA04 TCA0 Waveform output 4Write this bit to 1 to select alternative output pin for TCA0 waveform output 4 in split modeNote Not applicable when TCA in normal mode
Bit 3 ndash TCA03 TCA0 Waveform output 3Write this bit to 1 to select alternative output pin for TCA0 waveform output 3 in split modeNote Not applicable when TCA in normal mode
Bit 2 ndash TCA02 TCA0 Waveform output 2Write this bit to 1 to select alternative output pin for TCA0 waveform output 2
In Split Mode this bit controls output from compare channel C low byte
Bit 1 ndash TCA01 TCA0 Waveform output 1Write this bit to 1 to select alternative output pin for TCA0 waveform output 1
In Split Mode this bit controls output from compare channel B low byte
Bit 0 ndash TCA00 TCA0 Waveform output 0Write this bit to 1 to select alternative output pin for TCA0 waveform output 0
In Split Mode this bit controls output from compare channel A low byte
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
138
1644 Control D
Name CTRLDOffset 0x03Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 TCB0
Access RW Reset 0
Bit 0 ndash TCB0 TCB0 outputWrite this bit to 1 to select alternative output pin for 16-bit timercounter B 0
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
139
17 PORT - IO Pin Controller
171 OverviewThis device has up to three instances of the IO Pin Controller (PORT) called PORTA PORTB andPORTC Each instance controls a pin group of up to eight pins called PA[70] PB[70] and PC[70]
Refer to the IO Multiplexing table to see which pins are controlled by what instance The offset of thePORT instances and of the corresponding Virtual PORT instances is listed in the Peripherals andArchitecture section
The PORT peripherals control the IO pins of the device One port consists of up to eight port pins pin 0to 7 Each port pin can be configured as input or output with configurable driver and pull settings Theyalso implement synchronous and asynchronous input sensing with interrupts and events for selectablepin change conditions Asynchronous pin-change sensing means that a pin change can wake the devicefrom all sleep modes including the modes where no clocks are running
All functions are individual and configurable per pin The pins have hardware read-modify-write (RMW)functionality for safe and correct change of drive value andor pull resistor configuration The direction ofone port pin can be changed without unintentionally changing the direction of any other pin
The PORT pin configuration also controls input and output selection of other device functionsNote Some peripherals may override the configuration set by the PORT controller
Related LinksIO Multiplexing and Considerations on page 18Peripherals and Architecture on page 38
172 Featuresbull General purpose input and output pins with individual configurationbull Output driver with configurable inverted IO and pullupbull Input with synchronous andor asynchronous sensing with interrupts and Events
ndash Sense both edgesndash Sense rising edgesndash Sense falling edgesndash Sense low level
bull Asynchronous pin change sensing that can wake the device from all sleep modesbull Efficient and safe access to PORT pins
ndash Hardware read-modify-write through dedicated toggleclearset registersndash Mapping of often-used PORT registers into bit-accessible IO memory space (Virtual Ports)
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
140
173 Block DiagramFigure 17-1 PORT Block Diagram
DQ
R
DQ
R
D Q
R
D Q
R
D Q
R
Control
Logic
PINnCTRL
Pull Enable
Pull Keep
Pull Direction
OUTn
DIRn
SynchronizerINn
Digital Input PIn
Analog InputOutput
Input Disable
Wired ANDOR
Slew Rate Limit
Inverted IO
Pxn
174 Signal Description
Signal Type Description
EXTINT Digital input External interrupt - available on all IO pins
Related LinksIO Multiplexing and Considerations on page 18
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
141
175 Product DependenciesIn order to use this peripheral other parts of the system must be configured correctly as described below
Table 17-1 PORT Product Dependencies
Dependency Applicable Peripheral
Clocks Yes CLKCTRL
IO Lines and Connections No -
Interrupts Yes CPUINT
Events No -
Debug No -
Related LinksClocks on page 93Interrupts on page 61
1751 ClocksThis peripheral depends on the peripheral clock
Related LinksCLKCTRL - Clock Controller on page 75Product Dependencies on page 105
1752 IO Lines and ConnectionsNot applicable
1753 InterruptsUsing the interrupts of this peripheral requires the Interrupt Controller to be configured first
Related LinksCPUINT - CPU Interrupt Controller on page 104SREG on page 58Interrupts on page 144
1754 EventsNot applicable
1755 Debug OperationThis peripheral is unaffected by entering debug mode
176 Functional Description
1761 Principle of OperationThe IO pins of the device are controlled by PORT peripheral registers Each of the port pins has acorresponding bit in the Data Direction (PORTDIR) and Data Output Value (PORTOUT) registers toenable that pin as an output and to define the output state For example pin PB3 is controlled by DIR[3]and OUT[3] of the PORTB instance
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
142
The direction (input or output) of each pin in a pin group is configured by the PORTDIR register
When the direction is set as output the corresponding bit in the PORTOUT register will select the level ofthe pin If bit n in PORTOUT is written to 1 pin n is driven HIGH If bit n in PORTOUT is written to 0pin n is driven LOW Pin configuration can be set by writing to the Pin n Control registers(PORT_PINnCTRL) with n=07 representing the bit position
The Data Input Value (PORTIN) is set as the input value of a PORT pin with resynchronization to theMain Clock To reduce power consumption these input synchronizers are clocked only when the value ofthe Input Sense Configuration bit field (ISC) in PORTPINnCTRL is not INPUT_DISABLE The value ofthe pin can always be read whether the pin is configured as input or output
1762 Basic Operation
17621 InitializationAfter Reset all standard function device IO pads are connected to the PORT with outputs tri-stated andinput buffers enabled even if there is no clock running
Note For best power consumption leave unused pins in their default configuration after Reset
Specific pins such as those used for connecting a debugger may be configured differently as requiredby their special function
17622 Basic FunctionsEach IO pin Pxn can be controlled by the registers in PORT x Each pin group x has its own set of PORTregisters the base address of the register set for pin n is at the byte address PORT + 0x10 + Theindex within that register set is n
To use pin number n as an output write bit n of the DIR register to 1 This can also be done by writing bitn in the DIRSET register to 1 - this will avoid disturbing the configuration of other pins in that group Thenth bit in the OUT register must be written to the desired output value
Similarly writing an OUTSET bit to 1 will set the corresponding bit in the OUT register to 1 Writing a bitin OUTCLR to 1 will set that bit in OUT to zero Writing a bit in OUTTGL or IN to 1 will toggle that bit inOUT
To use pin n as an input bit n in the DIR register must be written to 0 This can also be done by writingbit n in the DIRCLR register to 1 - this will avoid disturbing the configuration of other pins in that groupThe input value can be read from bit n in register IN as long as the ISC is not set to INPUT DISABLE
In a similar way as OUTTGL can be used to toggle the value on an output DIRTGL can be used to togglea bit in DIR
1763 Virtual PortsThe Virtual Port registers map the most frequently used regular Port registers into the bit-accessible IOspace Writing to the Virtual Port registers has the same effect as writing to the regular registers butallows for memory-specific instructions such as bit-manipulation instructions which are not valid for theextended IO memory space where the regular Port registers resideTable 17-2 Virtual Port Mapping
Regular Port Register Mapped to Virtual Port Register
PORTDIR VPORTDIR
PORTOUT VPORTOUT
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
143
Regular Port Register Mapped to Virtual Port Register
PORTIN VPORTIN
PORTINTFLAG VPORTINTFLAG
Related LinksIO Multiplexing and Considerations on page 18Peripherals and Architecture on page 38
1764 Pin ConfigurationThe Pin n Configuration register (PORTPINnCTRL) is used to configure inverted IO pullup and inputsensing of a pin
All input and output on the respective pin n can be inverted by writing a 1 to the Inverted IO Enable bit(INVEN) in PORTPINnCTRLNote A small number of peripherals will override this setting
Toggling the INVEN bit causes an edge on the pin which can be detected by all peripherals using thispin and is seen by interrupts or Events if enabled
Pullup of pin n is enabled by writing a 1 to the Pullup Enable bit (PULLUPEN) in PORTPINnCTRL
Changes of the signal on a pin can trigger an interrupt The exact conditions are defined by writing to theInputSense bit field (ISC) in PORTPINnCTRL
When setting or changing interrupt settings take these points into accountbull If an INVEN bit is toggled in the same cycle as the interrupt setting the edge caused by the
inversion toggling may not cause an interrupt requestbull If an input is disabled while synchronizing an interrupt that interrupt may be requested on re-
enabling the input even if it is re-enabled with a different interrupt settingbull If the interrupt setting is changed while synchronizing an interrupt that interrupt may not be
accepted
1765 InterruptsTable 17-3 Available Interrupt Vectors and Sources
Offset Name Vector Description Conditions
0x00 PORTx PORT A B C interrupt INTn in PORTINTFLAGS is raised as configured by ISC bit inPORTPINnCTRL
Each PORT pin n can be configured as an interrupt source Each interrupt can be individually enabled ordisabled by writing to ISC in PORTPINCTRL
When an interrupt condition occurs the corresponding Interrupt Flag is set in the Interrupt Flags registerof the peripheral (peripheralINTFLAGS)
An interrupt request is generated when the corresponding interrupt is enabled and the Interrupt Flag isset The interrupt request remains active until the Interrupt Flag is cleared See the peripheralsINTFLAGS register for details on how to clear Interrupt Flags
Note Interrupt requests are only generated when Interrupts are enabled globally
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
144
Asynchronous Sensing Pin PropertiesTable 17-4 Behavior Comparison of FullyPartly Asynchronous Sense Pin
Pin Behavior With
Property Without Full Asynchronous SenseSupport
With Full AsynchronousSense Support
Minimum pulse width totrigger interrupt
At least one system clock cycle Less than a system clock cycle
Waking the device fromsleep modes
Only from sleep modes with stoppedMain Clock by using low-priorityinterrupts or pin change interrupts
From any sleep mode using anyinterrupt setting
Interrupt dead time No new interrupt for three cycles after theprevious
No such limitation
Minimum Wakeup pulselength
The value on pad should be kept until thesystem clock has restarted
No such limitation
Writing a 1 to a clearedflag in the same cycle ashardware tries to set theflag
The interrupt is lost Interrupt flag will be set onecycle delayed
Related LinksAVR CPU on page 47SREG on page 58
1766 Sleep Mode OperationWith the exception of interrupts and input synchronization all pin configurations are independent of sleepmode Peripherals connected to the Ports can be affected by sleep modes refer to the respectiveperipherals documentation
The PORT peripheral will always use the Main Clock Input synchronization will halt when this clockstops
1767 SynchronizationNot applicable
1768 Configuration Change ProtectionNot applicable
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
145
177 Register Summary - PORT
Offset Name Bit Pos
0x00 DIR 70 DIR[70]
0x01 DIRSET 70 DIRSET[70]
0x02 DIRCLR 70 DIRCLR[70]
0x03 DIRTGL 70 DIRTGL[70]
0x04 OUT 70 OUT[70]
0x05 OUTSET 70 OUTSET[70]
0x06 OUTCLR 70 OUTCLR[70]
0x07 OUTTGL 70 OUTTGL[70]
0x08 IN 70 IN[70]
0x09 INTFLAGS 70 INT[70]
0x0A
0x0F
Reserved
0x10 PINCTRL0 70 INVEN PULLUPEN ISC[20]
0x11 PINCTRL1 70 INVEN PULLUPEN ISC[20]
0x12 PINCTRL2 70 INVEN PULLUPEN ISC[20]
0x13 PINCTRL3 70 INVEN PULLUPEN ISC[20]
0x14 PINCTRL4 70 INVEN PULLUPEN ISC[20]
0x15 PINCTRL5 70 INVEN PULLUPEN ISC[20]
0x16 PINCTRL6 70 INVEN PULLUPEN ISC[20]
0x17 PINCTRL7 70 INVEN PULLUPEN ISC[20]
178 Register Description - Ports
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
146
1781 Data Direction
Name DIROffset 0x00Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 DIR[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash DIR[70] Data DirectionThis bit field selects the data direction for the individual pins n of the PortWriting a 1 to PORTDIR[n] configures and enables pin n as output pin
Writing a 0 to PORTDIR[n] configures pin n as input pin It can be configured by writing to the ISC bit inPORTPINnCTRL
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
147
1782 Data Direction Set
Name DIRSETOffset 0x01Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 DIRSET[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash DIRSET[70] Data Direction SetThis bit field can be used instead of a read-modify-write to set individual pins as outputWriting a 1 to DIRSET[n] will set the corresponding PORTDIR[n] bit
Reading this bit field will always return the value of PORTDIR
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
148
1783 Data Direction Clear
Name DIRCLROffset 0x02Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 DIRCLR[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash DIRCLR[70] Data Direction ClearThis register can be used instead of a read-modify-write to configure individual pins as inputWriting a 1 to DIRCLR[n] will clear the corresponding bit in PORTDIR
Reading this bit field will always return the value of PORTDIR
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
149
1784 Data Direction Toggle
Name DIRTGLOffset 0x03Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 DIRTGL[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash DIRTGL[70] Data Direction ToggleThis bit field can be used instead of a read-modify-write to toggle the direction of individual pins
Writing a 1 to DIRTGL[n] will toggle the corresponding bit in PORTDIR
Reading this bit field will always return the value of PORTDIR
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
150
1785 Output Value
Name OUTOffset 0x04Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 OUT[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash OUT[70] Output ValueThis bit field defines the data output value for the individual pins n of the portIf OUT[n] is written to 1 pin n is driven high
If OUT[n] is written to 0 pin n is driven low
In order to have any effect the pin direction must be configured
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
151
1786 Output Value Set
Name OUTSETOffset 0x05Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 OUTSET[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash OUTSET[70] Output Value SetThis bit field can be used instead of a read-modify-write to set the output value of individual pins to 1Writing a 1 to OUTSET[n] will set the corresponding bit in PORTOUT
Reading this bit field will always return the value of PORTOUT
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
152
1787 Output Value Clear
Name OUTCLROffset 0x06Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 OUTCLR[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash OUTCLR[70] Output Value ClearThis register can be used instead of a read-modify-write to clear the output value of individual pins to 0Writing a 1 to OUTSET[n] will clear the corresponding bit in PORTOUT
Reading this bit field will always return the value of PORTOUT
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
153
1788 Output Value Toggle
Name OUTTGLOffset 0x07Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 OUTTGL[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash OUTTGL[70] Output Value ToggleThis register can be used instead of a read-modify-write to toggle the output value of individual pinsWriting a 1 to OUTSET[n] will toggle the corresponding bit in PORTOUT
Reading this bit field will always return the value of PORTOUT
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
154
1789 Input Value
Name INOffset 0x08Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 IN[70]
Access R R R R R R R R Reset 0 0 0 0 0 0 0 0
Bits 70 ndash IN[70] Input ValueThis register shows the value present on the pins if the digital input driver is enabled IN[n] shows thevalue of pin n of the Port The input is not sampled and cannot be read if the digital input buffers aredisabled
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
155
17810 Interrupt Flags
Name INTFLAGSOffset 0x09Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 INT[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash INT[70] Interrupt Pin FlagThe INT Flag is set when a pin changestate matches the pins input sense configurationWriting a 1 to a flags bit location will clear the flag
For enabling and executing the interrupt refer to the interrupt level description
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
156
17811 Pin n Control
Name PINCTRL0 PINCTRL1 PINCTRL2 PINCTRL3 PINCTRL4 PINCTRL5 PINCTRL6PINCTRL7
Offset 0x10 + n0x01 [n=07]Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 INVEN PULLUPEN ISC[20]
Access RW RW RW RW RW Reset 0 0 0 0 0
Bit 7 ndash INVEN Inverted IO Enable
Value Description0 IO on pin n not inverted
1 IO on pin n inverted
Bit 3 ndash PULLUPEN Pullup Enable
Value Description0 Pullup disabled for pin n
1 Pullup enabled for pin n
Bits 20 ndash ISC[20] InputSense ConfigurationThese bits configure the input and sense configuration of pin n The sense configuration decides how thepin can trigger port interrupts If the input buffer is disabled the input cannot be read in the IN register
Value Name Description0x0 INTDISABLE Interrupt disabled but input buffer enabled
0x1 BOTHEDGES Sense both edges
0x2 RISING Sense rising edge
0x3 FALLING Sense falling edge
0x4 INPUT_DISABLE Digital input buffer disabled
0x5 LEVEL Sense low level
other - Reserved
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
157
179 Register Summary - VPORT
Offset Name Bit Pos
0x00 DIR 70 DIR[70]
0x01 OUT 70 OUT[70]
0x02 IN 70 IN[70]
0x03 INTFLAGS 70 INT[70]
1710 Register Description - Virtual Ports
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
158
17101 Data Direction
Name DIROffset 0x00Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 DIR[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash DIR[70] Data DirectionThis bit field selects the data direction for the individual pins in the Port When a Port is mapped as virtualaccessing this bit field is identical to accessing the actual PORTDIR register for the Port
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
159
17102 Output Value
Name OUTOffset 0x01Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 OUT[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash OUT[70] Output ValueThis bit field selects the data output value for the individual pins in the Port When a Port is mapped asvirtual accessing this bit field is identical to accessing the actual PORTOUT register for the Port
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
160
17103 Input Value
Name INOffset 0x02Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 IN[70]
Access R R R R R R R R Reset 0 0 0 0 0 0 0 0
Bits 70 ndash IN[70] Input ValueThis bit field holds the value present on the pins if the digital input buffer is enabled This bit field sets thedata direction for the individual pins in the Port When a Port is mapped as virtual accessing this bit fieldis identical to accessing the actual PORTIN register for the Port
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
161
17104 Interrupt Flag
Name INTFLAGSOffset 0x03Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 INT[70]
Access R R R R R R R R Reset 0 0 0 0 0 0 0 0
Bits 70 ndash INT[70] Interrupt Pin FlagThe INT flag is set when a pin changestate matches the pins input sense configuration and the pin isconfigured as source for port interruptWriting a 1 to this flags bit location will clear the flag
For enabling and executing the interrupt refer to the interrupt level description
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
162
18 BOD - Brownout Detector
181 OverviewThe Brownout Detector (BOD) monitors the power supply and compares the voltage with twoprogrammable threshold levels One threshold level defines when to generate a Reset the otherthreshold defines when to generate an interrupt request
182 Featuresbull Brownout detectionbull Programmable BOD levelbull Three modes
ndash Enabledndash Sampledndash Disabled
bull Separate selection of mode for Active mode and sleep modesbull Voltage level monitor (VLM) with interruptbull Programmable VLM level relative to the BOD level
183 Block DiagramFigure 18-1 BOD Block Diagram
+
-
+
-
Bandgap
Bandgap
BOD level and
calibration
BOD interrupt level
Brownout detection
Low voltage interrupt detection
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
163
184 Product DependenciesIn order to use this peripheral other parts of the system must be configured correctly as described below
Table 18-1 BOD Product Dependencies
Dependency Applicable Peripheral
Clocks Yes CLKCTRL
IO Lines and Connections No -
Interrupts Yes CPUINT
Events Yes EVSYS
Debug Yes UPDI
Related LinksClocks on page 164Interrupts on page 61Events on page 61Debug Operation on page 164
1841 ClocksThe BOD uses the 32KHz oscillator (OSCULP32K) as clock source for CLK_BOD
1842 IO Lines and ConnectionsNot applicable
1843 InterruptsUsing the interrupts of this peripheral requires the Interrupt Controller to be configured first
Related LinksCPUINT - CPU Interrupt Controller on page 104SREG on page 58Interrupts on page 144
1844 EventsNot applicable
1845 Debug OperationThis peripheral is unaffected by entering debug mode
Note The VLM interrupt will not be executed if the CPU is halted in debug mode
If the peripheral is configured to require periodical service by the CPU through interrupts or similarimproper operation or data loss may result during halted debugging
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
164
185 Functional Description
1851 Principle of OperationThe BOD monitors the power supply and compares the voltage with the programmable brownoutthreshold level The BOD generates a Reset if the supply voltage crosses below the brownout thresholdlevel
The BOD also contains a voltage level monitor (VLM) that also monitors the power supply but comparesit to a threshold higher than the BOD threshold The VLM can then generate an interrupt request as earlywarning when the supply voltage is dropping below the VLM threshold The VLM threshold level isexpressed in percent above the BOD threshold level
The BOD is mainly controlled by fuses The mode used in Standby sleep mode and Power Down sleepmode can be altered in normal program execution The VLM part of the BOD is controlled by IO registersas well
In addition to Off mode the BOD can also operate in Continuous mode (the BOD is on all the time) andSampled mode (the BOD is periodically turned on briefly to check the supply voltage level)
1852 Basic Operation
18521 InitializationThe BOD is getting its default settings from fuses at device startup The BOD level operating mode inActive mode and Idle sleep mode are set by fuses and cannot be changed The operation mode inStandby sleep mode and Power Down sleep mode are loaded from fuses too but can be changed innormal program execution
The Voltage Level Monitor function can be enabled by writing a 1 to the VLMIE bit in the Interrupt Controlregister (BODINTCTRL)
Note The VLM functionality will follow the BOD mode If the BOD is turned off the VLM will notenabled even if the VLMINTEN is 1 If the BOD is using sampled mode the VLM will also be sampled
The VLM threshold is defined by writing the VLM Level bits (VLMLVL) in the VLM Control A register(BODVLMCTRLA)
The VLM interrupt is enabled by writing a 1 to the VLM Interrupt Enable bit (VLMIE) in the VLM InterruptControl register (BODINTCTRL) The VLM interrupt is configured by writing the VLM Configuration bits(VLMCFG) in BODINTCTRL An interrupt is requested either when the supply voltage crosses the VLMthreshold from above from below or from any directionNote If the BODVLM is enabled in sampled mode only VLMCFG=0x1 (crossing threshold from above)in BODINTCTRL is valid
1853 InterruptsTable 18-2 Available Interrupt Vectors and Sources
Offset Name Vector Description Conditions
0x00 VLM Voltage Level Monitor Supply voltage crossing the VLM threshold as configured byVLMCFG in BODINTCTRL
When an interrupt condition occurs the corresponding Interrupt Flag is set in the Interrupt Flags registerof the peripheral (peripheralINTFLAGS)
An interrupt source is enabled or disabled by writing to the corresponding enable bit in the peripheralsInterrupt Control register (peripheralINTCTRL)
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
165
An interrupt request is generated when the corresponding interrupt source is enabled and the InterruptFlag is set The interrupt request remains active until the Interrupt Flag is cleared See the peripheralsINTFLAGS register for details on how to clear Interrupt Flags
Note Interrupt requests are only generated when Interrupts are enabled globally
Related LinksAVR CPU on page 47SREG on page 58
1854 Sleep Mode OperationThere are two separate fuses defining the BOD configuration in different sleep modes One fuse definesthe mode used in Active mode and Idle sleep mode (ACTIVE in FUSEBODCFG) and is written to theACTIVE bits in the Control A register (BODCTRLA) The second fuse (SLEEP in FUSEBODCFG)selects the mode used in Standby sleep mode and Power Down sleep mode and is loaded into theSLEEP bits in the Control A register (BODCTRLA)
The operating mode in Idle sleep mode (ie ACTIVE in BODCTRLA) cannot be altered by software Theoperation mode in Standby sleep mode and Power Down sleep mode can be altered by writing to theSLEEP bits in the Control A register (BODCTRLA)
When the device is going into Standby sleep mode or Power Down sleep mode the BOD will changeoperation mode as defined by SLEEP in BODCTRLA When the device is waking up from Standby orPower Down sleep mode the BOD will operate in the mode defined by the ACTIVE bit field inBODCTRLA
1855 SynchronizationWhen the BOD changes mode from Enabled to Sampled mode it needs to re-synchronize to the sampledclock This is done automatically
Note When the sampling rate for the BOD is 1KHz and the BOD is switching from Enabled to Sampledmode the first sample is delayed up to 12 cycle due to synchronization This only happens on the firstsample after changing to Sampled mode
1856 Configuration Change ProtectionThis peripheral has registers that are under Configuration Change Protection (CCP) In order to write tothese a certain key must be written to the CPUCCP register first followed by a write access to theprotected bits within four CPU instructions
It is possible to try writing to these registers any time but the values are not altered
The following registers are under CCP
Table 18-3 Registers under Configuration Change Protection
Register Key
SLEEP in BODCTRLA IOREG
Related LinksSequence for Write Operation to Configuration Change Protected IO Registers on page 53
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
166
186 Register Summary
Offset Name Bit Pos
0x00 CTRLA 70 SAMPLFREQ ACTIVE[10] SLEEP[10]
0x01 CTRLB 70 LVL[20]
0x02
0x07
Reserved
0x08 CTRLA 70 VLMLVL[10]
0x09 INTCTRL 70 VLMCFG[10] VLMIE
0x0A INTFLAGS 70 VLMIF
0x0B STATUS 70 VLMS
187 Register Description
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
167
1871 Control A
Name CTRLAOffset 0x00Reset Loaded from fuseProperty
-
Bit 7 6 5 4 3 2 1 0 SAMPLFREQ ACTIVE[10] SLEEP[10]
Access R R R R R R RW RW Reset 0 0 0 0 0 0 0 0
Bit 4 ndash SAMPLFREQ Sample FrequencyThis bit selects the BOD sample frequencyNote The Reset value is loaded from the SAMPLEFREQ bit in FUSEBODCFG
Value Description0x0 Sample frequency is 1kHz
0x1 Sample frequency is 125Hz
Bits 32 ndash ACTIVE[10] ActiveThese bits selects the BOD operation mode when the device is in active or idle mode
Note The Reset value is loaded from the ACTIVE bits in FUSEBODCFG
Value Description0x0 Disabled
0x1 Enabled
0x2 Sampled
0x3 Enabled with wake-up halted until BOD is ready
Bits 10 ndash SLEEP[10] SleepThese bits select the BOD operation mode when the device is in standby or power-down sleep modeThese bits are under Configuration Change Protection (CCP)
Note The Reset value is loaded from the SLEEP bits in FUSEBODCFG
Value Description0x0 Disabled
0x1 Enabled
0x2 Sampled
0x3 Reserved
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
168
1872 Control B
Name CTRLBOffset 0x01Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 LVL[20]
Access R R R R R R R R Reset 0 0 0 0 0 0 0 0
Bits 20 ndash LVL[20] BOD LevelThese bits selects the BOD threshold level The value is loaded from the BOD Level bits (LVL) in theBOD Configuration fuse (FUSEBODCFG)
Value Description0x0 18V
0x1 215V
0x2 251V
0x3 287V
0x4 323V
0x5 359V
0x6 394V
0x7 43V
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
169
1873 VLM Control A
Name CTRLAOffset 0x08Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 VLMLVL[10]
Access R R R R R R RW RW Reset 0 0 0 0 0 0 0 0
Bits 10 ndash VLMLVL[10] VLM LevelThese bit select the Voltage Level Monitor threshold relative to the BOD threshold (LVL in BODCTRLB)
Value Description0x0 VLM threshold 5 above BOD threshold
0x1 VLM threshold 15 above BOD threshold
0x2 VLM threshold 25 above BOD threshold
other Reserved
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
170
1874 Interrupt Control
Name INTCTRLOffset 0x09Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 VLMCFG[10] VLMIE
Access R R R R R RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 21 ndash VLMCFG[10] VLM ConfigurationThese bits select which incidents will trigger a VLM interrupt
Value Description0x0 Voltage crosses VLM threshold from above
0x1 Voltage crosses VLM threshold from below
0x2 Either direction is triggering an interrupt request
Other Reserved
Bit 0 ndash VLMIE VLM Interrupt EnableWriting a 1 to this bit enables the Voltage Level Monitor (VLM) interrupt
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
171
1875 VLM Interrupt Flags
Name INTFLAGSOffset 0x0AReset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 VLMIF
Access R R R R R R R RW Reset 0 0 0 0 0 0 0 0
Bit 0 ndash VLMIF VLM Interrupt FlagThis flag is set when a trigger from the VLM is given as configured by the VLMCFG bit in theBODINTCTRL register The flag remains set only as long as the BOD is enabled
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
172
1876 VLM Status
Name STATUSOffset 0x0BReset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 VLMS
Access R R R R R R R R Reset 0 0 0 0 0 0 0 0
Bit 0 ndash VLMS VLM Status
Value Description0 The voltage is above the VLM threshold level
1 The voltage is below the VLM threshold level
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
173
19 VREF - Voltage Reference
191 OverviewThe Voltage Reference peripheral (VREF) provides control registers for the voltage reference sourcesused by several peripherals
A voltage reference source is enabled automatically when requested by a peripheral They can also beenabled even if not requested
192 Featuresbull Two programmable voltage reference sources
ndash One for ADC peripheralndash One for AC and DAC peripheral
bull Each reference source supports five different voltagesndash 055Vndash 11Vndash 15Vndash 25Vndash 434V
193 Block DiagramFigure 19-1 Block Diagram VREF
CTRLA CTRLB
ADC
REF
SEL
DAC
REF
SEL
ADCREFEN
DACREFEN
InternalBandgap
VREF
ADC Reference Generator
DAC and ACReference Generator
REF_ADC
REF_DAC REF_AC
ADC reference request
AC or DAC reference request
reference request
reference request
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
174
194 Functional Description
1941 Principal of OperationThe user can select the reference voltages for the ADC by writing to the ADC Reference Select bit field(ADCREFSEL) in the Control A register (VREFCTRLA) and for both AC and DAC by writing to the DACand AC Reference Select bit field DACREFSEL in VREFCTRLA
The user can enable the reference voltage sources (and thus override the automatic disabling of unusedsources) by writing to the respective Force Enable bit (ADCREFEN DACREFEN) in the Control Bregister (VREFCTRLB) This may be desirable to decrease startup time at the cost of increased powerconsumption
1942 Basic Operation
19421 InitializationThe default configuration will enable the respective source when the ADC AC or DAC is requesting areference voltage The default reference voltages are 055V but can be configured by writing to therespective Reference Select bit field (ADCREFSEL DACREFSEL) in the Control A register(VREFCTRLA)
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
175
195 Register Summary
Offset Name Bit Pos
0x00 CTRLA 70 ADCREFSEL[20] DACREFSEL[20]
0x01 CTRLB 70 ADCREFEN DACREFEN
196 Register Description
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
176
1961 Control A
Name CTRLAOffset 0x00Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 ADCREFSEL[20] DACREFSEL[20]
Access RW RW RW RW RW RW Reset 0 0 0 0 0 0
Bits 64 ndash ADCREFSEL[20] ADC Reference SelectThese bits select the reference voltage for the ADCTable 19-1 ADC Reference Voltage
ADCREFSEL Reference Voltage
0x0 055 V
0x1 11 V
0x2 25 V
0x3 4 34 V
0x4-0x7 15 V
Value Description0x0 055V
0x1 11V
0x2 25V
0x3 434V
other 15V
Bits 20 ndash DACREFSEL[20] DAC and AC Reference SelectThese bits select reference voltage for the DAC and AC
Value Description0x0 055V
0x1 11V
0x2 25V
0x3 434V
other 15V
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
177
1962 Control B
Name CTRLBOffset 0x01Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 ADCREFEN DACREFEN
Access RW RW Reset 0 0
Bit 1 ndash ADCREFEN ADC Reference Force EnableWriting a 1 to this bit forces the voltage reference for the ADC to be running even if it not requested
Writing a 0 to this bit allows automatic disabling of the reference source when not requested
Bit 0 ndash DACREFEN DAC and AC Reference Force EnableWriting a 1 to this bit forces the voltage reference for the DAC and AC to be running even if it notrequested
Writing a 0 to this bit allows automatic disabling of the reference source when not requested
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
178
20 WDT - Watchdog Timer
201 OverviewThe Watchdog Timer (WDT) is a system function for monitoring correct program operation It allows torecover from situations such as runaway or deadlocked code The WDT is a timer configured to apredefined timeout period and is constantly running when enabled If the WDT is not reset within thetimeout period it will issue a System Reset The WDT is reset by executing the WDR (Watchdog TimerReset) instruction from the application code
A window mode allows to define a time slot or window inside the timeout period during which the WDTmust be reset If the WDT is reset outside this window either too early or too late a System Reset will beissued Compared to the normal mode the window mode can also catch situations where a code errorcauses constant WDR execution
When enabled the WDT will run in active mode and all sleep modes It is asynchronous ie running froma CPU-independent clock source For this reason it will continue to operate and be able to issue aSystem Reset even if the main clock fails
The Configuration Change Protection mechanism ensures that the WDT settings cannot be changed byaccident For increased safety a configuration for locking the WDT settings is also available
Related LinksCCP - Configuration Change Protection on page 53
202 Featuresbull Issues a System Reset if the Watchdog Timer is not cleared before its timeout periodbull Operating asynchronously from system clock using an independent oscillatorbull Using the 1KHz output of the 32KHz Ultra Low Power oscillator (OSCULP32K)bull 11 selectable timeout periods from 8ms to 8sbull Two operation modes
ndash Normal Modendash Window Mode
bull Configuration lock to prevent unwanted changesbull Closed period timer activation after first WDT instruction for easy setup
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
179
203 Block DiagramFigure 20-1 WDT Block Diagram
PERIOD
WINDOW
COUNT
=
=
Inside closed window
Enable open window and clear count
CLK_WDT
WDR(instruction)
SystemReset
204 Signal DescriptionNot applicable
205 Product DependenciesIn order to use this peripheral other parts of the system must be configured correctly as described below
Table 20-1 WDT Product Dependencies
Dependency Applicable Peripheral
Clocks Yes CLKCTRL
IO Lines and Connections No -
Interrupts No -
Events No -
Debug Yes UPDI
Related LinksClocks on page 180Debug Operation on page 181
2051 ClocksA 1KHz oscillator clock (CLK_WDT_OSC) is sourced from the internal ultra-low-power oscillatorOSC32K Due to the ultra-low-power design the oscillator is not very accurate and so the exact time-outperiod may vary from device to device This variation must be kept in mind when designing software thatuses the WDT to ensure that the time-out periods used are valid for all devices
The counter clock CLK_WDT_OSC is asynchronous to the system clock Due to this asynchronicitywriting to WDT control register will require synchronization between the clock domains
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
180
2052 IO Lines and ConnectionsNot applicable
2053 InterruptsNot applicable
2054 EventsNot applicable
2055 Debug OperationWhen run-time debugging this peripheral will continue normal operation Halting the CPU in debuggingmode will halt normal operation of the peripheral
When halting the CPU in debug mode the WDT counter is reset
when starting the CPU again and the WDT was operating in window mode the first closed windowtimeout period will be disabled and a normal mode timeout period is executed
Related LinksWindow Mode on page 182
206 Functional Description
2061 Principle of OperationThe Watchdog Timer (WDT) is a system for monitoring correct program operation making it possible torecover from error situations such as runaway code by issuing a Reset When enabled the WDT is aconstantly running timer that is configured to a predefined time-out period Before the end of the time-outperiod the WDT should be set back or else a system Reset is issued
The WDT has two modes of operation Normal mode and Window mode The description for each of thebasic modes is given below The settings in the Control A register (CTRLA) determine the mode ofoperation
2062 Basic Operation
20621 Initializationbull The WDT is enabled when a non-zero value is written to the Period bits (PERIOD) in the Control A
register (WDTCTRLA)bull Optional Write a non-zero value to the Window bits (WINDOW) in WDTCTRLA to enable window
mode operation
All bits in the Control A register and the Lock bit (LOCK) in the Status register (WDTSTATUS) are writeprotected by the Configuration Change Protection mechanism
Note The Reset value of WDTCTRLA is defined by a fuse (FUSEWDTCFG) so the WDT can beenabled at boot time If this is the case the LOCK bit in WDTSTATUS is set at boot time too
Related LinksRegister Summary on page 185
20622 Normal ModeIn normal mode operation a single timeout period is set for the WDT If the WDT is not reset from theapplication code using the WDR any time before the timeout occurs the WDT will issue a System Reset
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
181
A new WDT timeout period will be started each time the WDT is reset by WDR
There are 11 possible WDT timeout periods (TOWDT) selectable from 8ms to 8s by writing to the Periodbit field (PERIOD) in the Control A register (WDTCTRLA)
Figure 20-2 Normal Mode Operation
t [ms]
WDT Count
5 10 15 20 25 30 35
Timely WDT Reset (WDR)
TOWDT
WDT TimeoutSystem Reset
TO WDT = 16msHere
Note Normal mode is enabled as long as the WINDOW bit field in the Control A register (WDTCTRLA)is 0x0
Related LinksRegister Summary on page 185
20623 Window ModeIn window mode operation the WDT uses two different timeout periods a closed window timeout period(TOWDTW) and the normal timeout period (TOWDT)
The closed window timeout period defines a duration from 8ms to 8s where the WDT cannot be reset Ifthe WDT is reset during this period the WDT will issue a System Reset
The normal WDT timeout period which is also 8ms to 8s defines the duration of the open period duringwhich the WDT can (and should) be reset The open period will always follow the closed period so thetotal duration of the timeout period is the sum of the closed window and the open window timeout periods
After device startup or in debug break mode the first closed period is activated after the first WDRinstruction
Figure 20-3 Window Mode Operation
t [ms]
WDT Count
5 10 15 20 25 30 35
Timely WDT Reset (WDR)
Clo
sed
TOWDTW
Op e
n
TOWDT
System ResetWDR too early
TOWDTW =TOWDT = 8msHere
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
182
Note The window mode is enabled by writing a non-zero value to the WINDOW bit field in the Control Aregister (WDTCTRLA) and disabled by writing WINDOW=0x0
2063 Configuration Protection and LockThe WDT provides two security mechanisms to avoid unintentional changes to the WDT settings
The first mechanism is the Configuration Change Protection mechanism employing a timed writeprocedure for changing the WDT control registers
The second mechanism locks the configuration by writing a 1 to the LOCK bit in the Status register(WDTSTATUS) When this bit is 1 the Control A register (WDTCTRLA) cannot be changedConsequently the WDT cannot be disabled from software
LOCK in WDTSTATUS can only be written to 1 It can only be cleared in debug mode
If the WDT is enabled in startup Boot code LOCK is automatically set in WDTSTATUS
Related LinksCCP - Configuration Change Protection on page 53
2064 EventsNot applicable
2065 InterruptsNot applicable
2066 Sleep Mode OperationThe WDT will continue to operate in any sleep mode where the source clock is active
2067 SynchronizationDue to asynchronicity between the main clock domain and the peripheral clock domain the Control Aregister (WDTCTRLA) is synchronized when written The Synchronization Busy flag (SYNCBUSY) in theStatus register (WDTSTATUS) indicates if there is an ongoing synchronization
Writing to WDTCTRLA while SYNCBUSY=1 is not allowed
The following registers are synchronized when written
bull PERIOD bits in Control A register (WDTCTRLA)bull Window Period bits (WINDOW) in WDTCTRLA
2068 Configuration Change ProtectionThis peripheral has registers that are under Configuration Change Protection (CCP) In order to write tothese a certain key must be written to the CPUCCP register first followed by a write access to theprotected bits within four CPU instructions
It is possible to try writing to these registers any time but the values are not altered
The following registers are under CCP
Table 20-2 WDT - Registers under Configuration Change Protection
Register Key
WDTCTRLA IOREG
LOCK bit in WDTSTATUS IOREG
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
183
List of bitsregisters protected by CCP
bull Period bits in Control A register (CTRLAPERIOD)bull Window Period bits in Control A register (CTRLAWINDOW)bull Lock bit in Status register (STATUSLOCK)
Related LinksCCP - Configuration Change Protection on page 53Sequence for Write Operation to Configuration Change Protected IO Registers on page 53CCP on page 56
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
184
207 Register Summary
Offset Name Bit Pos
0x00 CTRLA 70 WINDOW[30] PERIOD[30]
0x01 STATUS 70 LOCK SYNCBUSY
0x02
0x03
Reserved
0x04 CCP 70 CCP[70]
208 Register Description
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
185
2081 Control A
Name CTRLAOffset 0x00Reset From FUSEWDTCFGProperty
Configuration Change Protection
Bit 7 6 5 4 3 2 1 0 WINDOW[30] PERIOD[30]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 74 ndash WINDOW[30] WindowWriting a non-zero value to these bits enables the window mode and selects the according duration ofthe closed period
The bits are optionally lock protected
bull If LOCK bit in WDTSTATUS is 1 all bits are change protected (Access = R)bull If LOCK bit in WDTSTATUS is 0 all bits can be changed (Access = RW)
Value Name Description0x0 OFF -
0x1 8CLK 0008s
0x2 16CLK 0016s
0x3 32CLK 0032s
0x4 64CLK 0064s
0x5 128CLK 0128s
0x6 256CLK 0256s
0x7 512CLK 0512s
0x8 1KCLK 10s
0x9 2KCLK 20s
0xA 4KCLK 41s
other 8KCLK 82s
Bits 30 ndash PERIOD[30] PeriodWriting a non-zero value to this bit enables the WDT and selects the according timeout period in normalmode In window mode these bits select the duration of the open window
The bits are optionally lock protected
bull If LOCK in WDTSTATUS is 1 all bits are change protected (Access = R)bull If LOCK in WDTSTATUS is 0 all bits can be changed (Access = RW)
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
186
Value Name Description0x0 OFF -
0x1 8CLK 0008s
0x2 16CLK 0016s
0x3 32CLK 0032s
0x4 64CLK 0064s
0x5 128CLK 0128s
0x6 256CLK 0256s
0x7 512CLK 0512s
0x8 1KCLK 10s
0x9 2KCLK 20s
0xA 4KCLK 41s
other 8KCLK 82s
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
187
2082 Status
Name STATUSOffset 0x01Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 LOCK SYNCBUSY
Access RW R Reset 0 0
Bit 7 ndash LOCK LockWriting this bit to 1 write protects the WDTCTRLA register
It is only possible to write this bit to 1 This bit can only be cleared in debug
If the PERIOD bits in WDTCTRLA are different from zero after boot code Lock will automatically be set
This bit is under Configuration Change Protection (CCP)
Bit 0 ndash SYNCBUSY Synchronization BusyThis bit is set after writing to the WDTCTRLA register while the data is being synchronized from thesystem clock domain to the WDT clock domain
This bit is cleared by system after the synchronization is finished
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
188
21 TCA - 16-bit TimerCounter Type A
211 OverviewThe flexible 16-bit PWM TimerCounter type A (TCA) provides accurate program execution timingfrequency and waveform generation and command execution
A TCA consists of a base counter and a set of compare channels The base counter can be used to countclock cycles or events or let events control how it counts clock cycles It has direction control and periodsetting that can be used for timing The compare channels can be used together with the base counter todo compare match control frequency generation and pulse width waveform modulation
A timercounter can be clocked and timed from the peripheral clock with optional prescaling or from theevent system The event system can also be used for direction control or to synchronize operations
The timerCounter has a split mode feature that splits it into two 8-bit timercounters with three comparechannels each
A block diagram of the 16-bit timercounter with closely related peripheral modules (in grey) is shownbelow
Figure 21-1 16-bit Timercounter and Closely Related Peripherals
CounterControl Logic
Timer Period
TimerCounterBase Counter Prescaler
EventSystem
CLK_PER
POR
TS
Comparator
Buffer
Compare Channel 2Compare Channel 1
Compare Channel 0
WaveformGeneration
CLK_TCA
212 Featuresbull 16-bit timercounterbull Three compare channelsbull Double buffered timer period settingbull Double buffered compare channelsbull Waveform generation
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
189
ndash Frequency generationndash Single-slope PWM (pulse width modulation)ndash Dual-slope PWM
bull Count on eventbull Timer overflow interruptseventsbull One compare match per compare channelbull Two 8-bit timercounters in Split Mode
213 Block DiagramThe below figure shows a detailed block diagram of the timercounter
Figure 21-2 TimerCounter Block DiagramBase Counter
Compare(Unit x = ABC)
Counter
=
CMPx
CMPxBUF
WaveformGeneration
BV
=
PERB
PER
CNT
BV
= 0
countclear
directionload
Control Logic
EVCTRL
CTRLA
OVFUNF(INT Req)
TOP
match CMPx(INT Req)
Control Logic
Clock Select
ev
UPD
ATE
BOTTOM
WOn Out
EventSelect
The counter register (CNT) period registers with buffer (PER and PERB) and compare registers withbuffers (COMPx and COMPBx) are 16-bit registers All buffer registers have a buffer valid (BV) flag thatindicates when the buffer contains a new value
During normal operation the counter value is continuously compared to zero and the period (PER) valueto determine whether the counter has reached TOP or BOTTOM
The counter value is also compared to the COMPx registers These comparisons can be used togenerate interrupt requests The waveform generator modes use these comparisons to set the waveformperiod or pulse width
A prescaled peripheral clock and events from the event system can be used to control the counter
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
190
214 Signal Description
Signal Description Type
WO[20] Digital output Waveform output
WO[53] Digital output Waveform output - Split Mode only
215 Product DependenciesIn order to use this peripheral other parts of the system must be configured correctly as described below
Table 21-1 TCA Product Dependencies
Dependency Applicable Peripheral
Clocks Yes CLKCTRL
IO Lines and Connections No -
Interrupts Yes CPUINT
Events Yes EVSYS
Debug Yes UPDI
Related LinksClocks on page 191Interrupts on page 61Events on page 191Debug Operation on page 192
2151 ClocksThis peripheral uses the system clock CLK_PER and has its own prescaler
Related LinksCLKCTRL - Clock Controller on page 75
2152 IO Lines and ConnectionsNot applicable
2153 InterruptsUsing the interrupts of this peripheral requires the Interrupt Controller to be configured first
Related LinksCPUINT - CPU Interrupt Controller on page 104SREG on page 58Interrupts on page 144
2154 EventsThe events of this peripheral are connected to the Event System
Related LinksEVSYS - Event System on page 116
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
191
2155 Debug OperationWhen run-time debugging this peripheral will continue normal operation Halting the CPU in debuggingmode will halt normal operation of the peripheral
This peripheral can be forced to operate with halted CPU by writing a 1 to the Debug Run bit (DBGRUN)in the Debug Control register of the peripheral (peripheralDBGCTRL)
Related LinksUPDI - Unified Program and Debug Interface on page 502
216 Functional Description
2161 Principle of OperationDepending on the mode of operation the counter is cleared reloaded incremented or decremented ateach timercounter clock or event input
By default the TCA is a 16-bit timercounter It can be split to work as two 8-bit timercounters
2162 Basic Operation
21621 DefinitionsThe following definitions are used throughout the documentation
Table 21-2 TimerCounter Definitions
Name Description
BOTTOM The counter reaches BOTTOM when it becomes zero
MAX The counter reaches MAXimum when it becomes all ones
TOP The counter reaches TOP when it becomes equal to the highest value in the countsequence Depending on the waveform generator mode the TOP value can be equal to thePeriod register a Compare channel n register setting
UPDATE The timercounter signals an update when it reaches BOTTOM or TOP depending on thewaveform generator mode
CNT Counter register value
CAPT Capturecompare register value
In general the term ldquotimerrdquo is used when the timercounter clock control is handled by an internal sourceand the term ldquocounterrdquo is used when the clock control is handled externally (eg counting externalEvents)
21622 InitializationTo start using the timercounter in a basic mode follow these steps
bull Write a TOP value to the Period register (TCAPER)bull Enable the peripheral by writing a 1 to the ENABLE bit in the Control A register (TCACTRLA)
The counter will start counting clock ticks according to the prescaler setting in the Clock Select bitfield (CLKSEL) in TCACTRLA
bull Optional By writing a 1 to the Enable Count on Event Input bit (CNTEI) in the Event Controlregister (TCAEVCTRL) Event inputs are counted instead of clock ticks
bull The counter value can be read from the Counter bit field (CNT) in the Counter register (TCACNT)
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
192
21623 Normal OperationIn normal operation the counter is counting clock ticks in the direction selected by the Direction bit (DIR)in the Control E register (TCACTRLE) until it reaches TOP or BOTTOM The clock ticks are from theperipheral clock CLK_PER optionally prescaled depending on the Clock Select bit field (CLKSEL) in theControl A register (TCACTRLA)
When up-counting and TOP is reached the counter will wrap to zero at the next clock tick When down-counting the counter is reloaded with the Period register value (TCAPER) when BOTTOM is reached
Figure 21-3 Normal OperationCNT written
update
CNT
DIR
MAX
TOP
BOTTOM
It is possible to change the Counter value in the Counter register (TCACNT) when the counter is runningThe write access to TCACNT has higher priority than count clear or reload and will be immediate Thedirection of the counter can also be changed during normal operation by writing to DIR in TCACTRLE
21624 Double BufferingThe Period register value (TCAPER) and the Compare n register values (TCACMPn) are all doublebuffered (TCAPERBUF and TCACMPnBUF)
Each buffer register has a Buffer Valid flag (PERBV CMPnBV) in the Control F register (TCACTRLF)which indicates that the buffer register contains a valid ie new value that can be copied into thecorresponding Period or Compare register When the Period register and Compare n registers are usedfor a Compare operation the BV flag is set when data is written to the buffer register and cleared on anUPDATE condition This is shown for a Compare register in below
Figure 21-4 Period and Compare Double Buffering
UPDATE
write enable data write
CNT
match
EN
EN
CMPnBUF
CMPn
BV
=
Both the TCACMPn and TCACMPnBUF registers are available as IO registers This allows initializationand bypassing of the buffer register and the double buffering function
21625 Changing the PeriodThe Counter period is changed by writing a new TOP value to the Period register (TCAPER)
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
193
No Buffering If double buffering is not used any period update is immediate
Figure 21-5 Changing the Period without Buffering
CNT
MAX
BOTTOM
Counter wraparound
update
write
New TOP written toPER that is higherthan current CNT
New TOP written toPER that is lowerthan current CNT
A counter wraparound can occur in any mode of operation when up-counting without buffering This dueto the fact that the registers TCACNT and TCAPER are continuously compared if a new TOP value iswritten to TCAPER that is lower than current TCACNT the counter will wrap first before a comparematch happenedFigure 21-6 Unbuffered Dual-slope Operation
Counter wraparound
update
write
MAX
BOTTOM
CNT
New TOP written toPER that is higherthan current CNT
New TOP written toPER that is lowerthan current CNT
With Buffering When double buffering is used the buffer can be written at any time and still maintaincorrect operation The TCAPER is always updated on the UPDATE condition as shown for dual-slopeoperation in the figure below This prevents wraparound and the generation of odd waveformsFigure 21-7 Changing the Period Using Buffering
CNT
BOTTOM
MAX
update
write
New Period written toPERB that is higherthan current CNT
New Period written toPERB that is lowerthan current CNT
New PER is updatedwith PERB value
21626 Compare ChannelEach Compare Channel n continuously compares the counter value (TCACNT) with the Compare nregister (TCA_CMPn) If TCACNT equals TCACMPn the comparator n signals a match The match willset the Compare Channels interrupt flag at the next timer clock cycle and the optional interrupt isgenerated
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
194
The Compare n Buffer register (TCACMPnBUF) provides double buffer capability equivalent to that forthe period buffer The double buffering synchronizes the update of the TCACMPn register with the buffervalue to either the TOP or BOTTOM of the counting sequence according to the UPDATE condition Thesynchronization prevents the occurrence of odd-length non-symmetrical pulses for glitch-free output
Waveform GenerationThe compare channels can be used for waveform generation on the corresponding port pins To make thewaveform visible on the connected port pin the following requirements must be fulfilled
1 A waveform generation mode must be selected by writing the WGMODE bit field in TCACTRLB2 The TCA is counting clock tick not Events (CNTEI=0 in TCAEVCTRL)3 The compare channels used must be enabled (CMPnEN=1 in TCACTRLB) This will override the
corresponding PORT pin output register An alternative pin can be selected by writing to therespective TCA Waveform Output n bit (TCA0n) in the Control C register of the Port Multiplexer(PORTMUXCTRLC)
4 The direction for the associated Port pin n must be configured as output (PORTDIR[n]=1)5 Optional Enable inverted waveform output for the associated Port pin n (INVEN=1 in PORTPINn)
Frequency (FRQ) Waveform GenerationFor frequency generation the period time (T) is controlled by a TCACMPn register instead of the Periodregister (TCAPER) The waveform generation output WG is toggled on each compare match betweenthe TCACNT and TCACMPn registers
Figure 21-8 Frequency Waveform Generation
CNT
WG Output
MAX
TOP
BOTTOM
Period (T) Direction change CNT written
update
The waveform frequency (fFRQ) is defined by the following equationFRQ = fCLK_PER2 CMPn+1where N represents the prescaler divider used (CLKSEL in TCACTRLA) and fCLK_PER is the systemclock for the peripherals
The maximum frequency of the waveform generated is half of the peripheral clock frequency (fCLK_PER2)when TCACMPn is written to zero (0x0000) and no prescaling is used (N=1 CLKSEL=0x0 inTCACTRLA)
Single-Slope PWM GenerationFor single-slope Pulse Width Modulation (PWM) generation the period (T) is controlled by TCAPERwhile the values of TCACMPn control the duty cycle of the WG output The figure below shows how thecounter counts from BOTTOM to TOP and then restarts from BOTTOM The waveform generator (WG)output is set on the compare match between the TCACNT and TCACMPn registers and cleared at TOP
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
195
Figure 21-9 Single-Slope Pulse Width Modulation
CNT
Output WOn
MAXTOP
CMPn
BOTTOM
Period (T) CMPn=BOTTOM CMPn=TOP updatematch
The TCAPER register defines the PWM resolution The minimum resolution is 2 bits (TCAPER=0x0003)and the maximum resolution is 16 bits (TCAPER=MAX)
The following equation calculates the exact resolution for single-slope PWM (RPWM_SS)PWM_SS = log PER+1log 2The single-slope PWM frequency (fPWM_SS) depends on the period setting (TCA_PER) the systemsperipheral clock frequency fCLK_PER the TCA prescaler (CLKSEL in TCACTRLA) It is calculated by thefollowing equationPWM_SS = CLK_PER PER+1where N represents the prescaler divider used
Dual-slope PWMFor dual-slope PWM generation the period (T) is controlled by TCAPER while the values of TCACMPncontrol the duty cycle of the WG output
The figure below shows how for dual-slope PWM the counter counts repeatedly from BOTTOM to TOPand then from TOP to BOTTOM The waveform generator output is set on BOTTOM cleared on comparematch when up-counting and set on compare match when down-counting
Figure 21-10 Dual-slope Pulse Width Modulation
MAX
TOP
BOTTOM
CNT
Waveform Output WOn
Period (T) CMPn=BOTTOM CMPn=TOP updatematch
CMPn
Using dual-slope PWM results in a lower maximum operation frequency compared to the single-slopePWM operation
The period register (TCAPER) defines the PWM resolution The minimum resolution is 2 bits(TCAPER=0x0003) and the maximum resolution is 16 bits (TCAPER=MAX)
The following equation calculate the exact resolution for dual-slope PWM (RPWM_DS)
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
196
PWM_DS = log PER+1log 2The PWM frequency depends on the period setting (TCAPER) the peripheral clock frequency (fCLK_PER)and the prescaler divider used (CLKSEL in TCACTRLA) It is calculated by the following equationPWM_DS = CLK_PER2 sdot PERN represents the prescaler divider used
Port Override for Waveform GenerationTo make the waveform generation available on the Port pins the corresponding Port pin direction must beset as output (PORTDIR[n]=1) The TCA will override the port pin values when the compare channel isenabled (CMPnEN=1 in TCACTRLB) and a waveform generation mode is selected
The figure below shows the port override for TCA The timercounter compare channel will override theport pin output value (OUT) on the corresponding port pin Enabling inverted IO on the port pin(INVEN=1 in PORTPINn) inverts the corresponding WG output
Figure 21-11 Port Override for TimerCounter Type A
Waveform
OUT
CMPnEN INVEN
WOn
21627 TimerCounter CommandsA set of commands can be issued by software to immediately change the state of the peripheral Thesecommands give direct control of the UPDATE RESTART and RESET signals A command is issued bywriting the respective value to the Command bit field (CMD) in the Control E register (TCACTRLESET)
An UPDATE command has the same effect as when an update condition occurs except that the UPDATEcommand is not affected by the state of the Lock Update bit (LUPD) in the Control E register(TCACTRLE)
The software can force a restart of the current waveform period by issuing a RESTART command In thiscase the counter direction and all compare outputs are set to zero
A RESET command will set all timercounter registers to their initial values A RESET can be issued onlywhen the timercounter is not running (ENABLE=0 in TCACTRLA)
21628 Split Mode - Two 8-Bit TimerCounters
Split Mode OverviewTo double the number of timers and PWM channels in the TCA at a minimal cost a Split Mode isprovided In this Split Mode the 16-bit timercounter acts as two separate 8-bit timers which each havethree compare channels for PWM generation To eliminate the need for buffer registers the split modewill only work with single slope down count Split Mode does not support Event action controlledoperation
Split Mode Differences to Normal Modebull Count
ndash Down-count onlyndash TimerCounter counter high and low byte are independent (TCALCNT TCAHCNT)
bull Waveform generation
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
197
ndash Single Slope PWM only (WGMODE=SINGLESLOPE in TCACTRLB)bull Interrupt
ndash No change for low byte TimerCounter (TCALCNT)ndash Underflow interrupt for high byte TimerCounter (TCAHCNT)ndash No compare interrupt or flag for Compare n registers (TCAHCMPn)
bull Event actions Not compatiblebull Buffer registers and Buffer Valid flags Unusedbull Register access Byte access to all registersbull Temp register Unused 16-bit register of the Normal Mode are accessed as 8-bit TCA_H and
TCA_L respectively
Block DiagramFigure 21-12 TimerCounter Block Diagram Split Mode
Base Counter
Comparen = 012
C o u n te r
=
xCMPnWav e fo r m G e n e r a tion
=
xPER
= 0
c ou n t c l e a r l oa d C o n t r o l L o gi c
CT R L A
xUNF(INT Req)
T O P
m a t ch CMP[20](INT Req)
Cl oc k S e l ec t
B O T T O M
WO[50]
Counter xx = LH
xCNT
Split Mode InitializationNote When shifting between Normal Mode and Split Mode the functionality of some registers and bitschange but their values do not For this reason disabling the peripheral (ENABLE=0 in TCACTRLA) anddoing a Hard Reset (CMD=RESET in TCACTRLESET) is recommended when changing the mode toavoid unexpected behavior
To start using the timercounter in basic Split Mode after a Hard Reset follow these stepsbull Enable Split Mode by writing a 1 to the Split Mode Enable bit in the Control D register (SPLITM in
TCACTRLD)bull Write a TOP value to the Period registers (TCAPER)bull Enable the peripheral by writing a 1 to the ENABLE bit in the Control A register (TCACTRLA)
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
198
The counter will start counting clock ticks according to the prescaler setting in the Clock Select bitfield (CLKSEL) in TCACTRLA
bull The counter values can be read from the Counter bit field in the Counter registers (TCACNT)
Activating Split Mode results in changes to the functionality of some registers and register bits Themodifications are described in a separate register map See Register Summary - Split Mode
2163 EventsThe peripheral can take the following actions on an input Event
bull The counter counts positive edges of the Event signalbull The counter counts both positive and negative edges of the Event signalbull The counter counts prescaled clock cycles as long as the Event signal is highbull The event signal controls the direction of counting
The specific action is selected by writing to the Event Action bits (EVACT) in the Event Control register(TCAEVCTRL) Events as input are enabled by writing a 1 to the Enable Count on Event Input bit(CNTEI in TCAEVCTRL)
Event controlled operation is not available in Split Mode
2164 InterruptsTable 21-3 Available Interrupt Vectors and Sources in Normal Mode
Offset Name Vector Description Conditions
0x00 OVF Overflow and Compare matchinterrupt
The counter has reached its top value andwrapped to zero
0x04 CMP0 Compare or capture channel 0interrupt
Match between the counter value and theCompare 0 register
0x06 CMP1 Compare or capture channel 1interrupt
Match between the counter value and theCompare 1 register
0x08 CMP2 Compare or capture channel 2interrupt
Match between the counter value and theCompare 2 register
Table 21-4 Available Interrupt Vectors and Sources in Split Mode
Offset Name Vector Description Conditions
0x00 LUNF Low-byte Underflow interrupt Low-byte timer reaches BOTTOM
0x02 HUNF High-byte Underflow interrupt High-byte timer reaches BOTTOM
0x04 LCMP0 Compare or capture channel 0interrupt
Match between the counter value and the low-byteof Compare 0 register
0x06 LCMP1 Compare or capture channel 1interrupt
Match between the counter value and the low-byteof Compare 1 register
0x08 LCMP2 Compare or capture channel 2interrupt
Match between the counter value and the low-byteof the Compare 2 register
When an interrupt condition occurs the corresponding Interrupt Flag is set in the Interrupt Flags registerof the peripheral (peripheralINTFLAGS)
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
199
An interrupt source is enabled or disabled by writing to the corresponding enable bit in the peripheralsInterrupt Control register (peripheralINTCTRL)
An interrupt request is generated when the corresponding interrupt source is enabled and the InterruptFlag is set The interrupt request remains active until the Interrupt Flag is cleared See the peripheralsINTFLAGS register for details on how to clear Interrupt Flags
Note Interrupt requests are only generated when Interrupts are enabled globally
Related LinksAVR CPU on page 47SREG on page 58
2165 Sleep Mode OperationThe timercounter will halt operation in all sleep modes
2166 Configuration Change ProtectionNot applicable
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
200
217 Register Summary - Normal Mode (CTRLDSPLITM=0)
Offset Name Bit Pos
0x00 CTRLA 70 CLKSEL[20] ENABLE
0x01 CTRLB 70 CMP2EN CMP1EN CMP0EN ALUPD WGMODE[20]
0x02 CTRLC 70 CMP0 CMP1 CMP0
0x03 CTRLD 70 SPLITM
0x04 CTRLECLR 70 CMD[10] LUPD DIR
0x05 CTRLESET 70 CMD[10] LUPD DIR
0x06 CTRLFCLR 70 CMP2BV CMP1BV CMP0BV PERBV
0x07 CTRLFSET 70 CMP2BV CMP1BV CMP0BV PERBV
0x08 Reserved
0x09 EVCTRL 70 EVACT[10] CNTEI
0x0A INTCTRL 70 CMP2 CMP1 CMP0 OVF
0x0B INTFLAGS 70 CMP2 CMP1 CMP0 OVF
0x0C
0x0D
Reserved
0x0E DBGCTRL 70 DBGRUN
0x0F TEMP 70 TEMP[70]
0x10
0x1F
Reserved
0x20CNT
70 CNT[70]
0x21 158 CNT[158]
0x22
0x25
Reserved
0x26PER
70 PER[70]
0x27 158 PER[158]
0x28CMP0
70 CMP[70]
0x29 158 CMP[158]
0x2ACMP1
70 CMP[70]
0x2B 158 CMP[158]
0x2CCMP2
70 CMP[70]
0x2D 158 CMP[158]
0x2E
0x35
Reserved
0x36PERBUF
70 PERBUF[70]
0x37 158 PERBUF[158]
0x38CMPBUF0
70 CMPBUF[70]
0x39 158 CMPBUF[158]
0x3ACMPBUF1
70 CMPBUF[70]
0x3B 158 CMPBUF[158]
0x3CCMPBUF2
70 CMPBUF[70]
0x3D 158 CMPBUF[158]
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
201
218 Register Description - Normal Mode
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
202
2181 Control A
Name CTRLAOffset 0x00Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 CLKSEL[20] ENABLE
Access RW RW RW RW Reset 0 0 0 0
Bits 31 ndash CLKSEL[20] Clock SelectThese bits select the clock frequency for the timercounter
Value Name Description0x0 DIV1 fTCA = fCLK_PER1
0x1 DIV2 fTCA = fCLK_PER2
0x2 DIV4 fTCA = fCLK_PER4
0x3 DIV8 fTCA = fCLK_PER8
0x4 DIV16 fTCA = fCLK_PER16
0x5 DIV64 fTCA = fCLK_PER64
0x6 DIV256 fTCA = fCLK_PER256
0x7 DIV1024 fTCA = fCLK_PER1024
Bit 0 ndash ENABLE Enable
Value Description0 The peripheral is disabled
1 The peripheral is enabled
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
203
2182 Control B - Normal Mode
Name CTRLBOffset 0x01Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 CMP2EN CMP1EN CMP0EN ALUPD WGMODE[20]
Access RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0
Bit 6 ndash CMP2EN Capture 2 EnableSee CMP0EN
Bit 5 ndash CMP1EN Compare 1 EnableSee CMP0EN
Bit 4 ndash CMP0EN Compare 0 EnableSetting the CMPnEN bits in the FRQ or PWM waveform generation mode of operation will override theport output register for the corresponding TCn output pin
Bit 3 ndash ALUPD Auto Lock UpdateThe Auto Lock Update feature controls the Lock Update (LUPD) bit in the CTRLE register When ALUPDis set to 1 LUPD will be set to 1 until the Buffer Valid (CMPnBV) bit of all enabled compare channels is 1This event will clear LUPD and it will remain cleared until the next UPDATE condition where the buffervalues will be transferred to the CMPn registers and LUPD will be set to 1 again This makes sure thatCMPnBUF register values are not transferred to the CMPn registers until all enabled compare buffers arewritten
Bits 20 ndash WGMODE[20] Waveform Generation ModeThese bits select the waveform generation mode and control the counting sequence of the counter TOPvalue UPDATE condition interrupt condition and type of waveform that is generated
No waveform generation is performed in the normal mode of operation For all other modes the resultfrom the waveform generator will only be directed to the port pins if the corresponding CMPnEN bit hasbeen set to enable this The port pin direction must be set as output and output must be enabled inportmux
Table 21-5 Timer Waveform Generation Mode
WGMODE[20] Group Configuration Mode of Operation Top Update OVF
000 NORMAL Normal PER TOP TOP
001 FRQ Frequency CMP0 TOP TOP
010 Reserved - - -
011 SINGLESLOPE Single-slope PWM PER BOTTOM BOTTOM
100 Reserved - - -
101 DSTOP Dual-slope PWM PER BOTTOM TOP
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
204
WGMODE[20] Group Configuration Mode of Operation Top Update OVF
110 DSBOTH Dual-slope PWM PER BOTTOM TOP and BOTTOM
111 DSBOTTOM Dual-slope PWM PER BOTTOM BOTTOM
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
205
2183 Control C - Normal Mode
Name CTRLCOffset 0x02Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 CMP0 CMP1 CMP0
Access RW RW RW Reset 0 0 0
Bit 2 ndash CMP0 Compare Output Value 2See CMP0
Bit 1 ndash CMP1 Compare Output Value 1See CMP0
Bit 0 ndash CMP0 Compare Output Value 0The CMPn bits allow direct access to the waveform generators output compare value when the timercounter is not enabled This is used to set or clear the WG output value when the timercounter is notrunning
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
206
2184 Control D
Name CTRLDOffset 0x03Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 SPLITM
Access RW Reset 0
Bit 0 ndash SPLITM Enable Split ModeThis bit sets the timercounter in split mode operation It will then work as two 8-bit timercounters Notethat the register map will change compared to normal 16-bit mode
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
207
2185 Control Register E Clear - Normal ModeThe individual status bit can be cleared by writing a one to its bit location This allows each bit to becleared without use of a read-modify-write operation on a single registerEach Status bit can be read out either by reading TCACTRLESET or TCACTRLECLR
Name CTRLECLROffset 0x04Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 CMD[10] LUPD DIR
Access RW RW RW RW Reset 0 0 0 0
Bits 32 ndash CMD[10] CommandThese bits can be used for software control of update restart and reset of the timercounter Thecommand bits are always read as zero
Table 21-6 Command Selections
CMD[10] Group Configuration Command Action
00 NONE None
01 UPDATE Force update
10 RESTART Force restart
11 RESET Force hard reset (ignored if TC is enabled)
Bit 1 ndash LUPD Lock UpdateWhen this bit is set no update of the buffered registers is performed even though an UPDATE conditionhas occurred Locking the update ensures that all buffers are valid before an update is performed
Bit 0 ndash DIR Counter DirectionWhen zero this bit indicates that the counter is counting up (incrementing) A one indicates that thecounter is in the down-counting (decrementing) state
Normally this bit is controlled in hardware by the waveform generation mode or by event actions but thisbit can also be changed from software
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
208
2186 Control Register E Set - Normal ModeThe individual status bit can be set by writing a 1 to its bit location This allows each bit to be set withoutuse of a read-modify-write operation on a single registerEach Status bit can be read out either by reading TCACTRLESET or TCACTRLECLR
Name CTRLESETOffset 0x05Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 CMD[10] LUPD DIR
Access RW RW RW RW Reset 0 0 0 0
Bits 32 ndash CMD[10] CommandThese bits can be used for software control of update restart and reset of the timercounter Thecommand bits are always read as zero
Table 21-7 Command Selections
CMD[10] Group Configuration Command Action
00 NONE None
01 UPDATE Force update
10 RESTART Force restart
11 RESET Force hard reset (ignored if TC is enabled)
Bit 1 ndash LUPD Lock UpdateWhen this bit is set no update of the buffered registers is performed even though an UPDATE conditionhas occurred Locking the update ensures that all buffers are valid before an update is performed
Bit 0 ndash DIR Counter DirectionWhen zero this bit indicates that the counter is counting up (incrementing) A one indicates that thecounter is in the down-counting (decrementing) state
Normally this bit is controlled in hardware by the waveform generation mode or by event actions but thisbit can also be changed from software
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
209
2187 Control Register F ClearThe individual status bit can be cleared by writing a one to its bit location This allows each bit to becleared without use of a read-modify-write operation on a single register
Name CTRLFCLROffset 0x06Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 CMP2BV CMP1BV CMP0BV PERBV
Access RW RW RW RW Reset 0 0 0 0
Bit 3 ndash CMP2BV Compare 2 Buffer ValidSee CMP0BV
Bit 2 ndash CMP1BV Compare 1 Buffer ValidSee CMP0BV
Bit 1 ndash CMP0BV Compare 0 Buffer ValidThe CMPnBV bits are set when a new value is written to the corresponding CMPnBUF register Thesebits are automatically cleared on an UPDATE condition
Bit 0 ndash PERBV Period Buffer ValidThis bit is set when a new value is written to the PERB register This bit is automatically cleared on anUPDATE condition
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
210
2188 Control Register F SetThe individual status bit can be set by writing a one to its bit location This allows each bit to be setwithout use of a read-modify-write operation on a single register
Name CTRLFSETOffset 0x07Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 CMP2BV CMP1BV CMP0BV PERBV
Access RW RW RW RW Reset 0 0 0 0
Bit 3 ndash CMP2BV Compare 2 Buffer ValidSee CMP0BV
Bit 2 ndash CMP1BV Compare 1 Buffer ValidSee CMP0BV
Bit 1 ndash CMP0BV Compare 0 Buffer ValidThe CMPnBV bits are set when a new value is written to the corresponding CMPnBUF register Thesebits are automatically cleared on an UPDATE condition
Bit 0 ndash PERBV Period Buffer ValidThis bit is set when a new value is written to the PERB register This bit is automatically cleared on anUPDATE condition
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
211
2189 Event Control
Name EVCTRLOffset 0x09Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 EVACT[10] CNTEI
Access RW RW RW Reset 0 0 0
Bits 21 ndash EVACT[10] Event ActionThese bits define on what type of event action the counter will increment or decrement
Table 21-8 Timer Event Action Selection
EVACT[20] Group Configuration Description
00 EVACT_POSEDGE Count on postive edge event
01 EVACT_ANYEDGE Count on any edge event
10 EVACT_HIGHLVL Count on high level event
11 EVACT_UPDOWN Externally controlled updown count
Bit 0 ndash CNTEI Enable count on event inputThis bit enables count on event input according to setting of EVACT[10]
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
212
21810 Interrupt Control Register - Normal Mode
Name INTCTRLOffset 0x0AReset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 CMP2 CMP1 CMP0 OVF
Access RW RW RW RW Reset 0 0 0 0
Bit 6 ndash CMP2 Compare Channel 2 Interrupt Enable
Bit 5 ndash CMP1 Compare Channel 1 Interrupt Enable
Bit 4 ndash CMP0 Compare Channel 0 Interrupt Enable
Bit 0 ndash OVF Timer OverflowUnderflow Interrupt Enable
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
213
21811 Interrupt Flag Register - Normal ModeThe individual status bit can be set by writing a 1e to its bit location This allows each bit to be set withoutuse of a read-modify-write operation on a single register
Name INTFLAGSOffset 0x0BReset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 CMP2 CMP1 CMP0 OVF
Access RW RW RW RW Reset 0 0 0 0
Bit 6 ndash CMP2 Compare Channel 2 Interrupt FlagSee CMP0 flag description
Bit 5 ndash CMP1 Compare Channel 1 Interrupt FlagSee CMP0 flag description
Bit 4 ndash CMP0 Compare Channel 0 Interrupt FlagThe compare interrupt flag (CMPn) is set on a compare match on the corresponding compare channel
For all modes of operation the CMPn flag will be set when a compare match occurs between the countregister (CNT) and the corresponding compare register (CMPn) The CMPn flag will not be clearedautomatically and has to be cleared by software This is done by writing a one to its bit location
Bit 0 ndash OVF OverflowUnderflow Interrupt FlagThis flag is set either on a TOP (overflow) or BOTTOM (underflow) condition depending on theWGMODE setting OVF is not automatically cleared and needs to be cleared by software This is done bywriting a one to its bit location
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
214
21812 Debug Control Register
Name DBGCTRLOffset 0x0EReset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 DBGRUN
Access RW Reset 0
Bit 0 ndash DBGRUN Run in DebugWhen this bit is set the module will not be stopped when device is set in break for debugging
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
215
21813 Temporary bits for 16-bit AccessThe Temporary register is used by the CPU for single-cycle 16-bit access to the 16-bit registers of thisperipheral It can also be read and written by software See also Accessing 16-bit Registers There is onecommon Temporary register for all the 16-bit registers of this peripheral
Name TEMPOffset 0x0FReset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 TEMP[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash TEMP[70] Temporary Bits for 16-bit Access
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
216
21814 Counter Register - Normal ModeThe TCACNTL and TCACNTH register pair represents the 16-bit value TCACNT The low byte [70](suffix L) is accessible at the original offset The high byte [158] (suffix H) can be accessed at offset +0x01 For more details on reading and writing 16-bit registers refer to Accessing 16-bit Registers
CPU and PDI write access has priority over internal updates of the register
Name CNTOffset 0x20Reset 0x00Property
-
Bit 15 14 13 12 11 10 9 8 CNT[158]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0 CNT[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 158 ndash CNT[158] Counter high byteThese bits hold the MSB of the 16-bit counter register
Bits 70 ndash CNT[70] Counter low byteThese bits hold the LSB of the 16-bit counter register
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
217
21815 Period Register - Normal ModeTCAPER contains the 16-bit TOP value in the timercounter
The TCAPERL and TCAPERH register pair represents the 16-bit value TCAPER The low byte [70](suffix L) is accessible at the original offset The high byte [158] (suffix H) can be accessed at offset +0x01 For more details on reading and writing 16-bit registers refer to Accessing 16-bit Registers
Name PEROffset 0x26Reset 0xFFFFProperty
-
Bit 15 14 13 12 11 10 9 8 PER[158]
Access RW RW RW RW RW RW RW RW Reset 1 1 1 1 1 1 1 1
Bit 7 6 5 4 3 2 1 0 PER[70]
Access RW RW RW RW RW RW RW RW Reset 1 1 1 1 1 1 1 1
Bits 158 ndash PER[158] Periodic high byteThese bits hold the MSB of the 16-bit period register
Bits 70 ndash PER[70] Periodic low byteThese bits hold the LSB of the 16-bit period register
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
218
21816 Compare n Register - Normal ModeThis register is continuously compared to the counter value Normally the outputs from the comparatorsare then used for generating waveforms
TCACMPn registers are updated with the buffer value from their corresponding CMPnBUF register whenan UPDATE condition occurs
The TCACMPnL and TCACMPnH register pair represents the 16-bit value TCACMPn The low byte[70] (suffix L) is accessible at the original offset The high byte [158] (suffix H) can be accessed at offset+ 0x01 For more details on reading and writing 16-bit registers refer to Accessing 16-bit Registers
Name CMP0 CMP1 CMP2Offset 0x28 + n0x02 [n=02]Reset 0x00Property
-
Bit 15 14 13 12 11 10 9 8 CMP[158]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0 CMP[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 158 ndash CMP[158] Compare high byteThese bits hold the MSB of the 16-bit compare register
Bits 70 ndash CMP[70] Compare low byteThese bits hold the LSB of the 16-bit compare register
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
219
21817 Period Buffer RegisterThis register serves as the buffer for the period register (TCAPER) Accessing this register using theCPU or PDI will affect the PERBV flag
The TCAPERBUFL and TCAPERBUFH register pair represents the 16-bit value TCAPERBUF The lowbyte [70] (suffix L) is accessible at the original offset The high byte [158] (suffix H) can be accessed atoffset + 0x01 For more details on reading and writing 16-bit registers refer to Accessing 16-bit Registers
Name PERBUFOffset 0x36Reset 0x00Property
-
Bit 15 14 13 12 11 10 9 8 PERBUF[158]
Access RW RW RW RW RW RW RW RW Reset 1 1 1 1 1 1 1 1
Bit 7 6 5 4 3 2 1 0 PERBUF[70]
Access RW RW RW RW RW RW RW RW Reset 1 1 1 1 1 1 1 1
Bits 158 ndash PERBUF[158] Period Buffer high byteThese bits hold the MSB of the 16-bit period buffer register
Bits 70 ndash PERBUF[70] Period Buffer low byteThese bits hold the LSB of the 16-bit period buffer register
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
220
21818 Compare n Buffer RegisterThis register serves as the buffer for the associated compare registers (TCACMPn) Accessing any ofthese registers using the CPU or PDI will affect the corresponding CMPnBV status bit
The TCACMPnBUFL and TCACMPnBUFH register pair represents the 16-bit value TCACMPnBUFThe low byte [70] (suffix L) is accessible at the original offset The high byte [158] (suffix H) can beaccessed at offset + 0x01 For more details on reading and writing 16-bit registers refer to Accessing 16-bit Registers
Name CMPBUF0 CMPBUF1 CMPBUF2Offset 0x38 + n0x02 [n=02]Reset 0x00Property
-
Bit 15 14 13 12 11 10 9 8 CMPBUF[158]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0 CMPBUF[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 158 ndash CMPBUF[158] Compare high byteThese bits hold the MSB of the 16-bit compare buffer register
Bits 70 ndash CMPBUF[70] Compare low byteThese bits hold the LSB of the 16-bit compare buffer register
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
221
219 Register Summary - Split Mode (CTRLDSPLITM=1)
Offset Name Bit Pos
0x00 CTRLA 70 CLKSEL[20] ENABLE
0x01 CTRLB 70 HCMP2EN HCMP1EN HCMP0EN LCMP2EN LCMP1EN LCMP0EN
0x02 CTRLC 70 HCMP2 HCMP1 HCMP0 LCMP2 LCMP1 LCMP0
0x03 CTRLD 70 SPLITM
0x04 CTRLECLR 70 CMD[10]
0x05 CTRLESET 70 CMD[10]
0x06
0x09
Reserved
0x0A INTCTRL 70 LCMP2 LCMP1 LCMP0 HUNF LUNF
0x0B INTFLAGS 70 LCMP2 LCMP1 LCMP0 HUNF LUNF
0x0C
0x0D
Reserved
0x0E DBGCTRL 70 DBGRUN
0x0F
0x1F
Reserved
0x20 LCNT 70 LCNT[70]
0x21 HCNT 70 HCNT[70]
0x22
0x25
Reserved
0x26 LPER 70 LPER[70]
0x27 HPER 70 HPER[70]
0x28 LCMP0 70 LCMP[70]
0x29 HCMP0 70 HCMP[70]
0x2A LCMP1 70 LCMP[70]
0x2B HCMP1 70 HCMP[70]
0x2C LCMP2 70 LCMP[70]
0x2D HCMP2 70 HCMP[70]
2110 Register Description - Split Mode
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
222
21101 Control A
Name CTRLAOffset 0x00Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 CLKSEL[20] ENABLE
Access RW RW RW RW Reset 0 0 0 0
Bits 31 ndash CLKSEL[20] Clock SelectThese bits select the clock frequency for the timercounter
Value Name Description0x0 DIV1 fTCA = fCLK_PER1
0x1 DIV2 fTCA = fCLK_PER2
0x2 DIV4 fTCA = fCLK_PER4
0x3 DIV8 fTCA = fCLK_PER8
0x4 DIV16 fTCA = fCLK_PER16
0x5 DIV64 fTCA = fCLK_PER64
0x6 DIV256 fTCA = fCLK_PER256
0x7 DIV1024 fTCA = fCLK_PER1024
Bit 0 ndash ENABLE Enable
Value Description0 The peripheral is disabled
1 The peripheral is enabled
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
223
21102 Control B - Split Mode
Name CTRLBOffset 0x01Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 HCMP2EN HCMP1EN HCMP0EN LCMP2EN LCMP1EN LCMP0EN
Access RW RW RW RW RW RW Reset 0 0 0 0 0 0
Bit 6 ndash HCMP2EN High-byte Compare 2 EnableSee LCMP0EN
Bit 5 ndash HCMP1EN High-byte Compare 1 EnableSee LCMP0EN
Bit 4 ndash HCMP0EN High-byte Compare 0 EnableSee LCMP0EN
Bit 2 ndash LCMP2EN Low-byte Compare 2 EnableSee LCMP0EN
Bit 1 ndash LCMP1EN Low-byte Compare 1 EnableSee LCMP0EN
Bit 0 ndash LCMP0EN Low-byte Compare 0 EnableSetting the LCMPnENHCMPnEN bits in the FRQ or PWM waveform generation mode of operation willoverride the port output register for the corresponding WOn pin
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
224
21103 Control C - Split Mode
Name CTRLCOffset 0x02Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 HCMP2 HCMP1 HCMP0 LCMP2 LCMP1 LCMP0
Access RW RW RW RW RW RW Reset 0 0 0 0 0 0
Bit 6 ndash HCMP2 High-byte Compare 2 Output ValueSee LCMP0A
Bit 5 ndash HCMP1 High-byte Compare 1 Output ValueSee LCMP0
Bit 4 ndash HCMP0 High-byte Compare 0 Output ValueSee LCMP0
Bit 2 ndash LCMP2 Low-byte Compare 2 Output ValueSee LCMP0
Bit 1 ndash LCMP1 Low-byte Compare 1 Output ValueSee LCMP0
Bit 0 ndash LCMP0 Low-byte Compare 0 Output ValueThe LCMPnHCMPn bits allow direct access to the waveform generators output compare value when thetimercounter is not enabled This is used to set or clear the WOn output value when the timercounter isnot running
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
225
21104 Control D
Name CTRLDOffset 0x03Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 SPLITM
Access RW Reset 0
Bit 0 ndash SPLITM Enable Split ModeThis bit sets the timercounter in split mode operation It will then work as two 8-bit timercounters Notethat the register map will change compared to normal 16-bit mode
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
226
21105 Control Register E Clear - Split ModeThe individual status bit can be cleared by writing a 1 to its bit location This allows each bit to be clearedwithout use of a read-modify-write operation on a single registerEach Status bit can be read out either by reading TCACTRLESET or TCACTRLECLR
Name CTRLECLROffset 0x04Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 CMD[10]
Access RW RW Reset 0 0
Bits 32 ndash CMD[10] CommandThese bits can be used for software control of update restart and reset of the timercounter Thecommand bits are always read as zero
Table 21-9 Command Selections
CMD[10] Group Configuration Command Action
00 NONE None
01 UPDATE Force update
10 RESTART Force restart
11 RESET Force hard reset (ignored if TC is enabled)
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
227
21106 Control Register E Set - Split ModeThe individual status bit can be set by writing a 1 to its bit location This allows each bit to be set withoutuse of a read-modify-write operation on a single registerEach Status bit can be read out either by reading TCACTRLESET or TCACTRLECLR
Name CTRLESETOffset 0x05Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 CMD[10]
Access RW RW Reset 0 0
Bits 32 ndash CMD[10] CommandThese bits can be used for software control of update restart and reset of the timercounter Thecommand bits are always read as zero
Table 21-10 Command Selections
CMD[10] Group Configuration Command Action
00 NONE None
01 UPDATE Force update
10 RESTART Force restart
11 RESET Force hard reset (ignored if TC is enabled)
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
228
21107 Interrupt Control Register - Split Mode
Name INTCTRLOffset 0x0AReset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 LCMP2 LCMP1 LCMP0 HUNF LUNF
Access RW RW RW RW RW Reset 0 0 0 0 0
Bit 6 ndash LCMP2 Low-byte Compare Channel 0 Interrupt Enable
Bit 5 ndash LCMP1 Low-byte Compare Channel 1 Interrupt Enable
Bit 4 ndash LCMP0 Low-byte Compare Channel 0 Interrupt Enable
Bit 1 ndash HUNF High-byte Underflow Interrupt Enable
Bit 0 ndash LUNF Low-byte Underflow Interrupt Enable
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
229
21108 Interrupt Flag Register - Split ModeThe individual status bit can be set by writing a one to its bit location This allows each bit to be setwithout use of a read-modify-write operation on a single register
Name INTFLAGSOffset 0x0BReset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 LCMP2 LCMP1 LCMP0 HUNF LUNF
Access RW RW RW RW RW Reset 0 0 0 0 0
Bit 6 ndash LCMP2 Low-byte Compare Channel 0 Interrupt FlagSee LCMP0 flag description
Bit 5 ndash LCMP1 Low-byte Compare Channel 0 Interrupt FlagSee LCMP0 flag description
Bit 4 ndash LCMP0 Low-byte Compare Channel 0 Interrupt FlagThe compare interrupt flag (LCMPn) is set on a compare match on the corresponding compare channel
For all modes of operation the LCMPn flag will be set when a compare match occurs between the Low-byte count register (LCNT) and the corresponding compare register (LCMPn) The LCMPn flag will not becleared automatically and has to be cleared by software This is done by writing a one to its bit location
Bit 1 ndash HUNF High-byte Underflow Interrupt FlagThis flag is set on a high-byte timer BOTTOM (underflow) condition HUNF is not automatically clearedand needs to be cleared by software This is done by writing a one to its bit location
Bit 0 ndash LUNF Low-byte Underflow Interrupt FlagThis flag is set on a low-byte timer BOTTOM (underflow) condition LUNF is not automatically cleared andneeds to be cleared by software This is done by writing a one to its bit location
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
230
21109 Debug Control Register
Name DBGCTRLOffset 0x0EReset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 DBGRUN
Access RW Reset 0
Bit 0 ndash DBGRUN Run in DebugWhen this bit is set the module will not be stopped when device is set in break for debugging
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
231
211010 Low-byte Timer Counter Register - Split ModeTCALCNT contains the counter value in low-byte timer CPU and PDI write access has priority overcount clear or reload of the counter
Name LCNTOffset 0x20Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 LCNT[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash LCNT[70] Counter value for low-byte timerThese bits define the counter value of the low-byte timer
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
232
211011 High-byte Timer Counter Register - Split ModeTCAHCNT contains the counter value in high-byte timer CPU and PDI write access has priority overcount clear or reload of the counter
Name HCNTOffset 0x21Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 HCNT[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash HCNT[70] Counter value for high-byte timerThese bits define the counter value in high-byte timer
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
233
211012 Low-byte Timer Period Register - Split ModeThe TCALPER register contains the TOP value of low-byte timer
Name LPEROffset 0x26Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 LPER[70]
Access RW RW RW RW RW RW RW RW Reset 1 1 1 1 1 1 1 1
Bits 70 ndash LPER[70] Period value low-byte timerThese bits hold the TOP value of low-byte timer
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
234
211013 High-byte Period Register - Split ModeThe TCAHPER register contains the TOP value of high-byte timer
Name HPEROffset 0x27Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 HPER[70]
Access RW RW RW RW RW RW RW RW Reset 1 1 1 1 1 1 1 1
Bits 70 ndash HPER[70] Period value high-byte timerThese bits hold the TOP value of high-byte timer
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
235
211014 Compare Register n for low-byte Timer - Split ModeThe TCALCMPn register represents the compare value of compare channel n for low-byte Timer Thisregister is continuously compared to the counter value of low-byte timer LCNT Normally the outputsfrom the comparators are then used for generating waveforms
Name LCMPnOffset 0x28 + n0x02 [n=02]Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 LCMP[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash LCMP[70] Compare value of channel nThese bits hold the compare value of channel n that is compared to LCNT
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
236
211015 High-byte Compare Register n - Split ModeThe TCAHCMPn register represents the compare value of compare channel n for high-byte Timer Thisregister is continuously compared to the counter value of high-byte timer HCNT Normally the outputsfrom the comparators are then used for generating waveforms
Name HCMP0 HCMP1 HCMP2Offset 0x29 + n0x02 [n=02]Reset 0x00Property
-
Bit 7 6 5 4 3 2 1 0 HCMP[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash HCMP[70] Compare value of channel nThese bits hold the compare value of channel n that is compared to HCNT
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
237
22 TCB - 16-bit TimerCounter Type B
221 OverviewThe capabilities of the 16-bit TimerCounter type B (TCB) include frequency and waveform generationand input capture with time and frequency measurement of digital signals It consists of a base counterand control logic which can be set in one of eight different modes each mode providing uniquefunctionality The base counter is clocked by the peripheral clock with optional prescaling
222 Featuresbull 16-bit counter operation modes
ndash Input capturebull Input capture with noise cancelingbull Frequency capturebull Pulse width capturebull Frequency and pulse width capture
ndash Periodic interruptndash Timeout checkingndash 8-bit Pulse Width Modulation (PWM)ndash Single shot
bull Pull pin high while the counter is countingbull Optional operation synchronous with TCA
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
238
223 Block DiagramFigure 22-1 TimerCounter Type B Block Diagram
Counter
=
CNT
= 0
countclear Control
EVCTRL
CTRLA
IF(INT Req)
TOP
ClockSelect
BOTTOM
Edge Select CTRLB Mode
CAPTURE
Output controland
logicAsynchronous
Synchronousoutput
Asynchronousoutput
Mode Output enable initial value
CLK_PER
LogicEvent System
TCB
DIV2
CLK_TCA
224 Signal Description
Signal Description Type
W0 Digital asynchronous output Waveform Output
Related LinksIO Multiplexing and Considerations on page 18
225 Product DependenciesIn order to use this peripheral other parts of the system must be configured correctly as described below
Table 22-1 TCB Product Dependencies
Dependency Applicable Peripheral
Clocks Yes CLKCTRL
IO Lines and Connections No -
Interrupts Yes CPUINT
Events Yes EVSYS
Debug Yes UPDI
Related Links
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
239
Clocks on page 240Interrupts on page 61Events on page 191Debug Operation on page 240
2251 ClocksThis peripheral uses the systems peripheral clock CLK_PER The peripheral has its own local prescaleror can be configured to run off the prescaled clock signal of the Timer Counter type A (TCA)
Related LinksCLKCTRL - Clock Controller on page 75
2252 IO Lines and ConnectionsNot applicable
2253 InterruptsUsing the interrupts of this peripheral requires the Interrupt Controller to be configured first
Related LinksCPUINT - CPU Interrupt Controller on page 104SREG on page 58Interrupts on page 144
2254 EventsThe events of this peripheral are connected to the Event System
Related LinksEVSYS - Event System on page 116
2255 Debug OperationWhen the CPU is halted in debug mode this peripheral will halt normal operation This peripheral can beforced to continue operation during debugging
Related LinksUPDI - Unified Program and Debug Interface on page 502
226 Functional Description
2261 Principle of OperationDepending on the mode of operation the countertimer is cleared reloaded incremented or decrementedat each clock tick or Event input
2262 Basic Operation
22621 DefinitionsThe following definitions are used throughout the documentation
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
240
Table 22-2 TimerCounter Definitions
Name Description
BOTTOM The counter reaches BOTTOM when it becomes zero
MAX The counter reaches MAXimum when it becomes all ones
TOP The counter reaches TOP when it becomes equal to the highest value in the countsequence Depending on the waveform generator mode the TOP value can be equal to thePeriod register a Compare channel n register setting
UPDATE The timercounter signals an update when it reaches BOTTOM or TOP depending on thewaveform generator mode
CNT Counter register value
CAPT Capturecompare register value
In general the term ldquotimerrdquo is used when the timercounter clock control is handled by an internal sourceand the term ldquocounterrdquo is used when the clock control is handled externally (eg counting externalEvents)
22622 InitializationBy default the TCB is in Periodic Interrupt mode Follow these steps to start using it
bull Write a TOP value to the CompareCapture register (TCBCC)bull Enable the counter by writing a 1 to the ENABLE bit in the Control A register (TCBCTRLA)
The counter will start counting clock ticks according to the prescaler setting in the Clock Select bitfield (CLKSEL in TCBCTRLA)
bull The counter value can be read from the Count register (TCBCNT) The peripheral will generate aninterrupt when the CNT value reaches TOP
22623 ModesThe timer can be put in eight different modes which are explained below
Periodic Interrupt ModeIn the periodic interrupt mode the counter counts to the capture value and restarts from zero Interrupt isgenerated when counter is equal to TOP If TOP is updated to a value lower than count the counter willcontinue until MAX and wrap around without generating an interrupt
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
241
Figure 22-2 Periodic Interrupt Mode
BOTTOM
MAX
Inte rrupt
TOP
TOP changed to a va lue lower than CNT
CNT
Counte r wraps a round
Related LinksDefinitions on page 192
Timeout Check ModeIn timeout check mode the counter counts till MAX and wraps around On the first edge the counter willstart and on the second it will stop If the count register reaches TOP before the second edge an interruptwill be generated
Going out of freeze and clearing flag
1 Count register is initialized and started on the first edge and stopped on the second edge2 Reading count capture and writing run bit will have no effect
Figure 22-3 Timeout Check Mode
CNT
BOTTOM
MAX
ldquoInterruptrdquoTOP
ev_s rcTOP changed to a va lue
lower than CNT
Counte r wraps a round
IC S ource
Related LinksDefinitions on page 192
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
242
Input Capture on EventThe counter will count from BOTTOM to MAX continuously and when an event occurs the counter valuewill be transferred to the CC register and interrupt is generated The module has two asynchronous edgedetectors and the user can set up either posedge negedge
The figure below shows the input capture unit configured to capture on negedge of capture sourceInterrupt is cleared when higher byte of capture register is read in this mode
It is recommended to write zero to CNT register while entering this mode from any other mode
Figure 22-4 Input Capture on Event
IC S ource
ev_s rc
CNT
MAX
BOTTOM
update
Wrap aroundCopy CNT to CAPTand interrupt
Copy CNT to CAP Tand interrupt
Input Capture Frequency MeasurementIn the input capture frequency measurement mode the timer will do a capture and a restart on eachpositive or negative edge Interrupt is cleared when high byte of comparecapture register is read in thismode
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
243
Figure 22-5 Input Capture Frequency Measurement
IC S ource
ev_s rc
CNT
MAX
BOTTOM
update
Copy CNT to CAP T inte rrupt and res ta rt
Copy CNT to CAP T inte rrupt and res ta rt
Copy CNT to CAP Tinte rrupt and res ta rt
Input Capture Pulse Width MeasurementThe input capture pulse width measurement will restart the counter on a positive edge and do a captureon a negative edge This will require it to switch between the asynchronous edge detectors and require atwo cycle synchronization time Interrupt is cleared when higher byte of capture register is read in thismode
Figure 22-6 Input Capture Pulse Width Measurement
IC S ource
ev_s rc
CNT
MAX
BOTTOM
update
Re sta rt counter
Copy CNT to CAPT and interrupt
Re sta rt counter
Copy CNT to CAPT and give inte rrupt
Re sta rt counter
Input Capture Frequency and Pulse Width MeasurementThe input capture frequency and pulse width measurement will start the counter on the positive edge of acapture do a capture on the negative edge and stop the counter on the next positive edge
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
244
As can be seen in the figure on the second positive edge of event counter freezes At any stage in thismode reading capture will clear the flag If it is during the time when counter is counting flag is not setbut this will cause no problem In the freeze stage if capture is read flag will be cleared but count registerwill sustain its value A positive edge will make it start from 0 so it is a must to read the counter registerfirst and then capture register and an event should not occur
Figure 22-7 Input Capture Frequency and Pulse Width Measurement
IC S ource
ev_s rc
CNT
MAX
BOTTOM
update
S ta rt counte r
Copy CNT to CAP T
S top counter and inte rrupt
CPU reads the Capture regis te r
Ignore till Capture is read
Trigger next capture sequence
Single-Shot ModeThis mode generates a constant length pulse from the time an event occurs When the counter is notcounting the output pin is set to 0 When the event trigger is received the output will go high and thecounter will start from zero and count up to the CCMP register value The RUN bit in the Status registercan be read to see if the counter is counting or not When the counter register reaches the CCMP registervalue counter will stop and the output pin will go low for at least one prescaler cycle If a new eventarrives during this time that event will be ignored The following figure shows an example waveformThere is a two clock cycle delay from when the event is received until the output is set high If animmediate action is wanted the ASYNC bit in TCBCTRLB need to be set When EDGE bit of EVCTRLregister is set any edge will can trigger the start of counter otherwise only positive edge will trigger thestart
Note The counter will start as soon as the module is enabled even without triggering event This isprevented by writing TOP to the counter registerSimilar behavior is seen if the EDGE bit in the TCBEVCTRL register is 1 while the module is enabledWriting TOP to the Counter register prevents this as well
It is not recommended to change configuration while the module is enabled
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
245
Figure 22-8 Single-Shot Mode
ev_s rc
CNT
TOP
BOTTOMupdate
Event s ta rts counte r
Counte r reaches TOP va lue
Output
Ignored Ignored
Event s ta rts counte r
Counte r reaches TOP va lue
8-bit PWM ModeThis timer can also be set in an 8-bit PWM mode where each of the register pairs in the 16-bit comparecapture register (TCBCCH and TCBCCL) are used as individual compare registers The counter willcontinuously count from zero to CCL and the output will be set at BOTTOM and cleared when the counterreaches CCH When module is enabled and in PWM mode changing the value of comparecaptureregister will change the output but the transition is not guaranteed to be successful It is recommended todisable the module write comparecapture register to CCH CCL then write 0x0000 to count registerand then enable the module CCH is the number of cycles for which output will stay high CCL+1 is theperiod of the output pulse
Output of the module for different value of capture register are explained below
bull CCL = 0 Output = 0bull CCL = 0xFF
bull CCH = 0 Output = 0bull 0 lt CCH le 0xFF Output = 1 for CCH cycles low for the rest of the period
bull For 0 lt CCL lt 0xFFbull CCH = 0 Output = 0bull If 0 lt CCH le CCL Output = 1 for CCH cycles low for the restbull CCH = CCL + 1 Output = 1
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
246
Figure 22-9 8-bit PWM Mode
CNT
CCL
BOTTOM
update
(CNT == CCL) and output goes high
(CNT == CCH) and output goes low
Output
CCH
Related LinksDefinitions on page 192
22624 Synchronous OutputThe bits CCINIT CCEN and CNTMODE in TCBCTRLB are handling the behavior of the synchronousoutput signal which is shown in the table below
Table 22-3 Synchronous Output
CCEN CNTMODE Output sync
0 Any mode 0
1 Single shot mode Output high when counter starts and output low whencounter stops
1 8-bit PWM mode PWM mode output
1 Modes except single shot and PWM PININIT
22625 Asynchronous OutputThe bits CCIT CCEN ASYNC and CNTMODE in TCBCTRLB are handling the behavior of theasynchronous output signal which is shown in the table below
Table 22-4 Asynchronous Output
CCEN ASYNC CNTMODE Output async
0 0 Any mode 0
1 0 Single-shot mode Output high whencounter starts andoutput low when counterstops
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
247
CCEN ASYNC CNTMODE Output async
1 1 Single-shot mode Output high when eventarrives and output lowwhen counter stops
1 1 8-bit PWM mode PWM mode output
1 1 Modes except single-shot and PWM
PININIT
Changing modes while the peripheral is enabled can produce unpredictable output and it is notrecommended There is a possibility that the interrupt flag is set during the configuration of the timer andit is recommended to clear it after configuring the peripheral
22626 Noise CancellerThe noise canceller improves noise immunity by using a simple digital filtering scheme The noisecanceller input is monitored over four samples and all four must be equal to change the output that isused by the edge detector
When enabled the noise canceller introduces an additional four system clock cycles of delay from achange applied to the input to the update of the input compare register The noise canceller uses thesystem clock and is therefore not affected by the prescaler
2263 Synchronized with TCAThe TCB can also be configured to use the clock of the TimerCounter type A (TCA) This is configured bywriting 0x2 to the Clock Select bit field (CLKSEL) in the Control A register (TCBCTRLA)
The TCB will use the prescaled clock signal used by TCA for counting as configured by CLKSEL inTCACTRLA
When the Synchronize Update bit (SYNCUPD) in the Control A register (TCBCTRLA) is written to 1 theTCB counter will restart when the TCA counter restarts
2264 EventsTCB can generate an single strobe output event when TCB interrupt condition occurs and this Event issent to the event system
There is one input Event line to this peripheral which is used when the Capture Event Input Enable bit(CAPTEI) in the Event Control register (TCBEVCTRL) is written to 1 and different actions are takendepending on which mode the peripheral is configured The actions are explained in the description of theEvent Edge bit field (EDGE in TCBEVCTRL)
Related LinksEVCTRL on page 253EVSYS - Event System on page 116
2265 InterruptsTable 22-5 Available Interrupt Vectors and Sources
Offset Name Vector Description Conditions
0x00 CAPT TCB interrupt Depending on operating mode See description of CAPT inTCBINTFLAG
Atmel ATtiny417 ATtiny814 ATtiny816 ATtiny817 [DATASHEET]Atmel-42721A-ATtiny417814816817_Datasheet_Advance Information-092016
248