Upload
others
View
20
Download
0
Embed Size (px)
Citation preview
ATtiny161416161617Automotive
tinyAVRreg 1-series
Introduction
The ATtiny161416161617 Automotive are members of the tinyAVRreg 1-series of microcontrollers usingthe AVRreg processor with hardware multiplier running at up to 16 MHz with 16 KB Flash 2 KB of SRAMand 256 bytes of EEPROM in a 14- 20- or 24-pin package The tinyAVRreg 1-series uses the latesttechnologies with a flexible low-power architecture including Event System and SleepWalking accurateanalog features and Core Independent Peripherals Capacitive touch interfaces with driven shield aresupported with the integrated QTouchreg peripheral touch controller
Features
bull CPUndash AVRreg CPUndash Running at up to 16 MHzndash Single-cycle IO accessndash Two-level interrupt controllerndash Two-cycle hardware multiplier
bull Memoriesndash 16 KB In-system self-programmable Flash memoryndash 256 bytes EEPROMndash 2 KB SRAMndash Writeerase endurance
bull Flash 10000 cyclesbull EEPROM 100000 cycles
ndash Data retentionbull 40 years at 55degC
bull Systemndash Power-on Reset (POR)ndash Brown-out Detector (BOD)ndash Clock options
bull 16 MHz low-power internal RC oscillatorbull 32768 kHz Ultra Low-Power (ULP) internal RC oscillatorbull 32768 kHz external crystal oscillatorbull External clock input
ndash Single-pin Unified Program and Debug Interface (UPDI)ndash Three sleep modes
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 1
bull Idle with all peripherals running for immediate wake-upbull Standby
ndash Configurable operation of selected peripheralsndash SleepWalking peripherals
bull Power-Down with full data retentionbull Peripherals
ndash One 16-bit TimerCounter type A (TCA) with dedicated period register and three comparechannels
ndash Two 16-bit TimerCounter type B (TCB) with input capturendash One 12-bit TimerCounter type D (TCD) optimized for control applicationsndash One 16-bit Real-Time Counter (RTC) running from an external crystal external clock or internal
RC oscillatorndash Watchdog Timer (WDT) with Window mode with a separate on-chip oscillatorndash One USART with fractional baud rate generator auto-baud and start-of-frame detectionndash One masterslave Serial Peripheral Interface (SPI)ndash One Two-Wire Interface (TWI) with dual address match
bull Philips I2C compatiblebull Standard mode (Sm 100 kHz)bull Fast mode (Fm 400 kHz)bull Fast mode plus (Fm+ 1 MHz)
ndash Three Analog Comparators (AC) with low propagation delayndash Two 10-bit 115 ksps Analog-to-Digital Converters (ADC)ndash Three 8-bit Digital-to-Analog Converters (DAC) with one external channelndash Multiple voltage references (VREF)
bull 055Vbull 11Vbull 15Vbull 25Vbull 43V
ndash Event System (EVSYS) for CPU independent and predictable inter-peripheral signalingndash Configurable Custom Logic (CCL) with two programmable look-up tablesndash Automated CRC memory scanndash Peripheral Touch Controller (PTC)
bull Capacitive touch buttons sliders wheels and 2D surfacesbull Wake-up on touchbull Driven shield for improved moisture and noise handling performancebull Up to 13 self capacitance channelsbull Up to 42 mutual capacitance channels
ndash External interrupt on all general purpose pinsbull IO and Packages
ndash 121821 programmable IO linesndash 14-pin SOIC150ndash 20-pin VQFN 3x3 mm with wettable flanks
ATtiny161416161617 Automotive
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 2
ndash 20-pin SOIC300ndash 24-pin VQFN 4x4 mm with wettable flanks
bull Temperature Rangesndash -40degC to 105degCndash -40degC to 125degC
bull Speed Gradesndash 0-8 MHz 27V ndash 55Vndash 0-16 MHz 45V ndash 55V
ATtiny161416161617 Automotive
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 3
Table of Contents
Introduction1
Features 1
1 Silicon Errata and Data Sheet Clarification Document 11
2 tinyAVRreg 1-series Overview1221 Configuration Summary12
3 Block Diagram 14
4 Pinout 1641 14-Pin SOIC 1642 20-Pin SOIC 1743 20-Pin VQFN1844 24-Pin VQFN19
5 IO Multiplexing and Considerations2051 Multiplexed Signals 20
6 Automotive Quality Grade 21
7 Memories2271 Overview 2272 Memory Map 2373 In-System Reprogrammable Flash Program Memory2374 SRAM Data Memory 2475 EEPROM Data Memory 2476 User Row2477 Signature Bytes2578 IO Memory2579 Memory Section Access from CPU and UPDI on Locked Device26710 Configuration and User Fuses (FUSE)27
8 Peripherals and Architecture 4381 Peripheral Module Address Map4382 Interrupt Vector Mapping4483 System Configuration (SYSCFG)46
9 AVR CPU4991 Features 4992 Overview 4993 Architecture 4994 Arithmetic Logic Unit (ALU)5195 Functional Description5296 Register Summary - CPU57
ATtiny161416161617 Automotive
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 4
97 Register Description57
10 Nonvolatile Memory Controller (NVMCTRL) 61101 Features 61102 Overview 61103 Functional Description62104 Register Summary - NVMCTRL69105 Register Description69
11 Clock Controller (CLKCTRL) 77111 Features 77112 Overview 77113 Functional Description79114 Register Summary - CLKCTRL84115 Register Description84
12 Sleep Controller (SLPCTRL) 94121 Features 94122 Overview 94123 Functional Description95124 Register Summary - SLPCTRL 98125 Register Description98
13 Reset Controller (RSTCTRL)100131 Features 100132 Overview 100133 Functional Description101134 Register Summary - RSTCTRL104135 Register Description104
14 CPU Interrupt Controller (CPUINT) 107141 Features 107142 Overview 107143 Functional Description109144 Register Summary - CPUINT 116145 Register Description 116
15 Event System (EVSYS)121151 Features 121152 Overview 121153 Functional Description124154 Register Summary - EVSYS 126155 Register Description126
16 Port Multiplexer (PORTMUX) 135161 Overview 135162 Register Summary - PORTMUX 136163 Register Description136
ATtiny161416161617 Automotive
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 5
17 IO Pin Configuration (PORT)141171 Features 141172 Overview 141173 Functional Description143174 Register Summary - PORT 147175 Register Description - Ports 147176 Register Summary - VPORT 159177 Register Description - Virtual Ports 159
18 Brown-Out Detector (BOD)164181 Features 164182 Overview 164183 Functional Description166184 Register Summary - BOD168185 Register Description168
19 Voltage Reference (VREF)175191 Features 175192 Overview 175193 Functional Description175194 Register Summary - VREF177195 Register Description177
20 Watchdog Timer (WDT)182201 Features 182202 Overview 182203 Functional Description184204 Register Summary - WDT 188205 Register Description188
21 16-bit TimerCounter Type A (TCA)192211 Features 192212 Overview 192213 Functional Description196214 Register Summary - TCA in Normal Mode (CTRLDSPLITM=0) 206215 Register Description - Normal Mode 206216 Register Summary - TCA in Split Mode (CTRLDSPLITM=1)226217 Register Description - Split Mode226
22 16-bit TimerCounter Type B (TCB)242221 Features 242222 Overview 242223 Functional Description245224 Register Summary - TCB 253225 Register Description253
23 12-Bit TimerCounter Type D (TCD) 265
ATtiny161416161617 Automotive
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 6
231 Features 265232 Overview 265233 Functional Description269234 Register Summary - TCD291235 Register Description291
24 Real-Time Counter (RTC)311241 Features 311242 Overview311243 RTC Functional Description 314244 PIT Functional Description 314245 Events 316246 Interrupts 317247 Sleep Mode Operation 317248 Synchronization318249 Configuration Change Protection 3182410 Register Summary - RTC3192411 Register Description319
25 Universal Synchronous and Asynchronous Receiver and Transmitter (USART)335251 Features 335252 Overview 335253 Functional Description338254 Register Summary - USART 354255 Register Description354
26 Serial Peripheral Interface (SPI)373261 Features 373262 Overview 373263 Functional Description376264 Register Summary - SPI384265 Register Description384
27 Two-Wire Interface (TWI) 391271 Features 391272 Overview 391273 Functional Description393274 Register Summary - TWI407275 Register Description407
28 Cyclic Redundancy Check Memory Scan (CRCSCAN) 425281 Features 425282 Overview 425283 Functional Description427284 Register Summary - CRCSCAN430285 Register Description430
29 Configurable Custom Logic (CCL)434
ATtiny161416161617 Automotive
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 7
291 Features 434292 Overview 434293 Functional Description436294 Register Summary - CCL 445295 Register Description445
30 Analog Comparator (AC)453301 Features 453302 Overview 453303 Functional Description455304 Register Summary - AC 458305 Register Description458
31 Analog-to-Digital Converter (ADC) 463311 Features 463312 Overview 463313 Functional Description467314 Register Summary - ADCn474315 Register Description474
32 Digital-to-Analog Converter (DAC) 492321 Features 492322 Overview 492323 Functional Description494324 Register Summary - DAC496325 Register Description496
33 Peripheral Touch Controller (PTC) 499331 Features 499332 Overview 499333 Functional Description502
34 Unified Program and Debug Interface (UPDI)504341 Features 504342 Overview 504343 Functional Description507344 Register Summary - UPDI527345 Register Description527
35 Instruction Set Summary 538
36 Conventions543361 Numerical Notation543362 Memory Size and Type543363 Frequency and Time543364 Registers and Bits 544
37 Acronyms and Abbreviations545
ATtiny161416161617 Automotive
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 8
38 Electrical Characteristics 548381 Disclaimer548382 Absolute Maximum Ratings 548383 General Operating Ratings 549384 Power Consumption550385 Wake-Up Time551386 Power Consumption of Peripherals552387 BOD and POR Characteristics553388 External Reset Characteristics553389 Oscillators and Clocks5533810 IO Pin Characteristics 5553811 USART 5563812 SPI 5573813 TWI5593814 VREF5613815 ADC5623816 DAC5663817 AC 5673818 PTC5683819 UPDI Timing5693820 Programming Time570
39 Typical Characteristics571391 Power Consumption571392 GPIO 578393 VREF Characteristics584394 BOD Characteristics586395 ADC Characteristics589396 AC Characteristics599397 OSC20M Characteristics603398 OSCULP32K Characteristics 605399 TWI SDA Hold timing 606
40 Ordering Information607401 Product Information607402 Product Identification System607
41 Package Drawings608411 Online Package Drawings608412 14-Pin SOIC150 609413 20-Pin SOIC300 613414 20-Pin VQFN617415 24-Pin VQFN621
42 Thermal Considerations 625421 Thermal Resistance Data625422 Junction Temperature625
ATtiny161416161617 Automotive
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 9
43 Errata626431 Errata - ATtiny161416161617 Automotive 626
44 Data Sheet Revision History627441 RevC - 062019 627442 RevB - 052018628443 Rev A - 032018629
The Microchip Website630
Product Change Notification Service630
Customer Support 630
Microchip Devices Code Protection Feature 630
Legal Notice631
Trademarks 631
Quality Management System 632
Worldwide Sales and Service633
ATtiny161416161617 Automotive
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 10
1 Silicon Errata and Data Sheet Clarification DocumentOur intention is to provide our customers with the best documentation possible to ensure successful useof Microchip products Between data sheet updates a Silicon Errata and Data Sheet ClarificationDocument will contain the most recent information for the data sheet The ATtiny161416161617Automotive Silicon Errata and Data Sheet Clarification Document is available at the device product pageon httpswwwmicrochipcom
ATtiny161416161617 AutomotiveSilicon Errata and Data Sheet Clarification
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 11
2 tinyAVRreg 1-series OverviewThe figure below shows the tinyAVRreg 1-series devices laying out pin count variants and memory sizes
bull Vertical migration upwards is possible without code modification as these devices are pin compatibleand provide the same or more features Downward migration may require code modification due tofewer available instances of some peripherals
bull Horizontal migration to the left reduces the pin count and therefore the available features
Figure 2-1 tinyAVRreg 1-series Overview
16 KB
8 KB
4 KB
2 KB
8 14 20 24Pins
Flash
ATtiny816 ATtiny817
ATtiny417
ATtiny1616 ATtiny1617
ATtiny416
32 KB ATtiny3217
ATtiny1614
ATtiny3216
ATtiny814
ATtiny414ATtiny412
ATtiny212 ATtiny214
Devices with different Flash memory size typically also have different SRAM and EEPROM
Related Links7 Memories
21 Configuration Summary
211 Peripheral SummaryTable 2-1 Peripheral Summary
ATtin
y161
4
ATtin
y161
6
ATtin
y161
7
Pins 14 20 24SRAM 2 KB 2 KB 2 KBFlash 16 KB 16 KB 16 KBEEPROM 256B 256B 256BMax frequency (MHz) 16 16 1616-bit TimerCounter type A (TCA) 1 1 116-bit TimerCounter type B (TCB) 2 2 2
ATtiny161416161617 AutomotivetinyAVRreg 1-series Overview
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 12
continued
ATtin
y161
4
ATtin
y161
6
ATtin
y161
7
12-bit TimerCounter type D (TCD) 1 1 1Real-Time Counter (RTC) 1 1 1USART 1 1 1SPI 1 1 1TWI (I2C) 1 1 1ADC 2 2 2ADC channels 10+4 12+8 12+11DAC 3 3 3AC 3 3 3Peripheral Touch Controller (PTC)(1) 1 1 1PTC number of self capacitance channels(1) 6XY 12XY 13XYPTC number of mutual capacitance channels(1) 9 36 42Configurable Custom Logic 1 1 1Window Watchdog 1 1 1Event System channels 6 6 6General purpose IO 12 18 21External interrupts 12 18 21CRCSCAN 1 1 1
Note 1 The PTC takes control over the ADC0 while the PTC is used
ATtiny161416161617 AutomotivetinyAVRreg 1-series Overview
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 13
3 Block DiagramFigure 3-1 ATtiny1614 Automotive Block Diagram
INOUT
DATABUS
Clock generation
BUS Matrix
CPU
USART0
SPI0
CCL
AC[20]
ADC0 PTC
TCA0
TCB[10]
AINP[20]AINN[10]
OUT
WO[50]
RXDTXDXCK
XDIR
MISOMOSISCK
SS
PORTS
System Management
SLPCTRL
RSTCTRL
CLKCTRL
EVENT
ROUTING
NETWORK
DATABUS
UPDICRC
SRAM
NVMCTRL
Flash
EEPROM
OSC20M
OSC32K
DetectorsReferences
POR
Bandgap
WDT
RTC
CPUINT
M M
S
MS
S
OCD
RST
S
EXTCLK
LUT0-IN[20]LUTn-OUT
WO
PA[70]PB[30]
GPIOR
TWI0SDASCL
TCD0WO[AB]
XOSC32K
TOSC2
TOSC1
To detectors
UPDI RESET
EVSYS EVOUT[n0]
DACDAC0 OUT [20]
ADC1
VLMBOD
EXTCLK
AIN[1110 70]X[50]Y[50]
REFA
AIN[30]
analog peripherals
analog peripherals
analog peripherals
digital peripherals
analog peripheralscore components
clocksgenerators
reg
ATtiny161416161617 AutomotiveBlock Diagram
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 14
Figure 3-2 ATtiny16161617 Automotive Block Diagram
INOUT
DATABUS
Clock generation
BUS Matrix
CPU
USART0
SPI0
CCL
AC[n0]
ADC0 PTC
TCA0
TCB[10]
AINP[n0]AINN[10]
OUT
WO[n0]
RXDTXDXCK
XDIR
MISOMOSISCK
SS
PORTS
System Management
SLPCTRL
RSTCTRL
CLKCTRL
EVENT
ROUTING
NETWORK
DATABUS
UPDICRC
SRAM
NVMCTRL
Flash
EEPROM
OSC20M
OSC32K
DetectorsReferences
POR
Bandgap
WDT
RTC
CPUINT
M M
S
MS
S
OCD
RST
S
EXTCLK
LUTn-IN[m0]LUTn-OUT
WO CLKOUT
PA[n0]PB[n0]PC[n0]
GPIOR
TWI0SDASCL
TCD0WO[ABCD]
XOSC32K
TOSC2
TOSC1
To detectors
UPDI RESET
EVSYS EVOUT[n0]
DACOUT [n0]
ADC1
VLMBOD
EXTCLK
AIN[n0]X[n0]Y[n0]
REFA
AIN[n0]
analog peripherals
analog peripherals
analog peripherals
digital peripherals
analog peripheralscore components
clocksgenerators
reg
ATtiny161416161617 AutomotiveBlock Diagram
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 15
4 Pinout
41 14-Pin SOIC
1
2
3
4
5
6
7 8
9
13
10
11
12
14VDD GND
PA1
PA2
PA4
PA5
PA7
PA6
PB0
PB1
PA3EXTCLK
TOSC
2
PB3
TOSC
1
PB2
PA0RESETUPDI
GPIO VDD power domain
Clock crystal
Programming Debug ResetInput supply
Ground
Analog function
Digital function only
ATtiny161416161617 AutomotivePinout
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 16
42 20-Pin SOIC
1
2
3
4
5
6
7
13
11
12
14
VDD GND
PA1
PA2
PA4
PA5
PA7
PA6
PB0
8
9
10
15
20
19
18
17
16
PB1
PB4
PB5
PC0
PC2
PC3
PC1
PA0RESETUPDI
PA3EXTCLK
TOSC2PB3TOSC1
PB2
GPIO VDD power domain
Clock crystal
Programming Debug ResetInput supply
Ground
Analog function
Digital function only
ATtiny161416161617 AutomotivePinout
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 17
43 20-Pin VQFN
1
2
3
4
5
6 7 8
20 19 18 179
13
14
15
1610
11
12
PA1
PA4PA
7
PA6
PB0
PB1
PB4
PB5
PC2
PC3
PA5
GND
VDD
PA2 PC0
PC1
PA0
RES
ETU
PDI
PB3
TOSC2
EXTCLK PA3
PB2
TOSC1
GPIO VDD power domain
Clock crystal
Programming Debug ResetInput supply
Ground
Analog function
Digital function only
ATtiny161416161617 AutomotivePinout
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 18
44 24-Pin VQFN
1
2
3
4
5
6
7 8
24 23 22 21 20 19
18
17
9 10 11 12
13
14
15
16PA
1
PC3
PC2
PA2
PA4
PA5
PA7
PA6
NC
PC4
PC0
PC1
GND
VDD
PB4
PB5
PB6
PB7
PB0
PB1
EXTCLK PA3
PB3
TOSC2PB2
TOSC1
PA0
RES
ETU
PDI
GPIO VDD power domain
Clock crystal
Programming Debug ResetInput supply
Ground
Analog function
Digital function only
No Connected
ATtiny161416161617 AutomotivePinout
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 19
5 IO Multiplexing and Considerations
51 Multiplexed SignalsTable 5-1 PORT Function Multiplexing
VQFN
24-
Pin
VQFN
20-
Pin
SOIC
20-
Pin
SOIC
14-
Pin Pin Name (12) OtherSpecial ADC0 ADC1 PTC(4) AC0 AC1 AC2 DAC0 USART0 SPI0 TWI0 TCA0 TCBn TCD0 CCL
23 19 16 10 PA0 RESET UPDI AIN0 LUT0-IN024 20 17 11 PA1 AIN1 TxD(3) MOSI SDA(3) LUT0-IN11 1 18 12 PA2 EVOUT0 AIN2 RxD(3) MISO SCL(3) LUT0-IN22 2 19 13 PA3 EXTCLK AIN3 XCK(3) SCK WO3 TCB1 WO3 3 20 14 GND4 4 1 1 VDD5 5 2 2 PA4 AIN4 AIN0 X0Y0 XDIR(3) SS WO4 WOA LUT0-OUT6 6 3 3 PA5 VREFA AIN5 AIN1 X1Y1 OUT AINN0 WO5 TCB0 WO WOB7 7 4 4 PA6 AIN6 AIN2 X2Y2 AINN0 AINP1 AINP0 OUT8 8 5 5 PA7 AIN7 AIN3 X3Y3 AINP0 AINP0 AINN0 LUT1-OUT9 PB7 AIN4 AINN1 AINP310 PB6 AIN5 AINP3 AINN111 9 6 PB5 CLKOUT AIN8 X12Y12 AINP1 AINP2 WO2(3)
12 10 7 PB4 AIN9 X13Y13 AINN1 AINP3 WO1(3) LUT0-OUT(3)
13 11 8 6 PB3 TOSC1 OUT RxD WO0(3)
14 12 9 7 PB2 TOSC2EVOUT1
OUT TxD WO2
15 13 10 8 PB1 AIN10 X4Y4 AINP2 XCK SDA WO116 14 11 9 PB0 AIN11 X5Y5 AINP2 AINP1 XDIR SCL WO017 15 12 PC0 AIN6 X6Y6 SCK(3) TCB0
WO(3)WOC
18 16 13 PC1 AIN7 X7Y7 MISO(3) WOD LUT1-OUT(3)
19 17 14 PC2 EVOUT2 AIN8 X8Y8 MOSI(3)
20 18 15 PC3 AIN9 X9Y9 SS(3) WO3(3) LUT1-IN021 PC4 AIN10 X10Y10 WO4(3) TCB1
WO(3)LUT1-IN1
22 NC
Note 1 Pin names are of type Pxn with x being the PORT instance (A B) and n the pin number Notation
for signals is PORTx_PINn All pins can be used as event input2 All pins can be used for external interrupt where pins Px2 and Px6 of each port have full
asynchronous detection3 Alternate pin positions For selecting the alternate positions refer to the PORTMUX documentation4 Every PTC line can be configured as X- or Y-line
ATtiny161416161617 AutomotiveIO Multiplexing and Considerations
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 20
6 Automotive Quality GradeThe devices have been manufactured according to the most stringent requirements of the internationalstandard ISOTS 16949 This data sheet contains limit values extracted from the results of extensivecharacterization (temperature and voltage)
The quality and reliability have been verified during regular product qualification as per AEC-Q100 grade1 (ndash40degC to +125degC) and grade 2 (ndash40degC to +105degC)
Table 6-1 Temperature Grade Identification for Automotive Products
Temperature (degC) Temperature Identifier Comments
ndash40 to +125 Z Automotive temperature grade 1
ndash40 to +105 B Automotive temperature grade 2
ATtiny161416161617 AutomotiveAutomotive Quality Grade
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 21
7 Memories
71 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 7-1 Physical Properties of EEPROM
Property ATtiny161416161617 Automotive
Size 256 bytes
Page size 32 bytes
Number of pages 8
Start address 0x1400
Table 7-2 Physical Properties of SRAM
Property ATtiny161416161617 Automotive
Size 2 KB
Start address 0x3800
Table 7-3 Physical Properties of Flash Memory
Property ATtiny161416161617 Automotive
Size 16 KB
Page size 64 bytes
Number of pages 256
Start address 0x8000
Related Links72 Memory Map75 EEPROM Data Memory74 SRAM Data Memory73 In-System Reprogrammable Flash Program Memory10 Nonvolatile Memory Controller (NVMCTRL)
ATtiny161416161617 AutomotiveMemories
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 22
72 Memory MapFigure 7-1 Memory Map ATtiny161416161617 Automotive
(Reserved)
(Reserved)
NVM IO Registers and Data
64 IO Registers
960 Ext IO Registers
0x0000 ndash
0x003F
0x0040 ndash
0x0FFF
Internal SRAM2KB
EEPROM 256 bytes
0x8000 -
BOOTEND
0x1000 ndash
0x13FF
0x3800 ndash
0x3FFF
0x1400 ndash
0x14FF
0xBFFF
ApplicationCode
App DataAPPEND
Flash16KB
(Reserved)
Boot
0xFFFF
73 In-System Reprogrammable Flash Program MemoryThe ATtiny161416161617 Automotive contains 16 KB on-chip in-system reprogrammable Flash memoryfor program storage Since all AVR instructions are 16 or 32 bits wide the Flash is organized as 4K x 16For write protection the Flash program memory space can be divided into three sections (see theillustration below) Bootloader section application code section and application data section withrestricted access rights among them
The Program Counter (PC) is 13-bits wide to address the whole program memory The procedure forwriting Flash memory is described in detail in the documentation of the Nonvolatile 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 ATtiny161416161617 Automotive also has a CRC peripheral that is a master on the bus
ATtiny161416161617 AutomotiveMemories
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 23
Figure 7-2 Flash and the Three SectionsFLASHSTART 0x8000
BOOTENDgt0 0x8000+BOOTEND256
BO OT
APPENDgt0 0x8000+APPEND256
AP PL ICA TIO NCO DE
AP PLICA TIO NDA TA
FLASH
FLASHENDRelated Links21 Configuration Summary10 Nonvolatile Memory Controller (NVMCTRL)
74 SRAM Data MemoryThe 2 KB SRAM is used for data storage and stack
Related Links9 AVR CPU954 Stack and Stack Pointer
75 EEPROM Data MemoryThe ATtiny161416161617 Automotive has 256 bytes of EEPROM data memory see Memory Mapsection The EEPROM memory supports single byte read and write The EEPROM is controlled by theNonvolatile Memory Controller (NVMCTRL)
Related Links72 Memory Map10 Nonvolatile Memory Controller (NVMCTRL)18 Brown-Out Detector (BOD)
76 User RowIn addition to the EEPROM the ATtiny161416161617 Automotive has one extra page of EEPROMmemory that can be used for firmware settings the User Row (USERROW) This memory supports singlebyte read and write as the normal EEPROM The CPU can write and read this memory as normalEEPROM and the UPDI can write and read it as a normal EEPROM memory if the part is unlocked TheUser Row can be written by the UPDI when the part is locked USERROW is not affected by a chip erase
ATtiny161416161617 AutomotiveMemories
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 24
Related Links72 Memory Map10 Nonvolatile Memory Controller (NVMCTRL)34 Unified Program and Debug Interface (UPDI)
77 Signature BytesAll ATtiny microcontrollers have a 3-byte signature code that identifies the device The three bytes residein a separate address space For the device the signature bytes are given in the following table
Note When the device is locked only the System Information Block (SIB) can be obtained
Table 7-4 Device ID
Device Name Signature Bytes Address
0x00 0x01 0x02
ATtiny1617 0x1E 0x94 0x20
ATtiny1616 0x1E 0x94 0x21
ATtiny1614 0x1E 0x94 0x22
Related Links3436 System Information Block
78 IO MemoryAll ATtiny161416161617 Automotive IOs and peripherals are located in the IO memory space The IOaddress range from 0x00 to 0x3F can be accessed in a single cycle using IN and OUT instructions Theextended IO memory space from 0x0040 - 0x0FFF can be accessed by the LDLDSLDD and STSTSSTDinstructions transferring data between the 32 general purpose working registers and the IO memoryspace
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
For compatibility with future devices reserved bits should be written to zero if accessed Reserved IOmemory addresses should never be written
Some of the interrupt flags are cleared by writing a 1 to them On ATtiny161416161617 Automotivedevices the CBI and SBI instructions will only operate on the specified bit and can be used on registerscontaining such interrupt flags The CBI and SBI instructions work with registers 0x00 - 0x1F only
General Purpose IO RegistersThe ATtiny161416161617 Automotive devices provide four general purpose IO registers Theseregisters can be used for storing any information and they are particularly useful for storing globalvariables and interrupt flags general purpose IO registers which reside in the address range 0x1C -0x1F are directly bit accessible using the SBI CBI SBIS and SBIC instructions
Related Links72 Memory Map
ATtiny161416161617 AutomotiveMemories
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 25
35 Instruction Set Summary
79 Memory Section Access from CPU and UPDI on Locked DeviceThe device can be locked so that the memories cannot be read using the UPDI The locking protects boththe Flash (all BOOT APPCODE and APPDATA sections) SRAM and the EEPROM including the FUSEdata This prevents successful reading of application data or code using the debugger interface Regularmemory access from within the application still is enabled
The device is locked by writing any non-valid value to the LOCKBIT bit field in FUSELOCKBIT
Table 7-5 Memory Access in Unlocked Mode (FUSELOCKBIT Valid)(1)
Memory Section CPU Access UPDI Access
Read Write Read Write
SRAM Yes Yes Yes Yes
Registers Yes Yes Yes Yes
Flash Yes Yes Yes Yes
EEPROM Yes Yes Yes Yes
USERROW Yes Yes Yes Yes
SIGROW Yes No Yes No
Other Fuses Yes No Yes Yes
Table 7-6 Memory Access in Locked Mode (FUSELOCKBIT Invalid)(1)
Memory Section CPU Access UPDI Access
Read Write Read Write
SRAM Yes Yes No No
Registers Yes Yes No No
Flash Yes Yes No No
EEPROM Yes No No No
USERROW Yes Yes No Yes(2)
SIGROW Yes No No No
Other Fuses Yes No No No
Note 1 Read operations marked No in the tables may appear to be successful but the data is corrupt
Hence any attempt of code validation through the UPDI will fail on these memory sections2 In Locked mode the USERROW can be written blindly using the fuse Write command but the
current USERROW values cannot be read out
ATtiny161416161617 AutomotiveMemories
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 26
Important The only way to unlock a device is a CHIPERASE which will erase all devicememories to factory default so that no application data is retained
Related Links7103 Fuse Summary - FUSE71049 LOCKBIT34 Unified Program and Debug Interface (UPDI)3437 Enabling of KEY Protected Interfaces
710 Configuration and User Fuses (FUSE)Fuses are part of the nonvolatile memory and hold factory calibration data and device configuration Thefuses are available from device power-up The fuses can be read by the CPU or the UPDI but can onlybe programmed or cleared by the UPDI The configuration and calibration values stored in the fuses arewritten to their respective target registers at the end of the start-up sequence
The content of the Signature Row fuses (SIGROW) is pre-programmed and cannot be altered SIGROWholds information such as device ID serial number and calibration values
The fuses for peripheral configuration (FUSE) are pre-programmed but can be altered by the userAltered values in the configuration fuse will be effective only after a ResetNote When writing the fuses write all reserved bits to lsquo1rsquo
This device provides a User Row fuse area (USERROW) that can hold application data The USERROWcan be programmed on a locked device by the UPDI This can be used for final configuration withouthaving programming or debugging capabilities enabled
Related Links7101 SIGROW - Signature Row Summary7103 Fuse Summary - FUSE81 Peripheral Module Address Map
ATtiny161416161617 AutomotiveMemories
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 27
7101 SIGROW - Signature Row Summary
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
0x21
Reserved
0x22 OSC16ERR3V 70 OSC16ERR3V[70]0x23 OSC16ERR5V 70 OSC16ERR5V[70]
7102 Signature Row Description
ATtiny161416161617 AutomotiveMemories
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 28
71021 Device ID n
Name DEVICEIDnOffset 0x00 + n0x01 [n=02]Reset [Device ID]Property -
Each device has a device ID identifying the device and its properties such as memory sizes pin countand die revision This can be used to identify a device and hence the available features by software TheDevice ID consists of three bytes SIGROWDEVICEID[20]
Bit 7 6 5 4 3 2 1 0 DEVICEID[70]
Access R R R R R R R R Reset x x x x x x x x
Bits 70 ndash DEVICEID[70] Byte n of the Device ID
ATtiny161416161617 AutomotiveMemories
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 29
71022 Serial Number Byte n
Name SERNUMnOffset 0x03 + n0x01 [n=09]Reset [device serial number]Property -
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 SIGROWSERNUM[90]
Bit 7 6 5 4 3 2 1 0 SERNUM[70]
Access R R R R R R R R Reset x x x x x x x x
Bits 70 ndash SERNUM[70] Serial Number Byte n
ATtiny161416161617 AutomotiveMemories
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 30
71023 OSC16 Error at 3V
Name OSC16ERR3VOffset 0x22Reset [Oscillator frequency error value]Property -
Bit 7 6 5 4 3 2 1 0 OSC16ERR3V[70]
Access R R R R R R R R Reset x x x x x x x x
Bits 70 ndash OSC16ERR3V[70] OSC16 Error at 3VThese registers contain the signed oscillator frequency error value when running at internal 16 MHz at 3Vas measured during production
ATtiny161416161617 AutomotiveMemories
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 31
71024 OSC16 Error at 5V
Name OSC16ERR5VOffset 0x23Reset [Oscillator frequency error value]Property -
Bit 7 6 5 4 3 2 1 0 OSC16ERR5V[70]
Access R R R R R R R R Reset x x x x x x x x
Bits 70 ndash OSC16ERR5V[70] OSC16 Error at 5VThese registers contain the signed oscillator frequency error value when running at internal 16 MHz at 5Vas measured during production
ATtiny161416161617 AutomotiveMemories
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 32
7103 Fuse Summary - FUSE
Offset Name Bit Pos
0x00 WDTCFG 70 WINDOW[30] PERIOD[30]0x01 BODCFG 70 LVL[20] SAMPFREQ ACTIVE[10] SLEEP[10]0x02 OSCCFG 70 OSCLOCK FREQSEL[10]0x03 Reserved 0x04 TCD0CFG 70 CMPDEN CMPCEN CMPBEN CMPAEN CMPD CMPC CMPB CMPA0x05 SYSCFG0 70 CRCSRC[10] RESERVED RSTPINCFG[10] RESERVED EESAVE0x06 SYSCFG1 70 SUT[20]0x07 APPEND 70 APPEND[70]0x08 BOOTEND 70 BOOTEND[70]0x09 Reserved 0x0A LOCKBIT 70 LOCKBIT[70]
7104 Fuse Description
ATtiny161416161617 AutomotiveMemories
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 33
71041 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 Time-out PeriodThis value is loaded into the WINDOW bit field of the Watchdog Control A register (WDTCTRLA) duringReset
Bits 30 ndash PERIOD[30] Watchdog Time-out PeriodThis value is loaded into the PERIOD bit field of the Watchdog Control A register (WDTCTRLA) duringReset
ATtiny161416161617 AutomotiveMemories
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 34
71042 BOD Configuration
Name BODCFGOffset 0x01Reset -Property -
The settings of the BOD will be reloaded from this Fuse after a Power-on Reset For all other Resets theBOD configuration remains unchanged
Bit 7 6 5 4 3 2 1 0 LVL[20] SAMPFREQ 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) during ResetValue Name Description0x2 BODLEVEL2 26V0x7 BODLEVEL7 42V
Note bull Values in the description are typical valuesbull Refer to the BOD and POR Characteristics in Electrical Characteristics for maximum and minimum
values
Bit 4 ndash SAMPFREQ BOD Sample FrequencyThis value is loaded into the SAMPFREQ bit of the BOD Control A register (BODCTRLA) during ResetValue Description0x0 Sample frequency is 1 kHz0x1 Sample frequency is 125 Hz
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) during ResetValue Description0x0 Disabled0x1 Enabled0x2 Sampled0x3 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) during ResetValue Description0x0 Disabled0x1 Enabled0x2 Sampled0x3 Reserved
ATtiny161416161617 AutomotiveMemories
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 35
71043 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 1
Bit 7 ndash OSCLOCK Oscillator LockThis fuse bit is loaded to LOCK in CLKCTRLOSC20MCALIBB during ResetValue Description0 Calibration registers of the 20 MHz oscillator are accessible1 Calibration registers of the 20 MHz oscillator are locked
Bits 10 ndash FREQSEL[10] Frequency SelectThese bits select the operation frequency of the 16 MHz internal oscillator (OSC20M) and determine therespective factory calibration values to be written to CAL20M in CLKCTRLOSC20MCALIBA andTEMPCAL20M in CLKCTRLOSC20MCALIBBValue Description0x1 Run at 16 MHz with corresponding factory calibrationOther Reserved
ATtiny161416161617 AutomotiveMemories
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 36
71044 Timer Counter Type D Configuration
Name TCD0CFGOffset 0x04Reset -Property -
The bit values of this fuse register are written to the corresponding bits in the TCDFAULTCTRL registerof TCD0 at start-upThe CMPEN and CMP settings of the TCD will only be reloaded from the FUSE values after a Power-onReset For all other resets the corresponding TCD settings of the device will remain unchanged
Bit 7 6 5 4 3 2 1 0 CMPDEN CMPCEN CMPBEN CMPAEN 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 CMPEN Compare x EnableValue Description0 Compare x output on Pin is disabled1 Compare x output on Pin is enabled
Bits 0 1 2 3 ndash CMP Compare xThis bit selects the default state of Compare x after Reset or when entering debug if FAULTDET is 1Value Description0 Compare x default state is 01 Compare x default state is 1
ATtiny161416161617 AutomotiveMemories
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 37
71045 System Configuration 0
Name SYSCFG0Offset 0x05Reset -Property -
Bit 7 6 5 4 3 2 1 0 CRCSRC[10] RESERVED RSTPINCFG[10] RESERVED EESAVE
Access R R R R R R R Reset 1 1 1 0 1 1 0
Bits 76 ndash CRCSRC[10] CRC SourceSee the CRC description for more information about the functionalityValue Name Description0x0 FLASH CRC of full Flash (boot application code and application data)0x1 BOOT CRC of the boot section0x2 BOOTAPP CRC of application code and boot sections0x3 NOCRC No CRC
Bit 5 ndash RESERVED
Bits 32 ndash RSTPINCFG[10] Reset Pin ConfigurationThese bits select the ResetUPDI pin configurationValue Description0x0 GPIO0x1 UPDI0x2 RESETOther Reserved
Note When configuring the Reset Pin as GPIO there is a potential conflict between the GPIO activelydriving the output and a 12V UPDI enable sequence initiation To avoid this the GPIO output driver isdisabled for 768 OSC32K cycles after a System Reset Enable any interrupts for this pin only after thisperiod
Bit 1 ndash 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 erase1 EEPROM not erased under chip erase
Related Links28 Cyclic Redundancy Check Memory Scan (CRCSCAN)
ATtiny161416161617 AutomotiveMemories
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 38
71046 System Configuration 1
Name SYSCFG1Offset 0x06Reset -Property -
Bit 7 6 5 4 3 2 1 0 SUT[20]
Access R R R Reset 1 1 1
Bits 20 ndash SUT[20] Start-Up Time SettingThese bits select the start-up time between power-on and code executionValue Description0x0 0 ms0x1 1 ms0x2 2 ms0x3 4 ms0x4 8 ms0x5 16 ms0x6 32 ms0x7 64 ms
ATtiny161416161617 AutomotiveMemories
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 39
71047 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 plus application code size The remaining Flash will beapplication data A value of 0x00 defines the Flash from BOOTEND256 to end of Flash as applicationcode When both FUSEAPPEND and FUSEBOOTEND are 0x00 the entire Flash is BOOT section
ATtiny161416161617 AutomotiveMemories
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 40
71048 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 section When both FUSEAPPEND and FUSEBOOTEND are 0x00 the entire Flash is BOOTsection
ATtiny161416161617 AutomotiveMemories
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 41
71049 Lockbits
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] LockbitsWhen the part is locked UPDI cannot access the system bus so it cannot read out anything but CS-spaceValue Description0xC5 Valid key - the device is openother Invalid - the device is locked
Related Links79 Memory Section Access from CPU and UPDI on Locked Device
ATtiny161416161617 AutomotiveMemories
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 42
8 Peripherals and Architecture
81 Peripheral Module Address MapThe address map shows the base address for each peripheral For complete register description andsummary for each peripheral module refer to the respective module chapters
Table 8-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 Converter
0x0640 ADC1 Analog-to-Digital Converter instance 1
0x0680 AC0 Analog Comparator 0
0x0688 AC1 Analog Comparator 1
0x0690 AC2 Analog Comparator 2
ATtiny161416161617 AutomotivePeripherals and Architecture
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 43
continuedBase Address Name Description
0x06A0 DAC0 Digital-to-Analog Converter 0
0x06A8 DAC1 Digital-to-Analog Converter 1
0x06B0 DAC2 Digital-to-Analog Converter 2
0x0800 USART0 Universal Synchronous Asynchronous Receiver Transmitter
0x0810 TWI0 Two-Wire Interface
0x0820 SPI0 Serial Peripheral Interface
0x0A00 TCA0 TimerCounter Type A instance 0
0x0A40 TCB0 TimerCounter Type B instance 0
0x0A50 TCB1 TimerCounter Type B 1
0x0A80 TCD0 TimerCounter Type D instance 0
0x0F00 SYSCFG System Configuration
0x1000 NVMCTRL Nonvolatile Memory Controller
0x1100 SIGROW Signature Row
0x1280 FUSES Device-specific fuses
0x1300 USERROW User Row
82 Interrupt Vector MappingEach of the 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 Functional descriptionof 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)
The naming of the registers may vary slightly in some peripherals
An interrupt request is generated when the corresponding interrupt is enabled and the interrupt flag is setThe interrupt request remains active until the interrupt flag is cleared See the peripherals INTFLAGSregister for details on how to clear interrupt flags
Interrupts must be enabled globally for interrupt requests to be generated
Table 8-2 Interrupt Vector Mapping
Vector Number Base Address Peripheral Source
0 0x00 RESET
ATtiny161416161617 AutomotivePeripherals and Architecture
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 44
continuedVector Number Base Address Peripheral Source
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
14 0x1C TCB1 - Timer Counter Type B
15 0x1E TCD0 - Timer Counter Type D
17 0x22 AC0 ndash Analog Comparator
18 0x24 AC1 ndash Analog Comparator
19 0x26 AC2 ndash Analog Comparator
20 0x28 ADC0 ndash Analog-to-DigitalConverterPTC
22 0x2C ADC1 ndash Analog-to-DigitalConverter
24 0x30 TWI0 - Two-Wire InterfaceI2C
26 0x34 SPI0 - Serial Peripheral Interface
27 0x36 USART0 - UniversalAsynchronous Receiver-Transmitter
30 0x3C NVM - Nonvolatile Memory
Related Links10 Nonvolatile Memory Controller (NVMCTRL)17 IO Pin Configuration (PORT)24 Real-Time Counter (RTC)26 Serial Peripheral Interface (SPI)25 Universal Synchronous and Asynchronous Receiver and Transmitter (USART)27 Two-Wire Interface (TWI)28 Cyclic Redundancy Check Memory Scan (CRCSCAN)21 16-bit TimerCounter Type A (TCA)
ATtiny161416161617 AutomotivePeripherals and Architecture
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 45
22 16-bit TimerCounter Type B (TCB)23 12-Bit TimerCounter Type D (TCD)30 Analog Comparator (AC)31 Analog-to-Digital Converter (ADC)
83 System Configuration (SYSCFG)The system configuration contains the revision ID of the part The revision ID is readable from the CPUmaking it useful for implementing application changes between part revisions
ATtiny161416161617 AutomotivePeripherals and Architecture
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 46
831 Register Summary - SYSCFG
Offset Name Bit Pos
0x01 REVID 70 REVID[70]
832 Register Description - SYSCFG
ATtiny161416161617 AutomotivePeripherals and Architecture
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 47
8321 Device Revision ID Register
Name REVIDOffset 0x01Reset [revision ID]Property -
This register is read-only and displays the device revision ID
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
ATtiny161416161617 AutomotivePeripherals and Architecture
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 48
9 AVR CPU
91 Featuresbull 8-Bit High-Performance AVR RISC CPU
ndash 135 instructionsndash Hardware multiplier
bull 32 8-Bit Registers Directly Connected to the Arithmetic Logic Unit (ALU)bull Stack in RAMbull Stack Pointer Accessible in IO Memory Spacebull Direct Addressing of up to 64 KB of Unified Memory
ndash Entire Flash accessible with all LDST instructionsbull True 1624-Bit Access to 1624-Bit IO Registersbull Efficient Support for 8- 16- and 32-Bit Arithmeticbull Configuration Change Protection for System Critical Features
92 OverviewAll AVR devices use the 8-bit AVR CPU The CPU is able to access memories perform calculationscontrol peripherals and execute instructions in the program memory Interrupt handling is described in aseparate section
Related Links7 Memories10 Nonvolatile Memory Controller (NVMCTRL)14 CPU Interrupt Controller (CPUINT)
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 prefetched from the programmemory This enables instructions to be executed on every clock cycle
ATtiny161416161617 AutomotiveAVR CPU
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 49
Figure 9-1 AVR CPU Architecture
Register file
Flash Program Memory
Data Memory
ALU
R0R1R2R3R4R5R6R7R8R9R10R11R12R13R14R15R16R17R18R19R20R21R22R23R24R25
R26 (XL)R27 (XH)R28 (YL)R29 (YH)R30 (ZL)R31 (ZH)
Stack Pointer
Program Counter
Instruction Register
Instruction Decode
STATUS Register
The Arithmetic Logic Unit (ALU) supports arithmetic and logic operations between registers or between aconstant and a register Also single-register operations can 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 32 8-bit general purpose workingregisters all have single clock cycle access time allowing single-cycle arithmetic logic unit operation
ATtiny161416161617 AutomotiveAVR CPU
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 50
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 4 KB 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 be accessedusing load (LDLDSLDD) and store (STSTSSTD) instructions The lowest 32 addresses can even beaccessed with single-cycle SBICBI instructions and SBISSBIC instructions The rest is the extendedIO memory space ranging from 0x0040 to 0x0FFF The IO registers here must be accessed as dataspace 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 similarto the code space where the Flash starts at address 0x0000
For a summary of all AVR instructions refer to the Instruction Set Summary section For details of all AVRinstructions refer to httpwwwmicrochipcomdesign-centers8-bit
Related Links10 Nonvolatile Memory Controller (NVMCTRL)7 Memories35 Instruction Set Summary
94 Arithmetic Logic Unit (ALU)The Arithmetic Logic Unit (ALU) supports arithmetic and logic operations between registers or between aconstant and a register Also single-register operations can 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 are 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 signedunsigned integersbull Multiplication of signedunsigned fractional numbersbull Multiplication of a signed integer with an unsigned integerbull Multiplication of a signed fractional number with an unsigned one
A multiplication takes two CPU clock cycles
ATtiny161416161617 AutomotiveAVR CPU
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 51
95 Functional Description
951 Program FlowAfter Reset the CPU will 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 supported by conditional and unconditional JUMP and CALL instructions capable ofaddressing the whole address space directly Most AVR instructions use a 16-bit word format and 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 thefive different addressing modes supported by 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 to 1MIPSMHz performance with high efficiency
Figure 9-2 The Parallel Instruction Fetches and Instruction Executions
clk
1st Instruction Fetch1st Instruction Execute
2nd Instruction Fetch2nd Instruction Execute
3rd Instruction Fetch3rd Instruction Execute
4th Instruction Fetch
T1 T2 T3 T4
CPU
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 in the destination register
Figure 9-3 Single Cycle ALU Operation
Total Execution Time
Register Operands Fetch
ALU Operation Execute
Result Write Back
T1 T2 T3 T4
clkCPU
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 operations
ATtiny161416161617 AutomotiveAVR CPU
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 52
CPUSREG is updated after all ALU operations as specified in the Instruction Set Summary This will inmany cases remove the need for using the dedicated compare instructions resulting in faster and morecompact code CPUSREG is not automatically storedrestored when enteringreturning from an InterruptService Routine Maintaining the Status register between context switches must therefore be handled byuser-defined software CPUSREG is accessible in the IO memory space
Related Links35 Instruction Set Summary
954 Stack and Stack PointerThe stack is used for storing return addresses after interrupts and subroutine calls Also it can be usedfor storing temporary data The Stack Pointer (SP) always points to the top of the stack The SP isdefined by the Stack Pointer bits in the Stack Pointer register (CPUSP) The CPUSP is implemented astwo 8-bit registers 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 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 and the SP is decremented by 2 The return address consists of two bytes and the LeastSignificant Byte is pushed on the stack first (at the higher address) As an example a byte pointer returnaddress of 0x0006 is saved on the stack as 0x0003 (shifted one bit to the right) pointing to the fourth 16-bit instruction word in the program memory The return address is popped off the stack with RETI (whenreturning from interrupts) and RET (when returning from subroutine calls) and the SP is incremented bytwo
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
955 Register FileThe register file consists of 32 8-bit general purpose working registers with single clock cycle access timeThe 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
ATtiny161416161617 AutomotiveAVR CPU
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 53
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 and is therefore not accessible throughinstructions operation on data memory
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 Load and store instructions can use all X-Y- and Z-registers while the LPM instructions can only use the Z-register Indirect calls and jumps(ICALL and IJMP ) also use the Z-register
Refer to the instruction set or Instruction Set Summary for more information about how the X- Y- and Z-registers are used
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
The lowest register address holds the Least Significant Byte (LSB) and the highest register addressholds the Most Significant Byte (MSB) In the different addressing modes these address registersfunction as fixed displacement automatic increment and automatic decrement
Related Links35 Instruction Set Summary
ATtiny161416161617 AutomotiveAVR CPU
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 54
956 Accessing 16-Bit RegistersThe AVR data bus has a width of 8 bit and so accessing 16-bit registers requires atomic operationsThese registers must be byte accessed using two read or write operations 16-bit registers are connectedto the 8-bit bus and a temporary register using a 16-bit bus
For a write operation the low byte of the 16-bit register must be written before the high byte The low 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 be read and written directly from user software
9561 Accessing 24-Bit RegistersFor 24-bit registers the read and write access is done in the same way as described for 16-bit registersexcept there are two temporary registers for 24-bit registers The Least Significant Byte must be writtenfirst when doing a write and read first when doing a read
957 Configuration Change Protection (CCP)System 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 Links971 CCP
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 software writes the signature that enables change of protected IO registers to the CCP bit fieldin the CPUCCP register
2 Within four instructions the software must write the appropriate data to the protected registerMost protected registers also contain a write enablechange enablelock bit This bit must be writtento 1 in the same operation as the data are written
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 conductedor if the SLEEP instruction is executed
ATtiny161416161617 AutomotiveAVR CPU
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 55
9572 Sequence for Execution of Self-ProgrammingIn order to execute self-programming (the execution of writes to the NVM controllers command register)the following steps are required
1 The software temporarily enables self-programming by writing the SPM signature to the CCPregister (CPUCCP)
2 Within four instructions the software must execute the appropriate instruction The protectedchange is immediately disabled if the CPU performs accesses to the Flash NVMCTRL orEEPROM 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
ATtiny161416161617 AutomotiveAVR CPU
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 56
96 Register Summary - CPU
Offset Name Bit Pos
0x04 CCP 70 CCP[70]0x05
0x0C
Reserved
0x0D SP70 SP[70]158 SP[158]
0x0F SREG 70 I T H S V N Z C
97 Register Description
ATtiny161416161617 AutomotiveAVR CPU
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 57
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 executedAll 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 priorityWhen the protected IO register signature is written CCP[0] will read as 1 as long as the CCP feature isenabledWhen the protected self-programming signature is written CCP[1] will read as 1 as long as the CCPfeature is enabledCCP[72] will always read as zeroValue Name Description0x9D SPM Allow Self-Programming0xD8 IOREG Un-protect protected IO registers
ATtiny161416161617 AutomotiveAVR CPU
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 58
972 Stack Pointer
Name SPOffset 0x0DReset Top of stackProperty -
The 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 to64 KB) 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
To prevent corruption when updating the SP from software a write to CPUSPL will automatically disableinterrupts for the next four instructions or until the next IO memory write
Bit 15 14 13 12 11 10 9 8 SP[158]
Access RW RW RW RW RW RW RW RW Reset
Bit 7 6 5 4 3 2 1 0 SP[70]
Access RW RW RW RW RW RW RW RW Reset
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
ATtiny161416161617 AutomotiveAVR CPU
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 59
973 Status Register
Name SREGOffset 0x0FReset 0x00Property -
The 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
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 enables interrupts on the deviceWriting a 0 to this bit disables interrupts on the device independent of the individual interrupt enablesettings of the peripheralsThis bit is not cleared by hardware after an interrupt has occurredThis bit can be set and cleared by software with the SEI and CLI instructionsChanging the I flag through the IO register results 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 bitA bit from a register in the register file can be copied into this bit by the BST instruction and this bit canbe copied 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
ATtiny161416161617 AutomotiveAVR CPU
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 60
10 Nonvolatile Memory Controller (NVMCTRL)
101 Featuresbull Unified Memorybull In-System Programmablebull Self-Programming and Boot Loader Supportbull 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
102 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 when not poweredThe Flash is mainly used for program storage and can 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
1021 Block DiagramFigure 10-1 NVMCTRL Block Diagram
Flash
EEPROM
NVM Block
Signature Row
User Row
NVMCTRL
Program Memory Bus
Data Memory Bus
ATtiny161416161617 AutomotiveNonvolatile Memory Controller (NVMCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 61
1022 System DependenciesIn order to use this peripheral other parts of the system must be configured correctly as described below
Table 10-1 NVMCTRL System Dependencies
Dependency Applicable Peripheral
Clocks Yes CLKCTRL
IO Lines and Connections No -
Interrupts Yes CPUINT
Events No -
Debug Yes UPDI
Related Links10221 Clocks10225 Debug Operation10223 Interrupts
10221 ClocksThis peripheral always runs on the CPU clock (CLK_CPU) It will request this clock also in sleep modes ifa writeerase is ongoing
Related Links11 Clock Controller (CLKCTRL)
10222 IO Lines and ConnectionsNot applicable
10223 InterruptsUsing the interrupts of this peripheral requires the interrupt controller to be configured first
10224 EventsNot applicable
10225 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 Links34 Unified Program and Debug Interface (UPDI)
103 Functional Description
1031 Memory Organization
10311 FlashThe Flash is divided into a set of pages A page is the basic unit addressed when programming the FlashIt is only possible to write or erase a whole page at a time One page consists of several words
ATtiny161416161617 AutomotiveNonvolatile Memory Controller (NVMCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 62
The Flash can be divided into three sections in blocks of 256 bytes for different security The threedifferent sections are BOOT Application Code (APPCODE) and Application Data (APPDATA)
Figure 10-2 Flash SectionsFLASHSTART 0x8000
BOOTENDgt0 0x8000+BOOTEND256
BOOT
APPENDgt0 0x8000+APPEND256
APPLICATIONCODE
APPLICATIONDATA
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 The BOOT section stretches from the start ofthe Flash until BOOTEND The APPCODE section runs from BOOTEND until APPEND The remainingarea is the APPDATA section If APPEND is written to 0 the APPCODE section runs from BOOTEND tothe end of Flash (removing the APPDATA section) If BOOTEND and APPEND are written to 0 the entireFlash is regarded as BOOT section APPEND should either be set to 0 or a value greater or equal thanBOOTEND
Table 10-2 Setting Up Flash Sections
BOOTEND APPEND BOOT Section APPCODE Section APPDATA Section
0 0 0 to FLASHEND - -
gt 0 0 0 to 256BOOTEND 256BOOTEND toFLASHEND
-
gt 0 ==BOOTEND
0 to 256BOOTEND - 256BOOTEND toFLASHEND
gt 0 gtBOOTEND
0 to 256BOOTEND 256BOOTEND to256APPEND
256APPEND toFLASHEND
ATtiny161416161617 AutomotiveNonvolatile Memory Controller (NVMCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 63
Note bull See also the BOOTEND and APPEND descriptionsbull Interrupt vectors are by default located after the BOOT section This can be changed in the interrupt
controller
If FUSEBOOTEND is written to 0x04 and FUSEAPPEND is written to 0x08 the first4256 bytes will be BOOT the next 4256 bytes will be APPCODE and the remainingFlash will be APPDATA
Inter-Section Write ProtectionBetween the three Flash sections a directional write protection is implemented
bull The code in the BOOT section can write to APPCODE and APPDATAbull The code in APPCODE can write to APPDATAbull The code in APPDATA cannot write to Flash or EEPROM
Boot Section Lock and Application Code Section Write ProtectionThe two lockbits (APCWP and BOOTLOCK in NVMCTRLCTRLB) can be set to lock further updates ofthe respective APPCODE or BOOT section until the next Reset
The CPU can never write to the BOOT section NVMCTRL_CTRLBBOOTLOCK prevents reads andexecution of code from the BOOT section
10312 EEPROMThe EEPROM is divided into a set of pages where one page consists of multiple bytes The EEPROMhas byte granularity on erasewrite Within one page only the bytes marked to be updated will be erasedwritten The byte is marked by writing a new value to the page buffer for that address location
10313 User RowThe User Row is one extra page of EEPROM This page can be used to store various data such ascalibrationconfiguration data and serial numbers This page is not erased by a chip erase The User Rowis written as normal EEPROM but in addition it can be written through UPDI on a locked device
1032 Memory Access
10321 ReadReading of the Flash and EEPROM is done by using load instructions with an address according to thememory map Reading any of the arrays while a write or erase is in progress will result in a bus wait andthe instruction will be suspended until the ongoing operation is complete
10322 Page Buffer LoadThe page buffer is loaded by writing directly to the memories as defined in the memory map FlashEEPROM and User Row share the same page buffer so only one section can be programmed at a timeThe Least Significant bits (LSb) of the address are used to select where in the page buffer the data iswritten The resulting data will be a binary and operation between the new and the previous content of thepage buffer The page buffer will automatically be erased (all bits set) after
bull A device Resetbull Any page write or erase operationbull A Clear Page Buffer commandbull The device wakes up from any sleep mode
ATtiny161416161617 AutomotiveNonvolatile Memory Controller (NVMCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 64
10323 ProgrammingFor page programming filling the page buffer and writing the page buffer into Flash User Row andEEPROM are two separate operations
Before programming a Flash page with the data in the page buffer the Flash page must be erased Thepage buffer is also erased when the device enters a sleep mode Programming an unerased Flash pagewill corrupt its content
The Flash can either be written with the erase and write separately or one command handling both
Alternative 1bull Fill the page bufferbull Write the page buffer to Flash with the EraseWrite Page command
Alternative 2bull Write to a location on the page to set up the addressbull Perform an Erase Page commandbull Fill the page bufferbull Perform a Write Page command
The NVM command set supports both a single erase and write operation and split Page Erase and PageWrite commands This split commands enable shorter programming time for each command and theerase operations can be done during non-time-critical programming execution
The EEPROM programming is similar but only the bytes updated in the page buffer will be written orerased in the EEPROM
10324 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 Confirm that any previous operation is completed by reading the Busy Flags (EEBUSY and
FBUSY) in the NVMCTRLSTATUS register2 Write the NVM command unlock to the Configuration Change Protection register in the CPU
(CPUCCP)3 Write the desired command value to the CMD bits in the Control A register (NVMCTRLCTRLA)
within the next four instructions
103241 Write CommandThe Write command of the Flash controller writes the content of the page buffer to the Flash or EEPROM
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 is finished
103242 Erase CommandThe Erase command erases the current page There must be one byte written in the page buffer for theErase command to 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
ATtiny161416161617 AutomotiveNonvolatile Memory Controller (NVMCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 65
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 command Toerase a whole page all the bytes in the page buffer have to be updated before executing the commandThe CPU can continue running code while the operation is ongoing
The page buffer will automatically be cleared after the operation is finished
103243 Erase-Write OperationThe EraseWrite command is a combination of the Erase and Write command but without clearing thepage buffer after the Erase command The erasewrite operation first erases the selected page then itwrites 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 automatically be cleared after the operation is finished
103244 Page Buffer Clear CommandThe Page Buffer Clear command clears the page buffer The contents of the page buffer will be all 1rsquosafter the operation The CPU will be halted when the operation executes (seven CPU cycles)
103245 Chip Erase CommandThe Chip Erase command erases the Flash and the EEPROM The EEPROM is unaltered if theEEPROM Save During Chip Erase (EESAVE) fuse in FUSESYSCFG0 is set The Flash will not beprotected by Boot Section Lock (BOOTLOCK) or Application Code Section Write Protection (APCWP) inNVMCTRLCTRLB The memory will be all 1rsquos after the operation
103246 EEPROM Erase CommandThe EEPROM Erase command erases the EEPROM The EEPROM will be all 1rsquos after the operationThe CPU will be halted while the EEPROM is being erased
103247 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
For reading fuses use a regular read on the memory location
1033 Preventing FlashEEPROM CorruptionDuring periods of low VDD the Flash program or EEPROM data can be corrupted if the supply voltage istoo low for the CPU and the FlashEEPROM to operate properly These issues are the same as for boardlevel systems using FlashEEPROM and the same design solutions should be applied
A FlashEEPROM corruption can be caused by two situations when the voltage is too low1 A regular write sequence to the Flash which requires a minimum voltage to operate correctly2 The CPU itself can execute instructions incorrectly when the supply voltage is too low
See the Electrical Characteristics chapter for Maximum Frequency vs VDD
FlashEEPROM corruption can be avoided by these measures
ATtiny161416161617 AutomotiveNonvolatile Memory Controller (NVMCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 66
bull Keep the device in Reset during periods of insufficient power supply voltage This can be done byenabling the internal Brown-Out Detector (BOD)
bull The voltage level monitor in the BOD can be used to prevent starting a write to the EEPROM close tothe BOD level
bull If the detection levels of the internal BOD donrsquot match the required detection level an external lowVDD Reset protection circuit can be used If a Reset occurs while a write operation is ongoing thewrite operation will be aborted
Related Links383 General Operating Ratings18 Brown-Out Detector (BOD)
1034 InterruptsTable 10-3 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 register ofthe peripheral (NVMCTRLINTFLAGS)
An interrupt source is enabled or disabled by writing to the corresponding bit in the peripherals InterruptEnable register (NVMCTRLINTEN)
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
1035 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 enters a sleep mode the NVM block the NVM Controllerand the system clock will remain ON until the write is finished This is valid for all sleep modes includingPower-Down Sleep mode
The EEPROM Ready interrupt will wake up the device only from Idle Sleep mode
The page buffer is cleared when waking up from Sleep
1036 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
Attempting to write to a protected register without following the appropriate CCP unlock sequence leavesthe protected register unchanged
The following registers are under CCP
ATtiny161416161617 AutomotiveNonvolatile Memory Controller (NVMCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 67
Table 10-4 NVMCTRL - Registers under Configuration Change Protection
Register Key
NVMCTRLCTRLA SPM
Related Links9572 Sequence for Execution of Self-Programming
ATtiny161416161617 AutomotiveNonvolatile Memory Controller (NVMCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 68
104 Register Summary - NVMCTRL
Offset Name Bit Pos
0x00 CTRLA 70 CMD[20]0x01 CTRLB 70 BOOTLOCK APCWP0x02 STATUS 70 WRERROR EEBUSY FBUSY0x03 INTCTRL 70 EEREADY0x04 INTFLAGS 70 EEREADY0x05 Reserved
0x06 DATA70 DATA[70]158 DATA[158]
0x08 ADDR70 ADDR[70]158 ADDR[158]
105 Register Description
ATtiny161416161617 AutomotiveNonvolatile Memory Controller (NVMCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 69
1051 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 writeValue Name Description0x0 - No command0x1 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 clear0x5 CHER Chip erase erase Flash and EEPROM (unless EESAVE in FUSESYSCFG is 1)0x6 EEER EEPROM Erase0x7 WFU Write fuse (only accessible through UPDI)
ATtiny161416161617 AutomotiveNonvolatile Memory Controller (NVMCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 70
1052 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 rsquo1rsquo to this bit locks the boot section from read and instruction fetchIf this bit is rsquo1rsquo a read from the boot section will return rsquo0rsquo A fetch from the boot section will also return lsquo0rsquoas instructionThis bit can be written from the boot section only It can only be cleared to rsquo0rsquo by a ResetThis bit will take effect only when the boot section is left the first time after the bit is written
Bit 0 ndash APCWP Application Code Section Write ProtectionWriting a rsquo1rsquo to this bit protects the application code section from further writesThis bit can only be written to rsquo1rsquo It is cleared to rsquo0rsquo only by Reset
ATtiny161416161617 AutomotiveNonvolatile Memory Controller (NVMCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 71
1053 Status
Name STATUSOffset 0x02Reset 0x00Property -
Bit 7 6 5 4 3 2 1 0 WRERROR EEBUSY FBUSY
Access R R R 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 sectionsbefore 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
ATtiny161416161617 AutomotiveNonvolatile Memory Controller (NVMCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 72
1054 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 writeerase operationsThis is a level interrupt that will be triggered only when the EEREADY flag in the INTFLAGS register is setto zero Thus the interrupt should not be enabled before triggering an NVM command as the EEREADYflag will not be set before the NVM command issued The interrupt should be disabled in the interrupthandler
ATtiny161416161617 AutomotiveNonvolatile Memory Controller (NVMCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 73
1055 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 FlagThis flag is set continuously as long as the EEPROM is not busy This flag is cleared by writing a 1 to it
ATtiny161416161617 AutomotiveNonvolatile Memory Controller (NVMCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 74
1056 Data
Name DATAOffset 0x06Reset 0x00Property -
The 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
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 RegisterThis register is used by the UPDI for fuse write operations
ATtiny161416161617 AutomotiveNonvolatile Memory Controller (NVMCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 75
1057 Address
Name ADDROffset 0x08Reset 0x00Property -
The 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
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] AddressThe Address register contains the address to the last memory location that has been updated
ATtiny161416161617 AutomotiveNonvolatile Memory Controller (NVMCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 76
11 Clock Controller (CLKCTRL)
111 Featuresbull All clocks and clock sources are automatically enabled when requested by peripheralsbull Internal Oscillators
ndash 16 MHz Oscillator (OSC20M)ndash 32 KHz Ultra Low-Power Oscillator (OSCULP32K)
bull External Clock Optionsndash 32768 kHz Crystal Oscillator (XOSC32K)ndash External clock
bull Main Clock Featuresndash Safe run-time switchingndash Prescaler with 1x to 64x division in 12 different settings
112 OverviewThe Clock Controller peripheral (CLKCTRL) controls distributes and prescales the clock signals from theavailable oscillators The CLKCTRL supports internal and external clock sources
The CLKCTRL is based on an automatic clock request system implemented in all peripherals on thedevice The peripherals will automatically request the clocks needed If multiple clock sources areavailable the request is routed to the correct clock source
The Main Clock (CLK_MAIN) is used by the CPU RAM and the IO bus The main clock source can beselected and prescaled Some peripherals can share the same clock source as the main clock or runasynchronously to the main clock domain
ATtiny161416161617 AutomotiveClock Controller (CLKCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 77
1121 Block Diagram - CLKCTRLFigure 11-1 CLKCTRL Block Diagram
CPURAMNVM TCDBODRTC
OSC20Mint Oscillator
WDT
32768 kHzext Crystal Osc
DIV32
TOSC2 TOSC1
RTCCLKSEL
CLK_RTCCLK_PER
CLK_MAIN
CLK_WDT CLK_BOD CLK_TCD
TCDCLKCSEL
Main Clock Prescaler
Main Clock Switch
INT
PRESCALER
XOSC32KSEL
CLK_CPU
OtherPeripherals
CLKOUT
OSC20M
XOSC32K
OSCULP32K
32 KHz ULPInt Oscillator
EXTCLK
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 SRAM and the NVMCTRL peripheral to access the nonvolatile
memorybull CLK_PER is used by all peripherals that are not listed under asynchronous clocks
bull Clocks running asynchronously to the main clock domainndash CLK_RTC is used by the RTCPIT It will be requested when the RTCPIT is enabled The clock
source for CLK_RTC should only be changed if the peripheral is disabledndash CLK_WDT is used by the WDT It will be requested when the WDT is enabled
ATtiny161416161617 AutomotiveClock Controller (CLKCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 78
ndash CLK_BOD is used by the BOD It will be requested when the BOD is enabled in Sampled mode
The clock source for the for the main clock domain is configured by writing to the Clock Select bits(CLKSEL) in the Main Clock Control A register (CLKCTRLMCLKCTRLA) The asynchronous clocksources are configured by registers in the respective peripheral
1122 Signal Description
Signal Type Description
CLKOUT Digital output CLK_PER output
Related Links5 IO Multiplexing and Considerations
113 Functional Description
1131 Sleep Mode OperationWhen a clock source is not usedrequested it will turn OFF It is possible to request a 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 start-up 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 or 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
1132 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 Until a sufficient number of clock edges are detected the switch willnot occur and it will not be possible to change to another clock source again without executing a Reset
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 can provide amechanism 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 divide CLK_MAIN by a factor from 1 to 64
ATtiny161416161617 AutomotiveClock Controller (CLKCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 79
Figure 11-2 Main Clock and Prescaler
(Div 1 2 4 8 16 32 64 6 10 24 48)
OSC20M
32 kHz Osc
32768 kHz 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
Related Links957 Configuration Change Protection (CCP)
1133 Main Clock After Reset
After any Reset CLK_MAIN is provided by the 16 MHz Oscillator (OSC20M) and with a prescaler divisionfactor 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
16 MHz 266 MHz
See the OSC20M description for further details
Related Links113411 16 MHz Oscillator (OSC20M)
1134 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 32 KHzCrystal Oscillator Control A register (CLKCTRLXOSC32KCTRLA) before it can serve as a clock source
The respective Oscillator Status bits in the Main Clock Status register (CLKCTRLMCLKSTATUS) indicatewhether the clock source is running and stable
Related Links710 Configuration and User Fuses (FUSE)957 Configuration Change Protection (CCP)
11341 Internal OscillatorsThe internal oscillators do not require any external components to run See the related links for accuracyand electrical characteristics
Related Links38 Electrical Characteristics
113411 16 MHz Oscillator (OSC20M)This oscillator operates at 16 MHz
After a system Reset FUSEOSCCFG determines the initial frequency of CLK_MAIN
ATtiny161416161617 AutomotiveClock Controller (CLKCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 80
During Reset the calibration values for the OSC20M are loaded from fuses There are two differentcalibration bit fields The Calibration bit field (CAL20M) in the Calibration A register(CLKCTRLOSC20MCALIBA) enables calibration around the current center frequency The OscillatorTemperature Coefficient Calibration bit field (TEMPCAL20M) in the Calibration B register(CLKCTRLOSC20MCALIBB) enables adjustment of the slope of the temperature drift compensation
For applications requiring more fine-tuned frequency setting than the oscillator calibration providesfactory stored frequency error after calibrations are available
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 locked if this oscillator is usedas the main clock source and the Lock Enable bit (LOCKEN) in the Control B register(CLKCTRLOSC20MCALIBB) is 1
The calibration bits are protected by the Configuration Change Protection Mechanism requiring a timedwrite procedure for changing the main clock and prescaler settings
The start-up time of this oscillator is analog start-up time plus four oscillator cycles Refer to the ElectricalCharacteristics section for the start-up time
When changing the oscillator calibration value the frequency may overshoot If the oscillator is used asthe main clock (CLK_MAIN) it is recommended to change the main clock prescaler so that the main clockfrequency does not exceed frac14 of the maximum operation main clock frequency as described in theGeneral Operating Ratings section The system clock prescaler can be changed back after the oscillatorcalibration value has been updated
Related Links38 Electrical Characteristics710 Configuration and User Fuses (FUSE)1135 Configuration Change Protection383 General Operating Ratings1133 Main Clock After Reset389 Oscillators and Clocks
OSC20M Stored Frequency Error CompensationThis oscillator can operate at multiple frequencies selected by the value of the Frequency Select bits(FREQSEL) in the Oscillator Configuration fuse (FUSEOSCCFG) at Reset As previously mentionedappropriate calibration values are loaded to adjust to center frequency (OSC20M) and temperature driftcompensation (TEMPCAL20M) meeting the specifications defined in the internal oscillatorcharacteristics For applications requiring wider operating range the relative factory stored frequencyerror after calibrations can be used The four errors are measured at different settings and are available inthe signature row as signed byte values
bull SIGROWOSC16ERR3V is the frequency error from 16 MHz measured at 3Vbull SIGROWOSC16ERR5V is the frequency error from 16 MHz measured at 5V
The error is stored as a compressed Q110 fixed point 8-bit value in order not to lose resolution wherethe MSB is the sign bit and the seven LSBs the lower bits of the Q110BAUDact = BAUD+ BAUD 1024
ATtiny161416161617 AutomotiveClock Controller (CLKCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 81
The minimum legal BAUD register value is 0x40 the target BAUD register value should therefore not belower than 0x4A to ensure that the compensated BAUD value stays within the legal range even for partswith negative compensation values The example code below demonstrates how to apply this value formore accurate USART baud rate
include ltasserthgt Baud rate compensated with factory stored frequency error Asynchronous communication without Auto-baud (Sync Field) 16MHz Clock 3V and 600 BAUD
int8_t sigrow_val = SIGROWOSC16ERR3V read signed error int32_t baud_reg_val = 600 ideal BAUD register value assert (baud_reg_val gt= 0x4A) Verify legal min BAUD register value with max neg comp baud_reg_val = (1024 + sigrow_val) sum resolution + error baud_reg_val = 1024 divide by resolution USART0BAUD = (int16_t) baud_reg_val set adjusted baud rate
Related Links389 Oscillators and Clocks
113412 32 KHz Oscillator (OSCULP32K)The 32 KHz oscillator is optimized for Ultra Low-Power (ULP) operation Power consumption isdecreased at the cost of decreased accuracy compared to an external crystal oscillator
This oscillator provides the 1 KHz signal for the Real-Time Counter (RTC) the Watchdog Timer (WDT)and the Brown-out Detector (BOD)
The start-up time of this oscillator is the oscillator start-up time plus four oscillator cycles Refer to theElectrical Characteristics chapter for the start-up time
Related Links38 Electrical Characteristics18 Brown-Out Detector (BOD)20 Watchdog Timer (WDT)24 Real-Time Counter (RTC)
11342 External Clock SourcesThese external clock sources are available
bull External Clock from pin (EXTCLK)bull The TOSC1 and TOSC2 pins are dedicated to driving a 32768 kHz Crystal Oscillator (XOSC32K)bull Instead of a crystal oscillator TOSC1 can be configured to accept an external clock source
113421 32768 kHz 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 32 KHz 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 start-up time of a given crystal oscillator can be accommodated by writing to the Crystal Start-upTime bits (CSUT) in CLKCTRLXOSC32KCTRLA
When XOSC32K is configured to use an external clock on TOSC1 the start-up time is fixed to two cycles
ATtiny161416161617 AutomotiveClock Controller (CLKCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 82
113422 External Clock (EXTCLK)The EXTCLK is taken directly from the pin This GPIO pin is automatically configured for EXTCLK if anyperipheral is requesting this clock
This clock source has a start-up time of two cycles when first requested
1135 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
Attempting to write to a protected register without following the appropriate CCP unlock sequence leavesthe protected register unchanged
The following registers are under CCP
Table 11-2 CLKCTRL - Registers Under Configuration Change Protection
Register Key
CLKCTRLMCLKCTRLB IOREG
CLKCTRLMCLKLOCK IOREG
CLKCTRLXOSC32KCTRLA IOREG
CLKCTRLMCLKCTRLA IOREG
CLKCTRLOSC20MCTRLA IOREG
CLKCTRLOSC20MCALIBA IOREG
CLKCTRLOSC20MCALIBB IOREG
CLKCTRLOSC32KCTRLA IOREG
Related Links9571 Sequence for Write Operation to Configuration Change Protected IO Registers
ATtiny161416161617 AutomotiveClock Controller (CLKCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 83
114 Register Summary - CLKCTRL
Offset Name Bit Pos
0x00 MCLKCTRLA 70 CLKOUT CLKSEL[10]0x01 MCLKCTRLB 70 PDIV[30] PEN0x02 MCLKLOCK 70 LOCKEN0x03 MCLKSTATUS 70 EXTS XOSC32KS OSC32KS OSC20MS SOSC0x04
0x0F
Reserved
0x10 OSC20MCTRLA 70 RUNSTDBY 0x11 OSC20MCALIBA 70 0x12 OSC20MCALIBB 70 LOCK TEMPCAL20M[30]0x13
0x17
Reserved
0x18 OSC32KCTRLA 70 RUNSTDBY 0x19
0x1B
Reserved
0x1C XOSC32KCTRLA 70 CSUT[10] SEL RUNSTDBY ENABLE
115 Register Description
ATtiny161416161617 AutomotiveClock Controller (CLKCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 84
1151 Main Clock Control A
Name MCLKCTRLAOffset 0x00Reset 0x00Property Configuration Change Protection
Bit 7 6 5 4 3 2 1 0 CLKOUT CLKSEL[10]
Access RW RW RW Reset 0 0 0
Bit 7 ndash CLKOUT System Clock OutWhen this bit is written to 1 the system clock is output to CLKOUT pinWhen the device is in a Sleep mode there is no clock output unless a peripheral is using the systemclock
Bits 10 ndash CLKSEL[10] Clock SelectThis bit field selects the source for the Main Clock (CLK_MAIN)Value Name Description0x0 OSC20M 16 MHz internal oscillator0x1 OSCULP32K 32 KHz internal ultra low-power oscillator0x2 XOSC32K 32768 kHz external crystal oscillator0x3 EXTCLK External clock
ATtiny161416161617 AutomotiveClock Controller (CLKCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 85
1152 Main Clock Control B
Name MCLKCTRLBOffset 0x01Reset 0x11Property Configuration Change Protection
Bit 7 6 5 4 3 2 1 0 PDIV[30] PEN
Access RW RW RW RW RW Reset 1 0 0 0 1
Bits 41 ndash PDIV[30] Prescaler DivisionIf the Prescaler Enable (PEN) bit is written to lsquo1rsquo these bits define the division ratio of the main clockprescalerThese bits can be written during run-time to vary the clock frequency of the system to suit the applicationrequirementsThe user software must ensure a correct configuration of input frequency (CLK_MAIN) and prescalersettings such that the resulting frequency of CLK_PER never exceeds the allowed maximum (seeElectrical Characteristics)Value DescriptionValue Division0x0 20x1 40x2 80x3 160x4 320x5 640x8 60x9 100xA 120xB 240xC 48other Reserved
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 fieldWhen this bit is written to 0 the main clock will pass through undivided (CLK_PER=CLK_MAIN)regardless of the value of PDIV
ATtiny161416161617 AutomotiveClock Controller (CLKCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 86
1153 Main Clock Lock
Name MCLKLOCKOffset 0x02Reset Based on OSCLOCK in FUSEOSCCFGProperty Configuration Change Protection
Bit 7 6 5 4 3 2 1 0 LOCKEN
Access RW Reset x
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 ResetThis provides protection for the CLKCTRLMCLKCTRLA and CLKCTRLMCLKCTRLB registers andcalibration settings for the main clock source from unintentional modification by softwareAt Reset the LOCKEN bit is loaded based on the OSCLOCK bit in FUSEOSCCFGRelated Links710 Configuration and User Fuses (FUSE)
ATtiny161416161617 AutomotiveClock Controller (CLKCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 87
1154 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 Reset 0 0 0 0 0
Bit 7 ndash EXTS External Clock StatusValue Description0 EXTCLK has not started1 EXTCLK has started
Bit 6 ndash XOSC32KS XOSC32K StatusThe Status bit will only be available if the source is requested as the main clock or by another module Ifthe oscillator RUNSTDBY bit is set but the oscillator is unusednot requested this bit will be 0Value Description0 XOSC32K is not stable1 XOSC32K is stable
Bit 5 ndash OSC32KS OSCULP32K StatusThe Status bit will only be available if the source is requested as the main clock or by another module Ifthe oscillator RUNSTDBY bit is set but the oscillator is unusednot requested this bit will be 0Value Description0 OSCULP32K is not stable1 OSCULP32K is stable
Bit 4 ndash OSC20MS OSC20M StatusThe Status bit will only be available if the source is requested as the main clock or by another module Ifthe oscillator RUNSTDBY bit is set but the oscillator is unusednot requested this bit will be 0Value Description0 OSC20M is not stable1 OSC20M is stable
Bit 0 ndash SOSC Main Clock Oscillator ChangingValue Description0 The clock source for CLK_MAIN is not undergoing a switch1 The clock source for CLK_MAIN is undergoing a switch and will change as soon as the new
source is stable
ATtiny161416161617 AutomotiveClock Controller (CLKCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 88
1155 16 MHz Oscillator Control A
Name OSC20MCTRLAOffset 0x10Reset 0x00Property Configuration Change Protection
Bit 7 6 5 4 3 2 1 0 RUNSTDBY
Access RW Reset 0
Bit 1 ndash RUNSTDBY Run StandbyThis bit forces the oscillator ON in all modes even when unused by the system In Standby Sleep modethis can be used to ensure immediate wake-up and not waiting for oscillator start-up timeWhen not requested by peripherals no oscillator output is providedIt takes four oscillator cycles to open the clock gate after a request but the oscillator analog start-up timewill be removed when this bit is set
ATtiny161416161617 AutomotiveClock Controller (CLKCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 89
1156 16 MHz Oscillator Calibration A
Name OSC20MCALIBAOffset 0x11Reset Based on FREQSEL in FUSEOSCCFGProperty Configuration Change Protection
Bit 7 6 5 4 3 2 1 0
Access Reset
These bits change the frequency around the current center frequency of the OSC20M for fine-tuningAt Reset the factory calibrated values are loaded based on the FREQSEL bits in FUSEOSCCFG
ATtiny161416161617 AutomotiveClock Controller (CLKCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 90
1157 16 MHz Oscillator Calibration B
Name OSC20MCALIBBOffset 0x12Reset Based on FUSEOSCCFGProperty Configuration Change Protection
Bit 7 6 5 4 3 2 1 0 LOCK TEMPCAL20M[30]
Access R RW RW RW RW Reset x x x x x
Bit 7 ndash LOCK Oscillator Calibration Locked by FuseWhen this bit is set the calibration settings in CLKCTRLOSC20MCALIBA andCLKCTRLOSC20MCALIBB cannot be changedThe Reset the value is loaded from 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 compensationAt Reset the factory calibrated values are loaded based on the FREQSEL bits in FUSEOSCCFG
ATtiny161416161617 AutomotiveClock Controller (CLKCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 91
1158 32 KHz Oscillator Control A
Name OSC32KCTRLAOffset 0x18Reset 0x00Property Configuration Change Protection
Bit 7 6 5 4 3 2 1 0 RUNSTDBY
Access RW Reset 0
Bit 1 ndash RUNSTDBY Run StandbyThis bit forces the oscillator ON in all modes even when unused by the system In Standby Sleep modethis can be used to ensure immediate wake-up and not waiting for the oscillator start-up timeWhen not requested by peripherals no oscillator output is providedIt takes four oscillator cycles to open the clock gate after a request but the oscillator analog start-up timewill be removed when this bit is set
ATtiny161416161617 AutomotiveClock Controller (CLKCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 92
1159 32768 kHz Crystal Oscillator Control A
Name XOSC32KCTRLAOffset 0x1CReset 0x00Property Configuration Change Protection
The SEL and CSUT bits cannot be changed as long as the ENABLE bit is set or the XOSC32K Stable 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
Bit 7 6 5 4 3 2 1 0 CSUT[10] SEL RUNSTDBY ENABLE
Access RW RW RW RW RW Reset 0 0 0 0 0
Bits 54 ndash CSUT[10] Crystal Start-Up TimeThese bits select the start-up time for the XOSC32K It is write protected when the oscillator is enabled(ENABLE=1)If SEL=1 the start-up time will not be appliedValue Name Description0x0 1K 1k cycles0x1 16K 16k cycles0x2 32K 32k cycles0x3 64K 64k cycles
Bit 2 ndash SEL Source SelectThis bit selects the external source type It is write protected when the oscillator is enabled (ENABLE=1)Value Description0 External crystal1 External clock on TOSC1 pin
Bit 1 ndash RUNSTDBY Run StandbyWriting this bit to 1 starts the crystal oscillator and forces the oscillator ON in all modes even whenunused by the system if the ENABLE bit is set In Standby Sleep mode this can be used to ensureimmediate wake-up and not waiting for oscillator start-up time When this bit is 0 the crystal oscillator isonly running when requested and the ENABLE bit is setThe output of XOSC32K is not sent to other peripherals unless it is requested by one or more peripheralsWhen the RUNSTDBY bit is set there will only be a delay of two to three crystal oscillator cycles after arequest until the oscillator output is received if the initial crystal start-up time has already completedAccording to RUNSTBY bit the oscillator will be turned ON all the time if the device is in Active Idle orStandby Sleep mode or only be enabled when requestedThis 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-onlyThis bit is IO protected to prevent unintentional enabling of the oscillator
ATtiny161416161617 AutomotiveClock Controller (CLKCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 93
12 Sleep Controller (SLPCTRL)
121 Featuresbull Power management for adjusting power consumption and functionsbull Three sleep modes
ndash Idlendash Standbyndash Power-Down
bull Configurable Standby Sleep mode where peripherals can be configured as ON or OFF
122 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 and sleep mode
There are in total four modes available one active mode in which software is executed and three sleepmodes The available sleep modes are Idle Standby and Power-Down
All sleep modes are available and can be entered from active mode In active mode the CPU isexecuting application code When the device enters sleep mode program execution is stopped andinterrupts or a reset is used to wake the device again The application code decides which sleep mode toenter and when
Interrupts are used to wake the device from sleep The available interrupt wake-up sources depend onthe configured sleep mode When an interrupt occurs the device will wake up and execute the interruptservice routine before continuing normal program execution from the first instruction after the SLEEPinstruction Any Reset will take the device out of a sleep mode
The content of the register file SRAM and registers are kept during sleep If a Reset occurs during sleepthe device will reset start and execute from the Reset vector
1221 Block DiagramFigure 12-1 Sleep Controller in System
SLPCTRL
SLEEP Instruction
Interrupt Request
Peripheral
Interrupt Request
Sleep State
CPU
ATtiny161416161617 AutomotiveSleep Controller (SLPCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 94
1222 System DependenciesIn order to use this peripheral other parts of the system must be configured correctly as described below
Table 12-1 SLPCTRL System Dependencies
Dependency Applicable Peripheral
Clocks Yes CLKCTRL
IO Lines and Connections No -
Interrupts No -
Events No -
Debug Yes UPDI
12221 ClocksThis peripheral depends on the peripheral clock
Related Links11 Clock Controller (CLKCTRL)
12222 IO Lines and ConnectionsNot applicable
12223 InterruptsNot applicable
12224 EventsNot applicable
12225 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 SLPCTRL 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
123 Functional Description
1231 InitializationTo put the device into a sleep mode follow these steps
bull Configure and enable the interrupts that shall be able to wake the device from sleep Also enableglobal interrupts
WARNING If there are no interrupts enabled when going to sleep the device cannot wake up againOnly a Reset will allow the device to continue operation
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) A SLEEPinstruction must be run to make the device actually go to sleep
ATtiny161416161617 AutomotiveSleep Controller (SLPCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 95
1232 Operation
12321 Sleep ModesIn addition to Active mode there are three different sleep modes with decreasing power consumptionand functionality
Idle The CPU stops executing code no peripherals are disabledAll interrupt sources can wake-up the device
Standby The user can configure peripherals to be enabled or not using the respective RUNSTBY bitThis means that the power consumption is highly dependent on what functionality is enabledand thus may vary between the Idle and Power-Down levelsSleepWalking is available for the ADC moduleThe wake-up sources are pin interrupts TWI address match UART Start-of-Frame interrupt(if USART is enabled to run in Standby) ADC window interrupt (if PTC enabled to run inStandby) RTC interrupt (if RTC enabled to run in Standby) and TCB interrupt
Power-Down
Only the WDT and the PIT (a component of the RTC) are activeThe only wake-up sources are the pin change interrupt and TWI address match
Table 12-2 Sleep Mode Activity Overview
Group Peripheral Active in Sleep Mode
Clock Idle Standby Power-Down
Active ClockDomain
CPU CLK_CPU
Peripherals CLK_PER X
RTC CLK_RTC X X
ADCPTC CLK_PER X X
PIT (RTC) CLK_RTC X X X
WDT CLK_WDT X X X
Oscillators Main Clock Source X X
RTC Clock Source X X
WDT Oscillator X X X
Wake-UpSources
INTn and Pin Change X X X
TWI Address Match X X X
Periodic Interrupt Timer X X X
UART Start-of-Frame X X
ADCPTC Window X X
RTC Interrupt X X
All other Interrupts X
Note bull X means active X indicates that the RUNSTBY bit of the corresponding peripheral must be set to
enter the active state
ATtiny161416161617 AutomotiveSleep Controller (SLPCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 96
12322 Wake-Up TimeThe normal wake-up time for the device is six 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 timebull In Standby Sleep mode the main clock might be running so it depends on the peripheral
configurationbull In Power-Down Sleep mode only the ULP 32 KHz oscillator and RTC clock may be running if it is
used by the BOD or WDT All other clock sources will be OFF
Table 12-3 Sleep Modes and Start-Up Time
Sleep Mode Start-Up Time
IDLE 6 CLK
Standby 6 CLK + OSC start-up
Power-Down 6 CLK + OSC start-up
The start-up 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 readybefore executing 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 the total wake-up time will be the same If the BOD takes longer than the normal wake-up timethe wake-up time will be extended until the BOD is ready This ensures correct supply voltage whenevercode is executed
1233 Configuration Change ProtectionNot applicable
ATtiny161416161617 AutomotiveSleep Controller (SLPCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 97
124 Register Summary - SLPCTRL
Offset Name Bit Pos
0x00 CTRLA 70 SMODE[10] SEN
125 Register Description
ATtiny161416161617 AutomotiveSleep Controller (SLPCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 98
1251 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 executedValue Name Description0x0 IDLE Idle Sleep mode enabled0x1 STANDBY Standby Sleep mode enabled0x2 PDOWN Power-Down Sleep mode enabledother - 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
ATtiny161416161617 AutomotiveSleep Controller (SLPCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 99
13 Reset Controller (RSTCTRL)
131 Featuresbull Reset the device and set it to an initial statebull Reset Flag register for identifying the Reset source in softwarebull Multiple Reset sources
ndash Power supply Reset sources Brown-out Detect (BOD) Power-on Reset (POR)ndash User Reset sources External Reset pin (RESET) Watchdog Reset (WDT) Software Reset
(SW) and UPDI Reset
132 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 the software
1321 Block DiagramFigure 13-1 Reset System Overview
RESET SOURCES
POR
BOD
WDT
CPU (SW)
RESET CONTROLLER
UPDI
UPDI
All other Peripherals
TCD pin override settings
(Loaded from fuses)
RESET External ResetFILTER
VDD
Pull-upResistor
1322 Signal Description
Signal Description Type
RESET External Reset (active-low) Digital input
ATtiny161416161617 AutomotiveReset Controller (RSTCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 100
133 Functional Description
1331 InitializationThe Reset Controller (RSTCTRL) is always enabled but 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
1332 Operation
13321 Reset SourcesThere are two kinds of sources for Resets
bull Power supply Resets which are caused by changes in the power supply voltage Power-on Reset(POR) and Brown-out Detector (BOD)
bull User Resets which are issued by the application by the debug operation or by pin changes(Software Reset Watchdog Reset UPDI Reset and external Reset pin RESET)
133211 Power-On Reset (POR)A Power-on Reset (POR) is generated by an on-chip detection circuit The POR is activated when theVDD rises until it reaches the POR threshold voltage The POR is always enabled and will also detectwhen the VDD falls below the threshold voltage
All volatile logic is reset on POR All fuses are reloaded after the Reset is released
133212 Brown-Out Detector (BOD) Reset SourceThe on-chip Brown-out Detection circuit will monitor the VDD level during operation by comparing it to afixed trigger level The trigger level for the BOD can be selected by fuses If BOD is unused in theapplication it is forced to a configured level in order to ensure safe operation during chip erase
All logic is reset on BOD Reset except the BOD configuration All fuses are reloaded after the Reset isreleased
Related Links18 Brown-Out Detector (BOD)
133213 Software ResetThe software Reset makes it possible to issue a system Reset from software The Reset is generated bywriting a 1 to the Software Reset Enable bit (SWRE) in the Software Reset register (RSTCTRLSWRR)
The Reset will take place immediately after the bit is written and the device will be kept in reset until theReset sequence is completed All logic is reset on software Reset except UPDI and BOD configurationAll fuses are reloaded after the Reset is released
133214 External ResetThe external Reset is enabled by fuse (see fuse map)
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 All logic is reset on external reset except UPDI and BODconfiguration All fuses are reloaded after the Reset is released
ATtiny161416161617 AutomotiveReset Controller (RSTCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 101
Related Links710 Configuration and User Fuses (FUSE)
133215 Watchdog ResetThe Watchdog Timer (WDT) is a system function for monitoring correct program operation If the WDT isnot reset from software according to the programmed time-out period a Watchdog Reset will be issuedSee the WDT documentation for further details
All logic is reset on WDT Reset except UPDI and BOD configuration All fuses are reloaded after theReset is released
Related Links20 Watchdog Timer (WDT)
133216 Universal Program Debug Interface (UPDI) ResetThe UPDI contains a separate Reset source that is used to reset the device during external programmingand debugging The Reset source is accessible only from external debuggers and programmers All logicis reset on UPDI Reset except the UPDI itself and BOD configuration All fuses are reloaded after theReset is released See UPDI chapter on how to generate a UPDI Reset request
Related Links34 Unified Program and Debug Interface (UPDI)
13322 Reset Time
The Reset time can be split in two
The first part is when any of the Reset sources are active This part depends on the input to the Resetsources The external Reset is active as long as the RESET pin is low the Power-on Reset (POR) andBrown-out Detector (BOD) is active as long as the supply voltage is below the Reset source threshold
When all the Reset sources are released an internal Reset initialization of the device is done This timewill be increased with the start-up time given by the start-up time fuse setting (SUT in FUSESYSCFG1)The internal Reset initialization time will also increase if the CRCSCAN is configured to run at start-up(CRCSRC in FUSESYSCFG0)
1333 Sleep Mode OperationThe Reset Controller continues to operate in all active and sleep modes
1334 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
Attempting to write to a protected register without following the appropriate CCP unlock sequence leavesthe protected register unchanged
The following registers are under CCP
Table 13-1 RSTCTRL - Registers Under Configuration Change Protection
Register Key
RSTCTRLSWRR IOREG
Related Links
ATtiny161416161617 AutomotiveReset Controller (RSTCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 102
9571 Sequence for Write Operation to Configuration Change Protected IO Registers
ATtiny161416161617 AutomotiveReset Controller (RSTCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 103
134 Register Summary - RSTCTRL
Offset Name Bit Pos
0x00 RSTFR 70 UPDIRF SWRF WDRF EXTRF BORF PORF0x01 SWRR 70 SWRE
135 Register Description
ATtiny161416161617 AutomotiveReset Controller (RSTCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 104
1351 Reset Flag Register
Name RSTFROffset 0x00Reset 0xXXProperty -
All 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)
Bit 7 6 5 4 3 2 1 0 UPDIRF SWRF WDRF EXTRF BORF PORF
Access R R RW RW RW RW RW RW Reset 0 0 x x x x x x
Bit 5 ndash UPDIRF 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 Brown-Out Reset FlagThis bit is set if a Brown-out Reset occurs
Bit 0 ndash PORF Power-On Reset FlagThis bit is set if a Power-on Reset occursThis flag is only cleared by writing a 1 to itAfter a POR only the POR flag is set and all other flags are cleared No other flags can be set before afull system boot is run after the POR
ATtiny161416161617 AutomotiveReset Controller (RSTCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 105
1352 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 occurThis bit will always read as 0
ATtiny161416161617 AutomotiveReset Controller (RSTCTRL)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 106
14 CPU Interrupt Controller (CPUINT)
141 Featuresbull Short and Predictable Interrupt Response Timebull Separate Interrupt Configuration and Vector Address for Each Interruptbull Interrupt Prioritizing by Level and Vector Addressbull Non-Maskable Interrupts (NMI) for Critical Functionsbull Two Interrupt Priority Levels 0 (normal) and 1 (high)bull ndash One of the Interrupt Requests can optionally be assigned as a Priority Level 1 interrupt
ndash Optional Round Robin Priority Scheme for Priority Level 0 Interruptsbull Interrupt Vectors Optionally Placed in the Application Section or the Boot Loader Sectionbull Selectable Compact Vector Table
142 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 interrupt isenabled and the interrupt condition occurs the CPUINT will receive the interrupt request Based on theinterrupts priority level and the priority level of any ongoing interrupts the interrupt request is eitheracknowledged or kept pending until it has priority When an interrupt request is acknowledged by theCPUINT the Program Counter is set to point to the interrupt vector The interrupt vector is normally ajump to the interrupt handler (ie the software routine that handles the interrupt) After returning from theinterrupt handler program execution continues from where it was before the interrupt occurred Oneinstruction is always executed before any pending interrupt is served
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 request
By default all peripherals are priority level 0 It is possible to set one single interrupt vector to the higherpriority level 1 Interrupts are prioritized according to their priority level and their interrupt vector addressPriority level 1 interrupts will interrupt level 0 interrupt handlers Among priority level 0 interrupts thepriority is determined from the interrupt vector address where the lowest interrupt vector address has thehighest interrupt 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
Interrupt 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
ATtiny161416161617 AutomotiveCPU Interrupt Controller (CPUINT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 107
1421 Block DiagramFigure 14-1 CPUINT Block Diagram
INT REQ
INT LEVEL
INT ACK
Peripheral 1
Peripheral n
Interrupt Controller
SleepController
CPU
PriorityDecoder
STATUS
CPUSREG
INT REQ
INT REQ
GlobalInterruptEnable
CPU RETICPU INT ACK
CPU INT REQ
Wake-upLVL0PRILVL1VEC
1422 Signal DescriptionNot applicable
1423 System DependenciesIn order to use this peripheral other parts of the system must be configured correctly as described below
Table 14-1 CPUINT System Dependencies
Dependency Applicable Peripheral
Clocks Yes CLKCTRL
IO Lines and Connections No -
Interrupts No -
Events No -
Debug Yes UPDI
Related Links14235 Debug Operation14231 Clocks
14231 ClocksThis peripheral depends on the peripheral clock
Related Links11 Clock Controller (CLKCTRL)
14232 IO Lines and ConnectionsNot applicable
14233 InterruptsNot applicable
14234 EventsNot applicable
ATtiny161416161617 AutomotiveCPU Interrupt Controller (CPUINT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 108
14235 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 Links34 Unified Program and Debug Interface (UPDI)
143 Functional Description
1431 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)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)
1432 Operation
14321 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 (peripheralINTCTRL)
Interrupt flags are not automatically cleared after the interrupt is executed The respective INTFLAGSregister descriptions provide information on how to clear specific flags
14322 Interrupt Vector LocationsThe Interrupt vector placement is dependent on the value of Interrupt Vector Select bit (IVSEL) in theControl A register (CPUINTCTRLA) Refer to the IVSEL description in CPUINTCTRLA for the possiblelocations
If the program never enables an interrupt source the Interrupt Vectors are not used and regular programcode can be placed at these locations
14323 Interrupt Response TimeThe minimum interrupt response time for all enabled interrupts is three CPU clock cycles one cycle tofinish the ongoing instruction two cycles to store the Program Counter to the stack and three cycles(1) tojump to the interrupt handler (JMP)
After the Program Counter is pushed on the stack the program vector for the interrupt is executed See Figure 14-2 first diagram
ATtiny161416161617 AutomotiveCPU Interrupt Controller (CPUINT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 109
The jump to the interrupt handler takes three clock cycles(1) If an interrupt occurs during execution of amulticycle instruction this instruction is completed before the interrupt is served See Figure 14-2 seconddiagram
If an interrupt occurs when the device is in sleep mode the interrupt execution response time isincreased by five clock cycles In addition the response time is increased by the start-up time from theselected sleep mode See Figure 14-2 third diagram
A return from an interrupt handling routine takes four to five clock cycles depending on the size of theProgram Counter During these clock cycles the Program Counter is popped from the stack and theStack Pointer is incremented
ATtiny161416161617 AutomotiveCPU Interrupt Controller (CPUINT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 110
Figure 14-2 Interrupt Execution of a Single-Cycle Instruction Multicycle Instruction and FromSleep(1)
Single-Cycle Instruction
Multicycle Instruction
Sleep
Note 1 Devices with 8 KB of Flash or less use RJMP instead of JMP which takes only two clock cycles
14324 Interrupt PriorityAll interrupt vectors are assigned to one of three possible priority levels as shown in the table Aninterrupt request from a high priority source will interrupt any ongoing interrupt handler from a normalpriority source When returning from the high priority interrupt handler the execution of the normal priorityinterrupt handler will resume
ATtiny161416161617 AutomotiveCPU Interrupt Controller (CPUINT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 111
Table 14-2 Interrupt Priority Levels
Priority Level Source
Highest Non Maskable Interrupt (NMI) Device-dependent and staticallyassigned
High Priority (Level 1) One vector is optionally userselectable as Level 1
Lowest Normal Priority (Level 0) The remaining interrupt vectors
14325 Scheduling of Normal Priority Interrupts
143251 Non-Maskable Interrupts (NMI)An 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 an 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 the highestpriority
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 Vector Mapping of the devicefor available NMI lines
Related Links82 Interrupt Vector Mapping
143252 Static SchedulingIf several level 0 interrupt requests are pending at the same time the one with the highest priority isscheduled for execution first The CPUINTLVL0PRI register makes it possible to change the defaultpriority The Reset value for CPUINTLVL0PRI is zero resulting in a default priority as shown in thefollowing figure As the figure shows IVEC0 has the highest priority and IVECn has the lowest priority
Figure 14-3 Static Scheduling when CPUINTLVL0PRI is Zero
Lowest Priority
Highest PriorityIVEC 0
IVEC Y
IVEC Y+1
IVEC n
Lowest Address
Highest Address
IVEC 1
The default priority can be changed by writing to the CPUINTLVL0PRI register The value written to theregister will identify the vector number with the lowest priority The next interrupt vector in IVEC will havethe highest priority see the following figure In this figure the value Y has been written to
ATtiny161416161617 AutomotiveCPU Interrupt Controller (CPUINT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 112
CPUINTLVL0PRI so that interrupt vector Y+1 has the highest priority Note that in this case the prioritieswill wrap so that IVEC0 has lower priority than IVECn
Refer to the Interrupt Vector Mapping of the device for available interrupt requests and their interruptvector number
Figure 14-4 Static Scheduling when CPUINTLVL0PRI is Different From Zero
IVEC 0
IVEC Y
IVEC Y+1
IVEC n
Lowest Priority
Highest Priority
IVEC 1
Lowest Address
Highest Address
Related Links82 Interrupt Vector Mapping
143253 Round Robin SchedulingStatic scheduling may cause starvation ie some interrupts might never be serviced To avoid this theCPUINT offers round robin scheduling for normal priority (LVL0) interrupts In round robin schedulingCPUINTLVL0PRI contains the number of the vector number in IVEC with the lowest priority This registeris automatically updated by hardware with the interrupt vector number for the last acknowledged LVL0interrupt This interrupt vector will therefore have the lowest priority next time one or more LVL0interrupts are pending Figure 14-5 explains the new priority ordering after IVEC Y was the last interruptto be acknowledged and after IVEC Y+1 was the last interrupt to be acknowledged
Round robin scheduling for LVL0 interrupt requests is enabled by writing a lsquo1rsquo to the Round Robin PriorityEnable bit (LVL0RR) in the Control A register (CPUINTCTRLA)
ATtiny161416161617 AutomotiveCPU Interrupt Controller (CPUINT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 113
Figure 14-5 Round Robin Scheduling
IVEC Y was last acknowledgedinterrupt
IVEC Y+1 was last acknowledgedinterrupt
IVEC 0
IVEC Y
IVEC Y+1
IVEC n
IVEC Y+2
IVEC Y+1
IVEC Y
IVEC 0
IVEC n
Lowest Priority
Highest Priority Lowest Priority
Highest Priority
143254 Compact Vector TableThe Compact Vector Table (CVT) is a feature to allow 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
1433 EventsNot applicable
1434 Sleep Mode OperationNot applicable
1435 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
Attempting to write to a protected register without following the appropriate CCP unlock sequence leavesthe protected register unchanged
The following registers are under CCP
Table 14-3 INTCTRL - Registers under Configuration Change Protection
Register Key
IVSEL in CPUINTCTRLA IOREG
ATtiny161416161617 AutomotiveCPU Interrupt Controller (CPUINT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 114
continuedRegister Key
CVT in CPUINTCTRLA IOREG
Related Links9571 Sequence for Write Operation to Configuration Change Protected IO Registers
ATtiny161416161617 AutomotiveCPU Interrupt Controller (CPUINT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 115
144 Register Summary - CPUINT
Offset Name Bit Pos
0x00 CTRLA 70 IVSEL CVT LVL0RR0x01 STATUS 70 NMIEX LVL1EX LVL0EX0x02 LVL0PRI 70 LVL0PRI[70]0x03 LVL1VEC 70 LVL1VEC[70]
145 Register Description
ATtiny161416161617 AutomotiveCPU Interrupt Controller (CPUINT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 116
1451 Control A
Name CTRLAOffset 0x00Reset 0x00Property Configuration Change Protection
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 the boot section is defined it will be placed before the application section The actual start address ofthe application section is determined by the BOOTEND fuseThis bit is protected by the Configuration Change Protection mechanismValue Description0 Interrupt vectors are placed at the start of the application section of the Flash1 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 mechanismValue Description0 Compact Vector Table function is disabled1 Compact Vector Table function is enabled
Bit 0 ndash LVL0RR Round Robin Priority EnableThis bit is not protected by the Configuration Change Protection mechanismValue Description0 Priority is fixed for priority level 0 interrupt requests The lowest interrupt vector address has
the highest priority1 Round Robin priority scheme is enabled for priority level 0 interrupt requests
ATtiny161416161617 AutomotiveCPU Interrupt Controller (CPUINT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 117
1452 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
ATtiny161416161617 AutomotiveCPU Interrupt Controller (CPUINT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 118
1453 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 pendingIf Round Robin is disabled (LVL0RR in CPUINTCTRLA is 0) the vector address-based priority scheme(lowest address has the highest priority) is governing the priorities of LVL0 interrupt requestsIf a system Reset is asserted the lowest interrupt vector address will have the highest priority within theLVL0
ATtiny161416161617 AutomotiveCPU Interrupt Controller (CPUINT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 119
1454 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 number 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
ATtiny161416161617 AutomotiveCPU Interrupt Controller (CPUINT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 120
15 Event System (EVSYS)
151 Featuresbull System for Direct Peripheral-to-Peripheral Signalingbull Peripherals can Directly Produce Use and React to Peripheral Eventsbull Short Response Timebull Up to Six Parallel Event Channels Available Four Asynchronous and Two 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 and by Softwarebull Works in Active mode and Standby Sleep mode
152 OverviewThe 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) through eventchannels without using the CPU It is designed to provide short and predictable response times betweenperipherals allowing for autonomous peripheral control and interaction and also for the synchronizedtiming of actions in several peripheral modules It is thus a powerful tool for reducing the complexity sizeand the execution time of the software
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
Only one trigger from an event generator peripheral can be routed on each channel but multiplechannels can use the same generator source Multiple peripherals can use events from the samechannel
A channel path can be either asynchronous or synchronous to the main clock The mode must beselected based on the requirements of the application
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
ATtiny161416161617 AutomotiveEvent System (EVSYS)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 121
1521 Block DiagramFigure 15-1 Block Diagram
Sync user xSync user 0
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
SYNCSTROBE
To sync user
To async user
SYNCUSER
Async user 0Async user y
ASYNCUSERASYNCCH
SYNCCH
ASYNCSTROBE
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 refer the block diagram of the device2 For a list of event generators refer to the Channel n Generator Selection registers
(EVSYSSYNCCH and EVSYSASYNCCH)3 For a list of event users refer to the User Channel n Input Selection registers (EVSYSSYNCUSER
and EVSYSASYNCUSER)
Related Links
ATtiny161416161617 AutomotiveEvent System (EVSYS)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 122
1554 SYNCCH1553 ASYNCCH1556 SYNCUSER1555 ASYNCUSER
1522 Signal Description
Internal Event SignalingThe event signaling can happen either synchronously or asynchronously to the main clock (CLK_MAIN)
Depending on the underlying event the event signal can be a pulse with a duration of one clock cycle ora level signal (similar to a status flag)
Event Output to Pin
Signal Type Description
EVOUT[20] Digital Output Event Output
Related Links15232 IO Lines1121 Block Diagram - CLKCTRL
1523 System DependenciesIn order to use this peripheral other parts of the system must be configured correctly as described below
Table 15-1 EVSYS System Dependencies
Dependency Applicable Peripheral
Clocks Yes CLKCTRL
IO Lines and Connections Yes PORTMUX
Interrupts No -
Events Yes EVSYS
Debug Yes UPDI
Related Links15231 Clocks1535 Debug Operation
15231 ClocksThe EVSYS uses the peripheral clock for IO registers and software events When set up correctly therouting network can also be used in sleep modes without any clock Software events will not work insleep modes where the peripheral clock is halted
Related Links11 Clock Controller (CLKCTRL)
ATtiny161416161617 AutomotiveEvent System (EVSYS)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 123
15232 IO LinesThe EVSYS can output three event channels asynchronously on pins The output signals are calledEVOUT[20]
1 Configure which event channel (one of SYNCCH[10] or ASYNCCH[30]) is output on whichEVOUTn bit by writing to EVSYSASYNCUSER10 EVSYSASYNCUSER9 orEVSYSASYNCUSER8 respectively
2 Optional configure the pin properties using the port peripheral3 Enable the pin output by writing 1 to the respective EVOUTn bit in the Control A register of the
PORTMUX peripheral (PORTMUXCTRLA)
Related Links16 Port Multiplexer (PORTMUX)17 IO Pin Configuration (PORT)1555 ASYNCUSER
153 Functional Description
1531 InitializationBefore enabling events within the device the event users multiplexer and event channels must beconfigured
Related Links15321 Event User Multiplexer Setup15322 Event System Channel
1532 Operation
15321 Event User Multiplexer SetupThe event user multiplexer selects the channel for an event user Each event user has one dedicatedevent user multiplexer Each multiplexer is connected to the supported event channel outputs and can beconfigured 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 the corresponding registersbull Event users supporting both synchronous and asynchronous events are configured by writing to the
respective asynchronous User Channel Input Selection n register (EVSYSASYNCUSERn)bull The users of synchronous-only events are configured by writing to the respective Synchronous User
Channel Input Selection n register (EVSYSSYNCUSERn)
The default setup of all user multiplexers is OFF
15322 Event System ChannelAn event channel can be connected to one of the event generators Event channels support eitherasynchronous 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)
ATtiny161416161617 AutomotiveEvent System (EVSYS)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 124
15323 Event GeneratorsEach event channel can receive the events from several event generators For details on eventgeneration refer to the documentation of the corresponding peripheral
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
15324 Software EventIn a software event the CPU will ldquostroberdquo an event channel by inverting the current value for one systemclock cycle
A software event is triggered on a channel by writing a 1 to the respective Strobe bit in the appropriateChannel Strobe register
bull Software events on asynchronous channel l are initiated by writing a 1 to the ASYNCSTROBE[l] bitin the Asynchronous Channel Strobe register (EVSYSASYNCSTROBE)
bull Software events on synchronous channel k are initiated by writing a 1 to the SYNCSTROBE[k] bit inthe 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
1533 InterruptsNot applicable
1534 Sleep Mode OperationWhen configured the Event System will work in all sleep modes One exception is software events thatrequire a system clock
1535 Debug OperationThis peripheral is unaffected by entering Debug mode
Related Links34 Unified Program and Debug Interface (UPDI)
1536 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
1537 Configuration Change ProtectionNot applicable
Related Links9571 Sequence for Write Operation to Configuration Change Protected IO Registers
ATtiny161416161617 AutomotiveEvent System (EVSYS)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 125
154 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]
0x1E ASYNCUSER12 70 ASYNCUSER[70]0x1F
0x21
Reserved
0x22 SYNCUSER0 70 SYNCUSER[70]0x23 SYNCUSER1 70 SYNCUSER[70]
155 Register Description
ATtiny161416161617 AutomotiveEvent System (EVSYS)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 126
1551 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 cycle(ie a single event is generated)
ATtiny161416161617 AutomotiveEvent System (EVSYS)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 127
1552 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 cycle(ie a single event is generated)
ATtiny161416161617 AutomotiveEvent System (EVSYS)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 128
1553 Asynchronous Channel n Generator Selection
Name ASYNCCHOffset 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 Asynchronous Channel Generator Selection
Value ASYNCCH0 ASYNCCH1 ASYNCCH2 ASYNCCH3
0x00 OFF OFF OFF 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 PORTA_PIN0 PORTB_PIN0 PORTC_PIN0 PIT_DIV8192
0x0B PORTA_PIN1 PORTB_PIN1 PORTC_PIN1 PIT_DIV4096
0x0C PORTA_PIN2 PORTB_PIN2 PORTC_PIN2 PIT_DIV2048
0x0D PORTA_PIN3 PORTB_PIN3 PORTC_PIN3 PIT_DIV1024
0x0E PORTA_PIN4 PORTB_PIN4 PORTC_PIN4 PIT_DIV512
0x0F PORTA_PIN5 PORTB_PIN5 PORTC_PIN5 PIT_DIV256
0x10 PORTA_PIN6 PORTB_PIN6 AC1_OUT PIT_DIV128
0x11 PORTA_PIN7 PORTB_PIN7 AC2_OUT PIT_DIV64
0x12 UPDI AC1_OUT - AC1_OUT
0x13 AC1_OUT AC2_OUT - AC2_OUT
0x14 AC2_OUT - - -
Other - - - -
ATtiny161416161617 AutomotiveEvent System (EVSYS)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 129
Note Not all pins of a port are actually available on devices with low pin counts Check the PinoutDiagram andor the IO Multiplexing table for details
Related Links4 Pinout5 IO Multiplexing and Considerations
ATtiny161416161617 AutomotiveEvent System (EVSYS)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 130
1554 Synchronous Channel n Generator Selection
Name SYNCCHOffset 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-3 Synchronous Channel Generator Selection
Value SYNCCH0 SYNCCH1
0x00 OFF
0x01 TCB0
0x02 TCA0_OVF_LUNF
0x03 TCA0_HUNF
0x04 TCA0_CMP0
0x05 TCA0_CMP1
0x06 TCA0_CMP2
0x07 PORTC_PIN0 -
0x08 PORTC_PIN1 PORTB_PIN0
0x09 PORTC_PIN2 PORTB_PIN1
0x0A PORTC_PIN3 PORTB_PIN2
0x0B PORTC_PIN4 PORTB_PIN3
0x0C PORTC_PIN5 PORTB_PIN4
0x0D PORTA_PIN0 PORTB_PIN5
0x0E PORTA_PIN1 PORTB_PIN6
0x0F PORTA_PIN2 PORTB_PIN7
0x10 PORTA_PIN3 TCB1
0x11 PORTA_PIN4 -
0x12 PORTA_PIN5 -
0x13 PORTA_PIN6 -
0x14 PORTA_PIN7 -
0x15 TCB1 -
ATtiny161416161617 AutomotiveEvent System (EVSYS)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 131
continuedValue SYNCCH0 SYNCCH1
Other - -
ATtiny161416161617 AutomotiveEvent System (EVSYS)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 132
1555 Asynchronous User Channel n Input Selection
Name ASYNCUSEROffset 0x12 + n0x01 [n=012]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-4 User Multiplexer Numbers
USERn User Multiplexer Description
n=0 TCB0 TimerCounter B 0
n=1 ADC0 ADC 0
n=2 CCL_LUT0EV0 CCL LUT0 Event 0
n=3 CCL_LUT1EV0 CCL LUT1 Event 0
n=4 CCL_LUT0EV1 CCL LUT0 Event 1
n=5 CCL_LUT1EV1 CCL LUT1 Event 1
n=6 TCD0_EV0 Timer Counter D 0 Event 0
n=7 TCD0_EV1 Timer Counter D 0 Event 1
n=8 EVOUT0 Event OUT 0
n=9 EVOUT1 Event OUT 1
n=10 EVOUT2 Event OUT 2
n=11 TCB1 TimerCounter B 1
n=12 ADC1 ADC 1
Value Description0x0 OFF0x1 SYNCCH00x2 SYNCCH10x3 ASYNCCH00x4 ASYNCCH10x5 ASYNCCH20x6 ASYNCCH3
ATtiny161416161617 AutomotiveEvent System (EVSYS)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 133
1556 Synchronous User Channel n Input Selection
Name SYNCUSEROffset 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-5 User Multiplexer Numbers
USERn User Multiplexer Description
n=0 TCA0 TimerCounter A
n=1 USART0 USART
Value Name0x0 OFF0x1 SYNCCH00x2 SYNCCH1
ATtiny161416161617 AutomotiveEvent System (EVSYS)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 134
16 Port Multiplexer (PORTMUX)
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 PORTMUX register map
For available pins and functionalities refer to the Multiplexed Signals table
Related Links5 IO Multiplexing and Considerations
ATtiny161416161617 AutomotivePort Multiplexer (PORTMUX)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 135
162 Register Summary - PORTMUX
Offset Name Bit Pos
0x00 CTRLA 70 LUT1 LUT0 EVOUT2 EVOUT1 EVOUT00x01 CTRLB 70 TWI0 SPI0 USART00x02 CTRLC 70 TCA05 TCA04 TCA03 TCA02 TCA01 TCA000x03 CTRLD 70 TCB1 TCB0
163 Register Description
ATtiny161416161617 AutomotivePort Multiplexer (PORTMUX)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 136
1631 Control A
Name CTRLAOffset 0x00Reset 0x00Property -
Bit 7 6 5 4 3 2 1 0 LUT1 LUT0 EVOUT2 EVOUT1 EVOUT0
Access RW RW RW RW RW Reset 0 0 0 0 0
Bit 5 ndash LUT1 CCL LUT 1 outputWrite this bit to 1 to select alternative pin location for CCL LUT 1
Bit 4 ndash LUT0 CCL LUT 0 outputWrite this bit to 1 to select alternative pin location 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
ATtiny161416161617 AutomotivePort Multiplexer (PORTMUX)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 137
1632 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
ATtiny161416161617 AutomotivePort Multiplexer (PORTMUX)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 138
1633 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 modeNot 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 modeNot 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 modeNot 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 2In Split Mode this bit controls output from low byte compare channel 2
Bit 1 ndash TCA01 TCA0 Waveform output 1Write this bit to 1 to select alternative output pin for TCA0 waveform output 1In Split mode this bit controls output from low byte compare channel 1
Bit 0 ndash TCA00 TCA0 Waveform output 0Write this bit to 1 to select alternative output pin for TCA0 waveform output 0In Split mode this bit controls output from low byte compare channel 0
ATtiny161416161617 AutomotivePort Multiplexer (PORTMUX)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 139
1634 Control D
Name CTRLDOffset 0x03Reset 0x00Property -
Bit 7 6 5 4 3 2 1 0 TCB1 TCB0
Access RW RW Reset 0 0
Bit 1 ndash TCB1 TCB1 outputWrite this bit to 1 to select alternative output pin for 16-bit timercounter B 1
Bit 0 ndash TCB0 TCB0 outputWrite this bit to 1 to select alternative output pin for 16-bit timercounter B 0
ATtiny161416161617 AutomotivePort Multiplexer (PORTMUX)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 140
17 IO Pin Configuration (PORT)
171 Featuresbull General Purpose Input and Output Pins with Individual Configurationbull Output Driver with Configurable Inverted IO and Pullupbull Input 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)
172 OverviewThe IO pins of the device are controlled by instances of the port peripheral registers This device has thefollowing instances of the IO pin configuration (PORT) PORTA PORTB and PORTC
Refer to the IO Multiplexing table to see which pins are controlled by what instance of port The offsets ofthe port instances and of the corresponding virtual port instances are listed in the Peripherals andArchitecture section
Each of the port pins has a corresponding bit in the Data Direction (PORTDIR) and Data Output Value(PORTOUT) registers to enable that pin as an output and to define the output state For example pinPA3 is controlled by DIR[3] and OUT[3] of the PORTA instance
The Data Input Value (PORTIN) is set as the input value of a port pin with resynchronization to the mainclock To reduce power consumption these input synchronizers are not clocked if the Input SenseConfiguration bit field (ISC) in PORTPINnCTRL is INPUT_DISABLE The value of the pin can always beread whether the pin is configured as input or output
The port also supports synchronous and asynchronous input sensing with interrupts for selectable pinchange 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 pin functions are configurable individually per pin The pins have hardware read-modify-write (RMW)functionality for a safe and correct change of drive value andor pull resistor configuration The directionof one port pin can be changed without unintentionally changing the direction of any other pin
The port pin configuration also controls input and output selection of other device functions
Related Links5 IO Multiplexing and Considerations8 Peripherals and Architecture
ATtiny161416161617 AutomotiveIO Pin Configuration (PORT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 141
1721 Block DiagramFigure 17-1 PORT Block Diagram
DQ
R
DQ
R
Synchronizer
D Q
R
DIRn
OUTn
INn
Pxn
D Q
R
Input Disable
Digital Input Asynchronous Event
Invert Enable
Pullup Enable
Input Disable Override
OUT Override
DIR Override
Analog InputOutput
Synchronized Input
InterruptGenerator
Interrupt
1722 Signal Description
Signal Type Description
Pxn IO pin IO pin n on PORTx
Related Links5 IO Multiplexing and Considerations
1723 System DependenciesIn order to use this peripheral other parts of the system must be configured correctly as described below
ATtiny161416161617 AutomotiveIO Pin Configuration (PORT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 142
Table 17-1 PORT System Dependencies
Dependency Applicable Peripheral
Clocks Yes CLKCTRL
IO Lines and Connections No -
Interrupts Yes CPUINT
Events Yes EVSYS
Debug No -
Related Links17234 Events17231 Clocks17233 Interrupts
17231 ClocksThis peripheral depends on the peripheral clock
17232 IO Lines and ConnectionsNot applicable
17233 InterruptsUsing the interrupts of this peripheral requires the interrupt controller to be configured first
Related Links14 CPU Interrupt Controller (CPUINT)1733 Interrupts973 SREG
17234 EventsThe events of this peripheral are connected to the Event System
Related Links15 Event System (EVSYS)
17235 Debug OperationThis peripheral is unaffected by entering Debug mode
173 Functional Description
1731 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
Power consumption can be reduced by disabling digital input buffers for all unused pins and for pins usedas analog inputs or outputs
Specific pins such as those used for connecting a debugger may be configured differently as requiredby their special function
ATtiny161416161617 AutomotiveIO Pin Configuration (PORT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 143
1732 Operation
17321 Basic FunctionsEach IO pin Pxn can be controlled by the registers in PORTx 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 only write bit n of the PORTxDIR register to 1 This can be done bywriting bit n in the PORTxDIRSET register to 1 which will avoid disturbing the configuration of other pinsin that group The nth bit in the PORTxOUT register must be written to the desired output value
Similarly writing a PORTxOUTSET bit to 1 will set the corresponding bit in the PORTxOUT register to1 Writing a bit in PORTxOUTCLR to 1 will clear that bit in PORTxOUT to zero Writing a bit inPORTxOUTTGL or PORTxIN to 1 will toggle that bit in PORTxOUT
To use pin n as an input bit n in the PORTxDIR register must be written to 0 to disable the output driverThis can be done by writing bit n in the PORTxDIRCLR register to 1 which will avoid disturbing theconfiguration of other pins in that group The input value can be read from bit n in register PORTxIN aslong as the ISC bit is not set to INPUT_DISABLE
Writing a bit to 1 in PORTxDIRTGL will toggle that bit in PORTxDIR and toggle the direction of thecorresponding pin
17322 Virtual PortsThe Virtual PORT registers map the most frequently used regular PORT registers into the bit-accessibleIO space 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
PORTIN VPORTIN
PORTINTFLAG VPORTINTFLAG
Related Links176 Register Summary - VPORT5 IO Multiplexing and Considerations8 Peripherals and Architecture
17323 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 PORTPINnCTRL
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
ATtiny161416161617 AutomotiveIO Pin Configuration (PORT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 144
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
acceptedbull Only a few pins support full asynchronous interrupt detection see IO Multiplexing and
Considerations These limitations apply for waking the system from sleep
Interrupt Type Fully Asynchronous Pins Other Pins
BOTHEDGES Will wake the system Will wake the system
RISING Will wake the system Will not wake the system
FALLING Will wake the system Will not wake the system
LEVEL Will wake the system Will wake the system
Related Links5 IO Multiplexing and Considerations
1733 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 register ofthe peripheral (peripheralINTFLAGS)
An interrupt request is generated when the corresponding interrupt is enabled and the interrupt flag is setThe interrupt request remains active until the interrupt flag is cleared See the peripherals INTFLAGSregister for details on how to clear interrupt flags
Asynchronous Sensing Pin PropertiesTable 17-4 Behavior Comparison of FullyPartly Asynchronous Sense Pin
Property Synchronous or Partly Asynchronous SenseSupport
Full Asynchronous SenseSupport
Minimum pulse-widthto trigger interrupt
Minimum one system clock cycle Less than a system clockcycle
ATtiny161416161617 AutomotiveIO Pin Configuration (PORT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 145
continuedProperty Synchronous or Partly Asynchronous Sense
SupportFull Asynchronous SenseSupport
Waking the devicefrom sleep
From all interrupt sense configurations from sleepmodes with main clock running Only fromBOTHEDGES or LEVEL interrupt senseconfiguration from sleep modes with main clockstopped
From all interrupt senseconfigurations from all sleepmodes
Interrupt dead time No new interrupt for three cycles after theprevious
No limitation
Minimum wake-uppulse length
Value on pad must be kept until the system clockhas restarted
No limitation
Related Links9 AVR CPU973 SREG
1734 EventsAll PORT pins are asynchronous event system generators PORT has as many event generators as thereare PORT pins in the device Each event system output from PORT is the value present on thecorresponding pin if the digital input driver is enabled If a pin input driver is disabled the correspondingevent system output is zero
PORT has no event inputs
1735 Sleep Mode OperationWith the exception of interrupts and input synchronization all pin configurations are independent of theSleep mode Peripherals connected to the ports can be affected by Sleep modes described in therespective peripherals documentation
The port peripheral will always use the main clock Input synchronization will halt when this clock stops
1736 SynchronizationNot applicable
1737 Configuration Change ProtectionNot applicable
ATtiny161416161617 AutomotiveIO Pin Configuration (PORT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 146
174 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 PIN0CTRL 70 INVEN PULLUPEN ISC[20]0x11 PIN1CTRL 70 INVEN PULLUPEN ISC[20]0x12 PIN2CTRL 70 INVEN PULLUPEN ISC[20]0x13 PIN3CTRL 70 INVEN PULLUPEN ISC[20]0x14 PIN4CTRL 70 INVEN PULLUPEN ISC[20]0x15 PIN5CTRL 70 INVEN PULLUPEN ISC[20]0x16 PIN6CTRL 70 INVEN PULLUPEN ISC[20]0x17 PIN7CTRL 70 INVEN PULLUPEN ISC[20]
175 Register Description - Ports
ATtiny161416161617 AutomotiveIO Pin Configuration (PORT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 147
1751 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 an output pinWriting a 0 to PORTDIR[n] configures pin n as an input pin It can be configured by writing to the ISC bitin PORTPINnCTRL
ATtiny161416161617 AutomotiveIO Pin Configuration (PORT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 148
1752 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] bitReading this bit field will always return the value of PORTDIR
ATtiny161416161617 AutomotiveIO Pin Configuration (PORT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 149
1753 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 PORTDIRReading this bit field will always return the value of PORTDIR
ATtiny161416161617 AutomotiveIO Pin Configuration (PORT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 150
1754 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 pinsWriting a 1 to DIRTGL[n] will toggle the corresponding bit in PORTDIRReading this bit field will always return the value of PORTDIR
ATtiny161416161617 AutomotiveIO Pin Configuration (PORT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 151
1755 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 highIf OUT[n] is written to 0 pin n is driven lowIn order to have any effect the pin direction must be configured as output
ATtiny161416161617 AutomotiveIO Pin Configuration (PORT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 152
1756 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 PORTOUTReading this bit field will always return the value of PORTOUT
ATtiny161416161617 AutomotiveIO Pin Configuration (PORT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 153
1757 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 OUTCLR[n] will clear the corresponding bit in PORTOUTReading this bit field will always return the value of PORTOUT
ATtiny161416161617 AutomotiveIO Pin Configuration (PORT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 154
1758 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 OUTTGL[n] will toggle the corresponding bit in PORTOUTReading this bit field will always return the value of PORTOUT
ATtiny161416161617 AutomotiveIO Pin Configuration (PORT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 155
1759 Input Value
Name INOffset 0x08Reset 0x00Property -
Bit 7 6 5 4 3 2 1 0 IN[70]
Access RW RW RW RW RW RW RW RW 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 aredisabledWriting to a bit of PORTIN will toggle the corresponding bit in PORTOUT
ATtiny161416161617 AutomotiveIO Pin Configuration (PORT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 156
17510 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 flagFor enabling and executing the interrupt refer to ISC bit description in PORTPINnCTRL
ATtiny161416161617 AutomotiveIO Pin Configuration (PORT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 157
17511 Pin n Control
Name PINCTRLOffset 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 EnableValue Description0 IO on pin n not inverted1 IO on pin n inverted
Bit 3 ndash PULLUPEN Pullup EnableValue Description0 Pullup disabled for pin n1 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 determines howa port interrupt can be triggered If the input buffer is disabled the input cannot be read in the IN registerValue Name Description0x0 INTDISABLE Interrupt disabled but input buffer enabled0x1 BOTHEDGES Sense both edges0x2 RISING Sense rising edge0x3 FALLING Sense falling edge0x4 INPUT_DISABLE Digital input buffer disabled0x5 LEVEL Sense low levelother - Reserved
ATtiny161416161617 AutomotiveIO Pin Configuration (PORT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 158
176 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]
177 Register Description - Virtual Ports
ATtiny161416161617 AutomotiveIO Pin Configuration (PORT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 159
1771 Data Direction
Name DIROffset 0x00Reset 0x00Property -
Writing to the Virtual PORT registers has the same effect as writing to the regular registers but allows formemory-specific instructions such as bit-manipulation instructions which are not valid for the extendedIO memory space where the regular PORT registers reside
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
ATtiny161416161617 AutomotiveIO Pin Configuration (PORT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 160
1772 Output Value
Name OUTOffset 0x01Reset 0x00Property -
Writing to the Virtual PORT registers has the same effect as writing to the regular registers but allows formemory-specific instructions such as bit-manipulation instructions which are not valid for the extendedIO memory space where the regular PORT registers reside
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
ATtiny161416161617 AutomotiveIO Pin Configuration (PORT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 161
1773 Input Value
Name INOffset 0x02Reset 0x00Property -
Writing to the Virtual PORT registers has the same effect as writing to the regular registers but allows formemory-specific instructions such as bit-manipulation instructions which are not valid for the extendedIO memory space where the regular PORT registers reside
Bit 7 6 5 4 3 2 1 0 IN[70]
Access RW RW RW RW RW RW RW RW 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 enabledWriting to a bit of VPORTIN will toggle the corresponding bit in VPORTOUT
ATtiny161416161617 AutomotiveIO Pin Configuration (PORT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 162
1774 Interrupt Flag
Name INTFLAGSOffset 0x03Reset 0x00Property -
Writing to the Virtual PORT registers has the same effect as writing to the regular registers but allows formemory-specific instructions such as bit-manipulation instructions which are not valid for the extendedIO memory space where the regular PORT registers reside
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 flagFor enabling and executing the interrupt refer to PORT_PINnCTRLISC
ATtiny161416161617 AutomotiveIO Pin Configuration (PORT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 163
18 Brown-Out Detector (BOD)
181 Featuresbull Brown-out Detection monitors the power supply to avoid operation below a programmable levelbull There are three modes
ndash Enabledndash Sampledndash Disabled
bull Separate selection of mode for Active and Sleep modesbull Voltage Level Monitor (VLM) with Interruptbull Programmable VLM Level Relative to the BOD Level
182 OverviewThe Brown-out Detector (BOD) monitors the power supply and compares the voltage with twoprogrammable brown-out threshold levels The brown-out threshold level defines when to generate aReset A Voltage Level Monitor (VLM) monitors the power supply and compares it to a threshold higherthan the BOD threshold The VLM can then generate an interrupt request as an early warning when thesupply voltage is about to drop below the VLM threshold The VLM threshold level is expressed as apercentage 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
When activated the BOD can operate in Enabled mode where the BOD is continuously active and inSampled mode where the BOD is activated briefly at a given period to check the supply voltage level
ATtiny161416161617 AutomotiveBrown-Out Detector (BOD)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 164
1821 Block DiagramFigure 18-1 BOD Block Diagram
+
-
+
-
Bandgap
Bandgap
BOD Level and
Calibration
VLM Interrupt Level
Brown-out Detection
VDD
VLM InterruptDetection
1822 System DependenciesIn order to use this peripheral other parts of the system must be configured correctly as described below
Table 18-1 BOD System Dependencies
Dependency Applicable Peripheral
Clocks Yes CLKCTRL
IO Lines and Connections No -
Interrupts Yes CPUINT
Events Yes EVSYS
Debug Yes UPDI
Related Links18221 Clocks18225 Debug Operation18223 Interrupts18224 Events
18221 ClocksThe BOD uses the 32 KHz oscillator (OSCULP32K) as clock source for CLK_BOD
ATtiny161416161617 AutomotiveBrown-Out Detector (BOD)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 165
18222 IO Lines and ConnectionsNot applicable
18223 InterruptsUsing the interrupts of this peripheral requires the interrupt controller to be configured first
Related Links14 CPU Interrupt Controller (CPUINT)973 SREG1832 Interrupts
18224 EventsNot applicable
18225 Debug OperationThis peripheral is unaffected by entering Debug mode
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
183 Functional Description
1831 InitializationThe BOD settings are loaded from fuses during Reset The BOD level and operating mode in Active andIdle Sleep mode are set by fuses and cannot be changed by the CPU The operating mode in Standbyand Power-Down Sleep mode is loaded from fuses and can be changed by software
The Voltage Level Monitor function can be enabled by writing a 1 to the VLM Interrupt Enable bit(VLMIE) in the Interrupt Control register (BODINTCTRL) The VLM interrupt is configured by writing theVLM Configuration bits (VLMCFG) in BODINTCTRL An interrupt is requested when the supply voltagecrosses the VLM threshold either from above from below or from any direction
The VLM functionality will follow the BOD mode If the BOD is turned OFF the VLM will not be enabledeven if the VLMIE is 1 If the BOD is using Sampled mode the VLM will also be sampled When enablingVLM interrupt the interrupt flag will always be set if VLMCFG equals 0x2 and may be set if VLMCFG isconfigured to 0x0 or 0x1
The VLM threshold is defined by writing the VLM Level bits (VLMLVL) in the Control A register(BODVLMCTRLA)
If the BODVLM is enabled in Sampled mode only VLMCFG=0x1 (crossing threshold from above) inBODINTCTRL will trigger an interrupt
1832 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
ATtiny161416161617 AutomotiveBrown-Out Detector (BOD)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 166
When an interrupt condition occurs the corresponding interrupt flag is set in the Interrupt Flags register ofthe peripheral (peripheralINTFLAGS)
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
Related Links9 AVR CPU973 SREG
1833 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 Active mode and Idle Sleep mode (ie ACTIVE in BODCTRLA) cannot bealtered by software The operating mode in Standby Sleep mode and Power-Down Sleep mode can bealtered by writing to the SLEEP 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
1834 SynchronizationNot applicable
1835 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
Attempting to write to a protected register without following the appropriate CCP unlock sequence leavesthe protected register unchanged
The following registers are under CCP
Table 18-3 Registers Under Configuration Change Protection
Register Key
SLEEP in BODCTRLA IOREG
Related Links9571 Sequence for Write Operation to Configuration Change Protected IO Registers
ATtiny161416161617 AutomotiveBrown-Out Detector (BOD)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 167
184 Register Summary - BOD
Offset Name Bit Pos
0x00 CTRLA 70 SAMPFREQ ACTIVE[10] SLEEP[10]0x01 CTRLB 70 LVL[20]0x02
0x07
Reserved
0x08 VLMCTRLA 70 VLMLVL[10]0x09 INTCTRL 70 VLMCFG[10] VLMIE0x0A INTFLAGS 70 VLMIF0x0B STATUS 70 VLMS
185 Register Description
ATtiny161416161617 AutomotiveBrown-Out Detector (BOD)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 168
1851 Control A
Name CTRLAOffset 0x00Reset Loaded from fuseProperty Configuration Change Protection
Bit 7 6 5 4 3 2 1 0 SAMPFREQ ACTIVE[10] SLEEP[10]
Access R R R RW RW Reset x x x x x
Bit 4 ndash SAMPFREQ Sample FrequencyThis bit selects the BOD sample frequencyThe Reset value is loaded from the SAMPFREQ bit in FUSEBODCFG This bit is under ConfigurationChange Protection (CCP)Value Description0x0 Sample frequency is 1 kHz0x1 Sample frequency is 125 Hz
Bits 32 ndash ACTIVE[10] ActiveThese bits select the BOD operation mode when the device is in Active or Idle modeThe Reset value is loaded from the ACTIVE bits in FUSEBODCFGValue Description0x0 Disabled0x1 Enabled0x2 Sampled0x3 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 modeThe Reset value is loaded from the SLEEP bits in FUSEBODCFGThese bits are under Configuration Change Protection (CCP)Value Description0x0 Disabled0x1 Enabled0x2 Sampled0x3 Reserved
ATtiny161416161617 AutomotiveBrown-Out Detector (BOD)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 169
1852 Control B
Name CTRLBOffset 0x01Reset Loaded from fuseProperty -
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 x x x
Bits 20 ndash LVL[20] BOD LevelThese bits select the BOD threshold levelThe Reset value is loaded from the BOD Level bits (LVL) in the BOD Configuration Fuse(FUSEBODCFG)Value Name Description0x2 BODLEVEL2 26V0x7 BODLEVEL7 42V
Note bull Values in the description are typical valuesbull Refer to the BOD and POR Characteristics in Electrical Characteristics for maximum and minimum
values
ATtiny161416161617 AutomotiveBrown-Out Detector (BOD)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 170
1853 VLM Control A
Name VLMCTRLAOffset 0x08Reset 0x00Property -
Bit 7 6 5 4 3 2 1 0 VLMLVL[10]
Access RW RW Reset 0 0
Bits 10 ndash VLMLVL[10] VLM LevelThese bits select the VLM threshold relative to the BOD threshold (LVL in BODCTRLB)Value Description0x0 VLM threshold 5 above BOD threshold0x1 VLM threshold 15 above BOD threshold0x2 VLM threshold 25 above BOD thresholdother Reserved
ATtiny161416161617 AutomotiveBrown-Out Detector (BOD)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 171
1854 Interrupt Control
Name INTCTRLOffset 0x09Reset 0x00Property -
Bit 7 6 5 4 3 2 1 0 VLMCFG[10] VLMIE
Access RW RW RW Reset 0 0 0
Bits 21 ndash VLMCFG[10] VLM ConfigurationThese bits select which incidents will trigger a VLM interruptValue Description0x0 Voltage crosses VLM threshold from above0x1 Voltage crosses VLM threshold from below0x2 Either direction is triggering an interrupt requestOther Reserved
Bit 0 ndash VLMIE VLM Interrupt EnableWriting a 1 to this bit enables the VLM interrupt
ATtiny161416161617 AutomotiveBrown-Out Detector (BOD)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 172
1855 VLM Interrupt Flags
Name INTFLAGSOffset 0x0AReset 0x00Property -
Bit 7 6 5 4 3 2 1 0 VLMIF
Access RW Reset 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 is only updated when the BOD is enabled
ATtiny161416161617 AutomotiveBrown-Out Detector (BOD)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 173
1856 VLM Status
Name STATUSOffset 0x0BReset 0x00Property -
Bit 7 6 5 4 3 2 1 0 VLMS
Access R Reset 0
Bit 0 ndash VLMS VLM StatusThis bit is only valid when the BOD is enabledValue Description0 The voltage is above the VLM threshold level1 The voltage is below the VLM threshold level
ATtiny161416161617 AutomotiveBrown-Out Detector (BOD)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 174
19 Voltage Reference (VREF)
191 Featuresbull Programmable Voltage Reference Sources
ndash One for each ADC peripheralndash One for each AC and DAC peripheral
bull Each Reference Source Supports Five Different Voltagesndash 055Vndash 11Vndash 15Vndash 25Vndash 43V
192 OverviewThe Voltage Reference (VREF) peripheral provides control registers for the voltage reference sourcesused by several peripherals The user can select the reference voltages for the ADC0 by writing to theADC0 Reference Select bit field (ADC0REFSEL) in the Control A register (VREFCTRLA) and for bothAC0 and DAC0 by writing to the DAC0 and AC0 Reference Select bit field DAC0REFSEL inVREFCTRLA
A voltage reference source is enabled automatically when requested by a peripheral The user canenable the reference voltage sources (and thus override the automatic disabling of unused sources) bywriting to the respective Force Enable bit (ADC0REFEN DAC0REFEN) in the Control B register(VREFCTRLB) This may be desirable to decrease start-up time at the cost of increased powerconsumption
1921 Block DiagramFigure 19-1 VREF Block Diagram
Reference se lect
Bandgap ReferenceGenerator
InternalReferenceBUF
11V15V25V43V
055V
Reference enable
Reference request
Bandgapenable
193 Functional Description
ATtiny161416161617 AutomotiveVoltage Reference (VREF)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 175
1931 InitializationThe default configuration will enable the respective source when the ADC0 AC0 or DAC0 is requesting areference voltage The default reference voltages are 055V but can be configured by writing to therespective Reference Select bit field (ADC0REFSEL DAC0REFSEL) in the Control A register(VREFCTRLA)
ATtiny161416161617 AutomotiveVoltage Reference (VREF)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 176
194 Register Summary - VREF
Offset Name Bit Pos
0x00 CTRLA 70 ADC0REFSEL[20] DAC0REFSEL[20]0x01 CTRLB 70 DAC2REFEN ADC1REFEN DAC1REFEN ADC0REFEN DAC0REFEN0x02 CTRLC 70 ADC1REFSEL[20] DAC1REFSEL[20]0x03 CTRLD 70 DAC2REFSEL[20]
195 Register Description
ATtiny161416161617 AutomotiveVoltage Reference (VREF)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 177
1951 Control A
Name CTRLAOffset 0x00Reset 0x00Property -
Bit 7 6 5 4 3 2 1 0 ADC0REFSEL[20] DAC0REFSEL[20]
Access RW RW RW RW RW RW Reset 0 0 0 0 0 0
Bits 64 ndash ADC0REFSEL[20] ADC0 Reference SelectThese bits select the reference voltage for the ADC0Value Description0x0 055V0x1 11V0x2 25V0x3 43V0x4 15Vother Reserved
Bits 20 ndash DAC0REFSEL[20] DAC0 and AC0 Reference SelectThese bits select the reference voltage for the DAC0 and AC0Value Description0x0 055V0x1 11V0x2 25V0x3 43V0x4 15Vother Reserved
ATtiny161416161617 AutomotiveVoltage Reference (VREF)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 178
1952 Control B
Name CTRLBOffset 0x01Reset 0x00Property -
Bit 7 6 5 4 3 2 1 0 DAC2REFEN ADC1REFEN DAC1REFEN ADC0REFEN DAC0REFEN
Access RW RW RW RW RW Reset 0 0 0 0 0
Bit 5 ndash DAC2REFEN DAC2 and AC2 Reference Force EnableWriting a 1 to this bit forces the voltage reference for the DAC2 and AC2 to be running even if it is notrequestedWriting a 0 to this bit allows to automatic enabledisable the reference source when not requested
Bit 4 ndash ADC1REFEN ADC1 Reference Force EnableWriting a 1 to this bit forces the voltage reference for the ADC1 to be running even if it is not requestedWriting a 0 to this bit allows to automatic enabledisable the reference source when not requestedNote Do not force the internal reference enabled (ADCnREFEN=1 in VREFCTRLB) when the ADC isusing the external reference (REFSEL bits in ADCCTRLC)
Bit 3 ndash DAC1REFEN DAC1 and AC1 Reference Force EnableWriting a 1 to this bit forces the voltage reference for the DAC1 and AC1 to be running even if it is notrequestedWriting a 0 to this bit allows to automatic enabledisable the reference source when not requested
Bit 1 ndash ADC0REFEN ADC0 Reference Force EnableWriting a 1 to this bit forces the voltage reference for the ADC0 to be running even if it is not requestedWriting a 0 to this bit allows automatic enabledisable of the reference source by the peripheralNote Do not force the internal reference enabled (ADCnREFEN=1 in VREFCTRLB) when the ADC isusing the external reference (REFSEL bits in ADCCTRLC)
Bit 0 ndash DAC0REFEN DAC0 and AC0 Reference Force EnableWriting a 1 to this bit forces the voltage reference for the DAC0 and AC0 to be running even if it is notrequestedWriting a 0 to this bit allows automatic enabledisable of the reference source by the peripheral
ATtiny161416161617 AutomotiveVoltage Reference (VREF)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 179
1953 Control C
Name CTRLCOffset 0x02Reset 0x00Property -
Bit 7 6 5 4 3 2 1 0 ADC1REFSEL[20] DAC1REFSEL[20]
Access RW RW RW RW RW RW Reset 0 0 0 0 0 0
Bits 64 ndash ADC1REFSEL[20] ADC1 Reference SelectThese bits select the reference voltage for the ADC1Value Description0x0 055V0x1 11V0x2 25V0x3 43V0x4 15Vother Reserved
Bits 20 ndash DAC1REFSEL[20] DAC1 and AC1 Reference SelectThese bits select reference voltage for the DAC1 and AC1Value Description0x0 055V0x1 11V0x2 25V0x3 43V0x4 15Vother Reserved
ATtiny161416161617 AutomotiveVoltage Reference (VREF)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 180
1954 Control D
Name CTRLDOffset 0x03Reset 0x00Property -
Bit 7 6 5 4 3 2 1 0 DAC2REFSEL[20]
Access RW RW RW Reset 0 0 0
Bits 20 ndash DAC2REFSEL[20] DAC2 and AC2 Reference SelectThese bits select reference voltage for the DAC2 and AC2Value Description0x0 055V0x1 11V0x2 25V0x3 43V0x4 15Vother Reserved
ATtiny161416161617 AutomotiveVoltage Reference (VREF)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 181
20 Watchdog Timer (WDT)
201 Featuresbull Issues a System Reset if the Watchdog Timer is not Cleared Before its Time-out Periodbull Operating Asynchronously from System Clock Using an Independent Oscillatorbull Using the 1 KHz Output of the 32 KHz Ultra Low-Power Oscillator (OSCULP32K)bull 11 Selectable Time-out Periods from 8 ms 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
202 OverviewThe Watchdog Timer (WDT) is a system function for monitoring correct program operation It allows thesystem to recover from situations such as runaway or deadlocked code by issuing a Reset Whenenabled the WDT is a constantly running timer configured to a predefined time-out period If the WDT isnot reset within the time-out period it will issue a system Reset The WDT is reset by executing the WDR(Watchdog Timer Reset) instruction from software
The WDT has two modes of operation Normal mode and Window mode The settings in the Control Aregister (WDTCTRLA) determine the mode of operation
A Window mode defines a time slot or window inside the time-out period during which the WDT must bereset If the WDT is reset outside this window either too early or too late a system Reset will be issuedCompared to the Normal mode the Window mode can catch situations where a code error causesconstant WDR execution
When enabled the WDT will run in Active mode and all Sleep modes It is asynchronous (ie runningfrom a 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 CCP mechanism ensures that the WDT settings cannot be changed by accident For increasedsafety a configuration for locking the WDT settings is available
Related Links957 Configuration Change Protection (CCP)
ATtiny161416161617 AutomotiveWatchdog Timer (WDT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 182
2021 Block DiagramFigure 20-1 WDT Block Diagram
COUNT
=
=
Inside closed window
Enable open window and clear count
CLK_WDT
WDR(instruction)
SystemReset
CTRLA
CTRLA
WINDOW
PERIOD
2022 Signal DescriptionNot applicable
2023 System DependenciesIn order to use this peripheral other parts of the system must be configured correctly as described below
Table 20-1 WDT System Dependencies
Dependency Applicable Peripheral
Clocks Yes CLKCTRL
IO Lines and Connections No -
Interrupts No -
Events No -
Debug Yes UPDI
Related Links20231 Clocks20235 Debug Operation
20231 ClocksA 1 KHz Oscillator Clock (CLK_WDT_OSC) is sourced from the internal Ultra Low-Power OscillatorOSCULP32K Due to the ultra low-power design the oscillator is not very accurate and so the exacttime-out period may vary from device to device This variation must be kept in mind when designingsoftware that uses 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 the WDT Control register will require synchronization between the clock domains
20232 IO Lines and ConnectionsNot applicable
ATtiny161416161617 AutomotiveWatchdog Timer (WDT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 183
20233 InterruptsNot applicable
20234 EventsNot applicable
20235 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 is operating in Window mode the first closed window time-out period will be disabled and a Normal mode time-out period is executed
Related Links20322 Window Mode
203 Functional Description
2031 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
The Reset value of WDTCTRLA is defined by a fuse (FUSEWDTCFG) so the WDT can be enabled atboot time If this is the case the LOCK bit in WDTSTATUS is set at boot time
Related Links204 Register Summary - WDT
2032 Operation
20321 Normal ModeIn Normal mode operation a single time-out period is set for the WDT If the WDT is not reset fromsoftware using the WDR any time before the time-out occurs the WDT will issue a system Reset
A new WDT time-out period will be started each time the WDT is reset by WDR
There are 11 possible WDT time-out periods (TOWDT) selectable from 8 ms to 8s by writing to the Periodbit field (PERIOD) in the Control A register (WDTCTRLA)
ATtiny161416161617 AutomotiveWatchdog Timer (WDT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 184
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 = 16 msHere
Normal mode is enabled as long as the WINDOW bit field in the Control A register (WDTCTRLA) is 0x0
Related Links204 Register Summary - WDT
20322 Window ModeIn Window mode operation the WDT uses two different time-out periods a closed Window Time-outperiod (TOWDTW) and the normal time-out period (TOWDT)
bull The closed window time-out period defines a duration from 8 ms to 8s where the WDT cannot bereset If the WDT is reset during this period the WDT will issue a system Reset
bull The normal WDT time-out period which is also 8 ms to 8s defines the duration of the open periodduring which the WDT can (and should) be reset The open period will always follow the closedperiod so the total duration of the time-out period is the sum of the closed window and the openwindow time-out periods
When enabling Window mode or when going out of Debug mode the first closed period is activated afterthe first WDR instruction
If a second WDR is issued while a previous WDR is being synchronized the second one will be ignored
Figure 20-3 Window Mode Operation
t [ms]
WDT Count
5 10 15 20 25 30 35
Timely WDT Reset (WDR)
Clo
sed
TOWDTW
Ope
n
TOWDT
System ResetWDR too early
TOWDTW =TOWDT = 8 msHere
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
ATtiny161416161617 AutomotiveWatchdog Timer (WDT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 185
20323 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 configuration is loaded from fuses LOCK is automatically set in WDTSTATUS
Related Links957 Configuration Change Protection (CCP)
2033 EventsNot applicable
2034 InterruptsNot applicable
2035 Sleep Mode OperationThe WDT will continue to operate in any sleep mode where the source clock is active
2036 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 writtenbull PERIOD bits in Control A register (WDTCTRLA)bull Window Period bits (WINDOW) in WDTCTRLA
The WDR instruction will need two to three cycles of the WDT clock in order to be synchronized Issuing anew WDR instruction while a WDR instruction is being synchronized will be ignored
2037 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
Attempting to write to a protected register without following the appropriate CCP unlock sequence leavesthe protected register unchanged
The following registers are under CCP
Table 20-2 WDT - Registers Under Configuration Change Protection
Register Key
WDTCTRLA IOREG
ATtiny161416161617 AutomotiveWatchdog Timer (WDT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 186
continuedRegister Key
LOCK bit in WDTSTATUS IOREG
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 Links957 Configuration Change Protection (CCP)9571 Sequence for Write Operation to Configuration Change Protected IO Registers971 CCP
ATtiny161416161617 AutomotiveWatchdog Timer (WDT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 187
204 Register Summary - WDT
Offset Name Bit Pos
0x00 CTRLA 70 WINDOW[30] PERIOD[30]0x01 STATUS 70 LOCK SYNCBUSY
205 Register Description
ATtiny161416161617 AutomotiveWatchdog Timer (WDT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 188
2051 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 x x x x x x x x
Bits 74 ndash WINDOW[30] WindowWriting a non-zero value to these bits enables the Window mode and selects the duration of the closedperiod accordinglyThe 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 0008s0x2 16CLK 0016s0x3 32CLK 0032s0x4 64CLK 0064s0x5 128CLK 0128s0x6 256CLK 0256s0x7 512CLK 0512s0x8 1KCLK 1024s0x9 2KCLK 2048s0xA 4KCLK 4096s0xB 8KCLK 8192sother - Reserved
Bits 30 ndash PERIOD[30] PeriodWriting a non-zero value to this bit enables the WDT and selects the time-out period in Normal modeaccordingly In Window mode these bits select the duration of the open windowThe 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)
Value Name Description0x0 OFF -0x1 8CLK 0008s0x2 16CLK 0016s0x3 32CLK 0032s0x4 64CLK 0064s0x5 128CLK 0128s
ATtiny161416161617 AutomotiveWatchdog Timer (WDT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 189
Value Name Description0x6 256CLK 0256s0x7 512CLK 0512s0x8 1KCLK 10s0x9 2KCLK 20s0xA 4KCLK 41s0xB 8KCLK 82sother - Reserved
ATtiny161416161617 AutomotiveWatchdog Timer (WDT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 190
2052 Status
Name STATUSOffset 0x01Reset 0x00Property Configuration Change Protection
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 registerIt is only possible to write this bit to 1 This bit can be cleared in Debug mode onlyIf the PERIOD bits in WDTCTRLA are different from zero after boot code the lock will automatically besetThis bit is under 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 domainThis bit is cleared by the system after the synchronization is finishedThis bit is not under CCPRelated Links2036 Synchronization2037 Configuration Change Protection
ATtiny161416161617 AutomotiveWatchdog Timer (WDT)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 191
21 16-bit TimerCounter Type A (TCA)
211 Featuresbull 16-Bit TimerCounterbull Three Compare Channelsbull Double Buffered Timer Period Settingbull Double Buffered Compare Channelsbull Waveform Generation
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
212 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
Depending on the mode of operation the counter is cleared reloaded incremented or decremented ateach timercounter clock or event input
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
By default the TCA is a 16-bit timercounter The timercounter has a Split mode feature that splits it intotwo 8-bit timercounters with three compare channels each In Split mode each compare channel onlysupports single-slope PWM waveform generation
A block diagram of the 16-bit timercounter with closely related peripheral modules (in grey) is shown inthe figure below
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 192
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
This device provides one instance of the TCA peripheral TCA0
2121 Block DiagramThe figure below shows a detailed block diagram of the timercounter
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 193
Figure 21-2 TimerCounter Block DiagramBase Counter
Compare(Unit x = ABC)
Counter
=
CMPn
CMPnBUF
WaveformGeneration
BV
=
PERB
PER
CNT
BV
= 0
countclear
directionload
Control Logic
EVCTRL
CTRLA
OVFUNF(INT Req)
TOP
match CMPn(INT Req)
Control Logic
Clock Select
ev
UPD
ATE
BOTTOM
WOn Out
EventSelect
The counter register (TCAnCNT) period registers with buffer (TCAnPER and TCAnPERBUF) andcompare registers with buffers (TCAnCMPx and TCAnCMPBUFx) are 16-bit registers All bufferregisters have a buffer valid (BV) flag that indicates when the buffer contains a new value
During normal operation the counter value is continuously compared to zero and the period (PER) valueto determine whether the counter has reached TOP or BOTTOM
The counter value is also compared to the TCAnCMPx 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
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 194
Figure 21-3 TimerCounter Clock Logic
CKSEL
CNTEI
CLK_PER
event
Event SystemPrescaler
CNT
(Encoding)EVACTCLK_TCA
2122 Signal Description
Signal Description(1) Type
WO[20] Digital output Waveform output
WO[53] Digital output Waveform output - Split mode only
Note 1 Refer to the IO Multiplexing and Considerations section to see the availability of WOn on pins
2123 System DependenciesIn order to use this peripheral other parts of the system must be configured correctly as described below
Table 21-1 TCA System Dependencies
Dependency Applicable Peripheral
Clocks Yes CLKCTRL
IO Lines and Connections Yes WO[50]
Interrupts Yes CPUINT
Events Yes EVSYS
Debug Yes UPDI
Related Links21231 Clocks21235 Debug Operation21233 Interrupts21234 Events
21231 ClocksThis peripheral uses the system clock CLK_PER and has its own prescaler
Related Links11 Clock Controller (CLKCTRL)
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 195
21232 IO Lines and ConnectionsUsing the IO lines of the peripheral requires configuration of the IO pins
Related Links5 IO Multiplexing and Considerations17 IO Pin Configuration (PORT)
21233 InterruptsUsing the interrupts of this peripheral requires the interrupt controller to be configured first
Related Links14 CPU Interrupt Controller (CPUINT)973 SREG2135 Interrupts
21234 EventsThe events of this peripheral are connected to the Event System
Related Links15 Event System (EVSYS)
21235 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 Links34 Unified Program and Debug Interface (UPDI)
213 Functional Description
2131 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
UPDATE The update condition is met when the timercounter reaches BOTTOM or TOP depending onthe Waveform Generator mode
CNT Counter register value
CMP Compare register value
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 196
In general the term timer is used when the timercounter is counting periodic clock ticks The termcounter is used when the input signal has sporadic or irregular ticks
2132 InitializationTo start using the timercounter in a basic mode follow these steps
bull Write a TOP value to the Period register (TCAnPER)bull Enable the peripheral by writing a 1 to the ENABLE bit in the Control A register (TCAnCTRLA)
The counter will start counting clock ticks according to the prescaler setting in the Clock Select bitfield (CLKSEL) in TCAnCTRLA
bull Optional By writing a 1 to the Enable Count on Event Input bit (CNTEI) in the Event Control register(TCAnEVCTRL) 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 (TCAnCNT)
2133 Operation
21331 Normal OperationIn normal operation the counter is counting clock ticks in the direction selected by the Direction bit (DIR)in the Control E register (TCAnCTRLE) 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 (TCAnCTRLA)
When up-counting and TOP are reached the counter will wrap to zero at the next clock tick When down-counting the counter is reloaded with the Period register value (TCAnPER) when BOTTOM is reached
Figure 21-4 Normal OperationCNT written
update
CNT
DIR
MAX
TOP
BOTTOM
It is possible to change the counter value in the Counter register (TCAnCNT) when the counter isrunning The write access to TCAnCNT has higher priority than count clear or reload and will beimmediate The direction of the counter can also be changed during normal operation by writing to DIR inTCAnCTRLE
21332 Double BufferingThe Period register value (TCAnPER) and the Compare n register values (TCAnCMPn) are all doublebuffered (TCAnPERBUF and TCAnCMPnBUF)
Each buffer register has a Buffer Valid flag (PERBV CMPnBV) in the Control F register (TCAnCTRLF)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 (CMPn) below
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 197
Figure 21-5 Period and Compare Double Buffering
UPDATE
write enable data write
CNT
match
EN
EN
CMPnBUF
CMPn
BV
=
Both the TCAnCMPn and TCAnCMPnBUF registers are available as IO registers This allowsinitialization and bypassing of the buffer register and the double buffering function
21333 Changing the PeriodThe Counter period is changed by writing a new TOP value to the Period register (TCAnPER)
No Buffering If double buffering is not used any period update is immediate
Figure 21-6 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 isdue to the fact that the TCAnCNT and TCAnPER registers are continuously compared if a new TOPvalue is written to TCAnPER that is lower than current TCAnCNT the counter will wrap first before acompare match happensFigure 21-7 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
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 198
With Buffering When double buffering is used the buffer can be written at any time and still maintaincorrect operation The TCAnPER 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-8 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
21334 Compare ChannelEach Compare Channel n continuously compares the counter value (TCAnCNT) with the Compare nregister (TCAnCMPn) If TCAnCNT equals TCAnCMPn the comparator n signals a match The matchwill set the Compare Channels interrupt flag at the next timer clock cycle and the optional interrupt isgenerated
The Compare n Buffer register (TCAnCMPnBUF) provides double buffer capability equivalent to that forthe period buffer The double buffering synchronizes the update of the TCAnCMPn register with thebuffer value to either the TOP or BOTTOM of the counting sequence according to the UPDATE conditionThe synchronization prevents the occurrence of odd-length non-symmetrical pulses for glitch-free output
213341 Waveform GenerationThe compare channels can be used for waveform generation on the corresponding port pins To makethe waveform visible on the connected port pin the following requirements must be met
1 A Waveform Generation mode must be selected by writing the WGMODE bit field in TCAnCTRLB2 The TCA is counting clock ticks not events (CNTEI=0 in TCAnEVCTRL)3 The compare channels used must be enabled (CMPnEN=1 in TCAnCTRLB) 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 an output (PORTxDIR[n]=1)5 Optional Enable inverted waveform output for the associated port pin n (INVEN=1 in PORTxPINn)
213342 Frequency (FRQ) Waveform GenerationFor frequency generation the period time (T) is controlled by a TCAnCMPn register instead of the Periodregister (TCAnPER) The waveform generation output WG is toggled on each compare match betweenthe TCAnCNT and TCAnCMPn registers
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 199
Figure 21-9 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 TCAnCTRLA) 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 TCAnCMPn is written to zero (0x0000) and no prescaling is used (N=1 CLKSEL=0x0 inTCAnCTRLA)
213343 Single-Slope PWM GenerationFor single-slope Pulse-Width Modulation (PWM) generation the period (T) is controlled by TCAnPERwhile the values of TCAnCMPn 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 (WO)output is set at TOP and cleared on the compare match between the TCAnCNT and TCAnCMPnregisters
Figure 21-10 Single-Slope Pulse-Width Modulation
CNT
Output WOn
MAXTOP
CMPn
BOTTOM
Period (T) CMPn=BOTTOM CMPn=TOP updatematch
The TCAnPER 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 and the TCA prescaler (CLKSEL in TCAnCTRLA) It is calculated bythe following equation where N represents the prescaler divider used
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 200
PWM_SS = CLK_PER PER+1213344 Dual-Slope PWM
For dual-slope PWM generation the period (T) is controlled by TCAnPER while the values ofTCAnCMPn control 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-11 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 (TCAnPER) defines the PWM resolution The minimum resolution is 2 bits(TCAnPER=0x0003) and the maximum resolution is 16 bits (TCAnPER=MAX)
The following equation calculates the exact resolution for dual-slope PWM (RPWM_DS)PWM_DS = log PER+1log 2The PWM frequency depends on the period setting (TCAnPER) the peripheral clock frequency(fCLK_PER) and the prescaler divider used (CLKSEL in TCAnCTRLA) It is calculated by the followingequationPWM_DS = CLK_PER2 sdot PERN represents the prescaler divider used
213345 Port Override for Waveform GenerationTo make the waveform generation available on the port pins the corresponding port pin direction must beset as output (PORTxDIR[n]=1) The TCA will override the port pin values when the compare channel isenabled (CMPnEN=1 in TCAnCTRLB) 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-12 Port Override for TimerCounter Type A
Waveform
OUT
CMPnEN INVEN
WOn
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 201
21335 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 (TCAnCTRLESET)
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(TCAnCTRLE)
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 TCAnCTRLA)
21336 Split Mode - Two 8-Bit TimerCounters
Split Mode OverviewTo double the number of timers and PWM channels in the TCA a Split mode is provided In this Splitmode the 16-bit timercounter acts as two separate 8-bit timers which each have three comparechannels for PWM generation The Split mode will only work with single-slope down-count Split modedoes not support event action controlled operation
Split Mode Differences to Normal Modebull Count
ndash Down-count onlyndash Timercounter Counter high byte and Counter low byte are independent (TCAnLCNT
TCAnHCNT)bull Waveform Generation
ndash Single-slope PWM only (WGMODE=SINGLESLOPE in TCAnCTRLB)bull Interrupt
ndash No change for low byte TimerCounter (TCAnLCNT)ndash Underflow interrupt for high byte TimerCounter (TCAnHCNT)ndash No compare interrupt or flag for High-byte Compare n registers (TCAnHCMPn)
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
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 202
Block DiagramFigure 21-13 TimerCounter Block Diagram Split Mode
Base Counter
Compare (Unit n = 012)
Counter
= 0
Control Logic
HUNF(INT Req)
BOTTOML
Compare (Unit n = 012)
Waveform Generation
LCMPn(INT Req)
WOn Out
= match
BOTTOMH
count low load low
=
Waveform Generation
match
WO[n+3] Out
= 0
count high load high
Clock Select
LUNF(INT Req)
HPER CTRLALPER
LCMPn
LCNTHCNT
HCMPn
Split Mode InitializationWhen shifting between Normal mode and Split mode the functionality of some registers and bitschanges but their values do not For this reason disabling the peripheral (ENABLE=0 in TCAnCTRLA)and doing a hard Reset (CMD=RESET in TCAnCTRLESET) is recommended when changing the modeto avoid 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
TCAnCTRLD)bull Write a TOP value to the Period registers (TCAnPER)bull Enable the peripheral by writing a 1 to the ENABLE bit in the Control A register (TCAnCTRLA)
The counter will start counting clock ticks according to the prescaler setting in the Clock Select bitfield (CLKSEL) in TCAnCTRLA
bull The counter values can be read from the Counter bit field in the Counter registers (TCAnCNT)
Activating Split mode results in changes to the functionality of some registers and register bits Themodifications are described in a separate register map
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 203
2134 EventsThe TCA is an event generator The following events will generate a one-cycle strobe on the eventchannel outputs
bull Timer overflowbull Timer underflow in Split modebull Compare match channel 0bull Compare match channel 1bull Compare match channel 2
The 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 counter counts prescaled clock cycles The event signal controls the direction of counting Up-
counting when the event signal is low and down-counting when the event signal is high
The specific action is selected by writing to the Event Action bits (EVACT) in the Event Control register(TCAnEVCTRL) Events as input are enabled by writing a 1 to the Enable Count on Event Input bit(CNTEI in TCAnEVCTRL)
Event-controlled inputs are not used in Split mode
2135 InterruptsTable 21-3 Available Interrupt Vectors and Sources in Normal Mode For Devices With More Than8 KB Flash
Offset Name Vector Description Conditions
0x00 OVF Overflow and compare matchinterrupt
The counter has reached its top value and wrapped tozero
0x08 CMP0 Compare channel 0 interrupt Match between the counter value and the Compare 0register
0x0A CMP1 Compare channel 1 interrupt Match between the counter value and the Compare 1register
0x0E CMP2 Compare channel 2 interrupt Match between the counter value and the Compare 2register
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
0x04 HUNF High byte underflow interrupt High byte timer reaches BOTTOM
0x08 LCMP0 Compare channel 0 interrupt Match between the counter value and the low byte ofCompare 0 register
0x0A LCMP1 Compare channel 1 interrupt Match between the counter value and the low byte ofCompare 1 register
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 204
continuedOffset Name Vector Description Conditions
0x0E LCMP2 Compare channel 2 interrupt Match between the counter value and the low byte of theCompare 2 register
When an interrupt condition occurs the corresponding interrupt flag is set in the Interrupt Flags register ofthe peripheral (peripheralINTFLAGS)
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
Related Links9 AVR CPU973 SREG
2136 Sleep Mode OperationThe timercounter will continue operation in Idle Sleep mode
2137 Configuration Change ProtectionNot applicable
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 205
214 Register Summary - TCA in Normal Mode (CTRLDSPLITM=0)
Offset Name Bit Pos
0x00 CTRLA 70 CLKSEL[20] ENABLE0x01 CTRLB 70 CMP2EN CMP1EN CMP0EN ALUPD WGMODE[20]0x02 CTRLC 70 CMP2OV CMP1OV CMP0OV0x03 CTRLD 70 SPLITM0x04 CTRLECLR 70 CMD[10] LUPD DIR0x05 CTRLESET 70 CMD[10] LUPD DIR0x06 CTRLFCLR 70 CMP2BV CMP1BV CMP0BV PERBV0x07 CTRLFSET 70 CMP2BV CMP1BV CMP0BV PERBV0x08 Reserved 0x09 EVCTRL 70 EVACT[10] CNTEI0x0A INTCTRL 70 CMP2 CMP1 CMP0 OVF0x0B INTFLAGS 70 CMP2 CMP1 CMP0 OVF0x0C
0x0D
Reserved
0x0E DBGCTRL 70 DBGRUN0x0F TEMP 70 TEMP[70]0x10
0x1F
Reserved
0x20 CNT70 CNT[70]158 CNT[158]
0x22
0x25Reserved
0x26 PER70 PER[70]158 PER[158]
0x28 CMP070 CMP[70]158 CMP[158]
0x2A CMP170 CMP[70]158 CMP[158]
0x2C CMP270 CMP[70]158 CMP[158]
0x2E
0x35Reserved
0x36 PERBUF70 PERBUF[70]158 PERBUF[158]
0x38 CMP0nBUF70 CMPBUF[70]158 CMPBUF[158]
0x3A CMP1nBUF70 CMPBUF[70]158 CMPBUF[158]
0x3C CMP2nBUF70 CMPBUF[70]158 CMPBUF[158]
215 Register Description - Normal Mode
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 206
2151 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 timercounterValue Name Description0x0 DIV1 fTCA = fCLK_PER10x1 DIV2 fTCA = fCLK_PER20x2 DIV4 fTCA = fCLK_PER40x3 DIV8 fTCA = fCLK_PER80x4 DIV16 fTCA = fCLK_PER160x5 DIV64 fTCA = fCLK_PER640x6 DIV256 fTCA = fCLK_PER2560x7 DIV1024 fTCA = fCLK_PER1024
Bit 0 ndash ENABLE EnableValue Description0 The peripheral is disabled1 The peripheral is enabled
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 207
2152 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
Bits 4 5 6 ndash CMPEN Compare n EnableIn the FRQ or PWM Waveform Generation mode these bits will override the PORT output register for thecorresponding pinValue Description0 Port output settings for the pin with WOn output respected1 Port output settings for pin with WOn output overridden in FRQ or PWM Waveform
Generation mode
Bit 3 ndash ALUPD Auto-Lock UpdateThe Auto-Lock Update feature controls the Lock Update (LUPD) bit in the TCAnCTRLE register WhenALUPD is written to lsquo1rsquo LUPD will be set to lsquo1rsquo until the Buffer Valid (CMPnBV) bits of all enabled comparechannels are lsquo1rsquo This condition will clear LUPDIt will remain cleared until the next UPDATE condition where the buffer values will be transferred to theCMPn registers and LUPD will be set to lsquo1rsquo again This makes sure that CMPnBUF register values are nottransferred to the CMPn registers until all enabled compare buffers are writtenValue Description0 LUPD in TCACTRLE not altered by system1 LUPD in TCACTRLE set and cleared automatically
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 generatedNo 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 outputTable 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
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 208
continuedWGMODE[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
Value Name Description0x0 NORMAL Normal operation mode0x1 FRQ Frequency mode0x3 SINGLESLOPE Single-slope PWM mode0x5 DSTOP Dual-slope PWM mode0x6 DSBOTH Dual-slope PWM mode0x7 DSBOTTOM Dual-slope PWM modeOther - Reserved
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 209
2153 Control C - Normal Mode
Name CTRLCOffset 0x02Reset 0x00Property -
Bit 7 6 5 4 3 2 1 0 CMP2OV CMP1OV CMP0OV
Access RW RW RW Reset 0 0 0
Bit 2 ndash CMP2OV Compare Output Value 2See CMP0OV
Bit 1 ndash CMP1OV Compare Output Value 1See CMP0OV
Bit 0 ndash CMP0OV Compare Output Value 0The CMPnOV 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
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 210
2154 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 Theregister map will change compared to normal 16-bit mode
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 211
2155 Control Register E Clear - Normal Mode
Name CTRLECLROffset 0x04Reset 0x00Property -
The individual Status bit can be cleared by writing a 1 to its bit location This allows each bit to becleared without the use of a read-modify-write operation on a single registerEach Status bit can be read out either by reading TCAnCTRLESET or TCAnCTRLECLR
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 are used for software control of update restart and reset of the timercounter The commandbits are always read as 0Value Name Description0x0 NONE No command0x1 UPDATE Force update0x2 RESTART Force restart0x3 RESET Force hard Reset (ignored if TC is enabled)
Bit 1 ndash LUPD Lock UpdateLock update can be used to ensure that all buffers are valid before an update is performedValue Description0 The buffered registers are updated as soon as an UPDATE condition has occurred1 No update of the buffered registers is performed even though an UPDATE condition has
occurred
Bit 0 ndash DIR Counter DirectionNormally this bit is controlled in hardware by the Waveform Generation mode or by event actions but thisbit can also be changed from softwareValue Description0 The counter is counting up (incrementing)1 The counter is counting down (decrementing)
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 212
2156 Control Register E Set - Normal Mode
Name CTRLESETOffset 0x05Reset 0x00Property -
The individual Status bit can be set by writing a 1 to its bit location This allows each bit to be set withoutthe use of a read-modify-write operation on a single registerEach Status bit can be read out either by reading TCAnCTRLESET or TCAnCTRLECLR
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 are used for software control of update restart and reset the timercounter The command bitsare always read as 0Value Name Description0x0 NONE No command0x1 UPDATE Force update0x2 RESTART Force restart0x3 RESET Force hard Reset (ignored if TC is enabled)
Bit 1 ndash LUPD Lock UpdateLocking the update ensures that all buffers are valid before an update is performedValue Description0 The buffered registers are updated as soon as an UPDATE condition has occurred1 No update of the buffered registers is performed even though an UPDATE condition has
occurred
Bit 0 ndash DIR Counter DirectionNormally this bit is controlled in hardware by the Waveform Generation mode or by event actions but thisbit can also be changed from softwareValue Description0 The counter is counting up (incrementing)1 The counter is counting down (decrementing)
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 213
2157 Control Register F Clear
Name CTRLFCLROffset 0x06Reset 0x00Property -
The individual Status bit can be cleared by writing a 1 to its bit location This allows each bit to becleared without the use of a read-modify-write operation on a single register
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 TCAnCMPnBUF registerThese bits 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 TCAnPERBUF register This bit is automatically clearedon an UPDATE condition
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 214
2158 Control Register F Set
Name CTRLFSETOffset 0x07Reset 0x00Property -
The individual status bit can be set by writing a 1 to its bit location This allows each bit to be set withoutthe use of a read-modify-write operation on a single register
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 TCAnCMPnBUF registerThese bits 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 TCAnPERBUF register This bit is automatically clearedon an UPDATE condition
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 215
2159 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 what type of event action the counter will increment or decrementValue Name Description0x0 EVACT_POSEDGE Count on positive edge event0x1 EVACT_ANYEDGE Count on any edge event0x2 EVACT_HIGHLVL Count on prescaled clock while event line is 10x3 EVACT_UPDOWN Count on prescaled clock The Event controls the count direction Up-
counting when the event line is 0 down-counting when the event line is1
Bit 0 ndash CNTEI Enable Count on Event InputValue Description0 Counting on Event input is disabled1 Counting on Event input is enabled according to EVACT bit field
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 216
21510 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 EnableSee CMP0
Bit 5 ndash CMP1 Compare Channel 1 Interrupt EnableSee CMP0
Bit 4 ndash CMP0 Compare Channel 0 Interrupt EnableWriting the CMPn bits to 1 enable compare interrupt from channel n
Bit 0 ndash OVF Timer OverflowUnderflow Interrupt EnableWriting the OVF bit to 1 enables overflow interrupt
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 217
21511 Interrupt Flag Register - Normal Mode
Name INTFLAGSOffset 0x0BReset 0x00Property -
The individual Status bit can be cleared by writing a 1 to its bit location This allows each bit to be setwithout the use of a read-modify-write operation on a single register
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 channelFor all modes of operation the CMPn flag will be set when a compare match occurs between the Countregister (TCAnCNT) and the corresponding Compare register (TCAnCMPn) The CMPn flag is notcleared automatically only by writing a lsquo1rsquo 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 The OVF flag is not cleared automatically only by writing a lsquo1rsquo to its bit location
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 218
21512 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 DebugValue Description0 The peripheral is halted in Break Debug mode and ignores events1 The peripheral will continue to run in Break Debug mode when the CPU is halted
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 219
21513 Temporary Bits for 16-Bit Access
Name TEMPOffset 0x0FReset 0x00Property -
The Temporary register is used by the CPU for single-cycle 16-bit access to the 16-bit registers of thisperipheral It can be read and written by software Refer to 16-bit access in the AVR CPU chapter Thereis one common Temporary register for all the 16-bit registers of this peripheral
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
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 220
21514 Counter Register - Normal Mode
Name CNTOffset 0x20Reset 0x00Property -
The TCAnCNTL and TCAnCNTH register pair represents the 16-bit value TCAnCNT The low byte [70](suffix L) is accessible at the original offset The high byte [158] (suffix H) can be accessed at offset+ 0x01
CPU and UPDI write access has priority over internal updates of the register
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
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 221
21515 Period Register - Normal Mode
Name PEROffset 0x26Reset 0xFFFFProperty -
TCAnPER contains the 16-bit TOP value in the timercounter
The TCAnPERL and TCAnPERH register pair represents the 16-bit value TCAnPER The low byte[70] (suffix L) is accessible at the original offset The high byte [158] (suffix H) can be accessed at offset+ 0x01
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
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 222
21516 Compare n Register - Normal Mode
Name CMPnOffset 0x28 + n0x02 [n=02]Reset 0x00Property -
This register is continuously compared to the counter value Normally the outputs from the comparatorsare then used for generating waveforms
TCAnCMPn registers are updated with the buffer value from their corresponding TCAnCMPnBUFregister when an UPDATE condition occurs
The TCAnCMPnL and TCAnCMPnH register pair represents the 16-bit value TCAnCMPn The lowbyte [70] (suffix L) is accessible at the original offset The high byte [158] (suffix H) can be accessed atoffset + 0x01
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
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 223
21517 Period Buffer Register
Name PERBUFOffset 0x36Reset 0xFFFFProperty -
This register serves as the buffer for the period register (TCAnPER) Accessing this register using theCPU or UPDI will affect the PERBV flag
The TCAnPERBUFL and TCAnPERBUFH register pair represents the 16-bit value TCAnPERBUF Thelow byte [70] (suffix L) is accessible at the original offset The high byte [158] (suffix H) can be accessedat offset + 0x01
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
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 224
21518 Compare n Buffer Register
Name CMPnBUFOffset 0x38 + n0x02 [n=02]Reset 0x00Property -
This register serves as the buffer for the associated compare registers (TCAnCMPn) Accessing any ofthese registers using the CPU or UPDI will affect the corresponding CMPnBV status bit
The TCAnCMPnBUFL and TCAnCMPnBUFH register pair represents the 16-bit value TCAnCMPnBUFThe low byte [70] (suffix L) is accessible at the original offset The high byte [158] (suffix H) can beaccessed at offset + 0x01
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
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 225
216 Register Summary - TCA in Split Mode (CTRLDSPLITM=1)
Offset Name Bit Pos
0x00 CTRLA 70 CLKSEL[20] ENABLE0x01 CTRLB 70 HCMP2EN HCMP1EN HCMP0EN LCMP2EN LCMP1EN LCMP0EN0x02 CTRLC 70 HCMP2OV HCMP1OV HCMP0OV LCMP2OV LCMP1OV LCMP0OV0x03 CTRLD 70 SPLITM0x04 CTRLECLR 70 CMD[10] CMDEN[10]0x05 CTRLESET 70 CMD[10] CMDEN[10]0x06
0x09
Reserved
0x0A INTCTRL 70 LCMP2 LCMP1 LCMP0 HUNF LUNF0x0B INTFLAGS 70 LCMP2 LCMP1 LCMP0 HUNF LUNF0x0C
0x0D
Reserved
0x0E DBGCTRL 70 DBGRUN0x0F
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]
217 Register Description - Split Mode
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 226
2171 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 timercounterValue Name Description0x0 DIV1 fTCA = fCLK_PER10x1 DIV2 fTCA = fCLK_PER20x2 DIV4 fTCA = fCLK_PER40x3 DIV8 fTCA = fCLK_PER80x4 DIV16 fTCA = fCLK_PER160x5 DIV64 fTCA = fCLK_PER640x6 DIV256 fTCA = fCLK_PER2560x7 DIV1024 fTCA = fCLK_PER1024
Bit 0 ndash ENABLE EnableValue Description0 The peripheral is disabled1 The peripheral is enabled
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 227
2172 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
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 228
2173 Control C - Split Mode
Name CTRLCOffset 0x02Reset 0x00Property -
Bit 7 6 5 4 3 2 1 0 HCMP2OV HCMP1OV HCMP0OV LCMP2OV LCMP1OV LCMP0OV
Access RW RW RW RW RW RW Reset 0 0 0 0 0 0
Bit 6 ndash HCMP2OV High byte Compare 2 Output ValueSee LCMP0OV
Bit 5 ndash HCMP1OV High byte Compare 1 Output ValueSee LCMP0OV
Bit 4 ndash HCMP0OV High byte Compare 0 Output ValueSee LCMP0OV
Bit 2 ndash LCMP2OV Low byte Compare 2 Output ValueSee LCMP0OV
Bit 1 ndash LCMP1OV Low byte Compare 1 Output ValueSee LCMP0OV
Bit 0 ndash LCMP0OV Low byte Compare 0 Output ValueThe LCMPnOVHCMPn bits allow direct access to the waveform generators output compare value whenthe timercounter is not enabled This is used to set or clear the WOn output value when the timercounteris not running
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 229
2174 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 Theregister map will change compared to normal 16-bit mode
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 230
2175 Control Register E Clear - Split Mode
Name CTRLECLROffset 0x04Reset 0x00Property -
The individual Status bit can be cleared by writing a 1 to its bit location This allows each bit to becleared without the use of a read-modify-write operation on a single register
Bit 7 6 5 4 3 2 1 0 CMD[10] CMDEN[10]
Access RW RW RW RW Reset 0 0 0 0
Bits 32 ndash CMD[10] CommandThese bits are used for software control of update restart and reset of the timercounter The commandbits are always read as 0Value Name Description0x0 NONE No command0x1 - Reserved0x2 RESTART Force restart0x3 RESET Force hard Reset (ignored if TC is enabled)
Bits 10 ndash CMDEN[10] Command enableThese bits are used to indicate for which timercounter the command (CMD) is validValue Name Description0x0 NONE None0x1 - Reserved0x2 - Reserved0x3 BOTH Command valid for both low-byte and high-byte TC
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 231
2176 Control Register E Set - Split Mode
Name CTRLESETOffset 0x05Reset 0x00Property -
The individual Status bit can be set by writing a 1 to its bit location This allows each bit to be set withoutthe use of a read-modify-write operation on a single register
Bit 7 6 5 4 3 2 1 0 CMD[10] CMDEN[10]
Access RW RW RW RW Reset 0 0 0 0
Bits 32 ndash CMD[10] CommandThese bits are used for software control of update restart and reset of the timercounter The commandbits are always read as 0 The CMD bits must be used together with CMDEN Using the reset commandrequires that both low-byte and high-byte timercounter is selectedValue Name Description0x0 NONE No command0x1 - Reserved0x2 RESTART Force restart0x3 RESET Force hard Reset (ignored if TC is enabled)
Bits 10 ndash CMDEN[10] Command enableThese bits are used to indicate for which timercounter the command (CMD) is validValue Name Description0x0 NONE None0x1 - Reserved0x2 - Reserved0x3 BOTH Command valid for both low-byte and high-byte TC
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 232
2177 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 EnableSee LCMP0
Bit 5 ndash LCMP1 Low byte Compare Channel 1 Interrupt EnableSee LCMP0
Bit 4 ndash LCMP0 Low byte Compare Channel 0 Interrupt EnableWriting LCMPn bit to 1 enables low byte compare interrupt from channel n
Bit 1 ndash HUNF High byte Underflow Interrupt EnableWriting HUNF bit to 1 enables high byte underflow interrupt
Bit 0 ndash LUNF Low byte Underflow Interrupt EnableWriting HUNF bit to 1 enables low byte underflow interrupt
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 233
2178 Interrupt Flag Register - Split Mode
Name INTFLAGSOffset 0x0BReset 0x00Property -
The individual Status bit can be cleared by writing a lsquo1rsquo to its bit location This allows each bit to be setwithout the use of a read-modify-write operation on a single register
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 channelFor all modes of operation the LCMPn flag will be set when a compare match occurs between the LowByte Count register (TCAnLCNT) and the corresponding compare register (TCAnLCMPn) The LCMPnflag will not be cleared automatically and has to be cleared by software This is done by writing a lsquo1rsquo to itsbit 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 lsquo1rsquo 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 lsquo1rsquo to its bit location
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 234
2179 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 DebugValue Description0 The peripheral is halted in Break Debug mode and ignores events1 The peripheral will continue to run in Break Debug mode when the CPU is halted
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 235
21710 Low Byte Timer Counter Register - Split Mode
Name LCNTOffset 0x20Reset 0x00Property -
TCAnLCNT contains the counter value in low byte timer CPU and UPDI write access has priority overcount clear or reload of the counter
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
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 236
21711 High Byte Timer Counter Register - Split Mode
Name HCNTOffset 0x21Reset 0x00Property -
TCAnHCNT contains the counter value in high byte timer CPU and UPDI write access has priority overcount clear or reload of the counter
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
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 237
21712 Low Byte Timer Period Register - Split Mode
Name LPEROffset 0x26Reset 0x00Property -
The TCAnLPER register contains the TOP value of low byte timer
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
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 238
21713 High Byte Period Register - Split Mode
Name HPEROffset 0x27Reset 0x00Property -
The TCAnHPER register contains the TOP value of high byte timer
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
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 239
21714 Compare Register n For Low Byte Timer - Split Mode
Name LCMPOffset 0x28 + n0x02 [n=02]Reset 0x00Property -
The TCAnLCMPn register represents the compare value of compare channel n for low byte timer Thisregister is continuously compared to the counter value of the low byte timer TCAnLCNT Normally theoutputs from the comparators are then used for generating waveforms
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 TCAnLCNT
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 240
21715 High Byte Compare Register n - Split Mode
Name HCMPOffset 0x29 + n0x02 [n=02]Reset 0x00Property -
The TCAnHCMPn register represents the compare value of compare channel n for high byte timer Thisregister is continuously compared to the counter value of the high byte timer TCAnHCNT Normally theoutputs from the comparators are then used for generating waveforms
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 TCAnHCNT
ATtiny161416161617 Automotive16-bit TimerCounter Type A (TCA)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 241
22 16-bit TimerCounter Type B (TCB)
221 Featuresbull 16-Bit Counter Operation Modes
ndash Periodic interruptndash Time-out checkndash Input capture
bull On eventbull Frequency measurementbull Pulse-width measurementbull Frequency and pulse-width measurement
ndash Single shotndash 8-bit Pulse-Width Modulation (PWM)
bull Noise Canceler on Event Inputbull Optional Operation Synchronous with TCA0
222 OverviewThe capabilities of the 16-bit TimerCounter type B (TCB) include frequency and waveform generationand input capture on event with time and frequency measurement of digital signals The TCB consists ofa base counter and control logic which can be set in one of eight different modes each mode providingunique functionality The base counter is clocked by the peripheral clock with optional prescaling
This device has two instances of the TCB peripheral TCB0 and TCB1
2221 Block DiagramFigure 22-1 TimerCounter Type B Block Diagram
ATtiny161416161617 Automotive16-bit TimerCounter Type B (TCB)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 242
Counter
=
CNT
= 0
countclear Control
EVCTRL
CTRLA
IF(INT Req)
TOP
ClockSelect
BOTTOM
Edge Select CTRLB Mode
CCMP
Output controland
logicAsynchronous
Synchronousoutput
Asynchronousoutput
Mode Output enable initial value
CLK_PER
LogicEvent System
TCB
DIV2
CLK_TCA
22211 Noise CancelerThe noise canceler improves noise immunity by using a simple digital filter scheme When the noise filteris enabled the peripheral monitors the event channel and keeps a record of the last four observedsamples If four consecutive samples are equal the input is considered to be stable and the signal is fedto the edge detector
When enabled the noise canceler introduces an additional delay of four system clock cycles between achange applied to the input and the update of the input compare register
The noise canceler uses the system clock and is therefore not affected by the prescaler
2222 Signal Description
Signal Description Type
WO Digital Asynchronous Output Waveform Output
Related Links5 IO Multiplexing and Considerations
2223 System DependenciesIn order to use this peripheral other parts of the system must be configured correctly as described below
Table 22-1 TCB System Dependencies
Dependency Applicable Peripheral
Clocks Yes CLKCTRL
IO Lines and Connections Yes WO
Interrupts Yes CPUINT
ATtiny161416161617 Automotive16-bit TimerCounter Type B (TCB)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 243
continuedDependency Applicable Peripheral
Events Yes EVSYS
Debug Yes UPDI
Related Links22231 Clocks22235 Debug Operation22233 Interrupts22234 Events
22231 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 Links11 Clock Controller (CLKCTRL)
22232 IO Lines and ConnectionsUsing the IO lines of the peripheral requires configuration of the IO pins
Related Links5 IO Multiplexing and Considerations17 IO Pin Configuration (PORT)
22233 InterruptsUsing the interrupts of this peripheral requires the interrupt controller to be configured first
Related Links14 CPU Interrupt Controller (CPUINT)973 SREG2235 Interrupts
22234 EventsThe events of this peripheral are connected to the Event System
Related Links15 Event System (EVSYS)
22235 Debug OperationWhen the CPU is halted in Debug mode this peripheral will halt normal operation This peripheral can beforced to continue operation during debugging
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 Links34 Unified Program and Debug Interface (UPDI)
ATtiny161416161617 Automotive16-bit TimerCounter Type B (TCB)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 244
223 Functional Description
2231 DefinitionsThe following definitions are used throughout the documentation
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
UPDATE The update condition is met when the timercounter reaches BOTTOM or TOP depending onthe Waveform Generator mode
CNT Counter register value
CCMP CaptureCompare register value
In general the term timer is used when the timercounter is counting periodic clock ticks The termcounter is used when the input signal has sporadic or irregular ticks
2232 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 (TCBnCCMP)bull Enable the counter by writing a 1 to the ENABLE bit in the Control A register (TCBnCTRLA)
The counter will start counting clock ticks according to the prescaler setting in the Clock Select bitfield (CLKSEL in TCBnCTRLA)
bull The counter value can be read from the Count register (TCBnCNT) The peripheral will generate aninterrupt when the CNT value reaches TOP
2233 Operation
22331 ModesThe timer can be configured to run in one of the eight different modes listed below The event pulseneeds to be longer than one system clock cycle in order to ensure edge detection
223311 Periodic Interrupt ModeIn the Periodic Interrupt mode the counter counts to the capture value and restarts from zero Aninterrupt is generated when the counter is equal to TOP If TOP is updated to a value lower than countthe counter will continue until MAX and wrap around without generating an interrupt
Figure 22-2 Periodic Interrupt Mode
ATtiny161416161617 Automotive16-bit TimerCounter Type B (TCB)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 245
BOTTOM
MAX
Interrupt
TOP
TOP changed to a value lower than CNT
CNT
Counter wraps around
223312 Time-Out Check ModeIn this mode the counter counts to MAX and wraps around On the first edge the counter is restarted andon the second edge the counter is stopped If the count register (TCBnCNT) reaches TOP before thesecond edge an interrupt will be generated In Freeze state the counter will restart on a new edgeReading count (TCBnCNT) or comparecapture (TCBnCCMP) register or writing run bit (RUN inTCBnSTATUS) in Freeze state will have no effectFigure 22-3 Time-Out Check Mode
CNT
BOTTOM
MAX
ldquo Interruptrdquo
TOP
TOP changed to a valuelower than CNT
Counter wrapsaround
Event Input
Edge detector
223313 Input Capture on Event ModeThe counter will count from BOTTOM to MAX continuously When an event is detected the counter valuewill be transferred to the CompareCapture register (TCBnCCMP) and interrupt is generated The modulehas an edge detector that can be configured to trigger count capture on either rising or falling edges
The figure below shows the input capture unit configured to capture on falling edge on the event inputsignal The interrupt flag is automatically cleared after the high byte of the Capture register has beenread
ATtiny161416161617 Automotive16-bit TimerCounter Type B (TCB)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 246
Figure 22-4 Input Capture on Event
CNT
MAX
BOTTOM
Interrupt
WraparoundCopy CNT to CCMP
and interruptCopy CNT to CCMP
and interrupt
Event Input
Edge detector
It is recommended to write 0 to the TCBnCNT register when entering this mode from any other mode
223314 Input Capture Frequency Measurement ModeIn this mode the TCB captures the counter value and restarts on either a positive or negative edge of theevent input signal
The interrupt flag is automatically cleared after the high byte of the CompareCapture register(TCBnCCMP) has been read and an interrupt request is generated
The figure below illustrates this mode when configured to act on rising edge
Figure 22-5 Input Capture Frequency Measurement
CNT
MAX
BOTTOM
Interrupt
Copy CNT to CCMPinterrupt and restart
Copy CNT to CCMPinterrupt and restart
Copy CNT to CCMPinterrupt and restart
Event Input
Edge detector
ATtiny161416161617 Automotive16-bit TimerCounter Type B (TCB)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 247
223315 Input Capture Pulse-Width Measurement ModeThe input capture pulse-width measurement will restart the counter on a positive edge and capture on thenext falling edge before an interrupt request is generated The interrupt flag is automatically cleared whenthe high byte of the capture register is read The timer will automatically switch between rising and fallingedge detection but a minimum edge separation of two clock cycles is required for correct behavior
Figure 22-6 Input Capture Pulse-Width Measurement
CNT
MAX
BOTTOM
Interrupt
Restartcounter
Copy CNT to CCMPand interrupt
Restartcounter
Copy CNT to CCMPand give interrupt
Restartcounter
Event Input
Edge detector
223316 Input Capture Frequency and Pulse-Width Measurement ModeIn this mode the timer will start counting when a positive edge is detected on the even input signal Onthe following falling edge the count value is captured The counter stops when the second rising edge ofthe event input signal is detected and this will set the interrupt flag
Reading the capture will clear the interrupt flag When the capture register is read or the interrupt flag iscleared the TC is ready for a new capture sequence Therefore read the counter register before thecapture register since it is reset to zero at the next positive edge
ATtiny161416161617 Automotive16-bit TimerCounter Type B (TCB)
copy 2019 Microchip Technology Inc Complete Datasheet DS40002021C-page 248