automotive attiny212/214/412/414 the attiny212/214/412/414 … · 2020. 5. 26. ·...
TRANSCRIPT
ATtiny212214412414Automotive
tinyAVRreg 1-series
IntroductionThe ATtiny212214412414 Automotive are members of the tinyAVRreg 1-series of microcontrollers using the AVRreg
processor with hardware multiplier running at up to 16 MHz with 24 KB Flash 128256 bytes of SRAM and 64128bytes of EEPROM in a 8- and 14-pin package The tinyAVRreg 1-series uses the latest technologies with a flexiblelow-power architecture including Event System accurate analog features and Core Independent Peripherals (CIPs)
Featuresbull CPU
ndash AVRreg CPUndash Running at up to 16 MHzndash Single-cycle IO accessndash Two-level interrupt controllerndash Two-cycle hardware multiplier
bull Memoriesndash 24 KB In-system self-programmable Flash memoryndash 64128 bytes EEPROMndash 128256 bytes 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
bull Idle with all peripherals running for immediate wake-upbull Standby
ndash Configurable operation of selected peripheralsbull Power-Down with full data retention
bull Peripheralsndash One 16-bit TimerCounter type A (TCA) with a dedicated period register and three compare channelsndash One 16-bit TimerCounter type B (TCB) with input capture
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 1
ndash 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 One Analog Comparator (AC) with a low propagation delayndash One 10-bit 115 ksps Analog-to-Digital Converter (ADC)ndash One 8-bit Digital-to-Analog Converter (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 External interrupt on all general purpose pins
bull IO and Packagesndash Up to 12 programmable IO linesndash 8-pin SOIC150ndash 14-pin SOIC150
bull Temperature Rangesndash -40degC to 105degCndash -40degC to 125degC
bull Speed Gradesndash 0-8 MHz 27V ndash 55Vndash 0-16 MHz 45V ndash 55V
ATtiny212214412414 Automotive
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 2
Table of Contents
Introduction1
Features 1
1 Silicon Errata and Data Sheet Clarification Document9
2 tinyAVRreg 1-series Overview10
21 Configuration Summary10
3 Block Diagram12
4 Pinout 13
41 8-Pin SOIC 1342 14-Pin SOIC 13
5 IO Multiplexing and Considerations 14
51 Multiplexed Signals 14
6 Automotive Quality Grade 15
7 Memories 16
71 Overview 1672 Memory Map 1773 In-System Reprogrammable Flash Program Memory1774 SRAM Data Memory 1875 EEPROM Data Memory 1876 User Row1877 Signature Bytes1878 IO Memory1979 Memory Section Access from CPU and UPDI on Locked Device21710 Configuration and User Fuses (FUSE)22
8 Peripherals and Architecture38
81 Peripheral Address Map3882 Interrupt Vector Mapping3983 System Configuration (SYSCFG)40
9 AVRreg CPU 43
91 Features 4392 Overview 4393 Architecture 4394 Arithmetic Logic Unit (ALU)4595 Functional Description4596 Register Summary5097 Register Description50
10 NVMCTRL - Nonvolatile Memory Controller 54
101 Features 54102 Overview 54
ATtiny212214412414 Automotive
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 3
103 Functional Description55104 Register Summary60105 Register Description60
11 CLKCTRL - Clock Controller 68
111 Features 68112 Overview 68113 Functional Description70114 Register Summary74115 Register Description74
12 SLPCTRL - Sleep Controller 84
121 Features 84122 Overview 84123 Functional Description84124 Register Summary87125 Register Description87
13 RSTCTRL - Reset Controller 89
131 Features 89132 Overview 89133 Functional Description90134 Register Summary94135 Register Description94
14 CPUINT - CPU Interrupt Controller 97
141 Features 97142 Overview 97143 Functional Description98144 Register Summary 103145 Register Description103
15 EVSYS - Event System108
151 Features 108152 Overview 108153 Functional Description 110154 Register Summary112155 Register Description 112
16 PORTMUX - Port Multiplexer 119
161 Overview119162 Register Summary120163 Register Description120
17 PORT - IO Pin Configuration124
171 Features 124172 Overview 124173 Functional Description126174 Register Summary - PORTx129
ATtiny212214412414 Automotive
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 4
175 Register Description - PORTx 129176 Register Summary - VPORTx 141177 Register Description - VPORTx141
18 BOD - Brown-out Detector 146
181 Features 146182 Overview 146183 Functional Description147184 Register Summary149185 Register Description149
19 VREF - Voltage Reference156
191 Features 156192 Overview 156193 Functional Description156194 Register Summary 157195 Register Description157
20 WDT - Watchdog Timer160
201 Features 160202 Overview 160203 Functional Description161204 Register Summary - WDT 164205 Register Description164
21 TCA - 16-bit TimerCounter Type A167
211 Features 167212 Overview 167213 Functional Description169214 Register Summary - Normal Mode179215 Register Description - Normal Mode 179216 Register Summary - Split Mode 198217 Register Description - Split Mode198
22 TCB - 16-bit TimerCounter Type B214
221 Features 214222 Overview 214223 Functional Description216224 Register Summary224225 Register Description224
23 TCD - 12-Bit TimerCounter Type D 235
231 Features 235232 Overview 235233 Functional Description237234 Register Summary260235 Register Description260
24 RTC - Real-Time Counter 285
ATtiny212214412414 Automotive
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 5
241 Features 285242 Overview 285243 Clocks286244 RTC Functional Description 286245 PIT Functional Description 287246 Events 288247 Interrupts 289248 Sleep Mode Operation 290249 Synchronization2902410 Debug Operation2902411 Register Summary2912412 Register Description291
25 USART - Universal Synchronous and Asynchronous Receiver and Transmitter307
251 Features 307252 Overview 307253 Functional Description308254 Register Summary323255 Register Description323
26 SPI - Serial Peripheral Interface339
261 Features 339262 Overview 339263 Functional Description340264 Register Summary347265 Register Description347
27 TWI - Two-Wire Interface 354
271 Features 354272 Overview 354273 Functional Description355274 Register Summary366275 Register Description366
28 CRCSCAN - Cyclic Redundancy Check Memory Scan 383
281 Features 383282 Overview 383283 Functional Description384284 Register Summary - CRCSCAN387285 Register Description387
29 CCL - Configurable Custom Logic 391
291 Features 391292 Overview 391293 Functional Description393294 Register Summary401295 Register Description401
30 AC - Analog Comparator408
ATtiny212214412414 Automotive
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 6
301 Features 408302 Overview 408303 Functional Description410304 Register Summary412305 Register Description412
31 ADC - Analog-to-Digital Converter 417
311 Features 417312 Overview 417313 Functional Description418314 Register Summary - ADCn425315 Register Description425
32 DAC - Digital-to-Analog Converter 443
321 Features 443322 Overview 443323 Functional Description444324 Register Summary446325 Register Description446
33 UPDI - Unified Program and Debug Interface449
331 Features 449332 Overview 449333 Functional Description451334 Register Summary472335 Register Description472
34 Instruction Set Summary483
35 Conventions 484
351 Numerical Notation484352 Memory Size and Type484353 Frequency and Time484354 Registers and Bits 485355 ADC Parameter Definitions 486
36 Electrical Characteristics489
361 Disclaimer489362 Absolute Maximum Ratings 489363 General Operating Ratings 490364 Power Consumption490365 Wake-Up Time491366 Peripherals Power Consumption492367 BOD and POR Characteristics493368 External Reset Characteristics494369 Oscillators and Clocks4943610 IO Pin Characteristics 4953611 USART 4963612 SPI 497
ATtiny212214412414 Automotive
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 7
3613 TWI4983614 VREF5013615 ADC5023616 DAC5043617 AC 5053618 UPDI Timing5063619 Programming Time507
37 Typical Characteristics 508
371 Power Consumption508372 GPIO 515373 VREF Characteristics521374 BOD Characteristics523375 ADC Characteristics526376 AC Characteristics531377 OSC20M Characteristics535378 OSCULP32K Characteristics 537379 TWI SDA Hold Timing 538
38 Ordering Information 539
381 Product Information539382 Product Identification System539
39 Package Drawings 540
391 Online Package Drawings540392 8-Pin SOIC 541393 14-Pin SOIC 544394 Thermal Considerations 547
40 Errata 548
401 Errata - ATtiny212214412414 Automotive 548
41 Data Sheet Revision History 549
411 Rev A - 052020549
The Microchip Website550
Product Change Notification Service550
Customer Support 550
Product Identification System551
Microchip Devices Code Protection Feature 551
Legal Notice 551
Trademarks 551
Quality Management System 552
Worldwide Sales and Service553
ATtiny212214412414 Automotive
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 8
1 Silicon Errata and Data Sheet Clarification DocumentMicrochip aims to provide its customers with the best documentation possible to ensure a successful use ofMicrochip products Between data sheet updates a Silicon errata and data sheet clarification document will containthe most recent information for the data sheet The ATtiny212214412414 Automotive Silicon Errata and Data SheetClarification (wwwmicrochipcomDS80000893) is available at the device product page on wwwmicrochipcom
ATtiny212214412414 AutomotiveSilicon Errata and Data Sheet Clarification
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 9
2 tinyAVRreg 1-series OverviewThe following figure shows the tinyAVR 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-compatible andprovide the same or more features Downward migration may require code modification due to fewer availableinstances 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
8 Pins
20 24 14
8 KB
Flash
16 KB
32 KB
4 KB
2 KB
Devices described in this data sheet
Devices described in other data sheets
ATtiny3216 ATtiny3217
ATtiny1614 ATtiny1616 ATtiny1617
ATtiny412
ATtiny212
ATtiny414 ATtiny416 ATtiny417
ATtiny214
ATtiny814 ATtiny816 ATtiny817
Devices with different Flash memory sizes typically also have different SRAM and EEPROM
21 Configuration Summary
211 Peripheral SummaryTable 2-1 Peripheral Summary
ATtin
y212
ATtin
y214
ATtin
y412
ATtin
y414
Pins 8 14 8 14
SRAM 128B 128B 256B 256B
Flash 2 KB 2 KB 4 KB 4 KB
EEPROM 64B 64B 128B 128B
Max frequency (MHz) 16 16 16 16
16-bit TimerCounter type A (TCA) 1 1 1 1
16-bit TimerCounter type B (TCB) 1 1 1 1
12-bit TimerCounter type D (TCD) 1 1 1 1
ATtiny212214412414 AutomotivetinyAVRreg 1-series Overview
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 10
continued
ATtin
y212
ATtin
y214
ATtin
y412
ATtin
y414
Real-Time Counter (RTC) 1 1 1 1
USART 1 1 1 1
SPI 1 1 1 1
TWI (I2C) 1 1 1 1
ADC 1 1 1 1
ADC channels 6 10 6 10
DAC 1 1 1 1
AC 1 1 1 1
AC inputs 1p1n 1p1n 1p1n 1p1n
Peripheral Touch Controller (PTC) No No No No
Configurable Custom Logic 1 1 1 1
Window Watchdog 1 1 1 1
Event System channels 6 6 6 6
General purpose IO 6 12 6 12
External interrupts 6 12 6 12
CRCSCAN 1 1 1 1
ATtiny212214412414 AutomotivetinyAVRreg 1-series Overview
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 11
3 Block DiagramFigure 3-1 tinyAVRreg 1-series Block Diagram
INOUT
DATABUS
Clock Generation
BUS Matrix
CPU
USART0
SPI0
CCL
AC[20]
ADC0 PTC
TCA0
TCB[10]
AINP[30]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
LUTn-IN[20]LUTn-OUT
WO CLKOUT
PA[70]PB[70]PC[50]
GPIOR
TWI0SDASCL
TCD0WO[ABCD]
XOSC32K
TOSC2
TOSC1
To detectors
UPDI RESET
EVSYS EVOUT[n0]
DACOUT [20]
ADC1
VLMBOD
EXTCLK
AIN[110]X[130]Y[130]
VREFA
AIN[110]
analog peripherals
analog peripherals
Analog peripherals
Digital peripherals
analog peripheralsCore components
Clocksgenerators
reg
Note The block diagram represents the largest device of the tinyAVR 1-series both in terms of pin count and Flashsize See sections 21 Configuration Summary and 51 Multiplexed Signals for an overview of the features of thespecific devices in this data sheet
ATtiny212214412414 AutomotiveBlock Diagram
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 12
4 Pinout
41 8-Pin SOIC
VDD GND
PA2
PA6
PA7
PA1
1
23
4 5
67
8
GPIO VDD power domain
Clock crystal
Programming Debug ResetInput supply
Ground
Analog function
Digital function only
PA3EXTCLK
PA0RESETUPDI
42 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
ATtiny212214412414 AutomotivePinout
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 13
5 IO Multiplexing and Considerations
51 Multiplexed SignalsTable 5-1 PORT Function Multiplexing 14 Pins
SOIC
14-
Pin Pin Name (12) OtherSpecial ADC0 AC0 DAC0 USART0 SPI0 TWI0 TCA0 TCB0 TCD0 CCL
10 PA0 RESET UPDI AIN0 LUT0-IN0
11 PA1 AIN1 TxD(3) MOSI SDA(3) LUT0-IN1
12 PA2 EVOUT0 AIN2 RxD(3) MISO SCL(3) LUT0-IN2
13 PA3 EXTCLK AIN3 XCK(3) SCK WO3
14 GND
1 VDD2 PA4 AIN4 XDIR(3) SS WO4 WOA LUT0-OUT
3 PA5 AIN5 OUT WO5 WO WOB
4 PA6 AIN6 AINN0 OUT MOSI(3)
5 PA7 AIN7 AINP0 MISO(3) LUT1-OUT
6 PB3 TOSC1 RxD WO0(3)
7 PB2 TOSC2 EVOUT1 TxD WO2
8 PB1 AIN10 XCK SDA WO1
9 PB0 AIN11 XDIR SCL WO0
Notes 1 Pin names are of type Pxn with x being the PORT instance (A B) and n the pin number The 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 section 16 PORTMUX - Port Multiplexer
Table 5-2 PORT Function Multiplexing Eight PinsSOIC 8-Pin Pin Name
(12)OtherSpecial
ADC0 AC0 DAC0 USART0 SPI0 TWI0 TCA0 TCB0 TCD0 CCL
6 PA0 RESETUPDI AIN0 XDIR SS LUT0-IN0
4 PA1 AIN1 TxD(3) MOSI SDA WO1 LUT0-IN1
5 PA2 EVOUT0 AIN2 RxD(3) MISO SCL WO2 LUT0-IN2
7 PA3 EXTCLK AIN3 OUT XCK SCK WO0WO3
8 GND
1 VDD
2 PA6 AIN6 AINN0 OUT TxD MOSI(3) WO0 WOA LUT0-OUT
3 PA7 AIN7 AINP0 RxD MISO(3) WO0(3) WOB LUT1-OUT
Notes 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 inputs2 All pins can be used for external interrupts where pins Px2 and Px6 of each port have full asynchronous
detection3 Alternate pin positions For selecting the alternate positions refer to section 16 PORTMUX - Port Multiplexer
ATtiny212214412414 AutomotiveIO Multiplexing and Considerations
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 14
6 Automotive Quality GradeThe devices have been manufactured according to the most stringent requirements of the international standardISOTS 16949 This data sheet contains limit values extracted from the results of extensive characterization(temperature and voltage)
The quality and reliability have been verified during regular product qualification as per AEC-Q100 grade 1 (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
ATtiny212214412414 AutomotiveAutomotive Quality Grade
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 15
7 Memories
71 OverviewThe main memories are SRAM data memory EEPROM data memory and Flash program memory Also theperipheral registers are located in the IO memory space
Table 7-1 Physical Properties of Flash Memory
Property ATtiny212 ATtiny214 ATtiny412 ATtiny414
Size 2 KB 2 KB 4 KB 4 KB
Page size 64B 64B 64B 64B
Number of pages 32 32 64 64
Start address 0x8000 0x8000 0x8000 0x8000
Table 7-2 Physical Properties of SRAM
Property ATtiny212 ATtiny214 ATtiny412 ATtiny414
Size 128B 128B 256B 256B
Start address 0x3F80 0x3F80 0x3F00 0x3F00
Table 7-3 Physical Properties of EEPROM
Property ATtiny212 ATtiny214 ATtiny412 ATtiny414
Size 64B 64B 128B 128B
Page size 32B 32B 32B 32B
Number of pages 2 2 4 4
Start address 0x1400 0x1400 0x1400 0x1400
ATtiny212214412414 AutomotiveMemories
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 16
72 Memory MapFigure 7-1 Memory Map
(Reserved)
(Reserved)
NVM IO Registers and Data
64 IO Registers
960 Ext IO Registers
0x0000 ndash 0x003F
0x0040 ndash 0x0FFF
0x1400 0x1440 (For EEPROM 64B)0x1480 (For EEPROM 128B)
EEPROM 64128B
Flash Code
0x1000 ndash 0x13FF
Internal SRAM128256B
0x3F800x3F00
24 KB
0x87FF (For Flash 2K)0x8FFF (For Flash 4K)
0x8000
0x3FFF
Flash Code24 KB
0x0000
CPU Code space PDICPU Data space
73 In-System Reprogrammable Flash Program MemoryThe ATtiny212214412414 Automotive contains 24 KB on-chip in-system reprogrammable Flash memory forprogram storage Since all AVR instructions are 16 or 32-bit wide the Flash is organized as 4K x 16 For writeprotection the Flash program memory space can be divided into three sections (see the illustration below)Bootloader section Application code section and Application data section with restricted access rights among them
ATtiny212214412414 AutomotiveMemories
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 17
The Program Counter (PC) is 11-bit wide to address the whole program memory The procedure for writing Flashmemory 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 LDST instructions as well asthe LPM instruction For LDST instructions the Flash is mapped from address 0x8000 For the LPM instruction theFlash start address is 0x0000
The ATtiny212214412414 Automotive also has a CRC peripheral that is a master on the bus
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
FLASHEND
74 SRAM Data MemoryThe 128256 bytes SRAM is used for data storage and stack
75 EEPROM Data MemoryThe ATtiny212214412414 Automotive has 64128 bytes of EEPROM data memory see section 72 Memory MapThe EEPROM memory supports single-byte read and write The EEPROM is controlled by the Nonvolatile MemoryController (NVMCTRL)
76 User RowIn addition to the EEPROM the ATtiny212214412414 Automotive has one extra page of EEPROM memory thatcan be used for firmware settings the User Row (USERROW) This memory supports single-byte read and write asthe normal EEPROM The CPU can write and read this memory as normal EEPROM and the UPDI can write andread it as a normal EEPROM memory if the part is unlocked The User Row can be written by the UPDI when thepart is locked USERROW is not affected by a chip erase
77 Signature BytesAll tinyAVRreg microcontrollers have a 3-byte signature code that identifies the device The three bytes reside in aseparate 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 accessed
ATtiny212214412414 AutomotiveMemories
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 18
Table 7-4 Device ID
Device Name Signature Bytes Address
0x00 0x01 0x02
ATtiny212 0x1E 0x91 0x21
ATtiny214 0x1E 0x91 0x20
ATtiny412 0x1E 0x92 0x23
ATtiny414 0x1E 0x92 0x22
78 IO MemoryAll ATtiny212214412414 Automotive IOs and peripherals are located in the IO memory space The IO addressrange from 0x00 to 0x3F can be accessed in a single cycle using IN and OUT instructions The extended IO memoryspace from 0x0040 to 0x0FFF can be accessed by the LDLDSLDD and STSTSSTD instructions transferring databetween the 32 general purpose working registers and the IO memory space
IO registers within the address range 0x00-0x1F are directly bit-accessible using the SBI and CBI instructions Inthese registers the value of single bits can be checked by using the SBIS and SBIC instructions Refer to theInstruction Set section for more details
For compatibility with future devices reserved bits must be written to lsquo0rsquo if accessed Reserved IO memoryaddresses must never be written
Some of the interrupt flags are cleared by writing a lsquo1rsquo to them On ATtiny212214412414 Automotive devices theCBI and SBI instructions will only operate on the specified bit and can be used on registers containing such interruptflags The CBI and SBI instructions work with registers 0x00-0x1F only
General Purpose IO RegistersThe ATtiny212214412414 Automotive devices provide four general purpose IO registers These registers can beused for storing any information and they are particularly useful for storing global variables and interrupt flagsGeneral purpose IO registers which reside in the address range 0x1C-0x1F are directly bit-accessible using theSBI CBI SBIS and SBIC instructions
ATtiny212214412414 AutomotiveMemories
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 19
781 Register Summary
Offset Name Bit Pos 7 6 5 4 3 2 1 0
0x00 GPIOR0 70 GPIOR[70]0x01 GPIOR1 70 GPIOR[70]0x02 GPIOR2 70 GPIOR[70]0x03 GPIOR3 70 GPIOR[70]
782 Register Description
ATtiny212214412414 AutomotiveMemories
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 20
7821 General Purpose IO Register n
Name GPIORnOffset 0x00 + n0x01 [n=03]Reset 0x00Property -
These are general purpose registers that can be used to store data such as global variables and flags in the bit-accessible IO memory space
Bit 7 6 5 4 3 2 1 0 GPIOR[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 70 ndash GPIOR[70] General Purpose IO Register Byte
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 both the Flash(all Boot Application Code and Application Date sections) SRAM and the EEPROM including the FUSE data Thisprevents successful reading of application data or code using the debugger interface Regular memory access fromwithin the application is still enabled
The device is locked by writing a non-valid key to the LOCKBIT bit field in FUSELOCKBIT
Table 7-5 Memory Access Unlocked (FUSELOCKBIT Valid Key)(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 Locked (FUSELOCKBIT Invalid Key)(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 Yes No No
USERROW Yes Yes No Yes(2)
SIGROW Yes No No No
Other fuses Yes No No No
ATtiny212214412414 AutomotiveMemories
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 21
Notes 1 Read operations marked No in the tables may appear to be successful but the data are not valid Hence any
attempt of code validation through the UPDI will fail on these memory sections2 In the Locked mode the USERROW can be written using the Fuse Write command but the current
USERROW values cannot be read out
Important The only way to unlock a device is through a CHIPERASE No application data are retained
710 Configuration and User Fuses (FUSE)Fuses are part of the nonvolatile memory and hold the device configuration The fuses are available from the devicepower-up The fuses can be read by the CPU or the UPDI but can only be programmed or cleared by the UPDI Theconfiguration values stored in the fuses are written to their respective target registers at the end of the start-upsequence
The fuses for peripheral configuration (FUSE) are pre-programmed but can be altered by the user Altered values inthe configuration fuse will be effective only after a ResetNote When writing the fuses all reserved bits must be written to lsquo1rsquo
ATtiny212214412414 AutomotiveMemories
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 22
7101 Signature Row Summary
Offset Name Bit Pos 7 6 5 4 3 2 1 0
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
ATtiny212214412414 AutomotiveMemories
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 23
71021 Device ID n
Name DEVICEIDnOffset 0x00 + n0x01 [n=02]Default [Device ID]Property -
Each device has a device ID identifying this device and its properties such as memory sizes pin count and dierevision This can be used to identify a device and hence the available features by software The Device ID consistsof three bytes SIGROWDEVICEID[20]
Bit 7 6 5 4 3 2 1 0 DEVICEID[70]
Access R R R R R R R R Default x x x x x x x x
Bits 70 ndash DEVICEID[70] Byte n of the Device ID
ATtiny212214412414 AutomotiveMemories
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 24
71022 Serial Number Byte n
Name SERNUMnOffset 0x03 + n0x01 [n=09]Default [device serial number]Property -
Each device has an individual serial number representing a unique ID This can be used to identify a specific devicein 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 Default x x x x x x x x
Bits 70 ndash SERNUM[70] Serial Number Byte n
ATtiny212214412414 AutomotiveMemories
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 25
71023 OSC16 Error at 3V
Name OSC16ERR3VOffset 0x22Default [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 Default 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 relative to the nominal oscillator frequency whenrunning at an internal 16 MHz at 3V as measured during production
ATtiny212214412414 AutomotiveMemories
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 26
71024 OSC16 Error at 5V
Name OSC16ERR5VOffset 0x23Default [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 Default 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 relative to the nominal oscillator frequency whenrunning at an internal 16 MHz at 5V as measured during production
ATtiny212214412414 AutomotiveMemories
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 27
7103 Fuse Summary - FUSE
Offset Name Bit Pos 7 6 5 4 3 2 1 0
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] RSTPINCFG[10] 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
ATtiny212214412414 AutomotiveMemories
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 28
71041 Watchdog Configuration
Name WDTCFGOffset 0x00Default 0x00Property -
The default value given in this fuse description is the factory-programmed value and should not be mistaken for theReset value
Bit 7 6 5 4 3 2 1 0 WINDOW[30] PERIOD[30]
Access R R R R R R R R Default 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 (WDTCTRLA) register during Reset
Bits 30 ndash PERIOD[30] Watchdog Time-Out PeriodThis value is loaded into the PERIOD bit field of the Watchdog Control A (WDTCTRLA) register during Reset
ATtiny212214412414 AutomotiveMemories
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 29
71042 BOD Configuration
Name BODCFGOffset 0x01Default 0x00Property -
The default value given in this fuse description is the factory-programmed value and should not be mistaken for theReset value
The bit values of this fuse register are written to the corresponding BOD configuration registers at start-up
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 Default 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 (BODCTRLB) register during ResetValue Name Description0x2 BODLEVEL2 26V0x7 BODLEVEL7 42V
Notes bull The values in the description are typicalbull 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 (BODCTRLA) register 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 (BODCTRLA) register 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 (BODCTRLA) register during ResetValue Description0x0 Disabled0x1 Enabled0x2 Sampled0x3 Reserved
ATtiny212214412414 AutomotiveMemories
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 30
71043 Oscillator Configuration
Name OSCCFGOffset 0x02Default 0x01Property -
The default value given in this fuse description is the factory-programmed value and should not be mistaken for theReset value
Bit 7 6 5 4 3 2 1 0 OSCLOCK FREQSEL[10]
Access R R R Default 0 0 1
Bit 7 ndash OSCLOCK Oscillator LockThis fuse bit is loaded to LOCK in CLKCTRLOSC20MCALIBB during ResetValue Description0 Calibration registers of the OSC20M oscillator are accessible1 Calibration registers of the OSC20M oscillator are locked
Bits 10 ndash FREQSEL[10] Frequency SelectThis bit field selects the operation frequency of the 16 MHz internal oscillator (OSC20M) and determines therespective factory calibration values to be written to CAL20M in CLKCTRLOSC20MCALIBA and TEMPCAL20M inCLKCTRLOSC20MCALIBBValue Description0x1 Run at 16 MHz with corresponding factory calibrationOther Reserved
ATtiny212214412414 AutomotiveMemories
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 31
71044 Timer Counter Type D Configuration
Name TCD0CFGOffset 0x04Default 0x00Property -
The default value given in this fuse description is the factory-programmed value and should not be mistaken for theReset value
The bit values of this fuse register are written to the corresponding bits in the TCDFAULTCTRL register of TCD0 atstart-up
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 Default 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 lsquo0rsquo1 Compare x default state is lsquo1rsquo
ATtiny212214412414 AutomotiveMemories
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 32
71045 System Configuration 0
Name SYSCFG0Offset 0x05Default 0xF6Property -
The default value given in this fuse description is the factory-programmed value and should not be mistaken for theReset value
Bit 7 6 5 4 3 2 1 0 CRCSRC[10] RSTPINCFG[10] EESAVE
Access R R R R R Default 1 1 0 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
Bits 32 ndash RSTPINCFG[10] Reset Pin ConfigurationThis bit field selects 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 actively driving theoutput and a high-voltage UPDI enable sequence initiation To avoid this the GPIO output driver is disabled for 768OSC32K cycles after a System Reset Enable any interrupts for this pin only after this period
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
ATtiny212214412414 AutomotiveMemories
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 33
71046 System Configuration 1
Name SYSCFG1Offset 0x06Default 0x07Property -
The default value given in this fuse description is the factory-programmed value and should not be mistaken for theReset value
Bit 7 6 5 4 3 2 1 0 SUT[20]
Access R R R Default 1 1 1
Bits 20 ndash SUT[20] Start-Up Time SettingThis bit field selects 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
ATtiny212214412414 AutomotiveMemories
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 34
71047 Application Code End
Name APPENDOffset 0x07Default 0x00Property -
The default value given in this fuse description is the factory-programmed value and should not be mistaken for theReset value
Bit 7 6 5 4 3 2 1 0 APPEND[70]
Access R R R R R R R R Default 0 0 0 0 0 0 0 0
Bits 70 ndash APPEND[70] Application Code Section EndThis bit field sets the end of the application code section in blocks of 256 bytes The end of the application codesection will be set as (BOOT size) + (application code size) The remaining Flash will be application data A value of0x00 defines the Flash from BOOTEND256 to the end of Flash as the application code When both FUSEAPPENDand FUSEBOOTEND are 0x00 the entire Flash is the BOOT section
ATtiny212214412414 AutomotiveMemories
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 35
71048 Boot End
Name BOOTENDOffset 0x08Default 0x00Property -
The default value given in this fuse description is the factory-programmed value and should not be mistaken for theReset value
Bit 7 6 5 4 3 2 1 0 BOOTEND[70]
Access R R R R R R R R Default 0 0 0 0 0 0 0 0
Bits 70 ndash BOOTEND[70] Boot Section EndThis bit field sets the end of the boot section in blocks of 256 bytes A value of 0x00 defines the whole Flash as theBOOT section When both FUSEAPPEND and FUSEBOOTEND are 0x00 the entire Flash is the BOOT section
ATtiny212214412414 AutomotiveMemories
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 36
71049 Lockbits
Name LOCKBITOffset 0x0ADefault 0xC5Property -
The default value given in this fuse description is the factory-programmed value and should not be mistaken for theReset value
Bit 7 6 5 4 3 2 1 0 LOCKBIT[70]
Access RW RW RW RW RW RW RW RW Default 1 1 0 0 0 1 0 1
Bits 70 ndash LOCKBIT[70] LockbitsWhen the part is locked UPDI cannot access the system bus so it cannot read out anything but the SystemInformation Block (SIB)Value Description0xC5 Valid key - memory access is unlockedother Invalid key - memory access is locked
ATtiny212214412414 AutomotiveMemories
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 37
8 Peripherals and Architecture
81 Peripheral Address MapThe address map shows the base address for each peripheral For complete register description and summary foreach peripheral refer to the respective sections
Table 8-1 Peripheral Address Map
Base Address Name Description
0x0000 VPORTA Virtual Port A
0x0004 VPORTB Virtual Port B(1)
0x0008 VPORTC Virtual Port C(1)
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(1)
0x0440 PORTC Port C Configuration(1)
0x0600 ADC0 Analog-to-Digital Converter 0
0x0670 AC0 Analog Comparator 0
0x0680 DAC0 Digital-to-Analog Converter 0
0x0800 USART0 Universal Synchronous Asynchronous Receiver Transmitter 0
0x0810 TWI0 Two-Wire Interface 0
0x0820 SPI0 Serial Peripheral Interface 0
0x0A00 TCA0 TimerCounter Type A 0
0x0A40 TCB0 TimerCounter Type B 0
0x0A80 TCD0 TimerCounter Type D 0
ATtiny212214412414 AutomotivePeripherals and Architecture
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 38
continuedBase Address Name Description
0x0F00 SYSCFG System Configuration
0x1000 NVMCTRL Nonvolatile Memory Controller
0x1100 SIGROW Signature Row
0x1280 FUSES Device-specific fuses
0x1300 USERROW User Row
Note 1 The availability of this register depends on the device pin count PORTBVPORTB is available for devices with
14 pins or more PORTCVPORTC is available for devices with 20 pins or more
82 Interrupt Vector MappingEach of the interrupt vectors is connected to one peripheral instance as shown in the table below A peripheral canhave one or more interrupt sources see the Interrupt section in the Functional Description of the respectiveperipheral 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 the peripheral(peripheralINTFLAGS)
An interrupt is enabled or disabled by writing to the corresponding Interrupt Enable (nameIE) bit in the peripheralsInterrupt Control (peripheralINTCTRL) register
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 set Theinterrupt request remains Active until the Interrupt flag is cleared See the peripherals INTFLAGS register for detailson how to clear interrupt flags
Interrupts must be enabled globally for interrupt requests to be generatedTable 8-2 Interrupt Vector Mapping
Vector Number Program Address(word)
Peripheral Source Description
0 0x00 RESET RESET
1 0x01 CRCSCAN_NMI NMI - Non-Maskable Interrupt from CRC
2 0x02 BOD_VLM VLM - Voltage Level Monitor
3 0x03 PORTA_PORT PORTA - Port A
4 0x04 PORTB_PORT PORTB - Port B(1)
5 0x05 PORTC_PORT PORTC - Port C(1)
6 0x06 RTC_CNT RTC - Real-Time Counter
7 0x07 RTC_PIT PIT - Periodic Interrupt Timer (in RTCperipheral)
8 0x08 TCA0_LUNFTCA0_OVF TCA0 - Timer Counter Type A LUNFOVF
9 0x09 TCA0_HUNF TCA0 HUNF
10 0x0A TCA0_LCMP0TCA0_CMP0
TCA0 LCMP0CMP0
ATtiny212214412414 AutomotivePeripherals and Architecture
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 39
continuedVector Number Program Address
(word)Peripheral Source Description
11 0x0B TCA0_LCMP1TCA0_CMP1
TCA0 LCMP1CMP1
12 0x0C TCA0_CMP2TCA0_LCMP2
TCA0 LCMP2CMP2
13 0x0D TCB0_INT TCB0 - Timer Counter Type B
14 0x0E TCD0_OVF TCD0 - Timer Counter Type D OVF
15 0x0F TCD0_TRIG TCD0 TRIG
16 0x10 AC0_AC AC0 ndash Analog Comparator
17 0x11 ADC0_RESRDY ADC0 ndash Analog-to-Digital Converter RESRDY
18 0x12 ADC0_WCOMP ADC0 WCOMP
19 0x13 TWI0_TWIS TWI0 - Two-Wire InterfaceI2C TWIS
20 0x14 TWI0_TWIM TWI0 TWIM
21 0x15 SPI0_INT SPI0 - Serial Peripheral Interface
22 0x16 USART0_RXC USART0 - Universal Asynchronous Receiver-Transmitter RXC
23 0x17 USART0_DRE USART0 DRE
24 0x18 USART0_TXC USART0 TXC
25 0x19 NVMCTRL_EE NVM - Nonvolatile Memory
Note 1 The availability of the port pins depends on the device pin count PORTB is available for devices with 14 pins
or more PORTC is available for devices with 20 pins or more
83 System Configuration (SYSCFG)The system configuration contains the revision ID of the part The revision ID is readable from the CPU making ituseful for implementing application changes between part revisions
ATtiny212214412414 AutomotivePeripherals and Architecture
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 40
831 Register Summary
Offset Name Bit Pos 7 6 5 4 3 2 1 0
0x00 Reserved 0x01 REVID 70 REVID[70]
832 Register Description
ATtiny212214412414 AutomotivePeripherals and Architecture
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 41
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 IDThis bit field contains the device revision 0x00 = A 0x01 = B and so on
ATtiny212214412414 AutomotivePeripherals and Architecture
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 42
9 AVRreg CPU
91 Featuresbull 8-bit High-Performance AVR RISC CPU
ndash 135 instructionsndash Hardware multiplier
bull 32 8-bit Registers Directly Connected to the ALUbull Stack in RAMbull Stack Pointer Accessible in IO Memory Spacebull Direct Addressing of up to 64 KB of Unified Memorybull Efficient Support for 8- 16- and 32-bit Arithmeticbull Configuration Change Protection for System-Critical Featuresbull Native On-Chip Debugging (OCD) Support
ndash Two hardware breakpointsndash Change of flow interrupt and software breakpointsndash Run-time read-out of Stack Pointer (SP) register Program Counter (PC) and Status Register (SREG)ndash Register file read- and writable in Stopped mode
92 OverviewAll AVR devices use the AVR 8-bit CPU The CPU is able to access memories perform calculations controlperipherals and execute instructions in the program memory Interrupt handling is described in a separate section
93 ArchitectureTo maximize performance and parallelism the AVR CPU uses a Harvard architecture with separate buses forprogram and data Instructions in the program memory are executed with a single-level pipeline While oneinstruction is being executed the next instruction is pre-fetched from the program memory This enables instructionsto be executed on every clock cycle
Refer to the Instruction Set Summary section for a summary of all AVR instructions
ATtiny212214412414 AutomotiveAVRreg CPU
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 43
Figure 9-1 AVRreg 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
ATtiny212214412414 AutomotiveAVRreg CPU
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 44
94 Arithmetic Logic Unit (ALU)The Arithmetic Logic Unit (ALU) supports arithmetic and logic operations between working registers or between aconstant and a working register Also single-register operations can be executed
The ALU operates in a direct connection with all the 32 general purpose working registers in the register fileArithmetic operations between working registers or between a working register and an immediate operand areexecuted in a single clock cycle and the result is stored in the register file After an arithmetic or logic operation theStatus 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- and 16-bitarithmetic are supported and the instruction set allows for efficient implementation of the 32-bit arithmetic Thehardware multiplier supports signed and unsigned multiplication and fractional formats
941 Hardware MultiplierThe multiplier is capable of multiplying two 8-bit numbers into a 16-bit result The hardware multiplier supportsdifferent 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 fractional number
A multiplication takes two CPU clock cycles
95 Functional Description
951 Program FlowAfter being reset the CPU will execute instructions from the lowest address in the Flash program memory 0x0000The Program Counter (PC) addresses the next instruction to be fetched
The program flow is supported by conditional and unconditional change of flow instructions capable of addressingthe whole address space directly Most AVR instructions use a 16-bit word format and a limited number use a 32-bitformat
During interrupts and subroutine calls the return address PC is stored on the stack as a word pointer The stack isallocated in the general data SRAM and consequently the stack size is only limited by the total SRAM size and theusage of the SRAM After the Stack Pointer (SP) is reset it points to the highest address in the internal SRAM TheSP is readwrite accessible in the IO memory space enabling easy implementation of multiple stacks or stack areasThe data SRAM can easily be accessed through the five 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 figure below showsthe parallel instruction fetches and executions enabled by the Harvard architecture and the fast-access register fileconcept This is the basic pipelining concept enabling up to 1 MIPSMHz performance with high efficiency
Figure 9-2 The Parallel Instruction Fetches and 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 ALU operationusing two register operands is executed and the result is stored in the destination register
ATtiny212214412414 AutomotiveAVRreg CPU
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 45
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 executed arithmetic orlogic instructions This information can be used for altering the program flow to perform conditional operations
CPUSREG is updated after all ALU operations as specified in the Instruction Set Summary section This will inmany cases remove the need for using the dedicated compare instructions resulting in a faster and more compactcode CPUSREG is not automatically stored or restored when entering or returning from an Interrupt Service Routine(ISR) Therefore maintaining the Status Register between context switches must be handled by user-definedsoftware CPUSREG is accessible in the IO memory space
954 Stack and Stack PointerThe stack is used for storing return addresses after interrupts and subroutine calls Also it can be used for storingtemporary data The Stack Pointer (SP) always points to the top of the stack The SP is defined by the Stack Pointerbits in the Stack Pointer register (CPUSP) The CPUSP is implemented as two 8-bit registers that are accessible inthe IO memory space
Data are pushed and popped from the stack using the PUSH and POP instructions The stack grows from higher tolower memory locations This means that pushing data onto the stack decreases the SP and popping data off thestack increases the SP The SP is automatically set to the highest address of the internal SRAM after being reset Ifthe stack is changed it must be set to point above the SRAM start address (see the SRAM Data Memory section inthe Memories chapter for the SRAM start address) and it must be defined before any subroutine calls are executedand before interrupts are enabled See the table below for SP details
Table 9-1 Stack Pointer Instructions
Instruction Stack Pointer Description
PUSH Decremented by 1 Data are pushed onto the stack
ICALLRCALL
Decremented by 2 A return address is pushed onto the stack with a subroutine call or interrupt
POP Incremented by 1 Data are popped from the stack
RET RETI Incremented by 2 A return address is popped from the stack with a return from subroutine or returnfrom interrupt
During interrupts or subroutine calls the return address is automatically pushed on the stack as a word pointer andthe SP is decremented by two The return address consists of two bytes and the Least Significant Byte (LSB) ispushed on the stack first (at the higher address) As an example a byte pointer return address of 0x0006 is saved onthe stack as 0x0003 (shifted one bit to the right) pointing to the fourth 16-bit instruction word in the program memoryThe return address is popped off the stack with RETI (when returning from interrupts) and RET (when returning fromsubroutine calls) and the SP is incremented by two
The SP is decremented by lsquo1rsquo when data are pushed on the stack with the PUSH instruction and incremented by lsquo1rsquowhen data are popped off the stack using the POP instruction
To prevent corruption when updating the SP from software a write to SPL will automatically disable interrupts for upto four instructions or until the next IO memory write whichever comes first
ATtiny212214412414 AutomotiveAVRreg CPU
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 46
955 Register FileThe register file consists of 32 8-bit general purpose working registers used by the CPU The register file is located ina separate address space from the data memory
All CPU instructions that operate on working registers have direct and single-cycle access to the register file Somelimitations apply to which working registers can be accessed by an instruction like the constant arithmetic and logicinstructions SBCI SUBI CPI ANDI ORI and LDI These instructions apply to the second half of the workingregisters in the register file R16 to R31 See the AVR Instruction Set Manual for further details
Figure 9-4 AVRreg 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
9551 The X- Y- and Z-RegistersWorking registers R26R31 have added functions besides their general purpose usage
These registers can form 16-bit Address Pointers for indirect addressing of data memory These three addressregisters are called the X-register Y-register and Z-register The Z-register can also be used as Address Pointer forprogram memory
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 address holds the MostSignificant Byte (MSB) These address registers can function as fixed displacement automatic increment andautomatic decrement with different LDST instructions See the Instruction Set Summary section for details
956 Accessing 16-bit RegistersMost of the registers for the ATtiny212214412414 Automotive devices are 8-bit registers but the devices alsofeatures a few 16-bit registers As the AVR data bus has a width of 8 bits accessing the 16-bit requires two read orwrite operations All the 16-bit registers of the ATtiny212214412414 Automotive devices are connected to the 8-bitbus through a temporary (TEMP) register
ATtiny212214412414 AutomotiveAVRreg CPU
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 47
Figure 9-6 16-Bit Register Write Operation
DATA
BUS
AVR
Write Low Byte
DATAH
TEMP
DATAL
DATAH
Write High Byte
TEMP
DATAL
DATA
BUS
AVR
For a 16-bit write operation the low byte register (eg DATAL) of the 16-bit register must be written before the highbyte register (eg DATAH) Writing the low byte register will result in a write to the temporary (TEMP) register insteadof the low byte register as shown in the left side of Figure 9-6 When the high byte register of the 16-bit register iswritten TEMP will be copied into the low byte of the 16-bit register in the same clock cycle as shown in the right sideof Figure 9-6
Figure 9-7 16-Bit Register Read Operation
DATA
BUS
AVR
Read Low Byte
DATAH
TEMP
DATAL
DATAH
Read High Byte
TEMP
DATAL
DATA
BUS
AVR
For a 16-bit read operation the low byte register (eg DATAL) of the 16-bit register must be read before the high byteregister (eg DATAH) When the low byte register is read the high byte register of the 16-bit register is copied into
ATtiny212214412414 AutomotiveAVRreg CPU
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 48
the temporary (TEMP) register in the same clock cycle as show in the left side of Figure 9-7 Reading the high byteregister will result in a read from TEMP instead of the high byte register as shown in right side of Figure 9-7
The described mechanism ensures that the low and high bytes of 16-bit registers are always accessedsimultaneously when reading or writing the registers
Interrupts can corrupt the timed sequence if an interrupt is triggered during a 16-bit readwrite operation and a 16-bitregister within the same peripheral is accessed in the interrupt service routine To prevent this interrupts should bedisabled when writing or reading 16-bit registers Alternatively the temporary register can be read before andrestored after the 16-bit access in the interrupt service routine
957 Configuration Change Protection (CCP)System critical IO register settings are protected from accidental modification Flash self-programming (via store toNVM controller) is protected from accidental execution This is handled globally by the Configuration ChangeProtection (CCP) register
Changes to the protected IO registers or bits or execution of protected instructions are only possible after the CPUwrites a signature to the CCP register The different signatures are listed in the description of the CCP register(CPUCCP)
There are two modes of operation One for protected IO registers and one for protected self-programming
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 field in theCPUCCP 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 written to lsquo1rsquo inthe same operation as the data are written
The protected change is immediately disabled if the CPU performs write operations to the IO register or datamemory if load or store accesses to Flash NVMCTRL or EEPROM are conducted or if the SLEEP instructionis executed
9572 Sequence for Execution of Self-ProgrammingIn order to execute self-programming (the execution of writes to the NVM controllerrsquos command register) thefollowing steps are required
1 The software temporarily enables self-programming by writing the SPM signature to the CCP register(CPUCCP)
2 Within four instructions the software must execute the appropriate instruction The protected change isimmediately disabled if the CPU performs accesses to the Flash NVMCTRL or EEPROM or if the SLEEPinstruction is executed
Once the correct signature is written by the CPU interrupts will be ignored for the duration of the configurationchange enable period Any interrupt request (including non-maskable interrupts) during the CCP period will set thecorresponding Interrupt flag as normal and the request is kept pending After the CCP period is completed anypending interrupts are executed according to their level and priority
958 On-Chip Debug CapabilitiesThe AVR CPU includes native On-Chip Debug (OCD) support It includes some powerful debug capabilities to enableprofiling and detailed information about the CPU state It is possible to alter the CPU state and resume codeexecution Also normal debug capabilities like hardware Program Counter breakpoints breakpoints on change offlow instructions breakpoints on interrupts and software breakpoints (BREAK instruction) are present Refer to theUnified Program and Debug Interface section for details about OCD
ATtiny212214412414 AutomotiveAVRreg CPU
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 49
96 Register Summary
Offset Name Bit Pos 7 6 5 4 3 2 1 0
0x00
0x03Reserved
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
ATtiny212214412414 AutomotiveAVRreg CPU
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 50
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 are completed the interrupts will automatically behandled again 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 lsquo1rsquo as long as the CCP feature is enabledWhen the protected self-programming signature is written CCP[1] will read as lsquo1rsquo as long as the CCP feature isenabledCCP[72] will always read as lsquo0rsquoValue Name Description0x9D SPM Allow Self-Programming0xD8 IOREG Unlock protected IO registers
ATtiny212214412414 AutomotiveAVRreg CPU
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 51
972 Stack Pointer
Name SPOffset 0x0DReset Top of stackProperty -
The CPUSP register holds the Stack Pointer (SP) that points to the top of the stack After being reset the SP pointsto the highest internal SRAM address
Only the number of bits required to address the available data memory including external memory (up to 64 KB) isimplemented for each device Unused bits will always read as lsquo0rsquo
The CPUSPL and CPUSPH register pair represents the 16-bit value CPUSP The low byte [70] (suffix L) isaccessible 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 disable interruptsfor the next four instructions or until the next IO memory write whichever comes first
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
ATtiny212214412414 AutomotiveAVRreg CPU
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 52
973 Status Register
Name SREGOffset 0x0FReset 0x00Property -
The Status Register contains information about the result of the most recently executed arithmetic or logicinstructions For details about the bits in this register and how they are influenced by different instructions see theInstruction Set Summary section
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 Enable BitWriting a lsquo1rsquo to this bit enables interrupts on the deviceWriting a lsquo0rsquo to this bit disables interrupts on the device independent of the individual interrupt enable settings of theperipheralsThis bit is not cleared by hardware while entering an Interrupt Service Routine (ISR) or set when the RETI instructionis executedThis bit can be set and cleared by software with the SEI and CLI instructionsChanging the I bit through the IO register results in a one-cycle Wait state on the access
Bit 6 ndash T Transfer BitThe bit copy instructions Bit Load (BLD) and Bit Store (BST) use the T bit as source or destination for the operatedbit
Bit 5 ndash H Half Carry FlagThis flag is set when there is a half carry in arithmetic operations that support this and is cleared otherwise Halfcarry is useful in BCD arithmetic
Bit 4 ndash S Sign FlagThis flag is always an Exclusive Or (XOR) between the Negative flag (N) and the Tworsquos Complement Overflow flag(V)
Bit 3 ndash V Tworsquos Complement Overflow FlagThis flag is set when there is an overflow in arithmetic operations that support this and is cleared otherwise
Bit 2 ndash N Negative FlagThis flag is set when there is a negative result in an arithmetic or logic operation and is cleared otherwise
Bit 1 ndash Z Zero FlagThis flag is set when there is a zero result in an arithmetic or logic operation and is cleared otherwise
Bit 0 ndash C Carry FlagThis flag is set when there is a carry in an arithmetic or logic operation and is cleared otherwise
ATtiny212214412414 AutomotiveAVRreg CPU
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 53
10 NVMCTRL - Nonvolatile Memory Controller
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 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 CPU and Nonvolatile Memories (Flash EEPROMSignature Row User Row and fuses) These are reprogrammable memory blocks that retain their values even whenthey are not powered The Flash is mainly used for program storage and can also be used for data storage TheEEPROM is used for data storage and can be programmed while the CPU is running the program from the Flash
1021 Block DiagramFigure 10-1 NVMCTRL Block Diagram
NVM
Blo
ck
Flash
EEPROM
Signature Row
User Row
NVMCTRL
Program Memory Bus
Data Memory Bus
ATtiny212214412414 AutomotiveNVMCTRL - Nonvolatile Memory Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 54
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 Flash It is onlypossible to write or erase a whole page at a time One page consists of several words
The Flash can be divided into three sections in blocks of 256 bytes for different security The three different sectionsare BOOT Application Code (APPCODE) and Application Data (APPDATA)
Figure 10-2 Flash Sections
FLASHSTART 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 the Application CodeSection End fuse (FUSEAPPEND)
The fuses select the section sizes in blocks of 256 bytes The BOOT section stretches from the start of the Flash untilBOOTEND The APPCODE section runs from BOOTEND until APPEND The remaining area is the APPDATAsection If APPEND is written to lsquo0rsquo the APPCODE section runs from BOOTEND to the end of Flash (removing theAPPDATA section) If BOOTEND and APPEND are written to lsquo0rsquo the entire Flash is regarded as the BOOT sectionAPPEND may either be set to lsquo0rsquo or a value greater than or equal to BOOTEND
Table 10-1 Setting Up Flash Sections
BOOTEND APPEND BOOT Section APPCODE Section APPDATA Section
0 0 0 to FLASHEND mdash mdash
gt 0 0 0 to 256BOOTEND 256BOOTEND toFLASHEND mdash
gt 0 ==BOOTEND 0 to 256BOOTEND mdash
256BOOTEND toFLASHEND
gt 0 gt BOOTEND 0 to 256BOOTEND 256BOOTEND to256APPEND
256APPEND toFLASHEND
ATtiny212214412414 AutomotiveNVMCTRL - Nonvolatile Memory Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 55
Notes 1 See also the BOOTEND and APPEND descriptions2 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 first 4256 byteswill be BOOT the next 4256 bytes will be APPCODE and the remaining Flash will be APPDATA
Inter-Section Write ProtectionBetween the three Flash sections 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 Lock bits (APCWP and BOOTLOCK in NVMCTRLCTRLB) can be set to lock further updates of therespective APPCODE or BOOT section until the next Reset
The CPU can never write to the BOOT section NVMCTRL_CTRLBBOOTLOCK prevents reads and execution ofcode from the BOOT section
10312 EEPROMThe EEPROM is divided into a set of pages where one page consists of multiple bytes The EEPROM has bytegranularity on erasewrite Within one page only the bytes marked to be updated will be erasedwritten The byte ismarked 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 as calibrationconfiguration data and serial numbers This page is not erased by a chip erase The User Row is written as normalEEPROM 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 the memory mapReading any of the arrays while a write or erase is in progress will result in a bus wait and the instruction will besuspended 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 Flash EEPROM andUser Row share the same page buffer so only one section can be programmed at a time The Least Significant bits(LSb) of the address are used to select where in the page buffer the data is written The resulting data will be a binaryAND operation between the new and the previous content of the page buffer The page buffer will automatically beerased (all bits set) after
bull A device Resetbull Any page write or erase operationbull A Clear Page Buffer commandbull A device wake-up from any Sleep mode
10323 ProgrammingFor page programming filling the page buffer and writing the page buffer into Flash User Row and EEPROM aretwo separate operations
Before programming a Flash page with the data in the page buffer the Flash page must be erased The page bufferis also erased when the device enters a Sleep mode Programming an unerased Flash page will corrupt its content
The Flash can either be written with the erase and write separately or one command handling both
Alternative 1
ATtiny212214412414 AutomotiveNVMCTRL - Nonvolatile Memory Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 56
1 Fill the page buffer2 Write the page buffer to Flash with the Erase and Write Page (ERWP) command
Alternative 21 Write to a location in the page to set up the address2 Perform an Erase Page (ER) command3 Fill the page buffer4 Perform a Write Page (WP) command
The NVM command set supports both a single erase and write operation and split Erase Page (ER) and Write Page(WP) commands This split commands enable shorter programming time for each command and the eraseoperations 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 or erased in theEEPROM
10324 CommandsReading the FlashEEPROM and writing the page buffer is handled with normal loadstore instructions Otheroperations such as writing and erasing the memory arrays are handled by commands in 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 Page (WP) 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 write operation Ifthe write is to the EEPROM the CPU can continue executing code while the operation is ongoing
The page buffer will automatically be cleared after the operation is finished
103242 Erase CommandThe Erase Page (ER) command erases the current page There must be one byte written in the page buffer for theErase Page (ER) command to take effect
For erasing the Flash first write to one address in the desired page then execute the command The whole page inthe Flash will then be erased The CPU will be halted while the erase is ongoing
For the EEPROM only the bytes written in the page buffer will be erased when the command is executed To erase aspecific byte write to its corresponding address before executing the command To erase a whole page all the bytesin the page buffer have to be updated before executing the command The CPU can continue running code while theoperation is ongoing
The page buffer will automatically be cleared after the operation is finished
103243 EraseWrite OperationThe Erase and Write Page (ERWP) command is a combination of the Erase Page and Write Page commands butwithout clearing the page buffer after the Erase Page command The erasewrite operation first erases the selectedpage then it writes the content of the page buffer to the same page
When executed on the Flash the CPU will be halted when the operations are ongoing When executed on EEPROMthe 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 (PBC) command clears the page buffer The contents of the page buffer will be all lsquo1rsquos afterthe operation The CPU will be halted when the operation executes (seven CPU cycles)
ATtiny212214412414 AutomotiveNVMCTRL - Nonvolatile Memory Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 57
103245 Chip Erase CommandThe Chip Erase (CHER) command erases the Flash and the EEPROM The EEPROM is unaltered if the EEPROMSave During Chip Erase (EESAVE) fuse in FUSESYSCFG0 is set The Flash will not be protected by Boot SectionLock (BOOTLOCK) or Application Code Section Write Protection (APCWP) in NVMCTRLCTRLB The memory willbe all lsquo1rsquos after the operation
103246 EEPROM Erase CommandThe EEPROM Erase (EEER) command erases the EEPROM The EEPROM will be all lsquo1rsquos after the operation TheCPU will be halted while the EEPROM is being erased
103247 Write Fuse CommandThe Write Fuse (WFU) command writes the fuses It can only be used by the UPDI the CPU cannot start thiscommand
Follow this procedure to use the Write Fuse command1 Write the address of the fuse to the Address register (NVMCTRLADDR)2 Write the data to be written to the fuse to the Data register (NVMCTRLDATA)3 Execute the Write Fuse command4 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
10325 Write Access after ResetAfter a Power-on Reset (POR) the NVMCTRL rejects any write attempts to the NVM for a certain time During thisperiod the Flash Busy (FBUSY) and the EEPROM Busy (EBUSY) bits in the STATUS register will read lsquo1rsquo EEBUSYand FBUSY must read lsquo0rsquo before the page buffer can be filled or NVM commands can be issued
This time-out period is disabled either by writing the Time-Out Disable bit (TOUTDIS) in the System Configuration 0Fuse (FUSESYSCFG0) to lsquo0rsquo or by configuring the RSTPINCFG bit field in FUSESYSCFG0 to UPDI
1033 Preventing FlashEEPROM CorruptionDuring periods of low VDD the Flash program or EEPROM data can be corrupted if the supply voltage is too low forthe CPU and the FlashEEPROM to operate properly These issues are the same on-board level systems usingFlashEEPROM and the same design solutions may 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
Attention FlashEEPROM corruption can be avoided by taking these measures1 Keep the device in Reset during periods of insufficient power supply voltage This can be done by
enabling the internal Brown-Out Detector (BOD)2 The voltage level monitor in the BOD can be used to prevent starting a write to the EEPROM close
to the BOD level3 If the detection levels of the internal BOD do not match the required detection level an external low
VDD Reset protection circuit can be used If a Reset occurs while a write operation is ongoing thewrite operation will be aborted
1034 InterruptsTable 10-2 Available Interrupt Vectors and Sources
Offset Name Vector Description Conditions
0x00 EEREADY NVM The EEPROM is ready for new writeerase operations
ATtiny212214412414 AutomotiveNVMCTRL - Nonvolatile Memory Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 58
When an interrupt condition occurs the corresponding interrupt flag is set in the Interrupt Flags(NVMCTRLINTFLAGS) register
An interrupt source is enabled or disabled by writing to the corresponding bit in the Interrupt Control(NVMCTRLINTCTRL) register
An interrupt request is generated when the corresponding interrupt source is enabled and the interrupt flag is setThe interrupt request remains active until the interrupt flag is cleared See the NVMCTRLINTFLAGS register fordetails on how to clear interrupt flags
1035 Sleep Mode OperationIf there is no ongoing write operation the NVMCTRL will enter a sleep mode when the system enters a sleep mode
If a write operation is ongoing when the system enters a sleep mode the NVM block the NVM Controller and thesystem clock will remain ON until the write is finished This is valid for all sleep modes including Power-Down sleepmode
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) To write to these registers acertain key must first be written to the CPUCCP register followed by a write access to the protected bits within fourCPU instructions
Attempting to write to a protected register without following the appropriate CCP unlock sequence leaves theprotected register unchanged
The following registers are under CCP
Table 10-3 NVMCTRL - Registers under Configuration Change Protection
Register Key
NVMCTRLCTRLA SPM
ATtiny212214412414 AutomotiveNVMCTRL - Nonvolatile Memory Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 59
104 Register Summary
Offset Name Bit Pos 7 6 5 4 3 2 1 0
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
ATtiny212214412414 AutomotiveNVMCTRL - Nonvolatile Memory Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 60
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 tobe 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 lsquo1rsquo)0x6 EEER EEPROM Erase0x7 WFU Write fuse (only accessible through UPDI)
ATtiny212214412414 AutomotiveNVMCTRL - Nonvolatile Memory Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 61
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 lsquo1rsquo to this bit locks the boot section from read and instruction fetchIf this bit is lsquo1rsquo a read from the boot section will return lsquo0rsquo A fetch from the boot section will also return lsquo0rsquo asinstructionThis bit can be written from the boot section only It can only be cleared to lsquo0rsquo 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 lsquo1rsquo to this bit protects the application code section from further writesThis bit can only be written to lsquo1rsquo It is cleared to lsquo0rsquo only by Reset
ATtiny212214412414 AutomotiveNVMCTRL - Nonvolatile Memory Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 62
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 lsquo1rsquo when a write error has happened A write error could be writing to different sections before doinga 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 lsquo1rsquo when the EEPROM is busy with a command
Bit 0 ndash FBUSY Flash BusyThis bit will read lsquo1rsquo when the Flash is busy with a command
ATtiny212214412414 AutomotiveNVMCTRL - Nonvolatile Memory Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 63
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 lsquo1rsquo to this bit enables the interrupt which indicates that the EEPROM is ready for new writeeraseoperationsThis is a level interrupt that will be triggered only when the EEREADY flag in the INTFLAGS register is set to lsquo0rsquoThus the interrupt must not be enabled before triggering an NVM command as the EEREADY flag will not be setbefore the NVM command issued The interrupt may be disabled in the interrupt handler
ATtiny212214412414 AutomotiveNVMCTRL - Nonvolatile Memory Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 64
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 lsquo1rsquo to it
ATtiny212214412414 AutomotiveNVMCTRL - Nonvolatile Memory Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 65
1056 Data
Name DATAOffset 0x06Reset 0x00Property -
The NVMCTRLDATAL and NVMCTRLDATAH register pair represents the 16-bit value NVMCTRLDATA The lowbyte [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
ATtiny212214412414 AutomotiveNVMCTRL - Nonvolatile Memory Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 66
1057 Address
Name ADDROffset 0x08Reset 0x00Property -
The NVMCTRLADDRL and NVMCTRLADDRH register pair represents the 16-bit value NVMCTRLADDR The lowbyte [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
ATtiny212214412414 AutomotiveNVMCTRL - Nonvolatile Memory Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 67
11 CLKCTRL - Clock Controller
111 Featuresbull All Clocks and Clock Sources are Automatically Enabled when Requested by Peripheralsbull Internal Oscillators
ndash 16 MHz Oscillator (OSC20M)ndash 32768 kHz Ultra Low-Power Oscillator (OSCULP32K)
bull External Clock Optionsndash 32768 kHz Crystal Oscillator (XOSC32K)(1)
ndash External clockbull Main Clock Features
ndash Safe run-time switchingndash Prescaler with 1x to 64x division in 12 different settings
Note 1 Available for devices with 14 pins or more
112 OverviewThe Clock Controller (CLKCTRL) peripheral controls distributes and prescales the clock signals from the availableoscillators The CLKCTRL supports internal and external clock sources
The CLKCTRL is based on an automatic clock request system implemented in all peripherals on the device Theperipherals will automatically request the clocks needed If multiple clock sources are available the request is routedto the correct clock source
The Main Clock (CLK_MAIN) is used by the CPU RAM and the IO bus The main clock source can be selected andprescaled Some peripherals can share the same clock source as the main clock or run asynchronously to the mainclock domain
ATtiny212214412414 AutomotiveCLKCTRL - Clock Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 68
1121 Block Diagram - CLKCTRLFigure 11-1 CLKCTRL Block Diagram
CPURAMNVM TCDBODRTC
OSC20MInt Oscillator
WDT
32768 kHzExt Crystal Osc
DIV32
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
32768 kHz ULPInt Oscillator
EXTCLKTOSC1TOSC2Note Availability of TOSC1 TOSC2 and CLKOUT pin depends on the pin count of the device See section 51 Multiplexed Signals for an overview of which pins are available for each device represented in this data sheet
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 bus It is alwaysrunning in Active and Idle sleep modes and can be running in Standby sleep mode if requested
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 non-volatile 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 must only be changed if the peripheral is disabledndash CLK_WDT is used by the WDT It will be requested when the WDT is enabledndash CLK_BOD is used by the BOD It will be requested when the BOD is enabled in Sampled Mode
ATtiny212214412414 AutomotiveCLKCTRL - Clock Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 69
ndash CLK_TCD is used by the TCD It will be requested when the TCD is enabled The clock source can only bechanged if the peripheral is disabled
The clock source for the Main Clock domain is configured by writing to the Clock Select (CLKSEL) bits in the MainClock Control A (CLKCTRLMCLKCTRLA) register The asynchronous clock sources are configured by registers inthe respective peripheral
1122 Signal Description
Signal Type Description
CLKOUT Digital output CLK_PER output
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 directly by writing a1 to the Run in Standby (RUNSTDBY) bit in the respective oscillators Control A (CLKCTRL[osc]CTRLA) registerThis will cause the oscillator to run constantly except for Power-Down sleep mode Additionally when this bit iswritten to 1 the oscillator start-up time is eliminated when the clock source is requested by a peripheral
The main clock will always run in Active and Idle sleep mode In Standby sleep mode the main clock will only run ifany peripheral is requesting it or the Run in Standby (RUNSTDBY) bit in the respective oscillators Control A(CLKCTRL[osc]CTRLA) register 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 is selectable fromsoftware 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 edges are detectedindicating it is stable Until a sufficient number of clock edges are detected the switch will not occur and it will not bepossible to change to another clock source again without executing a Reset
An ongoing clock source switch is indicated by the System Oscillator Changing (SOSC) flag in the Main Clock Status(CLKCTRLMCLKSTATUS) register The stability of the external clock sources is indicated by the respective status(EXTS and XOSC32KS in CLKCTRLMCLKSTATUS) flags
CAUTIONIf an external clock source fails while used as CLK_MAIN source only the WDT can provide a mechanismto switch back via System Reset
CLK_MAIN is fed into a prescaler before it is used by the peripherals (CLK_PER) in the device The prescaler dividesCLK_MAIN by a factor from 1 to 64
Figure 11-2 Main Clock and Prescaler
(Div 1 2 4 8 16 32 64 6 10 24 48)
OSC20M
32768 kHz Osc
32768 kHz crystal Osc
External clock
CLK_MAIN CLK_PERMain Clock Prescaler
The Main Clock and Prescaler configuration (CLKCTRLMCLKCTRLA CLKCTRLMCLKCTRLB) registers areprotected by the Configuration Change Protection Mechanism employing a timed write procedure for changing theseregisters
ATtiny212214412414 AutomotiveCLKCTRL - Clock Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 70
1133 Main Clock After Reset
After any Reset CLK_MAIN is provided by the 16 MHz Oscillator (OSC20M) with a prescaler division factor of 6Since the actual frequency of the OSC20M is determined by the Frequency Select (FREQSEL) bits of the OscillatorConfiguration (FUSEOSCCFG) fuse these frequencies are possible after ResetTable 11-1 Peripheral Clock Frequencies After Reset
CLK_MAIN as Per FREQSEL in FUSEOSCCFG Resulting CLK_PER
16 MHz 266 MHz
See the OSC20M description for further details
1134 Clock SourcesAll internal clock sources are enabled automatically when they are requested by a peripheral The crystal oscillatorbased on an external crystal must be enabled by writing a 1 to the ENABLE bit in the 32768 kHz Crystal OscillatorControl A (CLKCTRLXOSC32KCTRLA) register before it can serve as a clock source
The respective Oscillator Status bits in the Main Clock Status (CLKCTRLMCLKSTATUS) register indicate whetherthe clock source is running and stable
11341 Internal OscillatorsThe internal oscillators do not require any external components to run
113411 16 MHz Oscillator (OSC20M)This oscillator can operate at multiple frequencies selected by the value of the Frequency Select (FREQSEL) bits inthe Oscillator Configuration (FUSEOSCCFG) fuse The center frequencies are
bull 16 MHz
After a System Reset FUSEOSCCFG determines the initial frequency of CLK_MAIN
During Reset the calibration values for the OSC20M are loaded from fuses There are two different Calibration bitfields
bull The Calibration (CAL20M) bit field in the Calibration A (CLKCTRLOSC20MCALIBA) register enables calibrationaround the current center frequency
bull The Oscillator Temperature Coefficient Calibration (TEMPCAL20M) bit field in the Calibration B(CLKCTRLOSC20MCALIBB) register enables adjustment of the slope of the temperature drift compensation
For applications requiring a more fine-tuned frequency setting than the oscillator calibration provides factory-storedfrequency error after calibrations are available
The oscillator calibration can be locked by the Oscillator Lock (OSCLOCK) Fuse (FUSEOSCCFG) When this fuse islsquo1rsquo it is not possible to change the calibration The calibration is locked if this oscillator is used as the main clocksource and the Lock Enable (LOCKEN) bit in the Control B (CLKCTRLOSC20MCALIBB) register is lsquo1rsquo
The Calibration bits are protected by the Configuration Change Protection Mechanism requiring a timed writeprocedure for changing the main clock and prescaler settings
The start-up time of this oscillator is the 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 as the mainclock (CLK_MAIN) it is recommended to change the main clock prescaler so that the main clock frequency does notexceed frac14 of the maximum operation main clock frequency as described in the General Operating Ratings sectionThe system clock prescaler can be changed back after the oscillator calibration value has been updated
OSC20M Stored Frequency Error CompensationThis oscillator can operate at multiple frequencies selected by the value of the Frequency Select (FREQSEL) bits inthe Oscillator Configuration (FUSEOSCCFG) fuse at Reset As previously mentioned appropriate calibration valuesare loaded to adjust to center frequency (OSC20M) and temperature drift compensation (TEMPCAL20M) meetingthe specifications defined in the internal oscillator characteristics For applications requiring a wider operating rangethe relative factory stored frequency error after calibrations can be used The four errors are measured with differentsettings and are available in the signature row as signed byte values
ATtiny212214412414 AutomotiveCLKCTRL - Clock Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 71
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 not to lose resolution where the MSb is the signbit and the seven LSbs are the lower bits of the Q110BAUDact = BAUD+ BAUD 1024The minimum legal BAUD register value is 0x40 the target BAUD register value must therefore not be lower than0x4A to ensure that the compensated BAUD value stays within the legal range even for parts with negativecompensation values The example code below demonstrates how to apply this value for more accurate USARTbaud 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
113412 32768 kHz Oscillator (OSCULP32K)The 32768 kHz oscillator is optimized for Ultra Low-Power (ULP) operation Power consumption is decreased at thecost of decreased accuracy compared to an external crystal oscillator
This oscillator provides the 1024 kHz signal for the Real-Time Counter (RTC) the Watchdog Timer (WDT) and theBrown-out Detector (BOD)
The start-up time of this oscillator is the oscillator start-up time plus four oscillator cycles Refer to the ElectricalCharacteristics section for the start-up time
11342 External Clock SourcesThese external clock sources are available
bull External Clock from pin EXTCLKbull 32768 kHz Crystal Oscillator on pins TOSC1 and TOSC2bull 32768 kHz External Clock on pin TOSC1
113421 External Clock (EXTCLK)The EXTCLK is taken directly from the pin This GPIO pin is automatically configured for EXTCLK if any peripheral isrequesting this clock
This clock source has a start-up time of two cycles when first requested
113422 32768 kHz Crystal Oscillator (XOSC32K)This oscillator supports two input options Either a crystal is connected to the pins TOSC1 and TOSC2 or an externalclock running at 32768 kHz is connected to TOSC1 The input option must be configured by writing the SourceSelect (SEL) bit in the XOSC32K Control A (CLKCTRLXOSC32KCTRLA) register
The XOSC32K is enabled by writing a 1 to its ENABLE bit in CLKCTRLXOSC32KCTRLA When enabled theconfiguration of the GPIO pins used by the XOSC32K is overridden as TOSC1 TOSC2 pins The ENABLE bit needsto 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-up Time (CSUT)bits in CLKCTRLXOSC32KCTRLA
When XOSC32K is configured to use an external clock on TOSC1 the start-up time is fixed to two cycles
ATtiny212214412414 AutomotiveCLKCTRL - Clock Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 72
1135 Configuration Change ProtectionThis peripheral has registers that are under Configuration Change Protection (CCP) To write to these registers acertain key must first be written to the CPUCCP register followed by a write access to the protected bits within fourCPU instructions
Attempting to write to a protected register without following the appropriate CCP unlock sequence leaves theprotected 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
ATtiny212214412414 AutomotiveCLKCTRL - Clock Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 73
114 Register Summary
Offset Name Bit Pos 7 6 5 4 3 2 1 0
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 CAL20M[50]0x12 OSC20MCALIBB 70 LOCK TEMPCAL20M[30]0x13
0x17
Reserved
0x18 OSC32KCTRLA 70 RUNSTDBY 0x19
0x1B
Reserved
0x1C XOSC32KCTRLA 70 CSUT[10] SEL RUNSTDBY ENABLE
115 Register Description
ATtiny212214412414 AutomotiveCLKCTRL - Clock Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 74
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 the CLKOUT pin The CLKOUT pin is available for deviceswith 20 pins or more See section 51 Multiplexed Signals for more informationWhen the device is in a sleep mode there is no clock output unless a peripheral is using the system clock
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 32768 kHz internal ultra low-power oscillator0x2 XOSC32K 32768 kHz external crystal oscillator0x3 EXTCLK External clock
ATtiny212214412414 AutomotiveCLKCTRL - Clock Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 75
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 this bit field defines the division ratio of the main clock prescalerThis bit field 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 prescaler settings suchthat the resulting frequency of CLK_PER never exceeds the allowed maximum (see Electrical 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 the PDIV bit fieldWhen this bit is written to 0 the main clock will pass through undivided (CLK_PER=CLK_MAIN) regardless of thevalue of PDIV
ATtiny212214412414 AutomotiveCLKCTRL - Clock Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 76
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 if applicablethe calibration settings for the current main clock source from further software updates Once locked theCLKCTRLMCLKLOCK registers cannot be accessed until the next hardware ResetThis protects the CLKCTRLMCLKCTRLA and CLKCTRLMCLKCTRLB registers and calibration settings for the mainclock source from unintentional modification by softwareAt Reset the LOCKEN bit is loaded based on the OSCLOCK bit in FUSEOSCCFG
ATtiny212214412414 AutomotiveCLKCTRL - Clock Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 77
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 If the oscillatorRUNSTDBY bit is set but the oscillator is unusednot requested this bit will be lsquo0rsquoValue 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 If the oscillatorRUNSTDBY bit is set but the oscillator is unusednot requested this bit will be lsquo0rsquoValue 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 If the oscillatorRUNSTDBY bit is set but the oscillator is unusednot requested this bit will be lsquo0rsquoValue 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
ATtiny212214412414 AutomotiveCLKCTRL - Clock Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 78
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 in StandbyThis bit forces the oscillator ON in all modes even when unused by the system In Standby sleep mode this can beused 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 time will beremoved when this bit is set
ATtiny212214412414 AutomotiveCLKCTRL - Clock Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 79
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 CAL20M[50]
Access RW RW RW RW RW RW Reset x x x x x x
Bits 50 ndash CAL20M[50] CalibrationThis bit field changes 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
ATtiny212214412414 AutomotiveCLKCTRL - Clock Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 80
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 and CLKCTRLOSC20MCALIBB cannotbe changedAt Reset the value is loaded from the OSCLOCK bit in the Oscillator Configuration (FUSEOSCCFG) fuse
Bits 30 ndash TEMPCAL20M[30] Oscillator Temperature Coefficient CalibrationThis bit field tunes the slope of the temperature compensationAt Reset the factory-calibrated values are loaded based on the FREQSEL bits in FUSEOSCCFG
ATtiny212214412414 AutomotiveCLKCTRL - Clock Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 81
1158 32768 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 in StandbyThis bit forces the oscillator ON in all modes even when unused by the system In Standby sleep mode this can beused 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 time will beremoved when this bit is set
ATtiny212214412414 AutomotiveCLKCTRL - Clock Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 82
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 (XOSC32KS)bit in CLKCTRLMCLKSTATUS is highTo change settings safely write a 0 to the ENABLE bit and wait until XOSC32KS is 0 before re-enabling theXOSC32K 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 TimeThis bit field selects 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 in StandbyWriting this bit to 1 starts the crystal oscillator and forces the oscillator ON in all modes even when unused by thesystem if the ENABLE bit is set In Standby sleep mode this can be used to ensure immediate wake-up and notwaiting for oscillator start-up time When this bit is 0 the crystal oscillator is only running when requested and theENABLE 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 a request untilthe oscillator output is received if the initial crystal start-up time has already completedDepending on the RUNSTBY bit the oscillator will be turned ON all the time if the device is in Active Idle or Standbysleep mode or only be enabled when requestedThis bit is IO protected to prevent any 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 and TOSC2 Alsothe Source Select (SEL) and Crystal Start-Up Time (CSUT) bits become read-onlyThis bit is IO protected to prevent any unintentional enabling of the oscillator
ATtiny212214412414 AutomotiveCLKCTRL - Clock Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 83
12 SLPCTRL - Sleep Controller
121 Featuresbull Power Management for Adjusting Power Consumption and Functionsbull Three Sleep Modes
ndash Idlendash Standbyndash Power-Down
bull Configurable Standby 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 power The SleepController (SLPCTRL) controls and handles the transitions between Active and sleep modes
There are four modes available One Active mode in which software is executed and three sleep modes Theavailable sleep modes are Idle Standby and Power-Down
All sleep modes are available and can be entered from the Active mode In Active mode the CPU is executingapplication code When the device enters sleep mode the program execution is stopped The application codedecides which sleep mode to enter and when
Interrupts are used to wake the device from sleep The available interrupt wake-up sources depend on the configuredsleep mode When an interrupt occurs the device will wake up and execute the Interrupt Service Routine beforecontinuing normal program execution from the first instruction after the SLEEP instruction Any Reset will take thedevice out of sleep mode
The content of the register file SRAM and registers is kept during sleep If a Reset occurs during sleep the devicewill reset start and execute from the Reset vector
1221 Block DiagramFigure 12-1 Sleep Controller in the System
SLPCTRL
SLEEP Instruction
Interrupt Request
Peripheral
Interrupt Request
Sleep State
CPU
123 Functional Description
1231 InitializationTo put the device into a sleep mode follow these steps
ATtiny212214412414 AutomotiveSLPCTRL - Sleep Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 84
1 Configure and enable the interrupts that are able to wake the device from sleepAlso enable global interrupts
WARNINGIf there are no interrupts enabled when going to sleep the device cannot wake up again Only aReset will allow the device to continue operation
2 Select which sleep mode to enter and enable the Sleep Controller by writing to the Sleep Mode (SMODE) bitfield and the Enable (SEN) bit in the Control A (SLPCTRLCTRLA) registerThe SLEEP instruction must be executed to make the device go to sleep
1232 Operation
12321 Sleep ModesIn addition to Active mode there are three different sleep modes with decreasing power consumption andfunctionality
Idle The CPU stops executing code No peripherals are disabled and all interrupt sources can wake thedevice
Standby The user can configure peripherals to be enabled or not using the respective RUNSTBY bit Thismeans that the power consumption is highly dependent on what functionality is enabled and thus mayvary between the Idle and Power-Down levelsSleepWalking is available for the ADC module
Power-Down
BOD WDT and PIT (a component of the RTC) are activeThe only wake-up sources are the pin change interrupt PIT VLM TWI address match and CCL
Table 12-1 Sleep Mode Activity Overview
Group Peripheral Active in Sleep Mode
Clock Idle Standby Power-Down
Active Clock Domain CPU CLK_CPU
RTC CLK_RTC X X(1) X(2)
ADCn CLK_PER X X(1)
TCBn CLK_PER X X(1)
BOD CLK_BOD X X X
WDT CLK_WDT X X X
All other peripherals CLK_PER X
Oscillators Main clock source X X(1)
RTC clock source X X(1) X(2)
WDT oscillator X X X
BOD oscillator(3) X X X
ATtiny212214412414 AutomotiveSLPCTRL - Sleep Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 85
continuedGroup Peripheral Active in Sleep Mode
Clock Idle Standby Power-Down
Wake-Up Sources PORT Pin interrupt X X X
TWI Address Match interrupt X X X
USART Start-of-Frame interrupts X X(1)
ADC interrupts X X(1)
RTC interrupts X X(1) X(2)
TCBn Capture interrupt X X(1)
All other interrupts X
Notes 1 The RUNSTBY bit of the corresponding peripheral must be set to enter the Active state2 Only the PIT is available in the Power-Down sleep mode3 Sampled mode only
12322 Wake-up TimeThe normal wake-up time for the device is six main clock cycles (CLK_PER) plus the time it takes to start the mainclock source
bull In Idle sleep mode the main clock source is kept running to eliminate additional wake-up timebull In Standby sleep mode the main clock might be running depending on the peripheral configurationbull In Power-Down sleep mode only the ULP 32768 kHz oscillator and the RTC clock may be running if it is used
by the BOD or WDT All other clock sources will be OFF
Table 12-2 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 ready before executingcode This is done by writing 0x3 to the BOD Operation mode in Active and Idle bits (ACTIVE) in the BODConfiguration fuse (FUSEBODCFG) If the BOD is ready before the normal wake-up time the total wake-up time willbe the same If the BOD takes longer than the normal wake-up time the wake-up time will be extended until the BODis ready This ensures correct supply voltage whenever code is executed
1233 Debug OperationDuring run-time debugging this peripheral will continue normal operation The SLPCTRL is only affected by a breakin the debug operation If the SLPCTRL is in a sleep mode when a break occurs the device will wake up and theSLPCTRL will go to Active mode even if there are no pending interrupt requests
If the peripheral is configured to require periodic service by the CPU through interrupts or similar improper operationor data loss may result during halted debugging
ATtiny212214412414 AutomotiveSLPCTRL - Sleep Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 86
124 Register Summary
Offset Name Bit Pos 7 6 5 4 3 2 1 0
0x00 CTRLA 70 SMODE[10] SEN
125 Register Description
ATtiny212214412414 AutomotiveSLPCTRL - Sleep Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 87
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 which sleep mode to enter when the Sleep Enable (SEN) bit is written to lsquo1rsquo and the SLEEPinstruction 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 lsquo1rsquo before the SLEEP instruction is executed to make the MCU enter the selected Sleepmode
ATtiny212214412414 AutomotiveSLPCTRL - Sleep Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 88
13 RSTCTRL - Reset Controller
131 Featuresbull Returns the Device to an Initial State after a Resetbull Identifies the Previous Reset Sourcebull Power Supply Reset Sources
ndash Power-on Reset (POR)ndash Brown-out Detector (BOD) Reset
bull User Reset Sourcesndash External Reset (RESET)ndash Watchdog Timer (WDT) Resetndash Software Reset (SWRST)ndash Universal Program Debug Interface (UPDI) Reset
132 OverviewThe Reset Controller (RSTCTRL) manages the Reset of the device It issues a device Reset sets the device to itsinitial state and allows the Reset source to be identified by software
1321 Block DiagramFigure 13-1 Reset System Overview
RESET SOURCES
POR
BOD
WDT
CPU (SW)
RESET CONTROLLER
UPDI
UPDI
All other peripherals
RESET External ResetFILTER
VDD
Pull-upresistor
1322 Signal Description
Signal Description Type
RESET External Reset (active-low) Digital input
ATtiny212214412414 AutomotiveRSTCTRL - Reset Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 89
133 Functional Description
1331 InitializationThe RSTCTRL is always enabled but some of the Reset sources must be enabled individually (either by Fuses or bysoftware) before they can request a Reset
After a Reset from any source the registers in the device with automatic loading from the Fuses or from theSignature Row are updated
1332 Operation
13321 Reset SourcesAfter any Reset the source that caused the Reset is found in the Reset Flag (RSTCTRLRSTFR) register The usercan identify the previous Reset source by reading this register in the software application
There are two types of Resets based on the sourcebull Power Supply Reset Sources
ndash Power-on Reset (POR)ndash Brown-out Detector (BOD) Reset
bull User Reset Sourcesndash External Reset (RESET)ndash Watchdog Timer (WDT) Resetndash Software Reset (SWRST)ndash Universal Program Debug Interface (UPDI) Reset
133211 Power-on Reset (POR)The purpose of the Power-on Reset (POR) is to ensure a safe start-up of logic and memories The POR will keep thedevice in Reset until the voltage level is high enough The POR is generated by an on-chip detection circuit ThePOR is always enabled and activated when VDD is below the POR threshold voltage
Figure 13-2 MCU Start-Up RESET Tied to VDD
V
RESET
TIME-OUT
INTERNALRESET
tTOUT
VPOT
VRST
DD
ATtiny212214412414 AutomotiveRSTCTRL - Reset Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 90
Figure 13-3 MCU Start-Up RESET Extended Externally
RESET
TIME-OUT
INTERNALRESET
tTOUT
VPOT
VRST
VDD
133212 Brown-out Detector (BOD) ResetThe on-chip Brown-out Detection (BOD) circuit will monitor the VDD level during operation by comparing it to a fixedtrigger level The trigger level for the BOD can be selected by fuses If BOD is unused in the application it is forced toa minimum level in order to ensure a safe operation during internal Reset and chip erase
Figure 13-4 Brown-out Detection Reset
VDD
TIME-OUT
INTERNALRESET
VBOT-VBOT+
tTOUT
tBOD
133213 Software ResetThe software Reset makes it possible to issue a system Reset from software The Reset is generated by writing a 1to 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 the Resetsequence is completed
133214 External ResetThe external Reset is enabled by a fuse see the RSTPINCFG field in FUSESYSCFG0
When enabled the external Reset requests a Reset as long as the RESET pin is low The device will stay in Resetuntil RESET is high again
ATtiny212214412414 AutomotiveRSTCTRL - Reset Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 91
Figure 13-5 External Reset CharacteristicsDD
tEXT
133215 Watchdog ResetThe Watchdog Timer (WDT) is a system function for monitoring correct program operation If the WDT is not resetfrom software according to the programmed time-out period a Watchdog Reset will be issued See the WDTdocumentation for further details
133216 Universal Program Debug Interface (UPDI) ResetThe Universal Program Debug Interface (UPDI) contains a separate Reset source used to reset the device duringexternal programming and debugging The Reset source is accessible only from external debuggers andprogrammers More details can be found in the UPDI section
133217 Domains Affected By ResetThe following logic domains are affected by the various Resets
Table 13-1 Logic Domains Affected by Various Resets
Reset Type Fuses areReloaded
TCD Pin OverrideFunctionalityAvailable
Reset of TCDPin OverrideSettings
Reset of BODConfiguration
Reset ofUPDI
Reset of OtherVolatile Logic
POR X X X X XBOD X X X XSoftware Reset X X XExternal Reset X X XWatchdog Reset X X XUPDI Reset X X X
13322 Reset Time
The Reset time can be split into two parts
The first part is when any of the Reset sources are active This part depends on the input to the Reset sources Theexternal Reset is active as long as the RESET pin is low The Power-on Reset (POR) and the Brown-out Detector(BOD) are active as long as the supply voltage is below the Reset source threshold
The second part is when all the Reset sources are released and an internal Reset initialization of the device is doneThis time will be increased with the start-up time given by the Start-Up Time Setting (SUT) bit field in the SystemConfiguration 1 (FUSESYSCFG1) fuse The internal Reset initialization time will also increase if the CyclicRedundancy Check Memory Scan (CRCSCAN) is configured to run at start-up This configuration can be changed inthe CRC Source (CRCSRC) bit field in the System Configuration 0 (FUSESYSCFG0) fuse
1333 Sleep Mode OperationThe RSTCTRL operates in Active mode and in all sleep modes
ATtiny212214412414 AutomotiveRSTCTRL - Reset Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 92
1334 Configuration Change ProtectionThis peripheral has registers that are under Configuration Change Protection (CCP) To write to these registers acertain key must first be written to the CPUCCP register followed by a write access to the protected bits within fourCPU instructions
Attempting to write to a protected register without following the appropriate CCP unlock sequence leaves theprotected register unchanged
The following registers are under CCP
Table 13-2 RSTCTRL - Registers Under Configuration Change Protection
Register Key
RSTCTRLSWRR IOREG
ATtiny212214412414 AutomotiveRSTCTRL - Reset Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 93
134 Register Summary
Offset Name Bit Pos 7 6 5 4 3 2 1 0
0x00 RSTFR 70 UPDIRF SWRF WDRF EXTRF BORF PORF0x01 SWRR 70 SWRE
135 Register Description
ATtiny212214412414 AutomotiveRSTCTRL - Reset Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 94
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 (POR) with the exception ofthe Power-on Reset Flag (PORF)
Bit 7 6 5 4 3 2 1 0 UPDIRF SWRF WDRF EXTRF BORF PORF
Access RW RW RW RW RW RW Reset 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 POR occursAfter a POR only the POR flag is set and all the other flags are cleared No other flags can be set before a fullsystem boot is run after the POR
ATtiny212214412414 AutomotiveRSTCTRL - Reset Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 95
1352 Software Reset Register
Name SWRROffset 0x01Reset 0x00Property Configuration Change Protection
Bit 7 6 5 4 3 2 1 0 SWRE
Access RW Reset 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
ATtiny212214412414 AutomotiveRSTCTRL - Reset Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 96
14 CPUINT - CPU Interrupt Controller
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)
ndash One of the interrupt requests can optionally be assigned as a priority level 1 interruptndash Optional round robin priority scheme for priority level 0 interrupts
bull Interrupt Vectors Optionally Placed in the Application Section or the Boot Loader Sectionbull Selectable Compact Vector Table (CVT)
142 OverviewAn interrupt request signals a change of state inside a peripheral and can be used to alter the program executionThe peripherals can have one or more interrupts All interrupts are individually enabled and configured When aninterrupt is enabled and configured it will generate an interrupt request when the interrupt condition occurs
The CPU Interrupt Controller (CPUINT) handles and prioritizes the interrupt requests When an interrupt is enabledand the interrupt condition occurs the CPUINT will receive the interrupt request Based on the interrupts priority leveland the priority level of any ongoing interrupt the interrupt request is either acknowledged or kept pending until it haspriority After returning from the interrupt handler the program execution continues from where it was before theinterrupt occurred and any pending interrupts are served after one instruction is executed
The CPUINT offers NMI for critical functions one selectable high-priority interrupt and an optional round robinscheduling scheme for normal-priority interrupts The round robin scheduling ensures that all interrupts are servicedwithin a certain amount of time
1421 Block DiagramFigure 14-1 CPUINT Block Diagram
Peripheral 1
Interrupt Controller
PriorityDecoder
STATUS
CPUSREG
INT REQ
INT REQ
GlobalInterruptEnable
CPU RETI
CPU INT ACK
CPU INT REQ
Wake-upLVL0PRILVL1VEC
Peripheral n
SLPCTRL
CPU
ATtiny212214412414 AutomotiveCPUINT - CPU Interrupt Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 97
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
(CPUINTCTRLA) registerndash Vector prioritizing by round robin is enabled by writing a lsquo1rsquo to the Round Robin Priority Enable (LVL0RR)
bit in CPUINTCTRLAndash Select the Priority Level 1 vector by writing the interrupt vector number to the Interrupt Vector with Priority
Level 1 (CPUINTLVL1VEC) register2 Configure the interrupt conditions within the peripheral and enable the peripheralrsquos interrupt3 Enable interrupts globally by writing a lsquo1rsquo to the Global Interrupt Enable (I) bit in the CPU Status (CPUSREG)
register
1432 Operation
14321 Enabling Disabling and ResettingThe global enabling of interrupts is done by writing a lsquo1rsquo to the Global Interrupt Enable (I) bit in the CPU Status(CPUSREG) register To disable interrupts globally write a lsquo0rsquo to the I bit in CPUSREG
The desired interrupt lines must also be enabled in the respective peripheral by writing to the peripheralrsquos InterruptControl (peripheralINTCTRL) register
The interrupt flags are not automatically cleared after the interrupt is executed The respective INTFLAGS registerdescriptions provide information on how to clear specific flags
14322 Interrupt Vector LocationsThe interrupt vector placement is dependent on the value of the Interrupt Vector Select (IVSEL) bit in the Control A(CPUINTCTRLA) register Refer to the IVSEL description in CPUINTCTRLA for the possible locations
If the program never enables an interrupt source the interrupt vectors are not used and the regular program codecan be placed at these locations
14323 Interrupt Response TimeThe minimum interrupt response time is represented in the following table
Table 14-1 Minimum Interrupt Response Time
Flash Size gt 8 KB Flash Size le 8 KB
Finish ongoing instruction One cycle One cycle
Store PC to stack Two cycles Two cycles
Jump to interrupt handler Three cycles (jmp) Two cycles (rjmp)
After the Program Counter is pushed on the stack the program vector for the interrupt is executed See the followingfigure
ATtiny212214412414 AutomotiveCPUINT - CPU Interrupt Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 98
Figure 14-2 Interrupt Execution of Single-Cycle Instruction
(1)
If an interrupt occurs during the execution of a multi-cycle instruction the instruction is completed before the interruptis served as shown in the following figure
Figure 14-3 Interrupt Execution of Multi-Cycle Instruction
(1)
If an interrupt occurs when the device is in a sleep mode the interrupt execution response time is increased by fiveclock cycles as shown in the figure below Also the response time is increased by the start-up time from the selectedsleep mode
Figure 14-4 Interrupt Execution From Sleep
(1)
A return from an interrupt handling routine takes four to five clock cycles depending on the size of the ProgramCounter During these clock cycles the Program Counter is popped from the stack and the Stack Pointer isincremented
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 below An interruptrequest from a high-priority source will interrupt any ongoing interrupt handler from a normal-priority source Whenreturning from the high-priority interrupt handler the execution of the normal-priority interrupt handler will resume
ATtiny212214412414 AutomotiveCPUINT - CPU Interrupt Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 99
Table 14-2 Interrupt Priority Levels
Priority Level Source
Highest Non-Maskable Interrupt Device-dependent and statically assigned
Level 1 (high priority) One vector is optionally user selectable as level 1
Lowest Level 0 (normal priority) The remaining interrupt vectors
143241 Non-Maskable InterruptsA Non-Maskable Interrupt (NMI) will be executed regardless of the setting of the I bit in CPUSREG An NMI willnever change the I bit No other interrupt can interrupt an NMI handler If more than one NMI is requested at thesame time the priority 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-maskable interruptsmust be enabled before they can be used Refer to the interrupt vector mapping of the device for available NMI lines
143242 High-Priority InterruptIt is possible to assign one interrupt request to level 1 (high priority) by writing its interrupt vector number to theCPUINTLVL1VEC register This interrupt request will have a higher priority than the other (normal priority) interruptrequests The priority level 1 interrupts will interrupt the level 0 interrupt handlers
143243 Normal-Priority InterruptsAll interrupt vectors other than NMI are assigned to priority level 0 (normal) by default The user may override this byassigning one of these vectors as a high-priority vector The device will have many normal-priority vectors and someof these may be pending at the same time Two different scheduling schemes are available to choose which of thepending normal-priority interrupts to service first Static or round robin
IVEC is the interrupt vector mapping as listed in the Peripherals and Architecture chapter The following sections useIVEC to explain the scheduling schemes IVEC0 is the Reset vector IVEC1 is the NMI vector and so on In a vectortable with n+1 elements the vector with the highest vector number is denoted IVECn Reset non-maskable interruptsand high-level interrupts are included in the IVEC map but will always be prioritized over the normal-priorityinterrupts
Static SchedulingIf several level 0 interrupt requests are pending at the same time the one with the highest priority is scheduled forexecution first The following figure illustrates the default configuration where the interrupt vector with the lowestaddress has the highest priority
Figure 14-5 Default Static Scheduling
Lowest Priority
Highest PriorityIVEC 0
IVEC n
Lowest Address
Highest Address
IVEC 1
Modified Static SchedulingThe default priority can be changed by writing a vector number to the CPUINTLVL0PRI register This vector numberwill be assigned the lowest priority The next interrupt vector in the IVEC will have the highest priority among the LVL0interrupts as shown in the following figure
ATtiny212214412414 AutomotiveCPUINT - CPU Interrupt Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 100
Figure 14-6 Static Scheduling when CPUINTLVL0PRI is Different From Zero
Lowest Address
Highest Address
IVEC 0
IVEC Y
IVEC Y+1
IVEC n
Lowest Priority
Highest Priority
IVEC 1
RESETNMI
Here value Y has been written to CPUINTLVL0PRI so that interrupt vector Y+1 has the highest priority Note that inthis case the priorities will wrap so that the lowest address no longer has the highest priority This does not includeRESET and NMI which will always have the highest priority
Refer to the interrupt vector mapping of the device for available interrupt requests and their interrupt vector number
Round Robin SchedulingThe static scheduling may prevent some interrupt requests from being serviced To avoid this the CPUINT offersround robin scheduling for normal-priority (LVL0) interrupts In the round robin scheduling the CPUINTLVL0PRIregister stores the last acknowledged interrupt vector number This register ensures that the last acknowledgedinterrupt vector gets the lowest priority and is automatically updated by the hardware The following figure illustratesthe priority order after acknowledging IVEC Y and after acknowledging IVEC Y+1
Figure 14-7 Round Robin Scheduling
IVEC Y was the last acknowledgedinterrupt
IVEC Y+1 was the 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
IVEC 1 IVEC 1
RESETNMI
RESETNMI
The round robin scheduling for LVL0 interrupt requests is enabled by writing a lsquo1rsquo to the Round Robin Priority Enable(LVL0RR) bit in the Control A (CPUINTCTRLA) register
ATtiny212214412414 AutomotiveCPUINT - CPU Interrupt Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 101
14325 Compact Vector TableThe Compact Vector Table (CVT) is a feature to allow writing of compact code by having all level 0 interrupts sharethe same interrupt vector number Thus the interrupts share the same Interrupt Service Routine (ISR) This reducesthe number of interrupt handlers and thereby frees up memory that can be used for the application code
When CVT is enabled by writing a lsquo1rsquo to the CVT bit in the Control A (CPUINTCTRLA) register the vector tablecontains 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 at vector address 3
This feature is most suitable for devices with limited memory and applications using a small number of interruptgenerators
1433 Debug OperationWhen using a level 1 priority interrupt it is important to make sure the Interrupt Service Routine is configuredcorrectly as it may cause the application to be stuck in an interrupt loop with level 1 priority
By reading the CPUINT STATUS (CPUINTSTATUS) register it is possible to see if the application has executed thecorrect RETI (interrupt return) instruction The CPUINTSTATUS register contains state information which ensuresthat the CPUINT returns to the correct interrupt level when the RETI instruction is executed at the end of an interrupthandler Returning from an interrupt will return the CPUINT to the state it had before entering the interrupt
1434 Configuration Change ProtectionThis peripheral has registers that are under Configuration Change Protection (CCP) To write to these registers acertain key must first be written to the CPUCCP register followed by a write access to the protected bits within fourCPU instructions
Attempting to write to a protected register without following the appropriate CCP unlock sequence leaves theprotected register unchanged
The following registers are under CCP
Table 14-3 CPUINT - Registers under Configuration Change Protection
Register Key
IVSEL in CPUINTCTRLA IOREG
CVT in CPUINTCTRLA IOREG
ATtiny212214412414 AutomotiveCPUINT - CPU Interrupt Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 102
144 Register Summary
Offset Name Bit Pos 7 6 5 4 3 2 1 0
0x00 CTRLA 70 IVSEL CVT LVL0RR0x01 STATUS 70 NMIEX LVL1EX LVL0EX0x02 LVL0PRI 70 LVL0PRI[70]0x03 LVL1VEC 70 LVL1VEC[70]
145 Register Description
ATtiny212214412414 AutomotiveCPUINT - CPU Interrupt Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 103
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 SelectThis 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 The round robin priority scheme is enabled for priority level 0 interrupt requests
ATtiny212214412414 AutomotiveCPUINT - CPU Interrupt Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 104
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) from the interrupthandler
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 been interrupted by anNMI 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 been interrupted by apriority level 1 interrupt or an NMI The flag is cleared when returning (RETI) from the interrupt handler
ATtiny212214412414 AutomotiveCPUINT - CPU Interrupt Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 105
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 0This register is used to modify the priority of the LVL0 interrupts See the section Normal-Priority Interrupts for moreinformation
ATtiny212214412414 AutomotiveCPUINT - CPU Interrupt Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 106
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 thevalue 0x00 no vector has LVL1 Consequently the LVL1 interrupt is disabled
ATtiny212214412414 AutomotiveCPUINT - CPU Interrupt Controller
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 107
15 EVSYS - Event System
151 Featuresbull System for Direct Peripheral-to-Peripheral Signalingbull Peripherals Can Directly Produce Use and React to Peripheral Eventsbull Short Response Timebull Up to Four Parallel Asynchronous Event Channels Availablebull Up to Two Parallel Synchronous Event Channels Availablebull 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 one peripheral(the event generator) to trigger actions in other peripherals (the event users) through event channels without usingthe CPU It is designed to provide short and predictable response times between peripherals allowing forautonomous peripheral control and interaction and also for the synchronized timing of actions in several peripheralmodules It is thus a powerful tool for reducing the complexity size and the execution time of the software
A change of the event generatorrsquos state is referred to as an event and usually corresponds to one of the peripheralrsquosinterrupt conditions Events can be directly forwarded to other peripherals using the dedicated event routing networkThe routing of each channel is configured in software including event generation and use
Only one trigger from an event generator peripheral can be routed on each channel but multiple channels can usethe same generator source Multiple peripherals can use events from the same channel
A channel path can be either asynchronous or synchronous to the main clock The mode must be selected based onthe requirements of the application
The Event System can directly connect analog and digital converters analog comparators IO port pins the real-timecounter timercounters and the configurable custom logic peripheral Events can also be generated from softwareand the peripheral clock
ATtiny212214412414 AutomotiveEVSYS - Event System
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 108
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
Notes 1 For an overview of peripherals supporting events refer to the block diagram of the device2 For a list of event generators refer to the Channel n Generator Selection (EVSYSSYNCCH and
EVSYSASYNCCH) registers3 For a list of event users refer to the User Channel n Input Selection (EVSYSSYNCUSER and
EVSYSASYNCUSER) registers
ATtiny212214412414 AutomotiveEVSYS - Event System
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 109
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 or a levelsignal (similar to a status flag)
Event Output to Pin
Signal Type Description
EVOUT[20] Digital Output Event Output
1523 System DependenciesTo 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
15231 ClocksThe EVSYS uses the peripheral clock for IO registers and software events When correctly set up the routingnetwork can also be used in sleep modes without any clock Software events will not work in sleep modes where theperipheral clock is halted
15232 IO LinesThe EVSYS can output three event channels asynchronously on pins The output signals are called EVOUT[20]
1 Configure which event channel (one of SYNCCH[10] or ASYNCCH[30]) is output on which EVOUTn bit bywriting to EVSYSASYNCUSER10 EVSYSASYNCUSER9 or EVSYSASYNCUSER8 respectively
2 Optional Configure the pin properties using the port peripheral3 Enable the pin output by writing lsquo1rsquo to the respective EVOUTn bit in the Control A (PORTMUXCTRLA) register
of the PORTMUX peripheral
153 Functional Description
1531 InitializationBefore enabling events within the device the event users multiplexer and event channels must be configured
1532 Operation
15321 Event User Multiplexer SetupThe event user multiplexer selects the channel for an event user Each event user has one dedicated event usermultiplexer Each multiplexer is connected to the supported event channel outputs and can be configured to selectone of these channels
Event users which support asynchronous events also support synchronous events There are also event users thatsupport only synchronous events
ATtiny212214412414 AutomotiveEVSYS - Event System
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 110
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 (EVSYSASYNCUSERn) registerbull The users of synchronous-only events are configured by writing to the respective Synchronous User Channel
Input Selection n (EVSYSSYNCUSERn) register
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 either asynchronousgenerators or synchronous generators
The source for each asynchronous event channel is configured by writing to the respective Asynchronous Channel nInput Selection (EVSYSASYNCCHn) register
The source for each synchronous event channel is configured by writing to the respective Synchronous Channel nInput Selection (EVSYSSYNCCHn) register
15323 Event GeneratorsEach event channel can receive the events from several event generators For details on event generation refer tothe documentation of the corresponding peripheral
For each event channel there are several possible event generators only one of which can be selected at a timeThe event generator trigger is selected for each channel by writing to the respective channel registers(EVSYSASYNCCHn EVSYSSYNCCHn) By default the channels are not connected to any event generator
15324 Software EventIn a software event the CPU will ldquostroberdquo an event channel by inverting the current value for one system clock cycle
A software event is triggered on a channel by writing a lsquo1rsquo to the respective Strobe bit in the appropriate ChannelStrobe register
bull Software events on asynchronous channel l are initiated by writing a lsquo1rsquo to the ASYNCSTROBE[l] bit in theAsynchronous Channel Strobe (EVSYSASYNCSTROBE) register
bull Software events on synchronous channel k are initiated by writing a lsquo1rsquo to the SYNCSTROBE[k] bit in theSynchronous Channel Strobe (EVSYSSYNCSTROBE) register
Software events are no different to those produced by event generator peripherals with respect to event users Whenthe bit is written to lsquo1rsquo an event will be generated on the respective channel and received and processed by theevent user
1533 InterruptsNot applicable
1534 Sleep Mode OperationWhen configured the Event System will work in all sleep modes One exception is software events that require asystem clock
1535 Debug OperationThis peripheral is unaffected by entering Debug mode
1536 SynchronizationAsynchronous events are synchronized and handled by compatible event users Event user peripherals notcompatible with asynchronous events can only be configured to listen to synchronous event channels
1537 Configuration Change ProtectionNot applicable
ATtiny212214412414 AutomotiveEVSYS - Event System
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 111
154 Register Summary
Offset Name Bit Pos 7 6 5 4 3 2 1 0
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
ATtiny212214412414 AutomotiveEVSYS - Event System
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 112
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 singleevent is generated)
ATtiny212214412414 AutomotiveEVSYS - Event System
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 113
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 singleevent is generated)
ATtiny212214412414 AutomotiveEVSYS - Event System
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 114
1553 Asynchronous Channel n Generator Selection
Name ASYNCCHnOffset 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 Selection
Value ASYNCCH0 ASYNCCH1 ASYNCCH2 ASYNCCH30x00 OFF OFF OFF OFF0x01 CCL_LUT00x02 CCL_LUT10x03 AC0_OUT0x04 TCD0_CMPBCLR0x05 TCD0_CMPASET0x06 TCD0_CMPBSET0x07 TCD0_PROGEV0x08 RTC_OVF0x09 RTC_CMP0x0A PORTA_PIN0 PORTB_PIN0 - PIT_DIV81920x0B PORTA_PIN1 PORTB_PIN1 - PIT_DIV40960x0C PORTA_PIN2 PORTB_PIN2 - PIT_DIV20480x0D PORTA_PIN3 PORTB_PIN3 - PIT_DIV10240x0E PORTA_PIN4 PORTB_PIN4 - PIT_DIV5120x0F PORTA_PIN5 PORTB_PIN5 - PIT_DIV2560x10 PORTA_PIN6 PORTB_PIN6 - PIT_DIV1280x11 PORTA_PIN7 PORTB_PIN7 - PIT_DIV640x12 UPDI - - -Other - - - -
Note Not all pins of a port are available on devices with low pin counts Check the Pinout Diagram andor the IOMultiplexing table for details
ATtiny212214412414 AutomotiveEVSYS - Event System
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 115
1554 Synchronous Channel n Generator Selection
Name SYNCCHnOffset 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 Selection
Value SYNCCH0 SYNCCH10x00 OFF0x01 TCB00x02 TCA0_OVF_LUNF0x03 TCA0_HUNF0x04 TCA0_CMP00x05 TCA0_CMP10x06 TCA0_CMP20x07 - -0x08 - PORTB_PIN00x09 - PORTB_PIN10x0A - PORTB_PIN20x0B - PORTB_PIN30x0C - PORTB_PIN40x0D PORTA_PIN0 PORTB_PIN50x0E PORTA_PIN1 PORTB_PIN60x0F PORTA_PIN2 PORTB_PIN70x10 PORTA_PIN3 -0x11 PORTA_PIN4 -0x12 PORTA_PIN5 -0x13 PORTA_PIN6 -0x14 PORTA_PIN7 -0x15 TCB1 -Other - -
Note Not all pins of a port are available on devices with low pin counts Check the Pinout Diagram andor the IOMultiplexing table for details
ATtiny212214412414 AutomotiveEVSYS - Event System
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 116
1555 Asynchronous User Channel n Input Selection
Name ASYNCUSERnOffset 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 Selection
ASYNCUSERn User Multiplexer Description0 TCB0 TimerCounter B 01 ADC0 ADC 02 CCL_LUT0EV0 CCL LUT0 Event 03 CCL_LUT1EV0 CCL LUT1 Event 04 CCL_LUT0EV1 CCL LUT0 Event 15 CCL_LUT1EV1 CCL LUT1 Event 16 TCD0_EV0 Timer Counter D 0 Event 07 TCD0_EV1 Timer Counter D 0 Event 18 EVOUT0 Event OUT 09 EVOUT1 Event OUT 110 EVOUT2 Event OUT 2
Value Name0x0 OFF0x1 SYNCCH00x2 SYNCCH10x3 ASYNCCH00x4 ASYNCCH10x5 ASYNCCH20x6 ASYNCCH3Other -
ATtiny212214412414 AutomotiveEVSYS - Event System
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 117
1556 Synchronous User Channel n Input Selection
Name SYNCUSERnOffset 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 Selection
SYNCUSERn User Multiplexer Description0 TCA0 TimerCounter A1 USART0 USART
Value Name0x0 OFF0x1 SYNCCH00x2 SYNCCH1Other -
ATtiny212214412414 AutomotiveEVSYS - Event System
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 118
16 PORTMUX - Port Multiplexer
161 OverviewThe Port Multiplexer (PORTMUX) can either enable or disable the functionality of pins or change between defaultand alternative pin positions This depends on the actual pin and property and is described in detail in the PORTMUXregister map
For available pins and functionalities refer to Table 5-1
ATtiny212214412414 AutomotivePORTMUX - Port Multiplexer
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 119
162 Register Summary
Offset Name Bit Pos 7 6 5 4 3 2 1 0
0x00 CTRLA 70 EVOUT1 EVOUT00x01 CTRLB 70 TWI0 SPI0 USART00x02 CTRLC 70 TCA00
163 Register Description
ATtiny212214412414 AutomotivePORTMUX - Port Multiplexer
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 120
1631 Control A
Name CTRLAOffset 0x00Reset 0x00Property -
Bit 7 6 5 4 3 2 1 0 EVOUT1 EVOUT0
Access RW RW Reset 0 0
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
ATtiny212214412414 AutomotivePORTMUX - Port Multiplexer
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 121
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
ATtiny212214412414 AutomotivePORTMUX - Port Multiplexer
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 122
1633 Control C
Name CTRLCOffset 0x02Reset 0x00Property -
Bit 7 6 5 4 3 2 1 0 TCA00
Access RW Reset 0
Bit 0 ndash TCA00 TCA0 Waveform Output 0Write this bit to 1 to select the alternative output pin for TCA0 waveform output 0In Split mode this bit controls output from low byte compare channel 0
ATtiny212214412414 AutomotivePORTMUX - Port Multiplexer
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 123
17 PORT - IO Pin Configuration
171 Featuresbull General Purpose Input and Output Pins with Individual Configuration
ndash Pull-upndash Inverted IO
bull Interrupts and Eventsndash 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 (RMW) 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 Each PORT instance has upto eight IO pins The PORTs are named PORTA PORTB PORTC etc Refer to the IO Multiplexing andConsiderations section to see which pins are controlled by what instance of PORT The base addresses of the PORTinstances and the corresponding Virtual PORT instances are listed in the Peripherals and Architecture section
Each PORT pin has a corresponding bit in the Data Direction (PORTxDIR) and Data Output Value (PORTxOUT)registers to enable that pin as an output and to define the output state For example pin PA3 is controlled by DIR[3]and OUT[3] of the PORTA instance
The input value of a PORT pin is synchronized to the Peripheral Clock (CLK_PER) and then made accessible as thedata input value (PORTxIN) The value of the pin can be read whether the pin is configured as input or output
The PORT also supports asynchronous input sensing with interrupts and events for selectable pin change conditionsAsynchronous pin change sensing means that a pin change can trigger an interrupt and wake the device from sleepincluding sleep modes where CLK_PER is stopped
All pin functions are individually configurable per pin The pins have hardware Read-Modify-Write functionality for asafe and correct change of the drive values andor input and sense configuration
The PORT pin configuration controls input and output selection of other device functions
ATtiny212214412414 AutomotivePORT - IO Pin Configuration
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 124
1721 Block DiagramFigure 17-1 PORT Block Diagram
D Q
R
OUTn
DQ
R
DQ
R
SynchronizerINn
Pxn
DIRn
D Q
R
Input Disable
Invert Enable
Pull-up Enable
Peripheral Override
InterruptGenerator
Interrupt
Peripheral Override
Peripheral Override
Sense Configuration
AsynchronousInputEvent
AnalogInputOutput
SynchronousInput
1722 Signal Description
Signal Type Description
Pxn IO pin IO pin n on PORTx
ATtiny212214412414 AutomotivePORT - IO Pin Configuration
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 125
173 Functional Description
1731 InitializationAfter Reset all outputs are tri-stated and digital input buffers enabled even if there is no clock running
The following steps are all optional when initializing PORT operation
bull Enable or disable the output driver for pin Pxn by respectively writing lsquo1rsquo to bit n in the PORTxDIRSET orPORTxDIRCLR register
bull Set the output driver for pin Pxn to high or low level respectively by writing lsquo1rsquo to bit n in the PORTxOUTSET orPORTxOUTCLR register
bull Read the input of pin Pxn by reading bit n in the PORTxIN registerbull Configure the individual pin configurations and interrupt control for pin Pxn in PORTxPINnCTRL
Important For lowest power consumption disable the digital input buffer of unused pins and pins thatare used as analog inputs or outputs
Specific pins such as those used to connect a debugger may be configured differently as required by their specialfunction
1732 Operation
17321 Basic FunctionsEach pin group x has its own set of PORT registers IO pin Pxn can be controlled by the registers in PORTx
To use pin number n as an output write bit n of the PORTxDIR register to lsquo1rsquo This can be done by writing bit n in thePORTxDIRSET register to lsquo1rsquo which will avoid disturbing the configuration of other pins in that group The nth bit inthe PORTxOUT register must be written to the desired output value
Similarly writing a PORTxOUTSET bit to lsquo1rsquo will set the corresponding bit in the PORTxOUT register to lsquo1rsquo Writing abit in PORTxOUTCLR to lsquo1rsquo will clear that bit in PORTxOUT to lsquo0rsquo Writing a bit in PORTxOUTTGL or PORTxIN tolsquo1rsquo will toggle that bit in PORTxOUT
To use pin n as an input bit n in the PORTxDIR register must be written to lsquo0rsquo to disable the output driver This canbe done by writing bit n in the PORTxDIRCLR register to lsquo1rsquo which will avoid disturbing the configuration of otherpins in that group The input value can be read from bit n in the PORTxIN register as long as the ISC bit is not set toINPUT_DISABLE
Writing a bit to lsquo1rsquo in PORTxDIRTGL will toggle that bit in PORTxDIR and toggle the direction of the correspondingpin
17322 Pin ConfigurationThe Pin n Control (PORTxPINnCTRL) register is used to configure inverted IO pull-up and input sensing of a pinThe control register for pin n is at the byte address PORTx + 0x10 +
All input and output on the respective pin n can be inverted by writing a lsquo1rsquo to the Inverted IO Enable (INVEN) bit inPORTxPINnCTRL When INVEN is lsquo1rsquo the PORTxINOUTOUTSETOUTTGL registers will have an invertedoperation for this pin
Toggling the INVEN bit causes an edge on the pin which can be detected by all peripherals using this pin and isseen by interrupts or events if enabled
The input pull-up of pin n is enabled by writing a lsquo1rsquo to the Pull-up Enable (PULLUPEN) bit in PORTxPINnCTRL Thepull-up is disconnected when the pin is configured as an output even if PULLUPEN is lsquo1rsquo
Pin interrupts can be enabled for pin n by writing to the InputSense Configuration (ISC) bit field inPORTxPINnCTRL Refer to 1733 Interrupts for further details
ATtiny212214412414 AutomotivePORT - IO Pin Configuration
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 126
The digital input buffer for pin n can be disabled by writing the INPUT_DISABLE setting to ISC This can reducepower consumption and may reduce noise if the pin is used as analog input While configured to INPUT_DISABLEbit n in PORTxIN will not change since the input synchronizer is disabled
17323 Virtual PortsThe Virtual PORT registers map the most frequently used regular PORT registers into the IO Register space withsingle-cycle bit access Access to the Virtual PORT registers has the same outcome as access to the regularregisters but allows for memory specific instructions such as bit manipulation instructions which cannot be used inthe extended IO Register space where the regular PORT registers reside The following table shows the mappingbetween the PORT and VPORT registersTable 17-1 Virtual Port Mapping
Regular PORT Register Mapped to Virtual PORT Register
PORTxDIR VPORTxDIR
PORTxOUT VPORTxOUT
PORTxIN VPORTxIN
PORTxINTFLAGS VPORTxINTFLAGS
17324 Peripheral OverridePeripherals such as USARTs ADCs and timers may be connected to IO pins Such peripherals will usually have aprimary and optionally one or more alternate IO pin connections selectable by PORTMUX or a multiplexer insidethe peripheral By configuring and enabling such peripherals the general purpose IO pin behavior normallycontrolled by PORT will be overridden in a peripheral dependent way Some peripherals may not override all thePORT registers leaving the PORT module to control some aspects of the IO pin operation
Refer to the description of each peripheral for information on the peripheral override Any pin in a PORT that is notoverridden by a peripheral will continue to operate as a general purpose IO pin
1733 InterruptsTable 17-2 Available Interrupt Vectors and Sources
Name Vector Description Conditions
PORTx PORT interrupt INTn in PORTxINTFLAGS is raised as configured by the InputSense Configuration(ISC) bit in PORTxPINnCTRL
Each PORT pin n can be configured as an interrupt source Each interrupt can be individually enabled or disabled bywriting to ISC in PORTxPINnCTRL
When an interrupt condition occurs the corresponding interrupt flag is set in the Interrupt Flags register of theperipheral (peripheralINTFLAGS)
An interrupt request is generated when the corresponding interrupt source is enabled and the interrupt flag is setThe interrupt request remains active until the interrupt flag is cleared See the peripherals INTFLAGS register fordetails on how to clear interrupt flags
When setting or changing interrupt settings take these points into accountbull If an Inverted IO Enable (INVEN) bit is toggled in the same cycle as ISC is changed the edge caused by the
inversion toggling may not cause an interrupt requestbull If an input is disabled by writing to ISC 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 by writing to ISC while synchronizing an interrupt that interrupt may not be
requested
17331 Asynchronous Sensing Pin PropertiesAll PORT pins support asynchronous input sensing with interrupts for selectable pin change conditions Fullyasynchronous pin change sensing can trigger an interrupt and wake the device from all sleep modes includingmodes where the Peripheral Clock (CLK_PER) is stopped while partially asynchronous pin change sensing is limited
ATtiny212214412414 AutomotivePORT - IO Pin Configuration
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 127
as per the table below See the IO Multiplexing and Considerations section for further details on which pins supportfully asynchronous pin change sensing
Table 17-3 Behavior Comparison of Sense Pins
Property Partially Asynchronous Pins Fully Asynchronous Pins
Waking the device from sleepmodes with CLK_PER running From all interrupt sense configurations
From all interrupt senseconfigurationsWaking the device from sleep
modes with CLK_PER stoppedOnly from BOTHEDGES or LEVELinterrupt sense configurations
Minimum pulse-width to trigger aninterrupt with CLK_PER running Minimum one CLK_PER cycle
Less than one CLK_PER cycleMinimum pulse-width to trigger aninterrupt with CLK_PER stopped
The pin value must be kept untilCLK_PER has restarted(1)
Interrupt ldquodead-timerdquo No new interrupt for three CLK_PERcycles after the previous
Note 1 If a partially asynchronous input pin is used for wake-up from sleep with CLK_PER stopped the required level
must be held long enough for the MCU to complete the wake-up to trigger the interrupt If the level disappearsthe MCU can wake up without any interrupt generated
1734 EventsPORT can generate the following events
Table 17-4 Event Generators in PORTx
Generator NameDescription Event Type Generating Clock Domain Length of Event
Peripheral Event
PORTx PINn Pin level Level Asynchronous Given by pin level
All PORT pins are asynchronous event system generators PORT has as many event generators as there are PORTpins in the device Each event system output from PORT is the value present on the corresponding pin if the digitalinput buffer is enabled If a pin input buffer is disabled the corresponding event system output is zero
PORT has no event inputs Refer to the Event System (EVSYS) section for more details regarding event types andEvent System configuration
1735 Sleep Mode OperationExcept for interrupts and input synchronization all pin configurations are independent of sleep modes All pins canwake the device from sleep see the PORT Interrupt section for further details
Peripherals connected to the PORTs can be affected by sleep modes described in the respective peripheralsrsquo datasheet section
Important The PORTs will always use the Peripheral Clock (CLK_PER) Input synchronization will haltwhen this clock stops
1736 Debug OperationWhen the CPU is halted in Debug mode the PORT continues normal operation If the PORT is configured in a waythat requires it to be periodically serviced by the CPU through interrupts or similar improper operation or data lossmay result during debugging
ATtiny212214412414 AutomotivePORT - IO Pin Configuration
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 128
174 Register Summary - PORTx
Offset Name Bit Pos 7 6 5 4 3 2 1 0
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 - PORTx
ATtiny212214412414 AutomotivePORT - IO Pin Configuration
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 129
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 controls the output driver for each PORTx pinThis bit field does not control the digital input buffer The digital input buffer for pin n (Pxn) can be configured in theInputSense Configuration (ISC) bit field in the Pin n Control (PORTxPINnCTRL) registerThe available configuration for each bit n in this bit field is shown in the table belowValue Description0 Pxn is configured as an input-only pin and the output driver is disabled1 Pxn is configured as an output pin and the output driver is enabled
ATtiny212214412414 AutomotivePORT - IO Pin Configuration
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 130
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 controls the output driver for each PORTx pin without using a read-modify-write operationWriting a lsquo0rsquo to bit n in this bit field has no effectWriting a lsquo1rsquo to bit n in this bit field will set the corresponding bit in PORTxDIR which will configure pin n (Pxn) as anoutput pin and enable the output driverReading this bit field will return the value of PORTxDIR
ATtiny212214412414 AutomotivePORT - IO Pin Configuration
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 131
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 bit field controls the output driver for each PORTx pin without using a read-modify-write operationWriting a lsquo0rsquo to bit n in this bit field has no effectWriting a lsquo1rsquo to bit n in this bit field will clear the corresponding bit in PORTxDIR which will configure pin n (Pxn) asan input-only pin and disable the output driverReading this bit field will return the value of PORTxDIR
ATtiny212214412414 AutomotivePORT - IO Pin Configuration
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 132
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 controls the output driver for each PORTx pin without using a read-modify-write operationWriting a lsquo0rsquo to bit n in this bit field has no effectWriting a lsquo1rsquo to bit n in this bit field will toggle the corresponding bit in PORTxDIRReading this bit field will return the value of PORTxDIR
ATtiny212214412414 AutomotivePORT - IO Pin Configuration
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 133
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 controls the output driver level for each PORTx pinThis configuration only has an effect when the output driver (PORTxDIR) is enabled for the corresponding pinThe available configuration for each bit n in this bit field is shown in the table belowValue Description0 The pin n (Pxn) output is driven low1 The Pxn output is driven high
ATtiny212214412414 AutomotivePORT - IO Pin Configuration
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 134
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 controls the output driver level for each PORTx pin without using a read-modify-write operationWriting a lsquo0rsquo to bit n in this bit field has no effectWriting a lsquo1rsquo to bit n in this bit field will set the corresponding bit in PORTxOUT which will configure the output for pinn (Pxn) to be driven highReading this bit field will return the value of PORTxOUT
ATtiny212214412414 AutomotivePORT - IO Pin Configuration
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 135
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 bit field controls the output driver level for each PORTx pin without using a read-modify-write operationWriting a lsquo0rsquo to bit n in this bit field has no effectWriting a lsquo1rsquo to bit n in this bit field will clear the corresponding bit in PORTxOUT which will configure the output forpin n (Pxn) to be driven lowReading this bit field will return the value of PORTxOUT
ATtiny212214412414 AutomotivePORT - IO Pin Configuration
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 136
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 bit field controls the output driver level for each PORTx pin without using a read-modify-write operationWriting a lsquo0rsquo to bit n in this bit field has no effectWriting a lsquo1rsquo to bit n in this bit field will toggle the corresponding bit in PORTxOUTReading this bit field will return the value of PORTxOUT
ATtiny212214412414 AutomotivePORT - IO Pin Configuration
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 137
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 bit field shows the state of the PORTx pins when the digital input buffer is enabledWriting a lsquo0rsquo to bit n in this bit field has no effectWriting a lsquo1rsquo to bit n in this bit field will toggle the corresponding bit in PORTxOUTIf the digital input buffer is disabled the input is not sampled and the bit value will not change The digital input bufferfor pin n (Pxn) can be configured in the InputSense Configuration (ISC) bit field in the Pin n Control(PORTxPINnCTRL) registerThe available states of each bit n in this bit field is shown in the table belowValue Description0 The voltage level on Pxn is low1 The voltage level on Pxn is high
ATtiny212214412414 AutomotivePORT - IO Pin Configuration
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 138
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] Pin Interrupt FlagPin interrupt flag n is cleared by writing a lsquo1rsquo to itPin interrupt flag n is set when the change or state of pin n (Pxn) matches the pins InputSense Configuration (ISC)in PORTxPINnCTRLWriting a lsquo0rsquo to bit n in this bit field has no effectWriting a lsquo1rsquo to bit n in this bit field will clear Pin interrupt flag n
ATtiny212214412414 AutomotivePORT - IO Pin Configuration
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 139
17511 Pin n Control
Name PINnCTRLOffset 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 EnableThis bit controls whether the input and output for pin n are inverted or notValue Description0 Input and output values are not inverted1 Input and output values are inverted
Bit 3 ndash PULLUPEN Pull-up EnableThis bit controls whether the internal pull-up of pin n is enabled or not when the pin is configured as input-onlyValue Description0 Pull-up disabled1 Pull-up enabled
Bits 20 ndash ISC[20] InputSense ConfigurationThis bit field controls the input and sense configuration of pin n The sense configuration determines how a portinterrupt can be triggeredValue Name Description0x0 INTDISABLE Interrupt disabled but input buffer enabled0x1 BOTHEDGES Interrupt enabled with sense on both edges0x2 RISING Interrupt enabled with sense on rising edge0x3 FALLING Interrupt enabled with sense on falling edge0x4 INPUT_DISABLE Interrupt and digital input buffer disabled(1)
0x5 LEVEL Interrupt enabled with sense on low levelother mdash Reserved
Note 1 If the digital input buffer for pin n is disabled bit n in the Input Value (PORTxIN) register will not be updated
ATtiny212214412414 AutomotivePORT - IO Pin Configuration
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 140
176 Register Summary - VPORTx
Offset Name Bit Pos 7 6 5 4 3 2 1 0
0x00 DIR 70 DIR[70]0x01 OUT 70 OUT[70]0x02 IN 70 IN[70]0x03 INTFLAGS 70 INT[70]
177 Register Description - VPORTx
ATtiny212214412414 AutomotivePORT - IO Pin Configuration
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 141
1771 Data Direction
Name DIROffset 0x00Reset 0x00Property -
Access to the Virtual PORT registers has the same outcome as access to the regular registers but allows for memoryspecific instructions such as bit manipulation instructions which cannot be used in the extended IO Register spacewhere 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 controls the output driver for each PORTx pinThis bit field does not control the digital input buffer The digital input buffer for pin n (Pxn) can be configured in theInputSense Configuration (ISC) bit field in the Pin n Control (PORTxPINnCTRL) registerThe available configuration for each bit n in this bit field is shown in the table belowValue Description0 Pxn is configured as an input-only pin and the output driver is disabled1 Pxn is configured as an output pin and the output driver is enabled
ATtiny212214412414 AutomotivePORT - IO Pin Configuration
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 142
1772 Output Value
Name OUTOffset 0x01Reset 0x00Property -
Access to the Virtual PORT registers has the same outcome as access to the regular registers but allows for memoryspecific instructions such as bit manipulation instructions which cannot be used in the extended IO Register spacewhere 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 controls the output driver level for each PORTx pinThis configuration only has an effect when the output driver (PORTxDIR) is enabled for the corresponding pinThe available configuration for each bit n in this bit field is shown in the table belowValue Description0 The pin n (Pxn) output is driven low1 The Pxn output is driven high
ATtiny212214412414 AutomotivePORT - IO Pin Configuration
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 143
1773 Input Value
Name INOffset 0x02Reset 0x00Property -
Access to the Virtual PORT registers has the same outcome as access to the regular registers but allows for memoryspecific instructions such as bit manipulation instructions which cannot be used in the extended IO Register spacewhere 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 shows the state of the PORTx pins when the digital input buffer is enabledWriting a lsquo0rsquo to bit n in this bit field has no effectWriting a lsquo1rsquo to bit n in this bit field will toggle the corresponding bit in PORTxOUTIf the digital input buffer is disabled the input is not sampled and the bit value will not change The digital input bufferfor pin n (Pxn) can be configured in the InputSense Configuration (ISC) bit field in the Pin n Control(PORTxPINnCTRL) registerThe available states of each bit n in this bit field is shown in the table belowValue Description0 The voltage level on Pxn is low1 The voltage level on Pxn is high
ATtiny212214412414 AutomotivePORT - IO Pin Configuration
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 144
1774 Interrupt Flags
Name INTFLAGSOffset 0x03Reset 0x00Property -
Access to the Virtual PORT registers has the same outcome as access to the regular registers but allows for memoryspecific instructions such as bit manipulation instructions which cannot be used in the extended IO Register spacewhere the regular PORT registers reside
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] Pin Interrupt FlagPin interrupt flag n is cleared by writing a lsquo1rsquo to itPin interrupt flag n is set when the change or state of pin n (Pxn) matches the pins InputSense Configuration (ISC)in PORTxPINnCTRLWriting a lsquo0rsquo to bit n in this bit field has no effectWriting a lsquo1rsquo to bit n in this bit field will clear Pin interrupt flag n
ATtiny212214412414 AutomotivePORT - IO Pin Configuration
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 145
18 BOD - Brown-out Detector
181 Featuresbull Brown-out Detector Monitors the Power Supply to Avoid Operation Below a Programmable Levelbull Three Available Modes
ndash Enabled mode (continuously active)ndash Sampled modendash 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 supply voltage with the programmablebrown-out threshold level The brown-out threshold level defines when to generate a System Reset The VoltageLevel Monitor (VLM) monitors the power supply and compares it to a threshold higher than the BOD threshold TheVLM can then generate an interrupt as an ldquoearly warningrdquo when the supply voltage is approaching the BOD thresholdThe VLM threshold level is expressed as a percentage above the BOD threshold level
The BOD is controlled mainly by fuses and has to be enabled by the user The mode used in Standby sleep modeand Power-Down sleep mode can be altered in normal program execution The VLM is controlled by IO registers aswell
When activated the BOD can operate in Enabled mode where the BOD is continuously active or in Sampled modewhere the BOD is activated briefly at a given period to check the supply voltage level
ATtiny212214412414 AutomotiveBOD - Brown-out Detector
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 146
1821 Block DiagramFigure 18-1 BOD Block Diagram
VDD
+
-
+
-
BOD
VLM
BODReset
VLMInterrupt
BOD Threshold
VLM Threshold
183 Functional Description
1831 InitializationThe BOD settings are loaded from fuses during Reset The BOD level and operating mode in Active and Idle sleepmode are set by fuses and cannot be changed by software The operating mode in Standby and Power-Down sleepmode is loaded from fuses and can be changed by software
The Voltage Level Monitor function can be enabled by writing a lsquo1rsquo to the VLM Interrupt Enable (VLMIE) bit in theInterrupt Control (BODINTCTRL) register The VLM interrupt is configured by writing the VLM Configuration(VLMCFG) bits in BODINTCTRL An interrupt is requested when the supply voltage crosses the VLM thresholdeither from above below or any direction
The VLM functionality will follow the BOD mode If the BOD is disabled the VLM will not be enabled even if theVLMIE is lsquo1rsquo If the BOD is using Sampled mode the VLM will also be sampled When the VLM interrupt is enabledthe interrupt flag will be set according to VLMCFG when the voltage level is crossing the VLM level
The VLM threshold is defined by writing the VLM Level (VLMLVL) bits in the Control A (BODVLMCTRLA) register
1832 InterruptsTable 18-1 Available Interrupt Vectors and Sources
Name Vector Description Conditions
VLM Voltage Level Monitor Supply voltage crossing the VLM threshold as configured by the VLM Configuration(VLMCFG) bit field in the Interrupt Control (BODINTCTRL) register
ATtiny212214412414 AutomotiveBOD - Brown-out Detector
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 147
The VLM interrupt will not be executed if the CPU is halted in Debug mode
When an interrupt condition occurs the corresponding interrupt flag is set in the peripheralrsquos Interrupt Flags(peripheralINTFLAGS) register
An interrupt source is enabled or disabled by writing to the corresponding enable bit in the peripheralrsquos InterruptControl (peripheralINTCTRL) register
An interrupt request is generated when the corresponding interrupt source is enabled and the interrupt flag is setThe interrupt request remains active until the interrupt flag is cleared See the peripheralrsquos INTFLAGS register fordetails on how to clear interrupt flags
1833 Sleep Mode OperationThe BOD configuration in the different sleep modes is defined by fuses The mode used in Active mode and Idlesleep mode is defined by the ACTIVE fuses in FUSEBODCFG which is loaded into the ACTIVE bit field in theControl A (BODCTRLA) register The mode used in Standby sleep mode and Power-Down sleep mode is defined bySLEEP in FUSEBODCFG which is loaded into the SLEEP bit field in the Control A (BODCTRLA) register
The operating mode in Active mode and Idle sleep mode (ie ACTIVE in BODCTRLA) cannot be altered bysoftware The operating mode in Standby sleep mode and Power-Down sleep mode can be altered by writing to theSLEEP bit field in the Control A (BODCTRLA) register
When the device is going into Standby or Power-Down sleep mode the BOD will change the operation mode asdefined by SLEEP in BODCTRLA When the device is waking up from Standby or Power-Down sleep mode theBOD will operate in the mode defined by the ACTIVE bit field in the Control A (BODCTRLA) register
1834 Configuration Change ProtectionThis peripheral has registers that are under Configuration Change Protection (CCP) To write to these registers acertain key must first be written to the CPUCCP register followed by a write access to the protected bits within fourCPU instructions
Attempting to write to a protected register without following the appropriate CCP unlock sequence leaves theprotected register unchanged
The following registers are under CCP
Table 18-2 Registers Under Configuration Change Protection
Register Key
SLEEP in BODCTRLA IOREG
ATtiny212214412414 AutomotiveBOD - Brown-out Detector
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 148
184 Register Summary
Offset Name Bit Pos 7 6 5 4 3 2 1 0
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
ATtiny212214412414 AutomotiveBOD - Brown-out Detector
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 149
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 controls the BOD sample frequencyThe Reset value is loaded from the SAMPFREQ bit in FUSEBODCFGThis bit is not under Configuration Change 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 bit field in FUSEBODCFGThis bit field is not under Configuration Change Protection (CCP)Value Name Description0x0 DIS Disabled0x1 ENABLED Enabled in continuous mode0x2 SAMPLED Enabled in sampled mode0x3 ENWAKE Enabled in continuous mode Execution is halted at wake-up until BOD is running
Bits 10 ndash SLEEP[10] SleepThese bits select the BOD operation mode when the device is in Standby or Power-Down sleep mode The Resetvalue is loaded from the SLEEP bit field in FUSEBODCFGValue Name Description0x0 DIS Disabled0x1 ENABLED Enabled in continuous mode0x2 SAMPLED Enabled in sampled mode0x3 - Reserved
ATtiny212214412414 AutomotiveBOD - Brown-out Detector
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 150
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 LevelThis bit field controls the BOD threshold levelThe Reset value is loaded from the BOD Level (LVL) bits in the BOD Configuration Fuse (FUSEBODCFG)Value Name Description0x2 BODLEVEL2 26V0x7 BODLEVEL7 42V
Notes bull Refer to the BOD and POR Characteristics in Electrical Characteristics for further detailsbull Values in the description are typical values
ATtiny212214412414 AutomotiveBOD - Brown-out Detector
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 151
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
ATtiny212214412414 AutomotiveBOD - Brown-out Detector
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 152
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 Name Description0x0 BELOW VDD falls below VLM threshold0x1 ABOVE VDD rises above VLM threshold0x2 CROSS VDD crosses VLM thresholdOther - Reserved
Bit 0 ndash VLMIE VLM Interrupt EnableWriting a lsquo1rsquo to this bit enables the VLM interrupt
ATtiny212214412414 AutomotiveBOD - Brown-out Detector
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 153
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 the BODINTCTRL registerThe flag is only updated when the BOD is enabled
ATtiny212214412414 AutomotiveBOD - Brown-out Detector
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 154
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
ATtiny212214412414 AutomotiveBOD - Brown-out Detector
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 155
19 VREF - Voltage Reference
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 sources used byseveral peripherals The user can select the reference voltages for the ADC0 by writing to the ADC0 ReferenceSelect (ADC0REFSEL) bit field in the Control A (VREFCTRLA) register and for both AC0 and DAC0 by writing to theDAC0 Reference Select (DAC0REFSEL) bit field in the Control A (VREFCTRLA) register
A voltage reference source is enabled automatically when requested by a peripheral The user can enable thereference voltage sources (and thus override the automatic disabling of unused sources) by writing to the respectiveForce Enable (ADC0REFEN DAC0REFEN) bit in the Control B (VREFCTRLB) register This may be done todecrease start-up time at the cost of increased power consumption
1921 Block DiagramFigure 19-1 VREF Block Diagram
Reference se lect
ReferenceGenerator
InternalReferenceBUF
11V15V25V43V
055V
Reference enable
Reference request
enable
Band gap
Band gap
193 Functional Description
1931 InitializationThe default configuration will enable the respective source when the ADC0 AC0 or DAC0 is requesting a referencevoltage The default reference voltages are 055V but can be configured by writing to the respective Reference Select(ADC0REFSEL DAC0REFSEL) bit field in the Control A (VREFCTRLA) register
ATtiny212214412414 AutomotiveVREF - Voltage Reference
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 156
194 Register Summary
Offset Name Bit Pos 7 6 5 4 3 2 1 0
0x00 CTRLA 70 ADC0REFSEL[20] DAC0REFSEL[20]0x01 CTRLB 70 ADC0REFEN DAC0REFEN
195 Register Description
ATtiny212214412414 AutomotiveVREF - Voltage Reference
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 157
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 SelectThis bit field selects the reference voltage for the ADC0Value Description0x0 055V0x1 11V0x2 25V0x3 43V0x4 15Vother Reserved
Bits 20 ndash DAC0REFSEL[20] DAC0 and AC0 Reference SelectThis bit field selects the reference voltage for the DAC0 and AC0Value Description0x0 055V0x1 11V0x2 25V0x3 43V0x4 15Vother Reserved
ATtiny212214412414 AutomotiveVREF - Voltage Reference
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 158
1952 Control B
Name CTRLBOffset 0x01Reset 0x00Property -
Bit 7 6 5 4 3 2 1 0 ADC0REFEN DAC0REFEN
Access RW RW Reset 0 0
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 peripheral
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 not requestedWriting a 0 to this bit allows automatic enabledisable of the reference source by the peripheral
ATtiny212214412414 AutomotiveVREF - Voltage Reference
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 159
20 WDT - Watchdog Timer
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 1024 kHz Output of the 32768 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 the system torecover from situations such as runaway or deadlocked code by issuing a Reset When enabled the WDT is aconstantly running timer configured to a predefined time-out period If the WDT is not reset within the time-out periodit will issue a system Reset The WDT is reset by executing the Watchdog Timer Reset (WDR) instruction fromsoftware
The WDT has two modes of operation Normal mode and Window mode The settings in the Control A (WDTCTRLA)register determine the mode of operation
A Window mode defines a time slot or window inside the time-out period during which the WDT must be reset If theWDT is reset outside this window either too early or too late a system Reset will be issued Compared to the Normalmode the Window mode can catch situations where a code error causes constant WDR execution
When enabled the WDT will run in Active mode and all sleep modes It is asynchronous (ie running from a CPUindependent clock source) For this reason it will continue to operate and be able to issue a system Reset even if themain clock fails
The CCP mechanism ensures that the WDT settings cannot be changed by accident For increased safety aconfiguration for locking the WDT settings is available
ATtiny212214412414 AutomotiveWDT - Watchdog Timer
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 160
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
203 Functional Description
2031 Initializationbull The WDT is enabled when a non-zero value is written to the Period (PERIOD) bits in the Control A
(WDTCTRLA) registerbull Optional Write a non-zero value to the Window (WINDOW) bits in WDTCTRLA to enable the Window mode
operation
All bits in the Control A register and the Lock (LOCK) bit in the STATUS (WDTSTATUS) register are write-protectedby the Configuration Change Protection mechanism
The Reset value of WDTCTRLA is defined by a fuse (FUSEWDTCFG) so the WDT can be enabled at boot time Ifthis is the case the LOCK bit in WDTSTATUS is set at boot time
2032 ClocksA 1024 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 exact time-out periodmay vary from device to device This variation must be kept in mind when designing software that uses the WDT toensure that the time-out periods used are valid for all devices
The 1024 kHz Oscillator 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
2033 Operation
20331 Normal ModeIn Normal mode operation a single time-out period is set for the WDT If the WDT is not reset from software using theWDR 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 Period (PERIOD)bit field in the Control A (WDTCTRLA) register
ATtiny212214412414 AutomotiveWDT - Watchdog Timer
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 161
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 (WDTCTRLA) register is 0x0
20332 Window ModeIn Window mode operation the WDT uses two different time-out periods A closed Window Time-out period(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 be reset If theWDT 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 period during whichthe WDT can (and needs to) be reset The open period will always follow the closed period so the total durationof the time-out period is the sum of the closed window and the open window time-out periods
When enabling Window mode or when going out of Debug mode the first closed period is activated after the first WDRinstruction
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 A (WDTCTRLA)register and disabled by writing it to 0x0
20333 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-write procedure forchanging the WDT control registers
The second mechanism locks the configuration by writing a lsquo1rsquo to the LOCK bit in the STATUS (WDTSTATUS)register When this bit is lsquo1rsquo the Control A (WDTCTRLA) register cannot be changed Consequently the WDT cannotbe disabled from the software
ATtiny212214412414 AutomotiveWDT - Watchdog Timer
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 162
LOCK in WDTSTATUS can only be written to lsquo1rsquo It can only be cleared in Debug mode
If the WDT configuration is loaded from fuses LOCK is automatically set in WDTSTATUS
2034 Sleep Mode OperationThe WDT will continue to operate in any sleep mode where the source clock is Active
2035 Debug OperationWhen run-time debugging this peripheral will continue normal operation Halting the CPU in Debugging mode willhalt the 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 willbe disabled and a Normal mode time-out period is executed
2036 SynchronizationDue to asynchronicity between the main clock domain and the peripheral clock domain the Control A (WDTCTRLA)register is synchronized when written The Synchronization Busy (SYNCBUSY) flag in the STATUS (WDTSTATUS)register 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 (WDTCTRLA) registerbull Window Period (WINDOW) bits in WDTCTRLA
The WDR instruction will need two to three cycles of the WDT clock to be synchronized Issuing a new WDR instructionwhile a WDR instruction is being synchronized will be ignored
2037 Configuration Change ProtectionThis peripheral has registers that are under Configuration Change Protection (CCP) To write to these registers acertain key must first be written to the CPUCCP register followed by a write access to the protected bits within fourCPU instructions
Attempting to write to a protected register without following the appropriate CCP unlock sequence leaves theprotected register unchanged
The following registers are under CCP
Table 20-1 WDT - Registers Under Configuration Change Protection
Register Key
WDTCTRLA IOREG
LOCK bit in WDTSTATUS IOREG
List of bitsregisters protected by CCP
bull Period bits in Control A (CTRLAPERIOD) registerbull Window Period bits in Control A (CTRLAWINDOW) registerbull LOCK bit in STATUS (STATUSLOCK) register
ATtiny212214412414 AutomotiveWDT - Watchdog Timer
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 163
204 Register Summary - WDT
Offset Name Bit Pos 7 6 5 4 3 2 1 0
0x00 CTRLA 70 WINDOW[30] PERIOD[30]0x01 STATUS 70 LOCK SYNCBUSY
205 Register Description
ATtiny212214412414 AutomotiveWDT - Watchdog Timer
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 164
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 closed periodaccordinglyThe bits are optionally lock-protected
bull If LOCK bit in WDTSTATUS is lsquo1rsquo all bits are change-protected (Access = R)bull If LOCK bit in WDTSTATUS is lsquo0rsquo all bits can be changed (Access = RW)
Value Name Description0x0 OFF -0x1 8CLK 0008s0x2 16CLK 0016s0x3 32CLK 0031s0x4 64CLK 0063s0x5 128CLK 0125s0x6 256CLK 025s0x7 512CLK 05s0x8 1KCLK 1s0x9 2KCLK 2s0xA 4KCLK 4s0xB 8KCLK 8sother - 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 mode accordingly InWindow mode these bits select the duration of the open windowThe bits are optionally lock-protected
bull If LOCK in WDTSTATUS is lsquo1rsquo all bits are change-protected (Access = R)bull If LOCK in WDTSTATUS is lsquo0rsquo all bits can be changed (Access = RW)
Value Name Description0x0 OFF -0x1 8CLK 0008s0x2 16CLK 0016s0x3 32CLK 0031s0x4 64CLK 0063s0x5 128CLK 0125s0x6 256CLK 025s0x7 512CLK 05s0x8 1KCLK 1s0x9 2KCLK 2s0xA 4KCLK 4s0xB 8KCLK 8sother - Reserved
ATtiny212214412414 AutomotiveWDT - Watchdog Timer
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 165
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 lsquo1rsquo write-protects the WDTCTRLA registerIt is only possible to write this bit to lsquo1rsquo This bit can be cleared in Debug mode onlyIf the PERIOD bits in WDTCTRLA are different from zero after boot code the lock will be automatically setThis 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 the system clockdomain to the WDT clock domainThis bit is cleared by the system after the synchronization is finishedThis bit is not under CCP
ATtiny212214412414 AutomotiveWDT - Watchdog Timer
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 166
21 TCA - 16-bit TimerCounter Type A
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 timing frequency andwaveform generation and command execution
A TCA consists of a base counter and a set of compare channels The base counter can be used to count clockcycles or events or let events control how it counts clock cycles It has direction control and period setting that canbe used for timing The compare channels can be used together with the base counter to do compare match controlfrequency generation and pulse-width waveform modulation
Depending on the mode of operation the counter is cleared reloaded incremented or decremented at each timercounter clock or event input
A timercounter can be clocked and timed from the peripheral clock with optional prescaling or from the EventSystem 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 into two 8-bittimercounters with three compare channels each
A block diagram of the 16-bit timercounter with closely related peripheral modules (in grey) is shown in the figurebelow
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 167
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
2121 Block DiagramThe figure below shows a detailed block diagram of the timercounter
Figure 21-2 TimerCounter Block Diagram
Base Counter
Compare Unit n
Counter
=
CMPn
CMPnBUF
WaveformGeneration
BV
=
PERBUF
PER
CNT
BV
=0
lsquolsquocountrsquorsquo
lsquolsquoclearrsquorsquo
lsquolsquodirectionrsquorsquo
lsquolsquoloadrsquorsquoControl Logic
OVF(INT Req and Event)
TOP
lsquolsquomatchrsquorsquo CMPn(INT Req and Event)
Control Logic
Clock Select
UP
DA
TE
BOTTOM
WOn Out
Event
CTRLA
CTRLB
EVCTRL
Mode
EventAction
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 168
The Counter (TCAnCNT) register Period and Compare (TCAnPER and TCAnCMPn) registers and theircorresponding buffer registers (TCAnPERBUF and TCAnCMPnBUF) are 16-bit registers All buffer registers have aBuffer Valid (BV) flag that indicates when the buffer contains a new value
During normal operation the counter value is continuously compared to zero and the period (PER) value todetermine whether the counter has reached TOP or BOTTOM The counter value can also be compared to theTCAnCMPn registers
The timercounter can generate interrupt requests events or change the waveform output after being triggered bythe Counter (TCAnCNT) register reaching TOP BOTTOM or CMPn The interrupt requests events or waveformoutput changes will occur on the next CLK_TCA cycle after the triggering
CLK_TCA is either the prescaled peripheral clock or events from the Event System as shown in the figure below
Figure 21-3 TimerCounter Clock Logic
CLKSEL
CNTxEI
CLK_PER
Event
Event SystemPrescaler
CNT
(Encoding)EVACT
CLK_TCA
2122 Signal Description
Signal Description Type
WOn Digital output Waveform output
213 Functional Description
2131 DefinitionsThe following definitions are used throughout the documentation
Table 21-1 TimerCounter Definitions
Name Description
BOTTOM The counter reaches BOTTOM when it becomes 0x0000
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 count sequence
UPDATEThe update condition is met when the timercounter reaches BOTTOM or TOP depending on theWaveform Generator mode Buffered registers with valid buffer values will be updated unless the LockUpdate (LUPD) bit in the TCAnCTRLE register has been set
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 169
continuedName Description
CNT Counter register value
CMP Compare register value
PER Period register value
In general the term timer is used when the timercounter is counting periodic clock ticks The term counter is usedwhen the input signal has sporadic or irregular ticks The latter can be the case when counting events
2132 InitializationTo start using the timercounter in a basic mode follow these steps
1 Write a TOP value to the Period (TCAnPER) register2 Enable the peripheral by writing a lsquo1rsquo to the ENABLE bit in the Control A (TCAnCTRLA) register
The counter will start counting clock ticks according to the prescaler setting in the Clock Select (CLKSEL) bitfield in the TCAnCTRLA register
3 Optional By writing a lsquo1rsquo to the Enable Count on Event Input (CNTEI) bit in the Event Control (TCAnEVCTRL)register events are counted instead of clock ticks
4 The counter value can be read from the Counter (CNT) bit field in the Counter (TCAnCNT) register
2133 Operation
21331 Normal OperationIn normal operation the counter is counting clock ticks in the direction selected by the Direction (DIR) bit in theControl E (TCAnCTRLE) register until it reaches TOP or BOTTOM The clock ticks are given by the peripheral clock(CLK_PER) prescaled according to the Clock Select (CLKSEL) bit field in the Control A (TCAnCTRLA) register
When TOP is reached while the counter is counting up the counter will wrap to lsquo0rsquo at the next clock tick Whencounting down the counter is reloaded with the Period (TCAnPER) register value when BOTTOM is reached
Figure 21-4 Normal OperationCNT written
lsquolsquoupdatersquorsquo
CNT
DIR
MAX
TOP
BOTTOM
It is possible to change the counter value in the Counter (TCAnCNT) register when the counter is running The writeaccess to TCAnCNT has higher priority than count clear or reload and will be immediate The direction of thecounter can also be changed during normal operation by writing to DIR in TCAnCTRLE
21332 Double BufferingThe Period (TCAnPER) register value and the Compare n (TCAnCMPn) register values are all double-buffered(TCAnPERBUF and TCAnCMPnBUF)
Each buffer register has a Buffer Valid (BV) flag (PERBV CMPnBV) in the Control F (TCAnCTRLF) register whichindicates that the buffer register contains a valid (new) value that can be copied into the corresponding Period orCompare register When the Period register and Compare n registers are used for a compare operation the BV flagis set when data are written to the buffer register and cleared on an UPDATE condition This is shown for a Compare(CMPn) register in the figure below
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 170
Figure 21-5 Period and Compare Double Buffering
UPDATE
lsquolsquowrite enablersquorsquo lsquolsquodata writersquorsquo
CNT
lsquolsquomatchrsquorsquo
EN
EN
CMPnBUF
CMPn
BV
=
Both the TCAnCMPn and TCAnCMPnBUF registers are available as IO registers This allows initialization andbypassing 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 (TCAnPER) register
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 wrap-around
lsquolsquoupdatersquorsquo
lsquolsquowritersquorsquo
New TOP written toPER that is higherthan current CNT
New TOP written toPER that is lowerthan current CNT
A counter wrap-around can occur in any mode of operation when counting up without buffering as the TCAnCNTand TCAnPER registers are continuously compared If a new TOP value is written to TCAnPER that is lower thanthe current TCAnCNT the counter will wrap first before a compare match occursFigure 21-7 Unbuffered Dual-Slope Operation
Counter wrap-around
lsquolsquoupdatersquorsquo
lsquolsquowritersquorsquo
MAX
BOTTOM
CNT
New TOP written toPER that is higherthan current CNT
New TOP written toPER that is lowerthan current CNT
With Buffering When double-buffering is used the buffer can be written at any time and still maintain correctoperation The TCAnPER is always updated on the UPDATE condition as shown for dual-slope operation in thefigure below This prevents wrap-around and the generation of odd waveforms
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 171
Figure 21-8 Changing the Period Using Buffering
CNT
BOTTOM
MAX
lsquolsquoupdatersquorsquo
lsquolsquowritersquorsquo
New Period written toPERB that is higherthan current CNT
New Period written toPERB that is lowerthan current CNT
New PER is updatedwith PERB value
Note Buffering is used in figures illustrating TCA operation if not otherwise specified
21334 Compare ChannelEach Compare Channel n continuously compares the counter value (TCAnCNT) with the Compare n (TCAnCMPn)register If TCAnCNT equals TCAnCMPn the Comparator n signals a match The match will set the CompareChannelrsquos interrupt flag at the next timer clock cycle and the optional interrupt is generated
The Compare n Buffer (TCAnCMPnBUF) register provides double-buffer capability equivalent to that for the periodbuffer The double-buffering synchronizes the update of the TCAnCMPn register with the buffer value to either theTOP or BOTTOM of the counting sequence according to the UPDATE condition The synchronization prevents theoccurrence 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 The followingrequirements must be met to make the waveform visible on the connected port pin
1 A Waveform Generation mode must be selected by writing the WGMODE bit field in TCAnCTRLB2 The compare channels used must be enabled (CMPnEN = 1 in TCAnCTRLB) This will override the output
value for the corresponding pin An alternative pin can be selected by configuring the Port Multiplexer(PORTMUX) Refer to the PORTMUX chapter for details
3 The direction for the associated port pin n must be configured as an output (PORTxDIR[n] = 1)4 Optional Enable the inverted waveform output for the associated port pin n (INVEN = 1 in PORTxPINnCTRL)
213342 Frequency (FRQ) Waveform GenerationFor frequency generation the period time (T) is controlled by the TCAnCMP0 register instead of the Period(TCAnPER) register The corresponding waveform generator output is toggled on each compare match between theTCAnCNT and TCAnCMPn registers
Figure 21-9 Frequency Waveform Generation
CNT
WG Output
MAX
TOP
BOTTOM
Period (T) Direction change CNT written
lsquolsquoupdatersquorsquo
The waveform frequency (fFRQ) is defined by the following equationFRQ = fCLK_PER2 CMPn+1
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 172
where N represents the prescaler divider used (see the CLKSEL bit field in the TCAnCTRLA register) and fCLK_PERis the peripheral clock frequency
The maximum frequency of the waveform generated is half of the peripheral clock frequency (fCLK_PER2) whenTCAnCMP0 is written to 0x0000 and no prescaling is used (N = 1 CLKSEL = 0x0 in TCAnCTRLA)
213343 Single-Slope PWM GenerationFor single-slope Pulse-Width Modulation (PWM) generation the period (T) is controlled by the TCAnPER registerwhile the values of the TCAnCMPn registers control the duty cycles of the generated waveforms The figure belowshows how the counter counts from BOTTOM to TOP and then restarts from BOTTOM The waveform generatoroutput is set at BOTTOM and cleared on the compare match between the TCAnCNT and TCAnCMPn registers
CMPn = BOTTOM will produce a static low signal on WOn while CMPn gt TOP will produce a static high signal onWOn
Figure 21-10 Single-Slope Pulse-Width Modulation
CNT
Output WOn
MAXTOP
CMPn
BOTTOM
Period (T) CMPn=BOTTOM CMPngtTOP lsquolsquoupdatersquorsquolsquolsquomatchrsquorsquo
The TCAnPER register defines the PWM resolution The minimum resolution is 2 bits (TCAnPER = 0x0002) andthe maximum resolution is 16 bits (TCAnPER = MAX-1)
The following equation calculates the exact resolution in bits for single-slope PWM (RPWM_SS)PWM_SS = log PER+2log 2The single-slope PWM frequency (fPWM_SS) depends on the period setting (TCAnPER) the peripheral clockfrequency fCLK_PER and the TCA prescaler (the CLKSEL bit field in the TCAnCTRLA register) It is calculated by thefollowing equation where N represents the prescaler divider usedPWM_SS = CLK_PER PER+1
213344 Dual-Slope PWMFor dual-slope PWM generation the period (T) is controlled by TCAnPER while the values of TCAnCMPn controlthe duty cycle of the WG output
The figure below shows how for dual-slope PWM the counter counts repeatedly from BOTTOM to TOP and thenfrom TOP to BOTTOM The waveform generator output is set at BOTTOM cleared on compare match when up-counting and set on compare match when down-counting
CMPn = BOTTOM will produce a static low signal on WOn while CMPn = TOP will produce a static high signal onWOn
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 173
Figure 21-11 Dual-Slope Pulse-Width Modulation
MAX
TOP
BOTTOM
CNT
Waveform Output WOn
Period (T) CMPn=BOTTOM CMPn=TOP lsquolsquoupdatersquorsquolsquolsquomatchrsquorsquo
CMPn
Using dual-slope PWM results in half the maximum operation frequency compared to single-slope PWM operationdue to twice the number of timer increments per period
The Period (TCAnPER) register 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 in bits for dual-slope PWM (RPWM_DS)PWM_DS = log PER+1log 2The PWM frequency depends on the period setting in the TCAnPER register the peripheral clock frequency(fCLK_PER) and the prescaler divider selected in the CLKSEL bit field in the TCAnCTRLA register It is calculated bythe following equationPWM_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 be set asoutput (PORTxDIR[n] = 1) The TCA will override the port pin values when the compare channel is enabled(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 the port pinoutput 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
21335 TimerCounter CommandsA set of commands can be issued by software to immediately change the state of the peripheral These commandsgive direct control of the UPDATE RESTART and RESET signals A command is issued by writing the respectivevalue to the Command (CMD) bit field in the Control E (TCAnCTRLESET) register
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 (LUPD) bit in the Control E (TCAnCTRLE) register
The software can force a restart of the current waveform period by issuing a RESTART command In this case thecounter direction and all compare outputs are set to lsquo0rsquo
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 174
A RESET command will set all timercounter registers to their initial values A RESET command can be issued onlywhen the timercounter is not running (ENABLE = 0 in the TCAnCTRLA register)
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 Split mode the 16-bittimercounter acts as two separate 8-bit timers which each have three compare channels for PWM generation TheSplit mode will only work with single-slope down-count Event controlled operation is not supported in Split mode
Activating Split mode results in changes to the functionality of some registers and register bits The modifications aredescribed in a separate register map (see 216 Register Summary - Split Mode)
Split Mode Differences Compared to Normal Modebull Count
ndash Down-count onlyndash Low Byte Timer Counter (TCAnLCNT) register and High Byte Timer Counter (TCAnHCNT) register are
independentbull Waveform Generation
ndash Single-slope PWM only (WGMODE = SINGLESLOPE in TCAnCTRLB)bull Interrupt
ndash No change for Low Byte Timer Counter (TCAnLCNT) registerndash Underflow interrupt for High Byte Timer Counter (TCAnHCNT) registerndash No compare interrupt or flag for High Byte Compare n (TCAnHCMPn) register
bull Event Actions Not Compatiblebull Buffer Registers and Buffer Valid Flags Unusedbull Register Access Byte Access to All Registers
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 175
Block DiagramFigure 21-13 TimerCounter Block Diagram Split Mode
Control Logic
lsquolsquo
lsquolsquo
lsquolsquo
lsquolsquo
lsquolsquo
lsquolsquo
Split Mode InitializationWhen shifting between Normal mode and Split mode the functionality of some registers and bits changes but theirvalues 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 mode to avoid unexpected behavior
To start using the timercounter in basic Split mode after a hard Reset follow these steps1 Enable Split mode by writing a lsquo1rsquo to the Split mode enable (SPLITM) bit in the Control D (TCAnCTRLD)
register2 Write a TOP value to the Period (TCAnPER) registers3 Enable the peripheral by writing a lsquo1rsquo to the Enable (ENABLE) bit in the Control A (TCAnCTRLA) register
The counter will start counting clock ticks according to the prescaler setting in the Clock Select (CLKSEL) bitfield in the TCAnCTRLA register
4 The counter values can be read from the Counter bit field in the Counter (TCAnCNT) registers
2134 EventsThe TCA can generate the events described in the table below All event generators except TCAn_HUNF are sharedbetween Normal mode and Split mode operation
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 176
Table 21-2 Event Generators in TCA
Generator NameDescription Event
TypeGenerating
Clock Domain Length of EventPeripheral Event
TCAn
OVF_LUNFNormal mode Overflow
Split mode Low byte timer underflowPulse CLK_PER One CLK_PER
period
HUNFNormal mode Not available
Split mode High byte timer underflowPulse CLK_PER One CLK_PER
period
CMP0
Normal mode Compare Channel 0match
Split mode Low byte timer CompareChannel 0 match
Pulse CLK_PER One CLK_PERperiod
CMP1
Normal mode Compare Channel 1match
Split mode Low byte timer CompareChannel 1 match
Pulse CLK_PER One CLK_PERperiod
CMP2
Normal mode Compare Channel 2match
Split mode Low byte timer CompareChannel 2 match
Pulse CLK_PER One CLK_PERperiod
Note The conditions for generating an event are identical to those that will raise the corresponding interrupt flag inthe TCAnINTFLAGS register for both Normal mode and Split mode
The TCA has one event user for detecting and acting upon input events The table below describes the event userand the associated functionalityTable 21-3 Event User in TCA
User Name Description Input Detection AsyncSync
TCAn
Count on a positive eventedge Edge Sync
Count on any event edge Edge Sync
Count while the eventsignal is high Level Sync
The event level controlscount direction up whenlow and down when high
Level Sync
The specific actions described in the table above are selected by writing to the Event Action Event Action (EVACT)bits in the Event Control (TCAnEVCTRL) register Input events are enabled by writing a lsquo1rsquo to the Enable Count onEvent Input (CNTEI) bit in the Event Control (TCAnEVCTRL) register
Event inputs are not used in Split mode
Refer to the Event System (EVSYS) chapter for more details regarding event types and Event System configuration
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 177
2135 InterruptsTable 21-4 Available Interrupt Vectors and Sources in Normal Mode
Name Vector Description Conditions
OVF Overflow or underflow interrupt The counter has reached TOP or BOTTOM
CMP0 Compare Channel 0 interrupt Match between the counter value and the Compare 0 register
CMP1 Compare Channel 1 interrupt Match between the counter value and the Compare 1 register
CMP2 Compare Channel 2 interrupt Match between the counter value and the Compare 2 register
Table 21-5 Available Interrupt Vectors and Sources in Split Mode
Name Vector Description Conditions
LUNF Low-byte Underflow interrupt Low byte timer reaches BOTTOM
HUNF High-byte Underflow interrupt High byte timer reaches BOTTOM
LCMP0 Compare Channel 0 interrupt Match between the counter value and the low byte of the Compare 0register
LCMP1 Compare Channel 1 interrupt Match between the counter value and the low byte of the Compare 1register
LCMP2 Compare Channel 2 interrupt Match between the counter value and the low byte of the Compare 2register
When an interrupt condition occurs the corresponding interrupt flag is set in the peripheralrsquos Interrupt Flags(peripheralINTFLAGS) register
An interrupt source is enabled or disabled by writing to the corresponding enable bit in the peripheralrsquos InterruptControl (peripheralINTCTRL) register
An interrupt request is generated when the corresponding interrupt source is enabled and the interrupt flag is setThe interrupt request remains active until the interrupt flag is cleared See the peripheralrsquos INTFLAGS register fordetails on how to clear interrupt flags
2136 Sleep Mode OperationThe timercounter will continue operation in Idle sleep mode
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 178
214 Register Summary - Normal Mode
Offset Name Bit Pos 7 6 5 4 3 2 1 0
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[20] 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 CMP0BUF70 CMPBUF[70]158 CMPBUF[158]
0x3A CMP1BUF70 CMPBUF[70]158 CMPBUF[158]
0x3C CMP2BUF70 CMPBUF[70]158 CMPBUF[158]
215 Register Description - Normal Mode
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 179
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_PER0x1 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
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 180
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 and PWM Waveform Generation modes the Compare n Enable (CMPnEN) bits will make the waveformoutput available on the pin corresponding to WOn overriding the value in the corresponding PORT output registerThe corresponding pin direction must be configured as an output in the PORT peripheralValue Description0 Waveform output WOn will not be available on the corresponding pin1 Waveform output WOn will override the output value of the corresponding pin
Bit 3 ndash ALUPD Auto-Lock UpdateThe Auto-Lock Update bit controls the Lock Update (LUPD) bit in the TCAnCTRLE register When ALUPD is writtento lsquo1rsquo LUPD will be set to lsquo1rsquo until the Buffer Valid (CMPnBV) bits of all enabled compare channels are lsquo1rsquo Thiscondition will clear LUPDIt will remain cleared until the next UPDATE condition where the buffer values will be transferred to the CMPnregisters and LUPD will be set to lsquo1rsquo again This makes sure that the CMPnBUF register values are not transferred tothe CMPn registers until all enabled compare buffers are writtenValue Description0 LUPD in TCACTRLE is not altered by the system1 LUPD in TCACTRLE is 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 TOP valueUPDATE condition Interrupt condition and the type of waveform generatedNo waveform generation is performed in the Normal mode of operation For all other modes the waveform generatoroutput will only be directed to the port pins if the corresponding CMPnEN bit has been set The port pin direction mustbe set as outputTable 21-6 Timer Waveform Generation Mode
Value Group Configuration Mode of Operation TOP UPDATE OVF0x0 NORMAL Normal PER TOP(1) TOP(1)
0x1 FRQ Frequency CMP0 TOP(1) TOP(1)
0x2 - Reserved - - -0x3 SINGLESLOPE Single-slope PWM PER BOTTOM BOTTOM0x4 - Reserved - - -0x5 DSTOP Dual-slope PWM PER BOTTOM TOP0x6 DSBOTH Dual-slope PWM PER BOTTOM TOP and BOTTOM0x7 DSBOTTOM Dual-slope PWM PER BOTTOM BOTTOM
Note 1 When counting up
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 181
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 generatorrsquos output compare value when the timercounter isnot enabled This is used to set or clear the WG output value when the timercounter is not running
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 182
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 The register mapwill change compared to normal 16-bit mode
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 183
2155 Control Register E Clear - Normal Mode
Name CTRLECLROffset 0x04Reset 0x00Property -
This register can be used instead of a Read-Modify-Write (RMW) to clear individual bits by writing a lsquo1rsquo to its bitlocation
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 command bits arealways read as lsquo0rsquoValue Name Description0x0 NONE No command0x1 UPDATE Force update0x2 RESTART Force restart0x3 RESET Force hard Reset (ignored if the timercounter 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 it can also bechanged from softwareValue Description0 The counter is counting up (incrementing)1 The counter is counting down (decrementing)
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 184
2156 Control Register E Set - Normal Mode
Name CTRLESETOffset 0x05Reset 0x00Property -
This register can be used instead of a Read-Modify-Write (RMW) to set individual bits by writing a lsquo1rsquo to its bitlocation
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 bits are alwaysread as lsquo0rsquoValue Name Description0x0 NONE No command0x1 UPDATE Force update0x2 RESTART Force restart0x3 RESET Force hard Reset (ignored if the timercounter 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 it can also bechanged from softwareValue Description0 The counter is counting up (incrementing)1 The counter is counting down (decrementing)
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 185
2157 Control Register F Clear
Name CTRLFCLROffset 0x06Reset 0x00Property -
This register can be used instead of a Read-Modify-Write (RMW) to clear individual bits by writing a lsquo1rsquo to its bitlocation
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 register These bits areautomatically 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 cleared on anUPDATE condition
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 186
2158 Control Register F Set
Name CTRLFSETOffset 0x07Reset 0x00Property -
This register can be used instead of a Read-Modify-Write (RMW) to set individual bits by writing a lsquo1rsquo to its bitlocation
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 register These bits areautomatically 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 cleared on anUPDATE condition
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 187
2159 Event Control
Name EVCTRLOffset 0x09Reset 0x00Property -
Bit 7 6 5 4 3 2 1 0 EVACT[20] CNTEI
Access RW RW RW RW Reset 0 0 0 0
Bits 31 ndash EVACT[20] Event ActionThese bits define what action the counter will take upon certain event conditionsValue Name Description0x0 EVACT_POSEDGE Count on positive event edge0x1 EVACT_ANYEDGE Count on any event edge0x2 EVACT_HIGHLVL Count prescaled clock cycles while the event signal is high0x3 EVACT_UPDOWN Count prescaled clock cycles The event signal controls the count direction up
when low and down when highOther Reserved
Bit 0 ndash CNTEI Enable Count on Event InputValue Description0 Count on Event input is disabled1 Count on Event input is enabled according to EVACT bit field
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 188
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 bit to lsquo1rsquo enables the interrupt from Compare Channel n
Bit 0 ndash OVF Timer OverflowUnderflow Interrupt EnableWriting the OVF bit to lsquo1rsquo enables the overflowunderflow interrupt
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 189
21511 Interrupt Flag Register - Normal Mode
Name INTFLAGSOffset 0x0BReset 0x00Property -
Bit 7 6 5 4 3 2 1 0 CMP2 CMP1 CMP0 OVF
Access RW RW RW RW Reset 0 0 0 0
Bit 6 ndash CMP2 Compare Channel 2 Interrupt FlagSee the CMP0 flag description
Bit 5 ndash CMP1 Compare Channel 1 Interrupt FlagSee the CMP0 flag description
Bit 4 ndash CMP0 Compare Channel 0 Interrupt FlagThe Compare Interrupt (CMPn) flag 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 Count (CNT)register and the corresponding Compare n (CMPn) register The CMPn flag is not cleared automatically It will becleared 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 the WGMODE settingThe OVF flag is not cleared automatically It will be cleared only by writing a lsquo1rsquo to its bit location
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 190
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
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 191
21513 Temporary Bits for 16-Bit Access
Name TEMPOffset 0x0FReset 0x00Property -
The Temporary register is used by the CPU for 16-bit single-cycle access to the 16-bit registers of this peripheral Theregister is common for all the 16-bit registers of this peripheral and can be read and written by software For moredetails on reading and writing 16-bit registers refer to Accessing 16-Bit Registers in the AVR CPU section
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
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 192
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) isaccessible 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
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 193
21515 Period Register - Normal Mode
Name PEROffset 0x26Reset 0xFFFFProperty -
TCAnPER contains the 16-bit TOP value in the timercounter in all modes of operation except Frequency WaveformGeneration (FRQ)
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
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 194
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 comparators are used togenerate waveforms
TCAnCMPn registers are updated with the buffer value from their corresponding TCAnCMPnBUF register when anUPDATE condition occurs
The TCAnCMPnL and TCAnCMPnH register pair represents the 16-bit value TCAnCMPn 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 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
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 195
21517 Period Buffer Register
Name PERBUFOffset 0x36Reset 0xFFFFProperty -
This register serves as the buffer for the Period (TCAnPER) register Writing to this register from the CPU or UPDIwill set the Period Buffer Valid (PERBV) bit in the TCAnCTRLF register
The TCAnPERBUFL and TCAnPERBUFH register pair represents the 16-bit value TCAnPERBUF 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 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
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 196
21518 Compare n Buffer Register
Name CMPnBUFOffset 0x38 + n0x02 [n=02]Reset 0x00Property -
This register serves as the buffer for the associated Compare n (TCAnCMPn) register Writing to this register fromthe CPU or UPDI will set the Compare Buffer valid (CMPnBV) bit in the TCAnCTRLF register
The TCAnCMPnBUFL and TCAnCMPnBUFH register pair represents the 16-bit value TCAnCMPnBUF The lowbyte [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 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
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 197
216 Register Summary - Split Mode
Offset Name Bit Pos 7 6 5 4 3 2 1 0
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
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 198
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_PER0x1 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
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 199
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 HCMP0EN
Bit 5 ndash HCMP1EN High byte Compare 1 EnableSee HCMP0EN
Bit 4 ndash HCMP0EN High byte Compare 0 EnableSetting the HCMPnEN bit in the FRQ or PWM Waveform Generation mode of operation will override the port outputregister for the corresponding WO[n+3] pin
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 LCMPnEN bit in the FRQ or PWM Waveform Generation mode of operation will override the port outputregister for the corresponding WOn pin
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 200
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 HCMP0OV
Bit 5 ndash HCMP1OV High byte Compare 1 Output ValueSee HCMP0OV
Bit 4 ndash HCMP0OV High byte Compare 0 Output ValueThe HCMPnOV bit allows direct access to the output compare value of the waveform generator when the timercounter is not enabled This is used to set or clear the WO[n+3] output value when the timercounter is not running
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 LCMPnOV bit allows direct access to the output compare value of the waveform generator when the timercounter is not enabled This is used to set or clear the WOn output value when the timercounter is not running
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 201
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 The register mapwill change compared to normal 16-bit mode
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 202
2175 Control Register E Clear - Split Mode
Name CTRLECLROffset 0x04Reset 0x00Property -
This register can be used instead of a Read-Modify-Write (RMW) to clear individual bits by writing a lsquo1rsquo to its bitlocation
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 restart and reset of the timercounter The command bits are always readas lsquo0rsquoValue Name Description0x0 NONE No command0x1 - Reserved0x2 RESTART Force restart0x3 RESET Force hard Reset (ignored if the timercounter is enabled)
Bits 10 ndash CMDEN[10] Command EnableThese bits configure what timercounters the command given by the CMD-bits will be applied toValue Name Description0x0 NONE None0x1 - Reserved0x2 - Reserved0x3 BOTH Command (CMD) will be applied to both low byte and high byte timercounter
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 203
2176 Control Register E Set - Split Mode
Name CTRLESETOffset 0x05Reset 0x00Property -
This register can be used instead of a Read-Modify-Write (RMW) to set individual bits by writing a lsquo1rsquo to its bitlocation
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] CommandThis bit field used for software control of restart and reset of the timercounter The command bits are always read aslsquo0rsquo The CMD bit field must be used together with the Command Enable (CMDEN) bits Using the RESET commandrequires that both low byte and high byte timercounter are selected with CMDENValue Name Description0x0 NONE No command0x1 - Reserved0x2 RESTART Force restart0x3 RESET Force hard Reset (ignored if the timercounter is enabled)
Bits 10 ndash CMDEN[10] Command EnableThese bits configure what timercounters the command given by the CMD-bits will be applied toValue Name Description0x0 NONE None0x1 - Reserved0x2 - Reserved0x3 BOTH Command (CMD) will be applied to both low byte and high byte timercounter
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 204
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 2 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 the LCMPn bit to lsquo1rsquo enables the low byte Compare Channel n interrupt
Bit 1 ndash HUNF High byte Underflow Interrupt EnableWriting the HUNF bit to lsquo1rsquo enables the high byte underflow interrupt
Bit 0 ndash LUNF Low byte Underflow Interrupt EnableWriting the LUNF bit to lsquo1rsquo enables the low byte underflow interrupt
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 205
2178 Interrupt Flag Register - Split Mode
Name INTFLAGSOffset 0x0BReset 0x00Property -
Bit 7 6 5 4 3 2 1 0 LCMP2 LCMP1 LCMP0 HUNF LUNF
Access RW RW RW RW RW Reset 0 0 0 0 0
Bit 6 ndash LCMP2 Low byte Compare Channel 2 Interrupt FlagSee LCMP0 flag description
Bit 5 ndash LCMP1 Low byte Compare Channel 1 Interrupt FlagSee LCMP0 flag description
Bit 4 ndash LCMP0 Low byte Compare Channel 0 Interrupt FlagThe Low byte Compare Interrupt (LCMPn) flag is set on a compare match on the corresponding compare channel inthe low byte timerFor all modes of operation the LCMPn flag will be set when a compare match occurs between the Low Byte TimerCounter (TCAnLCNT) register and the corresponding Compare n (TCAnLCMPn) register The LCMPn flag will notbe cleared automatically and has to be cleared by software This is done by writing a lsquo1rsquo to its bit location
Bit 1 ndash HUNF High byte Underflow Interrupt FlagThis flag is set on a high byte timer BOTTOM (underflow) condition HUNF is not automatically cleared and needs tobe 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 and needs tobe cleared by software This is done by writing a lsquo1rsquo to its bit location
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 206
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
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 207
21710 Low Byte Timer Counter Register - Split Mode
Name LCNTOffset 0x20Reset 0x00Property -
TCAnLCNT contains the counter value for the low byte timer CPU and UPDI write access has priority over countclear 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
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 208
21711 High Byte Timer Counter Register - Split Mode
Name HCNTOffset 0x21Reset 0x00Property -
TCAnHCNT contains the counter value for the high byte timer CPU and UPDI write access has priority over countclear 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
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 209
21712 Low Byte Timer Period Register - Split Mode
Name LPEROffset 0x26Reset 0xFFProperty -
The TCAnLPER register contains the TOP value for the 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 for the low byte timer
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 210
21713 High Byte Period Register - Split Mode
Name HPEROffset 0x27Reset 0xFFProperty -
The TCAnHPER register contains the TOP value for the 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 for the high byte timer
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 211
21714 Compare Register n For Low Byte Timer - Split Mode
Name LCMPnOffset 0x28 + n0x02 [n=02]Reset 0x00Property -
The TCAnLCMPn register represents the compare value of Compare Channel n for the low byte timer This registeris continuously compared to the counter value of the low byte timer TCAnLCNT Normally the outputs from thecomparators are then used to generate 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
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 212
21715 High Byte Compare Register n - Split Mode
Name HCMPnOffset 0x29 + n0x02 [n=02]Reset 0x00Property -
The TCAnHCMPn register represents the compare value of Compare Channel n for the high byte timer This registeris continuously compared to the counter value of the high byte timer TCAnHCNT Normally the outputs from thecomparators are then used to generate 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
ATtiny212214412414 AutomotiveTCA - 16-bit TimerCounter Type A
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 213
22 TCB - 16-bit TimerCounter Type B
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 Synchronize Operation with TCAn
222 OverviewThe capabilities of the 16-bit TimerCounter type B (TCB) include frequency and waveform generation and inputcapture on event with time and frequency measurement of digital signals The TCB consists of a base counter andcontrol logic that can be set in one of eight different modes each mode providing unique functionality The basecounter is clocked by the peripheral clock with optional prescaling
ATtiny212214412414 AutomotiveTCB - 16-bit TimerCounter Type B
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 214
2221 Block DiagramFigure 22-1 TimerCounter Type B Block
Counter
CTRLA
CTRLB
EVCTRL
Control
Logic
=
Waveform
Generation
CNT
CCMP
Clear
Count
Match
CAPT(Interrupt Request and Events)
WO
Clock Select
Mode
= 0BOTTOM
Events
Event Action
The timercounter can be clocked from the Peripheral Clock (CLK_PER) or a 16-bit TimerCounter type A(CLK_TCAn)
Figure 22-2 TimerCounter Clock Logic
CTRLA
CLK_PER
DIV2CLK_TCAn
Events
CNT
Control
Logic
CLK_TCB
ATtiny212214412414 AutomotiveTCB - 16-bit TimerCounter Type B
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 215
The Clock Select (CLKSEL) bit field in the Control A (TCBnCTRLA) register selects one of the prescaler outputsdirectly as the clock (CLK_TCB) input
Setting the timercounter to use the clock from a TCAn allows the timercounter to run in sync with that TCAn
By using the EVSYS any event source such as an external clock signal on any IO pin may be used as a controllogic input When an event action controlled operation is used the clock selection must be set to use an eventchannel as the counter input
2222 Signal Description
Signal Description Type
WO Digital Asynchronous Output Waveform Output
223 Functional Description
2231 DefinitionsThe following definitions are used throughout the documentation
Table 22-1 TimerCounter Definitions
Name Description
BOTTOM The counter reaches BOTTOM when it becomes 0x0000
MAX The counter reaches maximum when it becomes 0xFFFF
TOP The counter reaches TOP when it becomes equal to the highest value in the count sequence
CNT Counter register value
CCMP CaptureCompare register value
Note In general the term lsquotimerrsquo is used when the timercounter is counting periodic clock ticks The term lsquocounterrsquois 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
1 Write a TOP value to the CompareCapture (TCBnCCMP) register2 Optional Write the CompareCapture Output Enable (CCMPEN) bit in the Control B (TCBnCTRLB) register
tolsquo1rsquo This will make the waveform output available on the corresponding pin overriding the value in thecorresponding PORT output register
3 Enable the counter by writing a lsquo1rsquo to the ENABLE bit in the Control A (TCBnCTRLA) registerThe counter will start counting clock ticks according to the prescaler setting in the Clock Select (CLKSEL) bitfield in the Control A (TCBnCTRLA) register
4 The counter value can be read from the Count (TCBnCNT) register The peripheral will generate a CAPTinterrupt and event when the CNT value reaches TOP41 If the CompareCapture register is modified to a value lower than the current Count register the
peripheral will count to MAX and wrap around
2233 Operation
22331 ModesThe timer can be configured to run in one of the eight different modes described in the sections below The eventpulse needs to be longer than one system clock cycle in order to ensure edge detection
ATtiny212214412414 AutomotiveTCB - 16-bit TimerCounter Type B
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 216
223311 Periodic Interrupt ModeIn the Periodic Interrupt mode the counter counts to the capture value and restarts from BOTTOM A CAPT interruptand event is generated when the counter is equal to TOP If TOP is updated to a value lower than count uponreaching MAX the counter restarts from BOTTOM
Figure 22-3 Periodic Interrupt Mode
BOTTOM
MAX
TOP
CNT
TOP changed to
a value lower than CNTCNT set to BOTTOM
CAPT(Interrupt Request and Event)
223312 Time-Out Check ModeIn the Time-Out Check mode the peripheral starts counting on the first signal edge and stops on the next signal edgedetected on the event input channel Start or Stop edge is determined by the Event Edge (EDGE) bit in the EventControl (TCBnEVCTRL) register If the Count (TCBnCNT) register reaches TOP before the second edge a CAPTinterrupt and event will be generated In Freeze state after a Stop edge is detected the counter will restart on a newStart edge If TOP is updated to a value lower than the Count (TCBnCNT) register upon reaching MAX the counterrestarts from BOTTOM Reading the Count (TCBnCNT) register or CompareCapture (TCBnCCMP) register orwriting the Run (RUN) bit in the Status (TCBnSTATUS) register in Freeze state will have no effectFigure 22-4 Time-Out Check Mode
CNT
BOTTOM
MAX
TOP
Event Detector
TOP changed to a value lower
than CNT
CNT set to
BOTTOM
Event Input CAPT(Interrupt Request and Event)
223313 Input Capture on Event ModeIn the Input Capture on Event mode the counter will count from BOTTOM to MAX continuously When an event isdetected the Count (TCBnCNT) register value is transferred to the CompareCapture (TCBnCCMP) register and aCAPT interrupt and event is generated The Event edge detector that can be configured to trigger a capture on eitherrising or falling edges
ATtiny212214412414 AutomotiveTCB - 16-bit TimerCounter Type B
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 217
The figure below shows the input capture unit configured to capture on the falling edge of the event input signal TheCAPT Interrupt flag is automatically cleared after the low byte of the CompareCapture (TCBnCCMP) register hasbeen read
Figure 22-5 Input Capture on Event
CNT
MAX
BOTTOM
CNT set to
BOTTOM
Copy CNT to
CCMP and CAPT
Copy CNT to
CCMP and CAPT
Event Detector
Event Input CAPT(Interrupt Request and Event)
It is recommended to write zero to the TCBnCNT register when entering this mode from any other mode
223314 Input Capture Frequency Measurement ModeIn the Input Capture Frequency Measurement mode the TCB captures the counter value and restarts on either apositive or negative edge of the event input signal
The CAPT Interrupt flag is automatically cleared after the low byte of the CompareCapture (TCBnCCMP) registerhas been read
The figure below illustrates this mode when configured to act on rising edge
Figure 22-6 Input Capture Frequency Measurement
CNT
MAX
BOTTOM
Event Detector
Event Input
CNT set to
BOTTOM
Copy CNT to CCMP
CAPT and restart
Copy CNT to CCMP
CAPT and restart
CAPT(Interrupt Request and Event)
ATtiny212214412414 AutomotiveTCB - 16-bit TimerCounter Type B
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 218
223315 Input Capture Pulse-Width Measurement ModeIn the Input Capture Pulse-Width Measurement mode the input capture pulse-width measurement will restart thecounter on a positive edge and capture on the next falling edge before an interrupt request is generated The CAPTInterrupt flag is automatically cleared after the low byte of the CompareCapture (TCBnCCMP) register has beenread The timer will automatically switch between rising and falling edge detection but a minimum edge separation oftwo clock cycles is required for correct behavior
Figure 22-7 Input Capture Pulse-Width Measurement
Event Input
Edge Detector
CNT
MAX
BOTTOM
Start counterCopy CNT to
CCMP and CAPT
Restart
counter
Copy CNT to
CCMP and CAPT
CNT set to
BOTTOM
CAPT(Interrupt Request and Event)
223316 Input Capture Frequency and Pulse-Width Measurement ModeIn the Input Capture Frequency and Pulse-Width Measurement mode the timer will start counting when a positiveedge is detected on the event input signal The count value is captured on the following falling edge The counterstops when the second rising edge of the event input signal is detected This will set the interrupt flag
The CAPT Interrupt flag is automatically cleared after the low byte of the CompareCapture (TCBnCCMP) registerhas been read and the timercounter is ready for a new capture sequence Therefore the Count (TCBnCNT)register must be read before the CompareCapture (TCBnCCMP) register since it is reset to BOTTOM at the nextpositive edge of the event input signal
ATtiny212214412414 AutomotiveTCB - 16-bit TimerCounter Type B
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 219
Figure 22-8 Input Capture Frequency and Pulse-Width Measurement
CNT
MAX
BOTTOM
Start
counter
Copy CNT to
CCMP
Stop counter and
CAPT
CPU reads the
CCMP register
Ignored until CPU
reads CCMP register
Trigger next capture
sequence
Event Detector
Event InputCAPT(Interrupt Request and Event)
223317 Single-Shot ModeThe Single-Shot mode can be used to generate a pulse with a duration defined by the Compare (TCBnCCMP)register every time a rising or falling edge is observed on a connected event channel
When the counter is stopped the output pin is driven to low If an event is detected on the connected event channelthe timer will reset and start counting from BOTTOM to TOP while driving its output high The RUN bit in the Status(TCBnSTATUS) register can be read to see if the counter is counting or not When the Counter register reaches theCCMP register value the counter will stop and the output pin will go low for at least one prescaler cycle A new eventarriving during this time will be ignored There is a two clock-cycle delay from when the event is received until theoutput is set high
The counter will start counting as soon as the module is enabled even without triggering an event This is preventedby writing TOP to the Counter register Similar behavior is seen if the Event Edge (EDGE) bit in the Event Control(TCBnEVCTRL) register is lsquo1rsquo while the module is enabled Writing TOP to the Counter register prevents this as well
If the Event Asynchronous (ASYNC) bit in the Control B (TCBnCTRLB) register is written to lsquo1rsquo the timer will reactasynchronously to an incoming event An edge on the event will immediately cause the output signal to be set Thecounter will still start counting two clock cycles after the event is received
ATtiny212214412414 AutomotiveTCB - 16-bit TimerCounter Type B
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 220
Figure 22-9 Single-Shot Mode
Edge Detector
CNT
TOP
BOTTOM
Event starts
counter
Counter reaches
TOP value
Output
Ignored Ignored
Event starts
counter
Counter reaches
TOP value
CAPT(Interrupt Request and Event)
223318 8-Bit PWM ModeThe TCB can be configured to run in 8-bit PWM mode where each of the register pairs in the 16-bit CompareCapture (TCBnCCMPH and TCBnCCMPL) register are used as individual Compare registers The period (T) iscontrolled by CCMPL while CCMPH controls the duty cycle of the waveform The counter will continuously countfrom BOTTOM to CCMPL and the output will be set at BOTTOM and cleared when the counter reaches CCMPH
CCMPH is the number of cycles for which the output will be driven high CCMPL+1 is the period of the output pulse
Figure 22-10 8-Bit PWM Mode
CNT
MAX
TOP
Period (T)
BOTTOM
Output
CCMPH=BOTTOM
CCMPH
CCMPH=TOP CCMPHgtTOP
CCMPL
CAPT(Interrupt Request and Event)
22332 OutputTimer synchronization and output logic level are dependent on the selected Timer Mode (CNTMODE) bit field inControl B (TCBnCTRLB) register In Single-Shot mode the timercounter can be configured so that the signalgeneration happens asynchronously to an incoming event (ASYNC = 1 in TCBnCTRLB) The output signal is thenset immediately at the incoming event instead of being synchronized to the TCB clock Even though the output is setimmediately it will take two to three CLK_TCB cycles before the counter starts counting
ATtiny212214412414 AutomotiveTCB - 16-bit TimerCounter Type B
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 221
Writing the CompareCapture Output Enable (CCMPEN) bit in TCBnCTRLB to lsquo1rsquo enables the waveform output Thiswill make the waveform output available on the corresponding pin overriding the value in the corresponding PORToutput register
The different configurations and their impact on the output are listed in the table belowTable 22-2 Output Configuration
CCMPEN CNTMODE ASYNC Output
1
Single-Shot mode
0The output is high whenthe counter starts and theoutput is low when thecounter stops
1The output is high whenthe event arrives and theoutput is low when thecounter stops
8-bit PWM mode Not applicable 8-bit PWM mode
Other modes Not applicableThe output initial level setsthe CCMPINIT bit in theTCBnCTRLB register
0 Not applicable Not applicable No output
It is not recommended to change modes while the peripheral is enabled as this can produce an unpredictable outputThere is a possibility that an interrupt flag is set during the timer configuration It is recommended to clear the TimerCounter Interrupt Flags (TCBnINTFLAGS) register after configuring the peripheral
22333 Noise CancelerThe Noise Canceler improves the noise immunity by using a simple digital filter scheme When the Noise Filter(FILTER) bit in the Event Control (TCBnEVCTRL) register is enabled the peripheral monitors the event channel andkeeps a record of the last four observed samples If four consecutive samples are equal the input is considered to bestable and the signal is fed to the edge detector
When enabled the Noise Canceler introduces an additional delay of four system clock cycles between a changeapplied 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
22334 Synchronized with TimerCounter Type AThe TCB can be configured to use the clock (CLK_TCA) of a TimerCounter type A (TCAn) by writing to the ClockSelect bit field (CLKSEL) in the Control A register (TCBnCTRLA) In this setting the TCB will count on the exactsame clock source as selected in TCAn
When the Synchronize Update (SYNCUPD) bit in the Control A (TCBnCTRLA) register is written to lsquo1rsquo the TCBcounter will restart when the TCAn counter restarts
2234 EventsThe TCB can generate the events described in the following tableTable 22-3 Event Generators in TCB
Generator NameDescription Event Type Generating Clock Domain Length of Event
Peripheral Event
TCBn CAPT CAPT flag set Pulse CLK_PER One CLK_PER period
The conditions for generating the CAPT event is identical to those that will raise the corresponding interrupt flag inthe TimerCounter Interrupt Flags (TCBnINTFLAGS) register Refer to the Event System section for more detailsregarding event users and Event System configuration
ATtiny212214412414 AutomotiveTCB - 16-bit TimerCounter Type B
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 222
The TCB can receive the events described in the following tableTable 22-4 Event Users and Available Event Actions in TCB
User NameDescription Input Detection AsyncSync
Peripheral Input
TCBn CAPT
Time-Out Check Count mode
EdgeSync
Input Capture on Event Count mode
Input Capture Frequency Measurement Count mode
Input Capture Pulse-Width Measurement Count mode
Input Capture Frequency and Pulse-Width MeasurementCount mode
Single-Shot Count mode Both
If the Capture Event Input Enable (CAPTEI) bit in the Event Control (TCBnEVCTRL) register is written to lsquo1rsquoincoming events will result in an event action as defined by the Event Edge (EDGE) bit in Event Control(TCBnEVCTRL) register and the Timer Mode (CNTMODE) bit field in Control B (TCBnCTRLB) register The eventneeds to last for at least one CLK_PER cycle to be recognized
If the Asynchronous mode is enabled for Single-Shot mode the event is edge-triggered and will capture changes onthe event input shorter than one system clock cycle
2235 InterruptsTable 22-5 Available Interrupt Vectors and Sources
Name Vector Description Conditions
CAPT TCB interrupt Depending on the operating mode See the description of the CAPT bit in theTCBnINTFLAG register
When an interrupt condition occurs the corresponding interrupt flag is set in the peripheralrsquos Interrupt Flags(peripheralINTFLAGS) register
An interrupt source is enabled or disabled by writing to the corresponding enable bit in the peripheralrsquos InterruptControl (peripheralINTCTRL) register
An interrupt request is generated when the corresponding interrupt source is enabled and the interrupt flag is setThe interrupt request remains active until the interrupt flag is cleared See the peripheralrsquos INTFLAGS register fordetails on how to clear interrupt flags
2236 Sleep Mode OperationTCBn is by default disabled in Standby sleep mode It will be halted as soon as the sleep mode is entered
The module can stay fully operational in the Standby sleep mode if the Run Standby (RUNSTDBY) bit in theTCBnCTRLA register is written to lsquo1rsquo
All operations are halted in Power-Down sleep mode
ATtiny212214412414 AutomotiveTCB - 16-bit TimerCounter Type B
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 223
224 Register Summary
Offset Name Bit Pos 7 6 5 4 3 2 1 0
0x00 CTRLA 70 RUNSTDBY SYNCUPD CLKSEL[10] ENABLE0x01 CTRLB 70 ASYNC CCMPINIT CCMPEN CNTMODE[20]0x02
0x03
Reserved
0x04 EVCTRL 70 FILTER EDGE CAPTEI0x05 INTCTRL 70 CAPT0x06 INTFLAGS 70 CAPT0x07 STATUS 70 RUN0x08 DBGCTRL 70 DBGRUN0x09 TEMP 70 TEMP[70]
0x0A CNT70 CNT[70]158 CNT[158]
0x0C CCMP70 CCMP[70]158 CCMP[158]
225 Register Description
ATtiny212214412414 AutomotiveTCB - 16-bit TimerCounter Type B
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 224
2251 Control A
Name CTRLAOffset 0x00Reset 0x00Property -
Bit 7 6 5 4 3 2 1 0 RUNSTDBY SYNCUPD CLKSEL[10] ENABLE
Access RW RW RW RW RW Reset 0 0 0 0 0
Bit 6 ndash RUNSTDBY Run in StandbyWriting a lsquo1rsquo to this bit will enable the peripheral to run in Standby Sleep mode Not applicable when CLKSEL is set to0x2 (CLK_TCA)
Bit 4 ndash SYNCUPD Synchronize UpdateWhen this bit is written to lsquo1rsquo the TCB will restart whenever TCA0 is restarted or overflows This can be used tosynchronize capture with the PWM period
Bits 21 ndash CLKSEL[10] Clock SelectWriting these bits selects the clock source for this peripheral
Value Name Description0x0 CLKDIV1 CLK_PER0x1 CLKDIV2 CLK_PERDIV20x3 CLKTCA Use TCA_CLK from TCA00x4 - Reserved
Bit 0 ndash ENABLE EnableWriting this bit to lsquo1rsquo enables the TimerCounter type B peripheral
ATtiny212214412414 AutomotiveTCB - 16-bit TimerCounter Type B
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 225
2252 Control B
Name CTRLBOffset 0x01Reset 0x00Property -
Bit 7 6 5 4 3 2 1 0 ASYNC CCMPINIT CCMPEN CNTMODE[20]
Access RW RW RW RW RW RW Reset 0 0 0 0 0 0
Bit 6 ndash ASYNC Asynchronous EnableWriting this bit to lsquo1rsquo will allow asynchronous updates of the TCB output signal in Single-Shot modeValue Description0 The output will go HIGH when the counter starts after synchronization1 The output will go HIGH when an event arrives
Bit 5 ndash CCMPINIT CompareCapture Pin Initial ValueThis bit is used to set the initial output value of the pin when a pin output is used This bit has no effect in 8-bit PWMmode and Single-Shot modeValue Description0 Initial pin state is LOW1 Initial pin state is HIGH
Bit 4 ndash CCMPEN CompareCapture Output EnableWriting this bit to lsquo1rsquo enables the waveform output This will make the waveform output available on the correspondingpin overriding the value in the corresponding PORT output register The corresponding pin direction must beconfigured as an output in the PORT peripheralValue Description0 Waveform output is not enabled on the corresponding pin1 Waveform output will override the output value of the corresponding pin
Bits 20 ndash CNTMODE[20] Timer ModeWriting these bits selects the Timer modeValue Name Description0x0 INT Periodic Interrupt mode0x1 TIMEOUT Time-out Check mode0x2 CAPT Input Capture on Event mode0x3 FRQ Input Capture Frequency Measurement mode0x4 PW Input Capture Pulse-Width Measurement mode0x5 FRQPW Input Capture Frequency and Pulse-Width Measurement mode0x6 SINGLE Single-Shot mode0x7 PWM8 8-Bit PWM mode
ATtiny212214412414 AutomotiveTCB - 16-bit TimerCounter Type B
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 226
2253 Event Control
Name EVCTRLOffset 0x04Reset 0x00Property -
Bit 7 6 5 4 3 2 1 0 FILTER EDGE CAPTEI
Access RW RW RW Reset 0 0 0
Bit 6 ndash FILTER Input Capture Noise Cancellation FilterWriting this bit to lsquo1rsquo enables the Input Capture Noise Cancellation unit
Bit 4 ndash EDGE Event EdgeThis bit is used to select the event edge The effect of this bit is dependent on the selected Count Mode (CNTMODE)bit field in TCBnCTRLB ldquomdashrdquo means that an event or edge has no effect in this mode
Count Mode EDGE Positive Edge Negative Edge
Periodic Interrupt mode0 mdash mdash1 mdash mdash
Timeout Check mode0 Start counter Stop counter1 Stop counter Start counter
Input Capture on Event mode0 Input Capture interrupt mdash1 mdash Input Capture interrupt
Input Capture FrequencyMeasurement mode
0 Input Capture clear and restartcounter interrupt mdash
1 mdash Input Capture clear and restartcounter interrupt
Input Capture Pulse-WidthMeasurement mode
0 Clear and restart counter Input Capture interrupt1 Input Capture interrupt Clear and restart counter
Input Capture Frequency and Pulse-Width Measurement mode
0bull On the 1st Positive Clear and restart counterbull On the following Negative Input Capturebull On the 2nd Positive Stop counter interrupt
1bull On the 1st Negative Clear and restart counterbull On the following Positive Input Capturebull On the 2nd Negative Stop counter interrupt
Single-Shot mode0 Start counter mdash1 mdash Start counter
8-Bit PWM mode0 mdash mdash1 mdash mdash
Bit 0 ndash CAPTEI Capture Event Input EnableWriting this bit to lsquo1rsquo enables the input capture event
ATtiny212214412414 AutomotiveTCB - 16-bit TimerCounter Type B
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 227
2254 Interrupt Control
Name INTCTRLOffset 0x05Reset 0x00Property -
Bit 7 6 5 4 3 2 1 0 CAPT
Access RW Reset 0
Bit 0 ndash CAPT Capture Interrupt EnableWriting this bit to lsquo1rsquo enables interrupt on capture
ATtiny212214412414 AutomotiveTCB - 16-bit TimerCounter Type B
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 228
2255 Interrupt Flags
Name INTFLAGSOffset 0x06Reset 0x00Property -
Bit 7 6 5 4 3 2 1 0 CAPT
Access RW Reset 0
Bit 0 ndash CAPT Capture Interrupt FlagThis bit is set when a capture interrupt occurs The interrupt conditions are dependent on the Counter Mode(CNTMODE) bit field in the Control B (TCBnCTRLB) registerThis bit is cleared by writing a lsquo1rsquo to it or when the Capture register is read in Capture modeTable 22-6 Interrupt Sources Set Conditions by Counter Mode
Counter Mode Interrupt Set Condition TOPValue CAPT
Periodic Interrupt mode Set when the counter reaches TOPCCMP CNT == TOPTimeout Check mode Set when the counter reaches TOP
Single-Shot mode Set when the counter reaches TOP
Input Capture FrequencyMeasurement mode
Set on edge when the Capture register isloaded and the counter restarts the flag clearswhen the capture is read
--
On Event copy CNT toCCMP and restartcounting (CNT ==BOTTOM)
Input Capture on Eventmode
Set when an event occurs and the Captureregister is loaded the flag clears when thecapture is read
On Event copy CNT toCCMP and continuecounting
Input Capture Pulse-WidthMeasurement mode
Set on edge when the Capture register isloaded the previous edge initialized the countthe flag clears when the capture is read
Input Capture Frequencyand Pulse-WidthMeasurement mode
Set on the second edge (positive or negative)when the counter is stopped the flag clearswhen the capture is read
8-Bit PWM mode Set when the counter reaches CCML CCML CNT == CCML
ATtiny212214412414 AutomotiveTCB - 16-bit TimerCounter Type B
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 229
2256 Status
Name STATUSOffset 0x07Reset 0x00Property -
Bit 7 6 5 4 3 2 1 0 RUN
Access R Reset 0
Bit 0 ndash RUN RunWhen the counter is running this bit is set to lsquo1rsquo When the counter is stopped this bit is cleared to lsquo0rsquoThe bit is read-only and cannot be set by UPDI
ATtiny212214412414 AutomotiveTCB - 16-bit TimerCounter Type B
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 230
2257 Debug Control
Name DBGCTRLOffset 0x08Reset 0x00Property -
Bit 7 6 5 4 3 2 1 0 DBGRUN
Access RW Reset 0
Bit 0 ndash DBGRUN Debug RunValue 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
ATtiny212214412414 AutomotiveTCB - 16-bit TimerCounter Type B
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 231
2258 Temporary Value
Name TEMPOffset 0x09Reset 0x00Property -
The Temporary register is used by the CPU for 16-bit single-cycle access to the 16-bit registers of this peripheral Theregister is common for all the 16-bit registers of this peripheral and can be read and written by software For moredetails on reading and writing 16-bit registers refer to Accessing 16-Bit Registers in the AVR CPU section
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 Value
ATtiny212214412414 AutomotiveTCB - 16-bit TimerCounter Type B
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 232
2259 Count
Name CNTOffset 0x0AReset 0x00Property -
The TCBnCNTL and TCBnCNTH register pair represents the 16-bit value TCBnCNT The low byte [70] (suffix L) isaccessible 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] Count Value HighThese bits hold the MSB of the 16-bit Counter register
Bits 70 ndash CNT[70] Count Value LowThese bits hold the LSB of the 16-bit Counter register
ATtiny212214412414 AutomotiveTCB - 16-bit TimerCounter Type B
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 233
22510 CaptureCompare
Name CCMPOffset 0x0CReset 0x00Property -
The TCBnCCMPL and TCBnCCMPH register pair represents the 16-bit value TCBnCCMP The low byte [70](suffix L) is accessible at the original offset The high byte [158] (suffix H) can be accessed at offset + 0x01
This register has different functions depending on the mode of operationbull For Capture operation these registers contain the captured value of the counter at the time the capture occursbull In Periodic InterruptTime-Out and Single-Shot mode this register acts as the TOP valuebull In 8-bit PWM mode TCBnCCMPL and TCBnCCMPH act as two independent registers The period of the
waveform is controlled by CCMPL while CCMPH controls the duty cycle
Bit 15 14 13 12 11 10 9 8 CCMP[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 CCMP[70]
Access RW RW RW RW RW RW RW RW Reset 0 0 0 0 0 0 0 0
Bits 158 ndash CCMP[158] CaptureCompare Value High ByteThese bits hold the MSB of the 16-bit compare capture and top value
Bits 70 ndash CCMP[70] CaptureCompare Value Low ByteThese bits hold the LSB of the 16-bit compare capture and top value
ATtiny212214412414 AutomotiveTCB - 16-bit TimerCounter Type B
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 234
23 TCD - 12-Bit TimerCounter Type D
231 Featuresbull 12-bit TimerCounterbull Programmable Prescalerbull Double-Buffered Compare Registersbull Waveform Generation
ndash One Ramp modendash Two Ramp modendash Four Ramp modendash Dual Slope mode
bull Two Separate Input Channelsbull Software and Input Based Capturebull Programmable Filter for Input Eventsbull Conditional Waveform Generation on External Events
ndash Fault handlingndash Input blankingndash Overload protectionndash Fast emergency stop by hardware
bull Half-Bridge and Full-Bridge Output Support
232 OverviewThe TimerCounter type D (TCD) is a high-performance waveform generator that consists of an asynchronouscounter a prescaler and compare capture and control logic
The TCD contains a counter that can run on a clock which is asynchronous to the peripheral clock It containscompare logic that generates two independent outputs with optional dead time It is connected to the Event Systemfor capture and deterministic Fault control The timercounter can generate interrupts and events on compare matchand overflow
This device provides one instance of the TCD peripheral TCD0
ATtiny212214412414 AutomotiveTCD - 12-Bit TimerCounter Type D
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 235
2321 Block DiagramFigure 23-1 TimerCounter Block Diagram
CompareCaptureUnit A
CompareCaptureUnit B
CMPASET
CMPACLR
CMPBSET
CMPBCLR
CMPASET_BUF
CMPACLR_BUF
CMPBSET_BUF
CMPBCLR_BUF
Counter andFractional
Accumulator
Waveformgenerator A
Waveformgenerator B
Event InputLogic B
WOA
WOC
WOB
WOD
Event Input A
Event Input B
Peripheralclock
domain
TCD clockdomain
CLR A
SET A
CLR B
SET B
CAPTUREA_BUF
CAPTUREB_BUF
Event InputLogic A
=
=
=
=
CAPTUREA
CAPTUREB
CMPASETPROGEV
TRIGA (INT Req)
PROGEV (Event)
CMPBSETPROGEV
CMPBCLRPROGEV
TRIGB (INT Req)
(Event)
(Event)
(Event)TRIG OVF (INT Req)
The TCD core is asynchronous to the peripheral clock The timercounter consists of two comparecapture unitseach with a separate waveform output There are also two extra waveform outputs which can be equal to the outputfrom one of the units For each comparecapture unit there is a pair of compare registers which are stored in therespective peripheral registers (TCDnCMPASET TCDnCMPACLR TCDnCMPBSET TCDnCMPBCLR)
During normal operation the counter value is continuously compared to the compare registers This is used togenerate both interrupts and events
ATtiny212214412414 AutomotiveTCD - 12-Bit TimerCounter Type D
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 236
The TCD can use the input events in ten different input modes selected separately for the two input events Theinput mode defines how the input events will affect the outputs and where in the TCD cycle the counter must gowhen an event occurs
The TCD can select between four different clock sources that can be prescaled There are three different prescalerswith separate controls as shown belowFigure 23-2 Clock Selection and Prescalers Overview
Synchronizationprescaler
Counterprescaler
Delayprescaler(1)
Counter clock(CLK_TCD_CNT)
Synchronizer clock(CLK_TCD_SYNC)
Delay clock(CLK_TCD_DLY)
CLKSEL
CLK_TCD
1 Used by input blankingdelay event out
OSCHF
EXTCLKPLL
CLK_PER
The TCD synchronizer clock is separate from the other module clocks enabling faster synchronization between theTCD domain and the IO domain
The total prescaling for the counter isSYNCPRESC_division_factor times CNTPRESC_division_factorThe delay prescaler is used to prescale the clock used for the input blankingdelayed event output functionality Theprescaler can be configured independently allowing separate range and accuracy settings from the counterfunctionality The synchronization prescaler and counter prescaler can be configured from the Control A(TCDnCTRLA) register while the delay prescaler can be configured from the Delay Control (TCDnDLYCTRL)register
2322 Signal Description
Signal Description Type
WOA TCD waveform output A Digital output
WOB TCD waveform output B Digital output
WOC TCD waveform output C Digital output
WOD TCD waveform output D Digital output
233 Functional Description
2331 DefinitionsThe following definitions are used throughout the documentation
Table 23-1 TimerCounter Definitions
Name Description
TCD cycle The sequence of four states that the counter needs to go through before it has returned to thesame position
ATtiny212214412414 AutomotiveTCD - 12-Bit TimerCounter Type D
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 237
continuedName Description
Input blanking The functionality to ignore an event input for a programmable time in a selectable part of the TCDcycle
Asynchronousoutput control
Allows the event to override the output instantly when an event occurs It is used for handlingnon-recoverable Faults
One ramp The counter is reset to zero once during a TCD cycle
Two ramp The counter is reset to zero two times during a TCD cycle
Four ramp The counter is reset to zero four times during a TCD cycle
Dual ramp The counter counts both up and down between zero and a selected top value during a TCDcycle
Input mode A predefined setting that changes the output characteristics based on the given input events
2332 InitializationTo initialize the TCD
1 Select the clock source and the prescaler from the Control A (TCDnCTRLA) register2 Select the Waveform Generation Mode from the Control B (TCDnCTRLB) register3 Optional Configure the other static registers to the desired functionality4 Write the initial values in the Compare (TCDnCMPxSETCLR) registers5 Optional Write the desired values to the other double-buffered registers6 Ensure that the Enable Ready (ENRDY) bit in the Status (TCDnSTATUS) register is set to lsquo1rsquo7 Enable the TCD by writing a lsquo1rsquo to the ENABLE bit in the Control A (TCDnCTRLA) register
2333 Operation
23331 Register Synchronization CategoriesMost of the IO registers need to be synchronized to the TCD core clock domain This is done differently for differentregister categories
Table 23-2 Categorization of Registers
Enable andCommandRegisters
Double-BufferedRegisters
Static Registers Read-Only Registers Normal IORegisters
TCDnCTRLA(ENABLE bit)
TCDnDLYCTRL TCDnCTRLA(1) (All bitsexcept ENABLE bit)
TCDnSTATUS TCDnINTCTRL
TCDnCTRLE TCDnDLYVAL TCDnCTRLB TCDnCAPTUREA TCDnINTFLAGS
TCDnDITCTRL TCDnCTRLC TCDnCAPTUREB
TCDnDITVAL TCDnCTRLD
TCDnDBGCTRL TCDnEVCTRLA
TCDnCMPASET TCDnEVCTRLB
TCDnCMPACLR TCDnINPUTCTRLA
TCDnCMPBSET TCDnINPUTCTRLB
TCDnCMPBCLR TCDnFAULTCTRL(2)
ATtiny212214412414 AutomotiveTCD - 12-Bit TimerCounter Type D
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 238
Notes 1 The bits in the Control A (TCDnCTRLA) register are enable-protected except the ENABLE bit They can only
be written when ENABLE is written to lsquo0rsquo first2 This register is protected by the Configuration Change Protection Mechanism requiring a timed write
procedure for changing its value settings
Enable and Command RegistersBecause of the synchronization between the clock domains it is only possible to change the ENABLE bit in theControl A (TCDnCTRLA) register while the Enable Ready (ENRDY) bit in the Status (TCDnSTATUS) register is lsquo1rsquo
The Control E (TCDnCTRLE) register is automatically synchronized to the TCD core domain when the TCD isenabled and as long as no synchronization is ongoing already Check if the Command Ready (CCMDRDY) bit inTCDnSTATUS is lsquo1rsquo to ensure that it is possible to issue a new command TCDnCTRLE is a strobe register that willclear itself when the command is sent
Double-Buffered RegistersThe double-buffered registers can be updated in normal IO writes while TCD is enabled and no synchronizationbetween the two clock domains is ongoing Check that the CMDRDY bit in TCDnSTATUS is lsquo1rsquo to ensure that it ispossible to update the double-buffered registers The values will be synchronized to the TCD core domain when asynchronization command is sent or when TCD is enabled
Table 23-3 Issuing Synchronization Command
Synchronization Issuing Bit Double Register Update
CTRLCAUPDATE Every time the CMPBCLRH register is written thesynchronization occurs at the end of the TCD cycle
CTRLESYNC (1) Occurs once as soon as the SYNC bit is synchronizedwith the TDC domain
CTRLESYNCEOC (1) Occurs once at the end of the next TCD cycle
Note 1 If synchronization is already ongoing the action has no effect
Static RegistersStatic registers cannot be updated while TCD is enabled Therefore these registers must be configured beforeenabling TCD To see if TCD is enabled check if ENABLE in TCDnCTRLA is read as lsquo1rsquo
Normal IO and Read-Only RegistersNormal IO and read-only registers are not constrained by any synchronization between the domains The read-onlyregisters inform about synchronization status and values synchronized from the core domain
23332 Waveform Generation ModesThe TCD provides four different Waveform Generation modes controlled by the Waveform Generation Mode(WGMODE) bit field in the Control B (TCDnCTRLB) register The Waveform Generation modes are
bull One Ramp modebull Two Ramp modebull Four Ramp modebull Dual Slope mode
The Waveform Generation modes determine how the counter is counting during a TCD cycle and how the comparevalues influence the waveform A TCD cycle is split into these states
bull Dead time WOA (DTA)bull On time WOA (OTA)bull Dead time WOB (DTB)
ATtiny212214412414 AutomotiveTCD - 12-Bit TimerCounter Type D
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 239
bull On time WOB (OTB)
The Compare A Set (CMPASET) Compare A Clear (CMPACLR) Compare B Set (CMPBSET) and Compare B Clear(CMPBCLR) compare values define when each state ends and the next begins
233321 One Ramp ModeIn One Ramp mode the TCD counter counts up until it reaches the CMPBCLR value Then the TCD cycle iscompleted and the counter restarts from 0x000 beginning a new TCD cycle The TCD cycle period isTCD_cycle = CMPBCLR + 1CLK_TCD_CNTFigure 23-3 One Ramp Mode
Counter value
TCD cycle
WOA
WOB
Dead time A On time A Dead time B On time B
CMPBCLR
CMPBSET
CMPACLR
CMPASET
Compare values
In the figure above CMPASET lt CMPACLR lt CMPBSET lt CMPBCLR In One Ramp mode this is required to avoidoverlapping outputs during the on time The figure below is an example where CMPBSET lt CMPASET lt CMPACLRlt CMPBCLR which has overlapping outputs during the on time
ATtiny212214412414 AutomotiveTCD - 12-Bit TimerCounter Type D
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 240
Figure 23-4 One Ramp Mode with CMPBSET lt CMPASET
WOA
WOB
Dead time A On time A On time B
Countervalue
CMPASET
CMPACLR
CMPBSET
CMPBCLR
Comparevalues
TCD cycle
A match with CMPBCLR will always result in all outputs being cleared If any of the other compare values are biggerthan CMPBCLR their associated effect will never occur If the CMPACLR is smaller than the CMPASET value theclear value will not have any effect
233322 Two Ramp ModeIn Two Ramp mode the TCD counter counts up until it reaches the CMPACLR value then it resets and counts upuntil it reaches the CMPBCLR value Then the TCD cycle is completed and the counter restarts from 0x000beginning a new TCD cycle The TCD cycle period is given byTCD_cycle = CMPACLR + 1 + CMPBCLR + 1CLK_TCD_CNT
ATtiny212214412414 AutomotiveTCD - 12-Bit TimerCounter Type D
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 241
Figure 23-5 Two Ramp Mode
value CMPACLR
TCD cycleDead time A On time A Dead time B On time B
WOA
WOB
CMPBCLR
CMPBSET
CMPASET
Counter
In the figure above CMPASET lt CMPACLR and CMPBSET lt CMPBCLR This causes the outputs to go high Thereare no restrictions on the CMPASET and CMPACLR compared to the CMPBSET and CMPBCLR values
In Two Ramp mode it is not possible to get overlapping outputs without using the override feature Even ifCMPASETCMPBSET gt CMPACLRCMPBCLR the counter resets at CMPACLRCMPBCLR and will never reachCMPASETCMPBSET
233323 Four Ramp ModeIn Four Ramp mode the TCD cycle follows this pattern
1 A TCD cycle begins with the TCD counter counting up from zero until it reaches the CMPASET value andresets to zero
2 The counter counts up until it reaches the CMPACLR value and resets to zero3 The counter counts up until it reaches the CMPBSET value and resets to zero4 The counter counts up until it reaches the CMPBCLR value and ends the TCD cycle by resetting to zero
The TCD cycle period is given byTCD_cycle = CMPASET + 1 + CMPACLR + 1 + CMPBSET + 1 + CMPBCLR + 1CLK_TCD_CNT
ATtiny212214412414 AutomotiveTCD - 12-Bit TimerCounter Type D
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 242
Figure 23-6 Four Ramp Mode
value
CMPASET
TCD cycleDead time A On time A Dead time B On time B
WOA
WOB
CMPBSETCMPACLRCMPBCLR
Counter
There are no restrictions regarding the compare values because there are no dependencies between them
In Four Ramp mode it is not possible to get overlapping outputs without using the override feature
233324 Dual Slope ModeIn Dual Slope mode a TCD cycle consists of the TCD counter counting down from CMPBCLR value to zero and upagain to the CMPBCLR value This gives a TCD cycle periodTCD_cycle = 2 times CMPBCLR + 1CLK_TCD_CNTThe WOA output is set when the TCD counter counts down and matches the CMPASET value WOA is cleared whenthe TCD counter counts up and matches the CMPASET value
The WOB output is set when the TCD counter counts up and matches the CMPBSET value WOB is cleared whenthe TCD counter counts down and matches the CMPBSET value
The outputs will overlap if CMPASET gt CMPBSET
CMPACLR is not used in Dual Slope mode Writing a value to CMPACLR has no effectFigure 23-7 Dual Slope Mode
valueCMPBCLR
TCD cycle
Dead time A On time A
Dead time B On time BOn time B
WOA
WOB
Counter
Deadtime A On time A
CMPBSET
CMPASETCMPASET
ATtiny212214412414 AutomotiveTCD - 12-Bit TimerCounter Type D
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 243
When starting the TCD in Dual Slope mode the TCD counter starts at the CMPBCLR value and counts down In thefirst cycle the WOB will not be set until the TCD counter matches the CMPBSET value when counting up
When the Disable at End of Cycle Strobe (DISEOC) bit in the Control E (TCDnCTRLE) register is set the TCD willautomatically be disabled at the end of the TCD cycle
Figure 23-8 Dual Slope Mode Starting and Stopping
valueCMPBCLR
TCD cycle
Start
WOA
WOB
Stop
Counter
CMPBSET
CMPASETCMPASET
23333 Disabling TCDDisabling the TCD can be done in two different ways
1 By writing a lsquo0rsquo to the ENABLE bit in the Control A (TCDnCTRLA) register This disables the TCD instantlywhen synchronized to the TCD core domain
2 By writing a lsquo1rsquo to the Disable at End of Cycle Strobe (DISEOC) bit in the Control E (TCDnCTRLE) registerThis disables the TCD at the end of the TCD cycle
23334 TCD InputsThe TCD has two inputs connected to the Event System input A and input B Each input has a functionalityconnected to the corresponding output (WOA and WOB) This functionality is controlled by the Event Control(TCDnEVCTRLA and TCDnEVCTRLB) registers and the Input Control (TCDnINPUTCTRLA andTCDnINPUTCTRLB) registers
To enable the input events write a lsquo1rsquo to the Trigger Event Input Enable (TRIGEI) bit in the corresponding EventControl (TCDnEVCTRLA or TCDnEVCTRLB) register The inputs will be used as a Fault detect by default but theycan also be used as a capture trigger To enable a capture trigger write a lsquo1rsquo to the ACTION bit in the correspondingEvent Control (TCDnEVCTRLA or TCDnEVCTRLB) register To disable Fault detect the INPUTMODE bit field inthe corresponding Input Control (TCDnINPUTCTRLA or TCDnINPUTCTRLB) register must be written to lsquo0rsquo
There are ten different input modes for the Fault detection The two inputs have the same functionality except forinput blanking which is only supported by input A Input blanking is configured by the Delay Control(TCDnDLYCTRL) register and the Delay Value (TCDnDLYVAL) register
The inputs are connected to the Event System The connections between the event source and the TCD input mustbe configured in the Event System
ATtiny212214412414 AutomotiveTCD - 12-Bit TimerCounter Type D
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 244
Figure 23-9 TCD Input Overview
INPUTBLANKING
Digital Filter
Input processing logic(Input mode logic A)
Output control
Change flow
Asynchonous overrride
Synchronized override
Input Event A
INPUTMODE
Digital Filter Input processing logic
(Input mode logic B)
Change flow
Asynchonous overrride
Synchronized override
Input Event B
INPUTMODE
Output state
DLYPRESC
DLYTRIG
DLYSEL
EVCTRLAEDGE EVCTRLAASYNC
EVCTRLAFILTER
EVCTRLBEDGE EVCTRLBASYNC
EVCTRLBFILTER
TC Core(TimerCounter compare values
waveform generator)
There is a delay of twothree clock cycles on the TCD synchronizer clock between receiving the input eventprocessing it and overriding the outputs If using the asynchronous event detection the outputs will override instantlyoutside the input processing
233341 Input BlankingInput blanking functionality masks out the input events for a programmable time in a selectable part of the TCD cycleInput blanking can be used to mask out lsquofalsersquo input events triggered right after changes on the outputs occur
Input blanking can be enabled by configuring the Delay Select (DLYSEL) bit field in the Delay Control(TCDnDLYCTRL) register The trigger source is selected by the Delay Trigger (DLYTRIG) bit field inTCDnDLYCTRL
Input blanking uses the delay clock After a trigger a counter counts up until the Delay Value (DLYVAL) bit field in theDelay Value (TCDnDLYVAL) register is reached Afterward input blanking is turned off The TCD delay clock is aprescaled version of the synchronizer clock (CLK_TCD_SYNC) The division factor is set by the Delay Prescaler(DLYPRESC) bit field in the Delay Control (TCDnDLYCTRL) register The duration of the input blanking is given byBLANK = DLYPRESC_division_factor times DLYVALCLK_TCD_SYNCInput blanking uses the same logic as the programmable output event For this reason it is not possible to use bothat the same time
233342 Digital FilterThe digital filter for event input x is enabled by writing a lsquo1rsquo to the FILTER bit in the corresponding Event Control(TCDnEVCTRLA or TCDnEVCTRLB) register When the digital filter is enabled any pulse lasting less than fourcounter clock cycles will be filtered out Any change on the incoming event will therefore take four counter clockcycles before it affects the input processing logic
233343 Asynchronous Event DetectionTo enable asynchronous event detection on an input event the Event Configuration (CFG) bit field in thecorresponding Event Control (TCDnEVCTRLA or TCDnEVCTRLB) register must be configured accordingly
ATtiny212214412414 AutomotiveTCD - 12-Bit TimerCounter Type D
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 245
The asynchronous event detection makes it possible to asynchronously override the output when the input eventoccurs What the input event will do depends on the input mode The outputs have direct override while the counterflow will be changed when the event is synchronized to the synchronizer clock (CLK_TCD_SYNC)
It is not possible to use asynchronous event detection and digital filter at the same time
233344 Software CommandsThe following table displays the commands for the TCD module
Table 23-4 Software Commands
Trigger Software Command
The SYNCEOC bit in the TCDnCTRLE register Update the double-buffered registers at the end of theTCD cycle
The SYNC bit in the TCDnCTRLE register Update the double-buffered registers
The RESTART bit in the TCDnCTRLE register Restart the TCD counter
The SCAPTUREA bit in the TCDnCTRLE register Capture to Capture A (TCDnCAPTUREALH) register
The SCAPTUREB bit in the TCDnCTRLE register Capture to Capture B (TCDnCAPTUREBLH) register
233345 Input ModesThe user can select between ten input modes The selection is done by writing to the Input Mode (INPUTMODE) bitfield in the Input Control (TCDnINPUTCTRLA and TCDnINPUTCTRLB) registers
Input Modes ValidityNot all input modes work in all Waveform Generation modes The table below shows the Waveform Generationmodes in which the different input modes are valid
Table 23-5 Input Modes Validity
INPUTMODE One Ramp Mode Two Ramp Mode Four Ramp Mode Dual Slope Mode
0 Valid Valid Valid Valid
1 Valid Valid Valid Do not use
2 Do not use Valid Valid Do not use
3 Do not use Valid Valid Do not use
4 Valid Valid Valid Valid
5 Do not use Valid Valid Do not use
6 Do not use Valid Valid Do not use
7 Valid Valid Valid Valid
8 Valid Valid Valid Do not use
9 Valid Valid Valid Do not use
10 Valid Valid Valid Do not use
Input Mode 0 Input Has No ActionIn Input mode 0 the inputs do not affect the outputs but they can still trigger captures and interrupts if enabled
ATtiny212214412414 AutomotiveTCD - 12-Bit TimerCounter Type D
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 246
Figure 23-10 Input Mode 0
WOA
WOB
INPUT A
INPUT B
DTA OTA DTB OTB DTA OTA DTB OTB DTA OTA DTB
Input Mode 1 Stop Output Jump to Opposite Compare Cycle and WaitAn input event in Input mode 1 will stop the output signal jump to the opposite dead time and wait until the inputevent goes low before the TCD counter continues
If Input mode 1 is used on input A an event will only have an effect if the TCD is in dead time A or on time A and itwill only affect the WOA output When the event is done the TCD counter starts at dead time B
Figure 23-11 Input Mode 1 on Input A
WOA
WOB
INPUT A
INPUT B
DTA OTA DTB OTB DTA OTA Wait DTB OTB DTA OTA
If Input mode 1 is used on input B an event will only have an effect if the TCD is in dead time B or on time B and itwill only affect the WOB output When the event is done the TCD counter starts at dead time A
Figure 23-12 Input Mode 1 on Input B
WOA
WOB
INPUT A
INPUT B
DTA OTA DTB OTB DTA OTAWait DTB OTB DTA OTA
Input Mode 2 Stop Output Execute Opposite Compare Cycle and WaitAn input event in Input mode 2 will stop the output signal execute to the opposite dead time and on time and thenwait until the input event goes low before the TCD counter continues If the input is done before the opposite deadtime and on time have finished there will be no waiting but the opposite dead time and on time will continue
If Input mode 2 is used on input A an event will only have an effect if the TCD is in dead time A or on time A and willonly affect the WOA output
ATtiny212214412414 AutomotiveTCD - 12-Bit TimerCounter Type D
copy 2020 Microchip Technology Inc Draft Complete Datasheet DS40002229A-page 247