Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
ATtiny104_Datasheet.pdf
Скачиваний:
0
Добавлен:
12.02.2026
Размер:
3.8 Mб
Скачать

8-bit AVR Microcontroller

ATtiny102 / ATtiny104

DATASHEET COMPLETE

Introduction

The Atmel® ATtiny102/ATtiny104 is a low-power CMOS 8-bit microcontroller based on the AVR® enhanced RISC architecture. By executing powerful instructions in a single clock cycle, the ATtiny102/ATtiny104 achieves throughputs close to 1 MIPS per MHz. This empowers system designer to optimize the device for power consumption versus processing speed.

Feature

High Performance, Low Power Atmel® AVR® 8-Bit Microcontroller Family

Advanced RISC Architecture

54 Powerful Instructions

Mostly Single Clock Cycle Execution

16 x 8 General Purpose Working Registers

Fully Static Operation

Up to 12 MIPS Throughput at 12MHz

Non-volatile Program and Data Memories

1024 Bytes of In-system Programmable Flash Program Memory

32 Bytes Internal SRAM

Flash Write/Erase Cycles: 10,000

Data Retention: 20 Years at 85°C / 100 Years at 25°C

Self-programming Flash on Full Operating Voltage Range (1.8 – 5.5V)

Peripheral Features

One 16-bit Timer/Counter (TC) with Prescaler, Input Capture, Two Output Capture and Two PWM Channels

Programmable Watchdog Timer (WDT) with Separate On-chip Oscillator

Selectable Internal Voltage References: 1.1V, 2.2V and 4.3V

10-bit ADC with 8-channels/14-pin and 5-channel/8-pin Package Options

On-chip Analog Comparator (AC)

Serial Communication Module: USART

Atmel-42505D-ATtiny102-ATtiny104_Datasheet_Complete-10/2016

Special Microcontroller Features

In-system Programmable

External Programming (2.7 – 5.5V)

Self Programming (1.8 – 5.5V)

External and Internal Interrupt Sources

Low Power Idle, ADC Noise Reduction, and Power-pown Modes

Enhanced Power-on Reset Circuit

Programmable Supply Voltage Level Monitor with Interrupt and Reset

Accurate Internal Calibrated Oscillator

Fast and Normal Start-up Time Options Available

Individual Serial Number to Represent a Unique ID.

I/O and Packages

12 Programmable I/O Lines for ATtiny104 and 6 Programmable I/O Lines for ATtiny102

8-pin UDFN (ATtiny102)

8-pin SOIC150 (ATtiny102)

14-pin SOIC150 (ATtiny104)

Operating Voltage

1.8 - 5.5V

Temperature Range

-40 to +125°C

Speed Grades

0 – 4MHz at 1.8 – 5.5V

0 – 8MHz at 2.7 – 5.5V

0 – 12MHz at 4.5 – 5.5V

Atmel ATtiny102 / ATtiny104 [DATASHEET]

2

Atmel-42505D-ATtiny102-ATtiny104_Datasheet_Complete-10/2016

Table of Contents

Introduction......................................................................................................................

1

Feature

............................................................................................................................

1

1.

Description.................................................................................................................

8

2.

Configuration .............................................................................................Summary

9

3.

Ordering ...............................................................................................Information

10

4.

Block ..........................................................................................................Diagram

11

5.

Pin Configurations...................................................................................................

12

 

5.1. ..........................................................................................................................

Pin Descriptions

12

6.

I/O Multiplexing........................................................................................................

14

7.

General .................................................................................................Information

15

 

7.1. ..................................................................................................................................

Resources

15

 

7.2. ............................................................................................................................

Data Retention

15

 

7.3. ................................................................................................................

About Code Examples

15

8.

AVR ........................................................................................................CPU Core

16

 

8.1. .....................................................................................................................................

Overview

16

 

8.2. .....................................................................................................................................

Features

16

 

8.3. ............................................................................................................................

Block Diagram

16

 

8.4. ........................................................................................................

ALU – Arithmetic Logic Unit

18

 

8.5. ...........................................................................................................................

Status Register

18

 

8.6. ...................................................................................................

General Purpose Register File

18

 

8.7. ...................................................................................

The X - register, Y - register, and Z - register

19

 

8.8. ..............................................................................................................................

Stack Pointer

19

 

8.9. .........................................................................................................

Accessing 16 - bit Registers

20

 

8.10. ......................................................................................................

Instruction Execution Timing

21

 

8.11. .....................................................................................................

Reset and Interrupt Handling

21

 

8.12. ...................................................................................................................

Register Description

22

9.

AVR .........................................................................................................Memories

27

 

9.1. .....................................................................................................................................

Overview

27

 

9.2. .....................................................................................................................................

Features

27

 

9.3. ................................................................

In - System Reprogrammable Flash Program Memory

