Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
AVR / datasheets / atmega_8.pdf
Скачиваний:
68
Добавлен:
20.03.2015
Размер:
5.67 Mб
Скачать

 

 

ATmega8(L)

Table of Contents

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

1

 

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

2

 

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

3

 

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

3

 

Disclaimer .............................................................................................................

4

 

Pin Descriptions....................................................................................................

5

 

About Code Examples.........................................................................

6

 

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

7

 

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

7

 

Architectural Overview..........................................................................................

7

 

Arithmetic Logic Unit – ALU..................................................................................

9

 

Status Register .....................................................................................................

9

 

General Purpose Register File ...........................................................................

10

 

Stack Pointer ......................................................................................................

11

 

Instruction Execution Timing...............................................................................

12

 

Reset and Interrupt Handling..............................................................................

12

 

AVR ATmega8 Memories ..................................................................

15

 

In-System Reprogrammable Flash Program Memory ........................................

15

 

SRAM Data Memory...........................................................................................

16

 

Data Memory Access Times...............................................................................

17

 

EEPROM Data Memory......................................................................................

17

 

I/O Memory .........................................................................................................

22

 

System Clock and Clock Options ....................................................

23

 

Clock Systems and their Distribution ..................................................................

23

 

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

24

 

Crystal Oscillator.................................................................................................

25

 

Low-frequency Crystal Oscillator ........................................................................

26

 

External RC Oscillator ........................................................................................

27

 

Calibrated Internal RC Oscillator ........................................................................

28

 

External Clock.....................................................................................................

30

 

Timer/Counter Oscillator.....................................................................................

30

 

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

31

 

Idle Mode ............................................................................................................

32

 

ADC Noise Reduction Mode...............................................................................

32

 

Power-down Mode..............................................................................................

32

 

Power-save Mode...............................................................................................

32

 

Standby Mode.....................................................................................................

33

 

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

33

 

 

1

2486M–AVR–12/03

 

 

System Control and Reset ................................................................

35

Internal Voltage Reference .................................................................................

40

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

41

Timed Sequences for Changing the Configuration of the Watchdog Timer .......

43

Interrupts ............................................................................................

44

Interrupt Vectors in ATmega8.............................................................................

44

I/O Ports..............................................................................................

49

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

49

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

50

Alternate Port Functions .....................................................................................

54

Register Description for I/O Ports .......................................................................

63

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

64

8-bit Timer/Counter0..........................................................................

67

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

67

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

68

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

68

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

68

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

69

8-bit Timer/Counter Register Description ...........................................................

70

Timer/Counter0 and Timer/Counter1 Prescalers ............................

72

16-bit Timer/Counter1........................................................................

74

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

74

Accessing 16-bit Registers .................................................................................

77

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

80

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

80

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

81

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

83

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

85

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

86

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

93

16-bit Timer/Counter Register Description .........................................................

95

8-bit Timer/Counter2 with PWM and Asynchronous Operation ..

102

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

102

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

103

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

104

Output Compare Unit........................................................................................

105

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

107

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

108

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

113

2 ATmega8(L)

2486M–AVR–12/03

ATmega8(L)

8-bit Timer/Counter Register Description .........................................................

115

Asynchronous Operation of the Timer/Counter ................................................

117

Timer/Counter Prescaler...................................................................................

121

Serial Peripheral Interface – SPI.....................................................

122

SS Pin Functionality..........................................................................................

126

Data Modes ......................................................................................................

129

USART ..............................................................................................

130

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

130

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

131

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

134

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

135

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

137

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

140

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

144

Multi-processor Communication Mode .............................................................

148

Accessing UBRRH/UCSRC Registers..............................................................

149

USART Register Description ............................................................................

150

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

156

Two-wire Serial Interface ................................................................

160

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

160

Two-wire Serial Interface Bus Definition...........................................................

160

Data Transfer and Frame Format .....................................................................

161

Multi-master Bus Systems, Arbitration and Synchronization ............................

164

Overview of the TWI Module ............................................................................

166

TWI Register Description..................................................................................

168

Using the TWI ...................................................................................................

171

Transmission Modes.........................................................................................

175

Multi-master Systems and Arbitration...............................................................

188

Analog Comparator .........................................................................

190

Analog Comparator Multiplexed Input ..............................................................

192

Analog-to-Digital Converter ............................................................

193

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

193

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

195

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

195

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

197

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

198

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

202

3

2486M–AVR–12/03

Boot Loader Support – Read-While-Write Self-Programming .....

206

Boot Loader Features .......................................................................................

206

Application and Boot Loader Flash Sections ....................................................

206

Read-While-Write and No Read-While-Write Flash Sections...........................

206

Boot Loader Lock Bits.......................................................................................

208

Entering the Boot Loader Program ...................................................................

209

Addressing the Flash During Self-Programming ..............................................

211

Self-Programming the Flash .............................................................................

212

Memory Programming.....................................................................

219

Program And Data Memory Lock Bits ..............................................................

219

Fuse Bits...........................................................................................................

220

Signature Bytes ................................................................................................

221

Calibration Byte ................................................................................................

221

Parallel Programming Parameters, Pin Mapping, and Commands ..................

222

Parallel Programming .......................................................................................

224

Serial Downloading...........................................................................................

232

Serial Programming Pin Mapping .....................................................................

232

Electrical Characteristics ................................................................

237

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

237

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

237

