Скачиваний:
26
Добавлен:
23.02.2014
Размер:
4.33 Mб
Скачать

 

 

ATmega32(L)

Table of Contents

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

1

 

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

2

 

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

2

 

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

3

 

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

3

 

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

4

 

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

5

 

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

6

 

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

6

 

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

6

 

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

7

 

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

8

 

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

9

 

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

10

 

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

11

 

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

11

 

AVR ATmega32 Memories ................................................................

14

 

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

14

 

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

15

 

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

16

 

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

21

 

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

22

 

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

22

 

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

23

 

Default Clock Source ..........................................................................................

23

 

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

24

 

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

26

 

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

26

 

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

27

 

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

29

 

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

29

 

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

30

 

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

31

 

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

31

 

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

31

 

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

31

 

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

32

 

Extended Standby Mode ....................................................................................

32

 

 

i

2503F–AVR–12/03

 

 

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

32

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

34

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

39

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

39

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

42

Interrupt Vectors in ATmega32...........................................................................

42

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

47

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

47

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

48

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

52

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

62

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

64

8-bit Timer/Counter0 with PWM........................................................

67

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

67

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

68

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

68

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

69

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

70

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

71

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

76

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

78

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

82

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

84

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

84

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

87

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

89

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

89

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

91

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

92

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

94

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

95

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

103

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

105

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

112

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

112

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

113

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

113

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

114

ii ATmega32(L)

2503F–AVR–12/03

ATmega32(L)

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

115

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

116

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

121

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

123

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

126

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

129

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

130

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

134

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

137

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

138

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

138

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

139

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

142

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

144

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

145

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

148

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

151

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

155

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

156

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

157

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

163

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

167

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

167

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

167

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

168

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

170

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

173

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

175

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

178

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

181

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

194

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

196

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

198

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

199

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

199

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

200

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

201

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

202

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

205

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

207

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

211

 

iii

2503F–AVR–12/03

JTAG Interface and On-chip Debug System .................................

217

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

217

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

217

Test Access Port – TAP....................................................................................

217

TAP Controller ..................................................................................................

219

Using the Boundary-scan Chain .......................................................................

220

Using the On-chip Debug System ....................................................................

220

On-chip Debug Specific JTAG Instructions ......................................................

221

On-chip Debug Related Register in I/O Memory ..............................................

222

Using the JTAG Programming Capabilities ......................................................

222

Bibliography ......................................................................................................

222

IEEE 1149.1 (JTAG) Boundary-scan ..............................................

223

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

223

System Overview..............................................................................................

223

Data Registers ..................................................................................................

223

Boundary-scan Specific JTAG Instructions ......................................................

225

Boundary-scan Chain .......................................................................................

227

ATmega32 Boundary-scan Order.....................................................................

237

Boundary-scan Description Language Files .....................................................

241

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

242

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

242

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

242

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

242

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

244

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

245

Addressing the Flash during Self-Programming ...............................................

247

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

248

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

254

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

254

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

255

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

256

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

256

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

257

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

259

SPI Serial Downloading ....................................................................................

268

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

268

Programming via the JTAG Interface ...............................................................

272

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

285

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

285

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

285

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

287

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

287

iv ATmega32(L)

2503F–AVR–12/03

ATmega32(L)

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

288

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

289

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

291

ATmega32 Typical Characteristics – Preliminary Data ................

294

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

299

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

301

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

304

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

305

44A ...................................................................................................................

305

40P6 .................................................................................................................

306

44M1.................................................................................................................

307

Errata ................................................................................................

308

ATmega32 Rev. A ............................................................................................

308

Datasheet Change Log for ATmega32...........................................

309

Changes from Rev. 2503E-09/03 to Rev. 2503F-12/03 ...................................

309

Changes from Rev. 2503D-02/03 to Rev. 2503E-09/03 ...................................

309

Changes from Rev. 2503C-10/02 to Rev. 2503D-02/03...................................

309

Changes from Rev. 2503B-10/02 to Rev. 2503C-10/02 ...................................

309

Changes from Rev. 2503A-03/02 to Rev. 2503B-10/02 ...................................

310

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

i

v

2503F–AVR–12/03

vi ATmega32(L)

2503F–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.

2503F–AVR–12/03

Соседние файлы в папке информация