27

 

9.4. ...................................................................................................................

SRAM Data Memory

27

 

9.5. .................................................................................................................................

I/O Memory

29

10. Clock ...........................................................................................................System

30

 

10.1. .....................................................................................................................................

Overview

30

 

10.2. ........................................................................................................................

Clock Distribution

30

 

 

 

 

 

 

10.3.

......................................................................................................................Clock Subsystems

30

10.4.

Clock Sources............................................................................................................................

31

10.5.

System Clock Prescaler.............................................................................................................

32

10.6.

Starting.......................................................................................................................................

33

10.7.

Register Description...................................................................................................................

34

11. Power Management and Sleep Modes....................................................................

39

11.1.

Overview.....................................................................................................................................

39

11.2.

Features.....................................................................................................................................

39

11.3.

Sleep Modes...............................................................................................................................

39

11.4.

Power Reduction Register..........................................................................................................

40

11.5.

Minimizing Power Consumption.................................................................................................

41

11.6.

Register Description...................................................................................................................

42

12. SCRST - System Control and Reset.......................................................................

45

12.1.

Overview.....................................................................................................................................

45

12.2.

Features.....................................................................................................................................

45

12.3.

Resetting the AVR......................................................................................................................

45

12.4.

Reset Sources............................................................................................................................

46

12.5.

Watchdog Timer.........................................................................................................................

48

12.6.

Register Description...................................................................................................................

50

13. Interrupts.................................................................................................................

55

13.1.

Overview.....................................................................................................................................

55

13.2.

Interrupt Vectors ........................................................................................................................

55

13.3.

External Interrupts......................................................................................................................

56

13.4.

Register Description...................................................................................................................

57

14. I/O-Ports..................................................................................................................

65

14.1.

Overview.....................................................................................................................................

65

14.2.

Features.....................................................................................................................................

65

14.3. I/O Pin Equivalent Schematic.....................................................................................................

65

14.4. Ports as General Digital I/O........................................................................................................

66

14.5.

Register Description...................................................................................................................

79

15. USART - Universal Synchronous Asynchronous Receiver Transceiver

..................89

 

15.1.

Overview.....................................................................................................................................

89

 

15.2.

Features.....................................................................................................................................

89

 

15.3.

Block Diagram............................................................................................................................

89

 

15.4.

Clock Generation........................................................................................................................

90

 

15.5.

Frame Formats...........................................................................................................................

93

 

15.6.

USART Initialization....................................................................................................................

94

 

15.7.

Data Transmission – The USART Transmitter...........................................................................

95

 

15.8.

Data Reception – The USART Receiver....................................................................................

97

 

15.9.

Asynchronous Data Reception.................................................................................................

100

 

15.10. Multi-Processor Communication Mode....................................................................................

104

 

15.11. Examples of Baud Rate Setting...............................................................................................

105

 

15.12. Register Description.................................................................................................................

108

 

 

Atmel ATtiny102 / ATtiny104 [DATASHEET]

4

Atmel-42505D-ATtiny102-ATtiny104_Datasheet_Complete-10/2016

 

 

 

 

 

 

.........................................................................16. USARTSPI - USART in SPI Mode

119

16.1.

Overview...................................................................................................................................

119

16.2.

Features....................................................................................................................................

119

16.3.

Clock Generation......................................................................................................................

119

16.4. SPI Data Modes and Timing.....................................................................................................

120

16.5.

Frame Formats.........................................................................................................................

120

16.6.

Data Transfer............................................................................................................................

122

16.7. AVR USART MSPIM vs. AVR SPI............................................................................................

123

16.8.

Register Description.................................................................................................................

123

17. TC0 - 16-bit Timer/Counter0 with PWM.................................................................

124

17.1.

Overview...................................................................................................................................

124

17.2.

Features...................................................................................................................................

124

17.3.

Block Diagram..........................................................................................................................

124

17.4.

Definitions.................................................................................................................................

125

17.5.

Registers..................................................................................................................................

126

17.6.

Accessing 16-bit Timer/Counter Registers...............................................................................

127

17.7.

Timer/Counter Clock Sources..................................................................................................

129

17.8.

Counter Unit.............................................................................................................................

131

17.9.

Input Capture Unit....................................................................................................................

132

17.10. Output Compare Units.............................................................................................................

134

17.11. Compare Match Output Unit.....................................................................................................

136

17.12. Modes of Operation..................................................................................................................

137

17.13. Timer/Counter Timing Diagrams..............................................................................................

145

17.14. Register Description.................................................................................................................

146

18. AC - Analog Comparator.......................................................................................

160

18.1.

Overview...................................................................................................................................

160

18.2.

Features...................................................................................................................................

160

18.3.

Block Diagram..........................................................................................................................

160

18.4.

Register Description.................................................................................................................

161