External Clock Drive Waveforms ......................................................................

239

External Clock Drive .........................................................................................

239

Two-wire Serial Interface Characteristics .........................................................

240

SPI Timing Characteristics ...............................................................................

241

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

243

ATmega8 Typical Characteristics ..................................................

244

Register Summary ...........................................................................

282

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

284

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

287

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

288

32A ...................................................................................................................

288

28P3 .................................................................................................................

289

32M1-A .............................................................................................................

290

Erratas ..............................................................................................

291

ATmega8

 

Rev. D, E, F, and G ..........................................................................................

291

4 ATmega8(L)

2486M–AVR–12/03

 

ATmega8(L)

Datasheet Change Log for ATmega8.............................................

292

Changes from Rev. 2486K-08/03 to Rev. 2486L-10/03....................................

292

Changes from Rev. 2486K-08/03 to Rev. 2486L-10/03....................................

292

Changes from Rev. 2486J-02/03 to Rev. 2486K-08/03....................................

292

Changes from Rev. 2486I-12/02 to Rev. 2486J-02/03 .....................................

292

Changes from Rev. 2486H-09/02 to Rev. 2486I-12/02 ....................................

293

Changes from Rev. 2486G-09/02 to Rev. 2486H-09/02...................................

293

Changes from Rev. 2486F-07/02 to Rev. 2486G-09/02 ...................................

294

Changes from Rev. 2486E-06/02 to Rev. 2486F-07/02 ...................................

294

Changes from Rev. 2486D-03/02 to Rev. 2486E-06/02 ...................................

294

Changes from Rev. 2486C-03/02 to Rev. 2486D-03/02...................................

294

Changes from Rev. 2486B-12/01 to Rev. 2486C-03/02 ...................................

295

Table of Contents ................................................................................

1

5

2486M–AVR–12/03

6 ATmega8(L)

2486M–AVR–12/03

Atmel Corporation

Atmel Operations

2325 Orchard Parkway

San Jose, CA 95131, USA

Tel: 1(408) 441-0311

Fax: 1(408) 487-2600

Regional Headquarters

Europe

Atmel Sarl

Route des Arsenaux 41 Case Postale 80 CH-1705 Fribourg Switzerland

Tel: (41) 26-426-5555 Fax: (41) 26-426-5500

Asia

Room 1219

Chinachem Golden Plaza

77 Mody Road Tsimshatsui

East Kowloon

Hong Kong

Tel: (852) 2721-9778

Fax: (852) 2722-1369

Japan

9F, Tonetsu Shinkawa Bldg.

1-24-8 Shinkawa

Chuo-ku, Tokyo 104-0033

Japan

Tel: (81) 3-3523-3551

Fax: (81) 3-3523-7581

Memory

2325 Orchard Parkway

San Jose, CA 95131, USA

Tel: 1(408) 441-0311

Fax: 1(408) 436-4314

Microcontrollers

2325 Orchard Parkway

San Jose, CA 95131, USA

Tel: 1(408) 441-0311

Fax: 1(408) 436-4314

La Chantrerie

BP 70602

44306 Nantes Cedex 3, France

Tel: (33) 2-40-18-18-18

Fax: (33) 2-40-18-19-60

ASIC/ASSP/Smart Cards

Zone Industrielle

13106 Rousset Cedex, France

Tel: (33) 4-42-53-60-00

Fax: (33) 4-42-53-60-01

1150 East Cheyenne Mtn. Blvd.

Colorado Springs, CO 80906, USA

Tel: 1(719) 576-3300

Fax: 1(719) 540-1759

Scottish Enterprise Technology Park

Maxwell Building

East Kilbride G75 0QR, Scotland

Tel: (44) 1355-803-000

Fax: (44) 1355-242-743

RF/Automotive

Theresienstrasse 2

Postfach 3535

74025 Heilbronn, Germany

Tel: (49) 71-31-67-0

Fax: (49) 71-31-67-2340

1150 East Cheyenne Mtn. Blvd.

Colorado Springs, CO 80906, USA

Tel: 1(719) 576-3300

Fax: 1(719) 540-1759

Biometrics/Imaging/Hi-Rel MPU/

High Speed Converters/RF Datacom

Avenue de Rochepleine

BP 123

38521 Saint-Egreve Cedex, France

Tel: (33) 4-76-58-30-00

Fax: (33) 4-76-58-34-80

Literature Requests

www.atmel.com/literature

Disclaimer: Atmel Corporation makes no warranty for the use of its products, other than those expressly contained in the Company’s standard warranty which is detailed in Atmel’s Terms and Conditions located on the Company’s web site. The Company assumes no responsibility for any errors which may appear in this document, reserves the right to change devices or specifications detailed herein at any time without notice, and does not make any commitment to update the information contained herein. No licenses to patents or other intellectual property of Atmel are granted by the Company in connection with the sale of Atmel products, expressly or by implication. Atmel’s products are not authorized for use as critical components in life support devices or systems.

© Atmel Corporation 2003 . All rights reserved. Atmel® and combinations thereof, AVR® and AVR Studio® are the registered trademarks of Atmel Corporation or its subsidiaries. Microsoft®, Windows®, Windows NT®, and Windows XP® are the registered trademarks of Microsoft Corporation. Other terms and product names may be the trademarks of others

Printed on recycled paper.

2486M–AVR–12/03

Соседние файлы в папке datasheets