19. ADC - Analog to Digital Converter.........................................................................

166

 

19.1.

Overview...................................................................................................................................

166

 

19.2.

Features...................................................................................................................................

166

 

19.3.

Block Diagram..........................................................................................................................

166

 

19.4.

Operation..................................................................................................................................

167

 

19.5.

Starting a Conversion...............................................................................................................

168

 

19.6.

Prescaling and Conversion Timing...........................................................................................

169

 

19.7.

Changing Channel or Reference Selection..............................................................................

172

 

19.8.

ADC Input Channels.................................................................................................................

172

 

19.9.

ADC Voltage Reference...........................................................................................................

172

 

19.10. ADC Noise Canceler................................................................................................................

173

 

19.11. Analog Input Circuitry...............................................................................................................

173

 

19.12. Analog Noise Canceling Techniques........................................................................................

174

 

19.13. ADC Accuracy Definitions........................................................................................................

174

 

19.14. ADC Conversion Result...........................................................................................................

176

 

19.15. Register Description.................................................................................................................

176

 

 

 

Atmel ATtiny102 / ATtiny104 [DATASHEET]

5

Atmel-42505D-ATtiny102-ATtiny104_Datasheet_Complete-10/2016

 

 

 

 

 

 

......................................................................20. MEMPROGMemory Programming

185

20.1.

Overview...................................................................................................................................

185

20.2.

Features...................................................................................................................................

185

20.3.

Non-Volatile Memories (NVM)..................................................................................................

186

20.4.

Accessing the NVM..................................................................................................................

191

20.5.

Self programming.....................................................................................................................

194

20.6.

External Programming..............................................................................................................

194

20.7.

Register Description.................................................................................................................

195

21. TPI-Tiny Programming Interface............................................................................

198

21.1.

Overview...................................................................................................................................

198

21.2.

Features...................................................................................................................................

198

21.3.

Block Diagram..........................................................................................................................

198

21.4. Physical Layer of Tiny Programming Interface.........................................................................

199

21.5.

Instruction Set...........................................................................................................................

203

21.6. Accessing the Non-Volatile Memory Controller........................................................................

205

21.7.

Control and Status Space Register Descriptions.....................................................................

206

22. Electrical Characteristics ......................................................................................

210

22.1.

Absolute Maximum Ratings*....................................................................................................

210

22.2.

DC Characteristics....................................................................................................................

210

22.3.

Speed.......................................................................................................................................

212

22.4.

Clock Characteristics................................................................................................................

213

22.5. System and Reset Characteristics...........................................................................................

214

22.6.

Analog Comparator Characteristics..........................................................................................

215

22.7.

ADC Characteristics ................................................................................................................

216

22.8.

Serial Programming Characteristics.........................................................................................

217

23. Typical Characteristics...........................................................................................

218

23.1.

Active Supply Current...............................................................................................................

218

23.2.

Idle Supply Current...................................................................................................................

221

23.3.

Supply Current of I/O Modules.................................................................................................

222

23.4.

Power-down Supply Current.....................................................................................................

223

23.5.

Pin Driver Strength...................................................................................................................

224

23.6.

Pin Threshold and Hysteresis...................................................................................................

228

23.7.

Analog Comparator Offset........................................................................................................

232

23.8.

Pin Pull-up................................................................................................................................

233

23.9.

Internal Oscillator Speed..........................................................................................................

236

23.10. VLM Thresholds.......................................................................................................................

238

23.11. Current Consumption of Peripheral Units.................................................................................

240

23.12. Current Consumption in Reset and Reset Pulsewidth.............................................................

243

24. Register Summary.................................................................................................

244

 

 

24.1. Note..........................................................................................................................................

245

 

25.

Instruction Set Summary.......................................................................................

246

 

26.

Packaging Information...........................................................................................

250

 

 

26.1. 8-pin UDFN...............................................................................................................................

250

 

 

 

Atmel ATtiny102 / ATtiny104 [DATASHEET]

6

Atmel-42505D-ATtiny102-ATtiny104_Datasheet_Complete-10/2016

26.2.

8-pin SOIC150..........................................................................................................................

251

26.3.

14-pin SOIC150........................................................................................................................

252

27. Errata.....................................................................................................................

253

27.1.

ATtiny102..................................................................................................................................

253

27.2.

ATtiny104..................................................................................................................................

253

28. Datasheet Revision History...................................................................................

254

28.1.

Rev D - 10/2016.......................................................................................................................

254

28.2.

Rev C - 07/2016.......................................................................................................................

254

28.3.

Rev B - 06/2016........................................................................................................................

254

28.4.

Rev A - 02/2016........................................................................................................................

254

Atmel ATtiny102 / ATtiny104 [DATASHEET]

7

Atmel-42505D-ATtiny102-ATtiny104_Datasheet_Complete-10/2016