Rainbow-electronics ATmega162V Uživatelský manuál

Procházejte online nebo si stáhněte Uživatelský manuál pro Senzory Rainbow-electronics ATmega162V. Rainbow Electronics ATmega162V User Manual Uživatelská příručka

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 323
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 0
2513E–AVR–09/03
Features
High-performance, Low-power AVR
®
8-bit Microcontroller
Advanced RISC Architecture
131 Powerful Instructions – Most Single-clock Cycle Execution
32 x 8 General Purpose Working Registers
Fully Static Operation
Up to 16 MIPS Throughput at 16 MHz
On-chip 2-cycle Multiplier
Non-volatile Program and Data Memories
16K Bytes of In-System Self-programmable Flash
Endurance: 10,000 Write/Erase Cycles
Optional Boot Code Section with Independent Lock Bits
In-System Programming by On-chip Boot Program
True Read-While-Write Operation
512 Bytes EEPROM
Endurance: 100,000 Write/Erase Cycles
1K Bytes Internal SRAM
Up to 64K Bytes Optional External Memory Space
Programming Lock for Software Security
JTAG (IEEE std. 1149.1 Compliant) Interface
Boundary-scan Capabilities According to the JTAG Standard
Extensive On-chip Debug Support
Programming of Flash, EEPROM, Fuses, and Lock Bits through the JTAG Interface
Peripheral Features
Two 8-bit Timer/Counters with Separate Prescalers and Compare Modes
Two 16-bit Timer/Counters with Separate Prescalers, Compare Modes, and
Capture Modes
Real Time Counter with Separate Oscillator
Six PWM Channels
Dual Programmable Serial USARTs
Master/Slave SPI Serial Interface
Programmable Watchdog Timer with Separate On-chip Oscillator
On-chip Analog Comparator
Special Microcontroller Features
Power-on Reset and Programmable Brown-out Detection
Internal Calibrated RC Oscillator
External and Internal Interrupt Sources
Five Sleep Modes: Idle, Power-save, Power-down, Standby, and Extended Standby
I/O and Packages
35 Programmable I/O Lines
40-pin PDIP, 44-lead TQFP, and 44-pad MLF
Operating Voltages
1.8 - 5.5V for ATmega162V
2.7 - 5.5V for ATmega162
Speed Grades
0 - 8 MHz for ATmega162V (see Figure 113 on page 265)
0 - 16 MHz for ATmega162 (see Figure 114 on page 265)
8-bit
Microcontroller
with 16K Bytes
In-System
Programmable
Flash
ATmega162
ATmega162V
Zobrazit stránku 0
1 2 3 4 5 6 ... 322 323

Shrnutí obsahu

Strany 1 - Features

2513E–AVR–09/03Features• High-performance, Low-power AVR® 8-bit Microcontroller• Advanced RISC Architecture– 131 Powerful Instructions – Most Single-

Strany 2

10ATmega162/V2513E–AVR–09/03General Purpose Register FileThe Register File is optimized for the AVR Enhanced RISC instruction set. In order toachieve

Strany 3

100ATmega162/V2513E–AVR–09/03When OC0 is connected to the pin, the function of the COM01:0 bits depends on theWGM01:0 bit setting. Table 48 shows the

Strany 4

101ATmega162/V2513E–AVR–09/03• Bit 2:0 – CS02:0: Clock SelectThe three Clock Select bits select the clock source to be used by the Timer/Counter.If ex

Strany 5

102ATmega162/V2513E–AVR–09/03• Bit 0 – OCIE0: Timer/Counter0 Output Compare Match Interrupt EnableWhen the OCIE0 bit is written to one, and the I-bit

Strany 6

103ATmega162/V2513E–AVR–09/03Timer/Counter0, Timer/Counter1, and Timer/Counter3 PrescalersTimer/Counter3, Timer/Counter1, and Timer/Counter0 share the

Strany 7

104ATmega162/V2513E–AVR–09/03Each half period of the external clock applied must be longer than one system clockcycle to ensure correct sampling. The

Strany 8

105ATmega162/V2513E–AVR–09/0316-bit Timer/Counter (Timer/Counter1 and Timer/Counter3)The 16-bit Timer/Counter unit allows accurate program execution t

Strany 9

106ATmega162/V2513E–AVR–09/03Figure 46. 16-bit Timer/Counter Block Diagram(1)Note: 1. Refer to Figure 1 on page 2, Table 32 on page 71, and Table 38

Strany 10 - ATmega162/V

107ATmega162/V2513E–AVR–09/03(OCnA/B). See “Output Compare Units” on page 114. The Compare Match event willalso set the Compare Match Flag (OCFnA/B) w

Strany 11

108ATmega162/V2513E–AVR–09/03Accessing 16-bit RegistersThe TCNTn, OCRnA/B, and ICRn are 16-bit registers that can be accessed by the AVRCPU via the 8-

Strany 12

109ATmega162/V2513E–AVR–09/03Therefore, when both the main code and the interrupt code update the temporary regis-ter, the main code must disable the

Strany 13

11ATmega162/V2513E–AVR–09/03The X-register, Y-register, and Z-registerThe registers R26..R31 have some added functions to their general purpose usage.

Strany 14

110ATmega162/V2513E–AVR–09/03The following code examples show how to do an atomic write of the TCNTn Registercontents. Writing any of the OCRnA/B or I

Strany 15

111ATmega162/V2513E–AVR–09/03Timer/Counter Clock SourcesThe Timer/Counter can be clocked by an internal or an external clock source. The clocksource i

Strany 16

112ATmega162/V2513E–AVR–09/03how waveforms are generated on the Output Compare outputs OCnx. For more detailsabout advanced counting sequences and wav

Strany 17

113ATmega162/V2513E–AVR–09/03Reading the 16-bit value in the Input Capture Register (ICRn) is done by first reading thelow byte (ICRnL) and then the h

Strany 18

114ATmega162/V2513E–AVR–09/03(ICFn) must be cleared by software (writing a logical one to the I/O bit location). Formeasuring frequency only, the clea

Strany 19

115ATmega162/V2513E–AVR–09/03sequence. The synchronization prevents the occurrence of odd-length, non-symmetricalPWM pulses, thereby making the output

Strany 20

116ATmega162/V2513E–AVR–09/03Compare Match Output UnitThe Compare Output mode (COMnx1:0) bits have two functions. The waveform genera-tor uses the COM

Strany 21

117ATmega162/V2513E–AVR–09/03Compare Output Mode and Waveform GenerationThe Waveform Generator uses the COMnx1:0 bits differently in normal, CTC, and

Strany 22

118ATmega162/V2513E–AVR–09/03Figure 51. CTC Mode, Timing DiagramAn interrupt can be generated at each time the counter value reaches the TOP value by

Strany 23

119ATmega162/V2513E–AVR–09/03Fast PWM Mode The fast Pulse Width Modulation or fast PWM mode (WGMn3:0 = 5,6,7,14, or 15) pro-vides a high frequency PWM

Strany 24

12ATmega162/V2513E–AVR–09/03Instruction Execution TimingThis section describes the general access timing concepts for instruction execution. TheAVR CP

Strany 25

120ATmega162/V2513E–AVR–09/03When changing the TOP value the program must ensure that the new TOP value ishigher or equal to the value of all of the c

Strany 26

121ATmega162/V2513E–AVR–09/03Phase Correct PWM Mode The phase correct Pulse Width Modulation or phase correct PWM mode (WGMn3:0 = 1,2, 3, 10, or 11) p

Strany 27

122ATmega162/V2513E–AVR–09/03ICFn Flag is set accordingly at the same timer clock cycle as the OCRnx Registers areupdated with the double buffer value

Strany 28

123ATmega162/V2513E–AVR–09/03pared to the single-slope operation. However, due to the symmetric feature of the dual-slope PWM modes, these modes are p

Strany 29

124ATmega162/V2513E–AVR–09/03than any of the compare registers, a Compare Match will never occur between theTCNTn and the OCRnx.As Figure 54 shows the

Strany 30

125ATmega162/V2513E–AVR–09/03Timer/Counter Timing DiagramsThe Timer/Counter is a synchronous design and the timer clock (clkTn) is thereforeshown as a

Strany 31

126ATmega162/V2513E–AVR–09/03Figure 57. Timer/Counter Timing Diagram, no PrescalingFigure 58 shows the same timing data, but with the prescaler enabl

Strany 32

127ATmega162/V2513E–AVR–09/0316-bit Timer/Counter Register DescriptionTimer/Counter1 Control Register A – TCCR1ATimer/Counter3 Control Register A – TC

Strany 33

128ATmega162/V2513E–AVR–09/03Table 54 shows the COMnx1:0 bit functionality when the WGMn3:0 bits are set to thefast PWM mode.Note: 1. A special case o

Strany 34

129ATmega162/V2513E–AVR–09/03• Bit 1:0 – WGMn1:0: Waveform Generation ModeCombined with the WGMn3:2 bits found in the TCCRnB Register, these bits cont

Strany 35

13ATmega162/V2513E–AVR–09/03also be moved to the start of the Boot Flash section by programming the BOOTRSTFuse, see “Boot Loader Support – Read-While

Strany 36

130ATmega162/V2513E–AVR–09/03Timer/Counter1 Control Register B – TCCR1BTimer/Counter3 Control Register B – TCCR3B• Bit 7 – ICNCn: Input Capture Noise

Strany 37

131ATmega162/V2513E–AVR–09/03• Bit 2:0 – CSn2:0: Clock SelectThe three Clock Select bits select the clock source to be used by the Timer/Counter, seeF

Strany 38

132ATmega162/V2513E–AVR–09/03Timer/Counter1 – TCNT1H and TCNT1LTimer/Counter3 – TCNT3H and TCNT3LThe two Timer/Counter I/O locations (TCNTnH and TCNTn

Strany 39

133ATmega162/V2513E–AVR–09/03The Output Compare Registers contain a 16-bit value that is continuously comparedwith the counter value (TCNTn). A match

Strany 40

134ATmega162/V2513E–AVR–09/03• Bit 5 – OCIE1B: Timer/Counter1, Output Compare B Match Interrupt EnableWhen this bit is written to one, and the I-flag

Strany 41

135ATmega162/V2513E–AVR–09/03Timer/Counter Interrupt Flag Register – TIFR(1)Note: 1. This register contains flag bits for several Timer/Counters, but

Strany 42

136ATmega162/V2513E–AVR–09/03Extended Timer/Counter Interrupt Flag Register – ETIFR(1)Note: 1. This register contains flag bits for several Timer/Coun

Strany 43

137ATmega162/V2513E–AVR–09/038-bit Timer/Counter2 with PWM and Asynchronous operationTimer/Counter2 is a general purpose, single channel, 8-bit Timer/

Strany 44

138ATmega162/V2513E–AVR–09/03The Timer/Counter can be clocked internally, via the prescaler, or asynchronouslyclocked from the TOSC1/2 pins, as detail

Strany 45

139ATmega162/V2513E–AVR–09/03Counter Unit The main part of the 8-bit Timer/Counter is the programmable bi-directional counter unit.Figure 60 shows a b

Strany 46

14ATmega162/V2513E–AVR–09/03When using the SEI instruction to enable interrupts, the instruction following SEI will beexecuted before any pending inte

Strany 47

140ATmega162/V2513E–AVR–09/03Figure 61. Output Compare Unit, Block DiagramThe OCR2 Register is double buffered when using any of the Pulse Width Modu

Strany 48

141ATmega162/V2513E–AVR–09/03resulting in incorrect Waveform Generation. Similarly, do not write the TCNT2 valueequal to BOTTOM when the counter is do

Strany 49

142ATmega162/V2513E–AVR–09/03The design of the Output Compare pin logic allows initialization of the OC2 state beforethe output is enabled. Note that

Strany 50

143ATmega162/V2513E–AVR–09/03Clear Timer on Compare Match (CTC) ModeIn Clear Timer on Compare or CTC mode (WGM21:0 = 2), the OCR2 Register is used tom

Strany 51

144ATmega162/V2513E–AVR–09/03Fast PWM Mode The fast Pulse Width Modulation or fast PWM mode (WGM21:0 = 1) provides a high fre-quency PWM waveform gene

Strany 52

145ATmega162/V2513E–AVR–09/03The PWM frequency for the output can be calculated by the following equation:The N variable represents the prescale facto

Strany 53

146ATmega162/V2513E–AVR–09/03The Timer/Counter Overflow Flag (TOV2) is set each time the counter reaches BOT-TOM. The Interrupt Flag can be used to ge

Strany 54

147ATmega162/V2513E–AVR–09/03Figure 66. Timer/Counter Timing Diagram, no PrescalingFigure 67 shows the same timing data, but with the prescaler enabl

Strany 55

148ATmega162/V2513E–AVR–09/03Figure 69. Timer/Counter Timing Diagram, Clear Timer on Compare Match mode, withPrescaler (fclk_I/O/8)8-bit Timer/Counte

Strany 56

149ATmega162/V2513E–AVR–09/03match (CTC) mode, and two types of Pulse Width Modulation (PWM) modes. See Table60 and “Modes of Operation” on page 142.N

Strany 57

15ATmega162/V2513E–AVR–09/03AVR ATmega162 MemoriesThis section describes the different memories in the ATmega162. The AVR architecturehas two main mem

Strany 58

150ATmega162/V2513E–AVR–09/03• Bit 5:4 – COM21:0: Compare Match Output ModeThese bits control the Output Compare pin (OC2) behavior. If one or both of

Strany 59

151ATmega162/V2513E–AVR–09/03• Bit 2:0 – CS22:0: Clock SelectThe three Clock Select bits select the clock source to be used by the Timer/Counter, seeT

Strany 60

152ATmega162/V2513E–AVR–09/03Asynchronous operation of the Timer/CounterAsynchronous Status Register – ASSR• Bit 3 – AS2: Asynchronous Timer/Counter2W

Strany 61

153ATmega162/V2513E–AVR–09/03Asynchronous Operation of Timer/Counter2When Timer/Counter2 operates asynchronously, some considerations must be taken.•

Strany 62

154ATmega162/V2513E–AVR–09/03down or Standby mode due to unstable clock signal upon start-up, no matter whether the Oscillator is in use or a clock si

Strany 63 - Ports as General Digital

155ATmega162/V2513E–AVR–09/03Timer/Counter Interrupt Flag Register – TIFR• Bit 4 – OCF2: Output Compare Flag 2The OCF2 bit is set (one) when a Compare

Strany 64 - SYSTEM CLK

156ATmega162/V2513E–AVR–09/03Timer/Counter Prescaler Figure 70. Prescaler for Timer/Counter2The clock source for Timer/Counter2 is named clkT2S. clkT

Strany 65 - 2513E–AVR–09/03

157ATmega162/V2513E–AVR–09/03Serial Peripheral Interface – SPIThe Serial Peripheral Interface (SPI) allows high-speed synchronous data transferbetween

Strany 66

158ATmega162/V2513E–AVR–09/03When configured as a Master, the SPI interface has no automatic control of the SS line.This must be handled by user softw

Strany 67 - DATA BUS

159ATmega162/V2513E–AVR–09/03The following code examples show how to initialize the SPI as a Master and how to per-form a simple transmission. DDR_SPI

Strany 68

16ATmega162/V2513E–AVR–09/03SRAM Data Memory Figure 9 shows how the ATmega162 SRAM Memory is organized. Memory configura-tion B refers to the ATmega16

Strany 69

160ATmega162/V2513E–AVR–09/03The following code examples show how to initialize the SPI as a slave and how to per-form a simple reception.Note: 1. The

Strany 70

161ATmega162/V2513E–AVR–09/03SS Pin FunctionalitySlave Mode When the SPI is configured as a slave, the Slave Select (SS) pin is always input. WhenSS i

Strany 71

162ATmega162/V2513E–AVR–09/03• Bit 4 – MSTR: Master/Slave SelectThis bit selects Master SPI mode when written to one, and Slave SPI mode when writtenl

Strany 72

163ATmega162/V2513E–AVR–09/03SPI Status Register – SPSR• Bit 7 – SPIF: SPI Interrupt FlagWhen a serial transfer is complete, the SPIF Flag is set. An

Strany 73

164ATmega162/V2513E–AVR–09/03Data Modes There are four combinations of SCK phase and polarity with respect to serial data,which are determined by cont

Strany 74

165ATmega162/V2513E–AVR–09/03USART The Universal Synchronous and Asynchronous serial Receiver and Transmitter(USART) is a highly flexible serial commu

Strany 75

166ATmega162/V2513E–AVR–09/03Figure 75. USART Block Diagram(1)Note: 1. Refer to Figure 1 on page 2, Table 34 on page 73, Table 39 on page 79, and Tab

Strany 76

167ATmega162/V2513E–AVR–09/03AVR USART vs. AVR UART – CompatibilityThe USART is fully compatible with the AVR UART regarding:• Bit locations inside al

Strany 77

168ATmega162/V2513E–AVR–09/03Signal description:txclk Transmitter clock. (Internal Signal)rxclk Receiver base clock. (Internal Signal)xcki Input from

Strany 78

169ATmega162/V2513E–AVR–09/03Double Speed Operation (U2X)The transfer rate can be doubled by setting the U2X bit in UCSRA. Setting this bit onlyhas ef

Strany 79

17ATmega162/V2513E–AVR–09/03When using register indirect addressing modes with automatic pre-decrement and post-increment, the address registers X, Y,

Strany 80

170ATmega162/V2513E–AVR–09/03Frame Formats A serial frame is defined to be one character of data bits with synchronization bits (startand stop bits),

Strany 81

171ATmega162/V2513E–AVR–09/03If used, the parity bit is located between the last data bit and first stop bit of a serialframe.USART Initialization The

Strany 82

172ATmega162/V2513E–AVR–09/03Baud and Control Registers, and for these types of applications the initialization codecan be placed directly in the main

Strany 83

173ATmega162/V2513E–AVR–09/03Sending Frames with 9 Data BitIf 9-bit characters are used (UCSZ = 7), the ninth bit must be written to the TXB8 bit inUC

Strany 84

174ATmega162/V2513E–AVR–09/03Empty Interrupt, otherwise a new interrupt will occur once the interrupt routineterminates.The Transmit Complete (TXC) Fl

Strany 85

175ATmega162/V2513E–AVR–09/03Receiving Frames with 5 to 8 Data BitsThe Receiver starts data reception when it detects a valid start bit. Each bit that

Strany 86

176ATmega162/V2513E–AVR–09/03Receiving Frames with 9 Data BitsIf 9-bit characters are used (UCSZ=7) the ninth bit must be read from the RXB8 bit inUCS

Strany 87

177ATmega162/V2513E–AVR–09/03The receive function example reads all the I/O Registers into the Register File beforeany computation is done. This gives

Strany 88

178ATmega162/V2513E–AVR–09/03Parity Checker The Parity Checker is active when the high USART Parity mode (UPM1) bit is set. Typeof parity check to be

Strany 89

179ATmega162/V2513E–AVR–09/03(U2X = 1) of operation. Samples denoted zero are samples done when the RxD line isidle (i.e., no communication activity).

Strany 90

18ATmega162/V2513E–AVR–09/03EEPROM Data Memory The ATmega162 contains 512 bytes of data EEPROM memory. It is organized as a sep-arate data space, in w

Strany 91

180ATmega162/V2513E–AVR–09/03Figure 81. Stop Bit Sampling and Next Start Bit SamplingThe same majority voting is done to the stop bit as done for the

Strany 92

181ATmega162/V2513E–AVR–09/03The recommendations of the maximum receiver baud rate error was made under theassumption that the Receiver and Transmitte

Strany 93

182ATmega162/V2513E–AVR–09/03The Multi-processor Communication mode enables several slave MCUs to receive datafrom a Master MCU. This is done by first

Strany 94

183ATmega162/V2513E–AVR–09/03Accessing UBRRH/UCSRC RegistersThe UBRRH Register shares the same I/O location as the UCSRC Register. Thereforesome speci

Strany 95

184ATmega162/V2513E–AVR–09/03Read Access Doing a read access to the UBRRH or the UCSRC Register is a more complex opera-tion. However, in most applica

Strany 96

185ATmega162/V2513E–AVR–09/03USART Register DescriptionUSART I/O Data Register – UDRThe USART Transmit Data Buffer Register and USART Receive Data Buf

Strany 97

186ATmega162/V2513E–AVR–09/03UDRE is set after a Reset to indicate that the transmitter is ready.• Bit 4 – FE: Frame ErrorThis bit is set if the next

Strany 98

187ATmega162/V2513E–AVR–09/03• Bit 5 – UDRIE: USART Data Register Empty Interrupt EnableWriting this bit to one enables interrupt on the UDRE Flag. A

Strany 99

188ATmega162/V2513E–AVR–09/03USART Control and Status Register C – UCSRC(1)Note: 1. The UCSRC Register shares the same I/O location as the UBRRH Regis

Strany 100

189ATmega162/V2513E–AVR–09/03• Bit 2:1 – UCSZ1:0: Character SizeThe UCSZ1:0 bits combined with the UCSZ2 bit in UCSRB sets the number of data bits(Cha

Strany 101

19ATmega162/V2513E–AVR–09/03The EEPROM Data Register – EEDR• Bits 7..0 – EEDR7.0: EEPROM DataFor the EEPROM write operation, the EEDR Register contain

Strany 102

190ATmega162/V2513E–AVR–09/03• Bit 11:0 – UBRR11:0: USART Baud Rate RegisterThis is a 12-bit register which contains the USART baud rate. The UBRRH co

Strany 103

191ATmega162/V2513E–AVR–09/03Table 79. Examples of UBRR Settings for Commonly Used Oscillator Frequencies (Continued)Baud Rate (bps)fosc = 3.6864 MHz

Strany 104

192ATmega162/V2513E–AVR–09/03Table 80. Examples of UBRR Settings for Commonly Used Oscillator Frequencies (Continued)Baud Rate (bps)fosc = 8.0000 MHz

Strany 105

193ATmega162/V2513E–AVR–09/03Table 81. Examples of UBRR Settings for Commonly Used Oscillator Frequencies (Continued)Baud Rate (bps)fosc = 16.0000 MH

Strany 106

194ATmega162/V2513E–AVR–09/03Analog Comparator The Analog Comparator compares the input values on the positive pin AIN0 and nega-tive pin AIN1. When t

Strany 107

195ATmega162/V2513E–AVR–09/03the ACIE bit is set and the I-bit in SREG is set. ACI is cleared by hardware when execut-ing the corresponding interrupt

Strany 108

196ATmega162/V2513E–AVR–09/03JTAG Interface and On-chip Debug SystemFeatures • JTAG (IEEE std. 1149.1 Compliant) Interface• Boundary-scan Capabilities

Strany 109

197ATmega162/V2513E–AVR–09/03The IEEE std. 1149.1 also specifies an optional TAP signal; TRST – Test ReSeT –which is not provided.When the JTAGEN fuse

Strany 110

198ATmega162/V2513E–AVR–09/03Figure 84. TAP Controller State DiagramTest-Logic-ResetRun-Test/IdleShift-DRExit1-DRPause-DRExit2-DRUpdate-DRSelect-IR S

Strany 111

199ATmega162/V2513E–AVR–09/03TAP Controller The TAP controller is a 16-state finite state machine that controls the operation of theBoundary-scan circ

Strany 112

2ATmega162/V2513E–AVR–09/03Pin Configurations Figure 1. Pinout ATmega162Disclaimer Typical values contained in this datasheet are based on simulation

Strany 113

20ATmega162/V2513E–AVR–09/03can be omitted. See “Boot Loader Support – Read-While-Write Self-programming” onpage 216 for details about boot programmin

Strany 114

200ATmega162/V2513E–AVR–09/03Using the On-chip Debug systemAs shown in Figure 83, the hardware support for On-chip Debugging consists mainly of• A sca

Strany 115

201ATmega162/V2513E–AVR–09/03On-chip debug specific JTAG instructionsThe On-chip debug support is considered being private JTAG instructions, and dist

Strany 116

202ATmega162/V2513E–AVR–09/03Bibliography For more information about general Boundary-scan, the following literature can beconsulted:• IEEE: IEEE Std.

Strany 117

203ATmega162/V2513E–AVR–09/03IEEE 1149.1 (JTAG) Boundary-scanFeatures • JTAG (IEEE std. 1149.1 Compliant) Interface• Boundary-scan Capabilities Accord

Strany 118

204ATmega162/V2513E–AVR–09/03Data Registers The data registers relevant for Boundary-scan operations are:• Bypass Register• Device Identification Reg

Strany 119

205ATmega162/V2513E–AVR–09/03on the Fuse settings for the clock options, the part will remain reset for a Reset Time-outPeriod (refer to “Clock Source

Strany 120

206ATmega162/V2513E–AVR–09/03IDCODE; 0x1 Optional JTAG instruction selecting the 32-bit ID-register as data register. The ID-Regis-ter consists of a v

Strany 121

207ATmega162/V2513E–AVR–09/03If the JTAG interface is left unconnected to other JTAG circuitry, the JTD bit should beset to one. The reason for this i

Strany 122

208ATmega162/V2513E–AVR–09/03Figure 87. Boundary-scan Cell for Bi-directional Port Pin with Pull-up Function.DQ DQG0101DQ DQG01010101DQ DQG01Port Pin

Strany 123

209ATmega162/V2513E–AVR–09/03Figure 88. General Port Pin Schematic DiagramScanning the RESET pin The RESET pin accepts 5V active low logic for standa

Strany 124

21ATmega162/V2513E–AVR–09/03The following code examples show one assembly and one C function for writing to theEEPROM. The examples assume that interr

Strany 125

210ATmega162/V2513E–AVR–09/03Scanning the Clock Pins The AVR devices have many clock options selectable by fuses. These are: Internal RCOscillator, Ex

Strany 126

211ATmega162/V2513E–AVR–09/03Scanning the Analog ComparatorThe relevant Comparator signals regarding Boundary-scan are shown in Figure 91. TheBoundary

Strany 127

212ATmega162/V2513E–AVR–09/03ATmega162 Boundary-scan OrderTable 88 shows the Scan order between TDI and TDO when the Boundary-scan chainis selected as

Strany 128

213ATmega162/V2513E–AVR–09/0387 PB5.Data Port B86 PB5.Control85 PB5.Pullup_Enable84 PB6.Data83 PB6.Control82 PB6.Pullup_Enable81 PB7.Data80 PB7.Contro

Strany 129

214ATmega162/V2513E–AVR–09/0351 PD7.Pullup_Enable Port D50 EXTCLKEN Enable signals for main Clock/Oscillators49 OSCON48 OSC32EN47 EXTCLK (XTAL1) Clock

Strany 130

215ATmega162/V2513E–AVR–09/03Note: 1. PRIVATE_SIGNAL1 should always be scanned in as zero.Boundary-scan Description Language FilesBoundary-scan Descri

Strany 131

216ATmega162/V2513E–AVR–09/03Boot Loader Support – Read-While-Write Self-programmingThe Boot Loader Support provides a real Read-While-Write Self-prog

Strany 132

217ATmega162/V2513E–AVR–09/03Note that the user software can never read any code that is located inside the RWWsection during a Boot Loader software o

Strany 133

218ATmega162/V2513E–AVR–09/03Figure 94. Memory Sections(1)Note: 1. The parameters are given in Table 94 on page 228.Boot Loader Lock Bits If no Boot

Strany 134

219ATmega162/V2513E–AVR–09/03ming of the Flash memory by SPM instruction. Similarly, the general Read/Write Lock(Lock bit mode 1) does not control rea

Strany 135

22ATmega162/V2513E–AVR–09/03The next code examples show assembly and C functions for reading the EEPROM. Theexamples assume that interrupts are contro

Strany 136

220ATmega162/V2513E–AVR–09/03Entering the Boot Loader ProgramEntering the Boot Loader takes place by a jump or call from the application program.This

Strany 137

221ATmega162/V2513E–AVR–09/03• Bit 3 – BLBSET: Boot Lock Bit SetIf this bit is written to one at the same time as SPMEN, the next SPM instruction with

Strany 138

222ATmega162/V2513E–AVR–09/03Addressing the Flash During Self-programmingThe Z-pointer is used to address the SPM commands.Since the Flash is organize

Strany 139

223ATmega162/V2513E–AVR–09/03Self-programming the FlashThe program memory is updated in a page by page fashion. Before programming apage with the data

Strany 140

224ATmega162/V2513E–AVR–09/03Using the SPM Interrupt If the SPM interrupt is enabled, the SPM interrupt will generate a constant interruptwhen the SPM

Strany 141

225ATmega162/V2513E–AVR–09/03executed within four CPU cycles. When BLBSET and SPMEN are cleared, LPM willwork as described in the Instruction set Manu

Strany 142

226ATmega162/V2513E–AVR–09/033. Keep the AVR core in Power-down sleep mode during periods of low VCC. This will prevent the CPU from attempting to dec

Strany 143

227ATmega162/V2513E–AVR–09/03ldi looplo, low(PAGESIZEB) ;init loop variableldi loophi, high(PAGESIZEB) ;not required for PAGESIZEB<=256subi YL, low

Strany 144

228ATmega162/V2513E–AVR–09/03ATmega162 Boot Loader ParametersIn Table 94 through Table 96, the parameters used in the description of the self pro-gram

Strany 145

229ATmega162/V2513E–AVR–09/03Note: 1. Z15:Z14: always ignoredZ0: should be zero for all SPM commands, byte select for the LPM instruction.See “Address

Strany 146

23ATmega162/V2513E–AVR–09/03Keep the AVR RESET active (low) during periods of insufficient power supply voltage.This can be done by enabling the inter

Strany 147

230ATmega162/V2513E–AVR–09/03Memory ProgrammingProgram And Data Memory Lock BitsThe ATmega162 provides six Lock bits which can be left unprogrammed (“

Strany 148

231ATmega162/V2513E–AVR–09/03Notes: 1. Program the Fuse bits and Boot Lock bits before programming the LB1 and LB2.2. “1” means unprogrammed, “0” mean

Strany 149

232ATmega162/V2513E–AVR–09/03Notes: 1. The SPIEN Fuse is not accessible in SPI Serial Programming mode.2. The default value of BOOTSZ1:0 results in ma

Strany 150

233ATmega162/V2513E–AVR–09/03Latching of Fuses The Fuse values are latched when the device enters Programming mode and changesof the Fuse values will

Strany 151

234ATmega162/V2513E–AVR–09/03Table 102. Pin Name Mapping Signal Name in Programming Mode Pin Name I/O FunctionRDY/BSY PD1 O0: Device is busy programm

Strany 152

235ATmega162/V2513E–AVR–09/03Parallel ProgrammingEnter Programming Mode The following algorithm puts the device in Parallel Programming mode:1. Apply

Strany 153

236ATmega162/V2513E–AVR–09/03Chip Erase The Chip Erase will erase the Flash and EEPROM(1) memories plus Lock bits. The Lockbits are not reset until th

Strany 154

237ATmega162/V2513E–AVR–09/03While the lower bits in the address are mapped to words within the page, the higher bitsaddress the pages within the FLAS

Strany 155

238ATmega162/V2513E–AVR–09/03Figure 98. Programming the Flash WaveformsNote: “XX” is don’t care. The letters refer to the programming description abo

Strany 156

239ATmega162/V2513E–AVR–09/03Figure 99. Programming the EEPROM WaveformsReading the Flash The algorithm for reading the Flash memory is as follows (r

Strany 157

24ATmega162/V2513E–AVR–09/03External Memory InterfaceWith all the features the External Memory Interface provides, it is well suited to operateas an i

Strany 158

240ATmega162/V2513E–AVR–09/03Programming the Fuse High BitsThe algorithm for programming the Fuse high bits is as follows (refer to “Programmingthe Fl

Strany 159

241ATmega162/V2513E–AVR–09/03Programming the Lock Bits The algorithm for programming the Lock bits is as follows (refer to “Programming theFlash” on p

Strany 160

242ATmega162/V2513E–AVR–09/03Reading the Calibration Byte The algorithm for reading the calibration byte is as follows (refer to “Programming theFlash

Strany 161

243ATmega162/V2513E–AVR–09/03Figure 104. Parallel Programming Timing, Reading Sequence (within the Same Page)with Timing Requirements(1)Note: 1. The

Strany 162

244ATmega162/V2513E–AVR–09/03Notes: 1. tWLRH is valid for the Write Flash, Write EEPROM, Write Fuse Bits and Write LockBits commands.2. tWLRH_CE is

Strany 163

245ATmega162/V2513E–AVR–09/03Depending on CKSEL Fuses, a valid clock must be present. The minimum low and highperiods for the serial clock (SCK) input

Strany 164

246ATmega162/V2513E–AVR–09/036. Any memory location can be verified by using the Read instruction which returns the content at the selected address at

Strany 165

247ATmega162/V2513E–AVR–09/03Table 111. SPI Serial Programming Instruction Set(1) Instruction Instruction Format OperationByte 1 Byte 2 Byte 3 Byte4P

Strany 166

248ATmega162/V2513E–AVR–09/03Note: 1. a = address high bits, b = address low bits, H = 0 – Low byte, 1 – High Byte, o = data out, i = data in, x = don

Strany 167

249ATmega162/V2513E–AVR–09/03Programming via the JTAG InterfaceProgramming through the JTAG interface requires control of the four JTAG specificpins:

Strany 168

25ATmega162/V2513E–AVR–09/03The control bits for the External Memory Interface are located in three registers, theMCU Control Register – MCUCR, the Ex

Strany 169

250ATmega162/V2513E–AVR–09/03Figure 107. State machine sequence for changing the instruction wordTest-Logic-ResetRun-Test/IdleShift-DRExit1-DRPause-D

Strany 170

251ATmega162/V2513E–AVR–09/03AVR_RESET (0xC) The AVR specific public JTAG instruction for setting the AVR device in the Reset modeor taking the device

Strany 171

252ATmega162/V2513E–AVR–09/03Data Registers The Data Registers are selected by the JTAG Instruction Registers described in section“Programming Specifi

Strany 172

253ATmega162/V2513E–AVR–09/03Programming Command RegisterThe Programming Command Register is a 15-bit register. This register is used to seri-ally shi

Strany 173

254ATmega162/V2513E–AVR–09/03Table 112. JTAG Programming Instruction Set Instruction TDI sequence TDO sequence Notes1a. Chip eRase 0100011_1000000001

Strany 174

255ATmega162/V2513E–AVR–09/035d. Read Data Byte 0110011_bbbbbbbb0110010_000000000110011_00000000xxxxxxx_xxxxxxxxxxxxxxx_xxxxxxxxxxxxxxx_oooooooo6a. En

Strany 175

256ATmega162/V2513E–AVR–09/03Notes: 1. This command sequence is not required if the seven MSB are correctly set by the previous command sequence (whic

Strany 176

257ATmega162/V2513E–AVR–09/03Figure 110. State Machine Sequence for Changing/Reading the Data WordVirtual Flash Page Load RegisterThe Virtual Flash P

Strany 177

258ATmega162/V2513E–AVR–09/03Figure 111. Virtual Flash Page Load RegisterVirtual Flash Page Read RegisterThe Virtual Flash Page Read Register is a vi

Strany 178

259ATmega162/V2513E–AVR–09/03Figure 112. Virtual Flash Page Read RegisterProgramming Algorithm All references below of type “1a”, “1b”, and so on, re

Strany 179

26ATmega162/V2513E–AVR–09/03Pull-up and Bus Keeper The pull-up resistors on the AD7:0 ports may be activated if the corresponding Port reg-ister is wr

Strany 180

260ATmega162/V2513E–AVR–09/038. Poll for Flash write complete using programming instruction 2h, or wait for tWLRH_FLASH (refer to Table 108 on page 24

Strany 181

261ATmega162/V2513E–AVR–09/03Programming the EEPROM Before programming the EEPROM a Chip Erase must be performed. See “PerformingChip Erase” on page 2

Strany 182

262ATmega162/V2513E–AVR–09/03Reading the Fuses and Lock Bits1. Enter JTAG instruction PROG_COMMANDS.2. Enable Fuse/Lock bit read using programming ins

Strany 183

263ATmega162/V2513E–AVR–09/03Electrical CharacteristicsDC CharacteristicsAbsolute Maximum Ratings*Operating Temperature...

Strany 184

264ATmega162/V2513E–AVR–09/03Notes: 1. “Max” means the highest value where the pin is guaranteed to be read as low2. “Min” means the lowest value wher

Strany 185

265ATmega162/V2513E–AVR–09/03Figure 113. Absolute Maximum Frequency as a function of VCC, ATmega162VFigure 114. Absolute Maximum Frequency as a func

Strany 186

266ATmega162/V2513E–AVR–09/03External Clock Drive WaveformsFigure 115. External Clock Drive WaveformsExternal Clock DriveVIL1VIH1Table 113. External

Strany 187

267ATmega162/V2513E–AVR–09/03SPI Timing CharacteristicsSee Figure 116 and Figure 117 for details.Note: 1. In SPI Programming mode, the minimum SCK hig

Strany 188

268ATmega162/V2513E–AVR–09/03Figure 117. SPI Interface Timing Requirements (Slave Mode)MISO(Data Output)SCK(CPOL = 1)MOSI(Data Input)SCK(CPOL = 0)SSM

Strany 189

269ATmega162/V2513E–AVR–09/03External Data Memory TimingNotes: 1. This assumes 50% clock duty cycle. The half period is actually the high time of the

Strany 190

27ATmega162/V2513E–AVR–09/03Figure 14. External Data Memory Cycles with SRWn1 = 0 and SRWn0 = 1(1)Note: 1. SRWn1 = SRW11 (upper sector) or SRW01 (low

Strany 191

270ATmega162/V2513E–AVR–09/03Table 117. External Data Memory Characteristics, 4.5 - 5.5 Volts, SRWn1 = 1, SRWn0 = 0Symbol Parameter4 MHz Oscillator V

Strany 192

271ATmega162/V2513E–AVR–09/03Notes: 1. This assumes 50% clock duty cycle. The half period is actually the high time of the external clock, XTAL1.2. Th

Strany 193

272ATmega162/V2513E–AVR–09/03Figure 118. External Memory Timing (SRWn1 = 0, SRWn0 = 0Figure 119. External Memory Timing (SRWn1 = 0, SRWn0 = 1)ALET1

Strany 194

273ATmega162/V2513E–AVR–09/03Figure 120. External Memory Timing (SRWn1 = 1, SRWn0 = 0)Figure 121. External Memory Timing (SRWn1 = 1, SRWn0 = 1)(1)No

Strany 195

274ATmega162/V2513E–AVR–09/03ATmega162 Typical CharacteristicsThe following charts show typical behavior. These figures are not tested during manu-fac

Strany 196

275ATmega162/V2513E–AVR–09/03Figure 123. Active Supply Current vs. Frequency (1 - 20 MHz)Figure 124. Active Supply Current vs. VCC (Internal RC Osci

Strany 197

276ATmega162/V2513E–AVR–09/03Figure 125. Active Supply Current vs. VCC (32 kHz External Oscillator)Idle Supply Current Figure 126. Idle Supply Curre

Strany 198

277ATmega162/V2513E–AVR–09/03Figure 127. Idle Supply Current vs. Frequency (1 - 20 MHz)Figure 128. Idle Supply Current vs. VCC (Internal RC Oscillat

Strany 199

278ATmega162/V2513E–AVR–09/03Figure 129. Idle Supply Current vs. VCC (32 kHz External Oscillator)Power-down Supply Current Figure 130. Power-down Su

Strany 200

279ATmega162/V2513E–AVR–09/03Figure 131. Power-down Supply Current vs. VCC (Watchdog Timer Enabled)Power-save Supply Current Figure 132. Power-save

Strany 201

28ATmega162/V2513E–AVR–09/03Figure 16. External Data Memory Cycles with SRWn1 = 1 and SRWn0 = 1(1)Note: 1. SRWn1 = SRW11 (upper sector) or SRW01 (low

Strany 202

280ATmega162/V2513E–AVR–09/03Standby Supply Current Figure 133. Standby Supply Current vs. VCC (455 kHz Resonator, Watchdog TimerDisabled)Figure 134.

Strany 203

281ATmega162/V2513E–AVR–09/03Figure 135. Standby Supply Current vs. VCC (2 MHz Resonator, Watchdog TimerDisabled)Figure 136. Standby Supply Current

Strany 204

282ATmega162/V2513E–AVR–09/03Figure 137. Standby Supply Current vs. VCC (4 MHz Resonator, Watchdog TimerDisabled)Figure 138. Standby Supply Current

Strany 205

283ATmega162/V2513E–AVR–09/03Figure 139. Standby Supply Current vs. VCC (6 MHz Resonator, Watchdog TimerDisabled)Figure 140. Standby Supply Current

Strany 206

284ATmega162/V2513E–AVR–09/03Pin Pull-up Figure 141. I/O Pin Pull-up Resistor Current vs. Input Voltage (VCC = 5V)Figure 142. I/O Pin Pull-up Resist

Strany 207

285ATmega162/V2513E–AVR–09/03Figure 143. I/O Pin Pull-up Resistor Current vs. Input Voltage (VCC = 1.8V)Figure 144. Reset Pull-up Resistor Current v

Strany 208

286ATmega162/V2513E–AVR–09/03Figure 145. Reset Pull-up Resistor Current vs. Reset Pin Voltage (VCC = 2.7V)Figure 146. Reset Pull-up Resistor Current

Strany 209

287ATmega162/V2513E–AVR–09/03Pin Driver Strength Figure 147. I/O Pin Source Current vs. Output Voltage (VCC = 5V)Figure 148. I/O Pin Source Current

Strany 210

288ATmega162/V2513E–AVR–09/03Figure 149. I/O Pin Source Current vs. Output Voltage (VCC = 1.8V)Figure 150. I/O Pin Sink Current vs. Output Voltage (

Strany 211

289ATmega162/V2513E–AVR–09/03Figure 151. I/O Pin Sink Current vs. Output Voltage (VCC = 2.7V)Figure 152. I/O Pin Sink Current vs. Output Voltage (VC

Strany 212

29ATmega162/V2513E–AVR–09/03SRAM address space is configured as one sector, the wait-states are configured by theSRW11 and SRW10 bits.• Bit 1 and Bit

Strany 213

290ATmega162/V2513E–AVR–09/03Pin Thresholds and HysteresisFigure 153. I/O Pin Input Threshold Voltage vs. VCC (VIH, I/O Pin Read as “1”)Figure 154.

Strany 214

291ATmega162/V2513E–AVR–09/03Figure 155. I/O Pin Input Hysteresis vs. VCC Figure 156. Reset Input Threshold Voltage vs. VCC (VIH, Reset Pin Read as

Strany 215

292ATmega162/V2513E–AVR–09/03Figure 157. Reset Input Threshold Voltage vs. VCC (VIL, Reset Pin Read as “0”)Figure 158. Reset Input Pin Hysteresis vs

Strany 216

293ATmega162/V2513E–AVR–09/03BOD Thresholds and Analog Comparator OffsetFigure 159. BOD Thresholds vs. Temperature (BOD Level is 4.3V)Figure 160. BO

Strany 217

294ATmega162/V2513E–AVR–09/03Figure 161. BOD Thresholds vs. Temperature (BOD Level is 2.3V)Figure 162. BOD Thresholds vs. Temperature (BOD Level is

Strany 218

295ATmega162/V2513E–AVR–09/03Figure 163. Bandgap Voltage vs. VCC Figure 164. Analog Comparator Offset Voltage vs. Common Mode Voltage (VCC = 5V)BAND

Strany 219

296ATmega162/V2513E–AVR–09/03Figure 165. Analog Comparator Offset Voltage vs. Common Mode Voltage(VCC=2.7V)Internal Oscillator Speed Figure 166. Wat

Strany 220

297ATmega162/V2513E–AVR–09/03Figure 167. Calibrated 8 MHz RC Oscillator Frequency vs. TemperatureFigure 168. Calibrated 8 MHz RC Oscillator Frequenc

Strany 221

298ATmega162/V2513E–AVR–09/03Figure 169. Calibrated 8 MHz RC Oscillator Frequency vs. Osccal ValueCurrent Consumption of Peripheral UnitsFigure 170.

Strany 222

299ATmega162/V2513E–AVR–09/03Figure 171. 32 kHz TOSC Current vs. VCC (Watchdog Timer Disabled)Figure 172. Watchdog TImer Current vs. VCC 32kHz TOSC

Strany 223

3ATmega162/V2513E–AVR–09/03Overview The ATmega162 is a low-power CMOS 8-bit microcontroller based on the AVRenhanced RISC architecture. By executing p

Strany 224

30ATmega162/V2513E–AVR–09/03Special Function IO Register – SFIOR• Bit 6 – XMBK: External Memory Bus Keeper EnableWriting XMBK to one enables the Bus K

Strany 225

300ATmega162/V2513E–AVR–09/03Figure 173. Analog Comparator Current vs. VCC Figure 174. Programming Current vs. VCC ANALOG COMPARATOR CURRENT vs. VCC

Strany 226

301ATmega162/V2513E–AVR–09/03Current Consumption in Reset and Reset PulsewidthFigure 175. Reset Supply Current vs. Frequency (0.1 - 1.0 MHz, Excludin

Strany 227

302ATmega162/V2513E–AVR–09/03Figure 177. Reset Pulse Width vs. VCC RESET PULSE WIDTH vs. VCC050010001500200025001.5 2 2.5 3 3.5 4 4.5 5 5.5VCC (V)Pul

Strany 228

303ATmega162/V2513E–AVR–09/03Register SummaryAddress Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Page(0xFF) Reserved – – – – – – – –.. Reserv

Strany 229

304ATmega162/V2513E–AVR–09/03(0x60) Reserved – – – – – – – –0x3F (0x5F) SREG I T H S V N Z C 80x3E (0x5E) SPH SP15 SP14 SP13 SP12 SP11 SP10 SP9 SP8 11

Strany 230

305ATmega162/V2513E–AVR–09/03Notes: 1. When the OCDEN Fuse is unprogrammed, the OSCCAL Register is always accessed on this address. Refer to the debug

Strany 231

306ATmega162/V2513E–AVR–09/03Instruction Set SummaryMnemonicsOperands Description OperationFlags #ClocksARITHMETIC AND LOGIC INSTRUCTIONSADD Rd, Rr Ad

Strany 232

307ATmega162/V2513E–AVR–09/03BRIE k Branch if Interrupt Enabled if ( I = 1) then PC ← PC + k + 1 None 1/2BRID k Branch if Interrupt Disabled if ( I

Strany 233

308ATmega162/V2513E–AVR–09/03CLHClear Half Carry Flag in SREGH ← 0 H 1MCU CONTROL INSTRUCTIONSNOP No Operation None 1SLEEP Sleep (see specific descr.

Strany 234

309ATmega162/V2513E–AVR–09/03Ordering InformationNotes: 1. This device can also be supplied in wafer form. Please contact your local Atmel sales offic

Strany 235

31ATmega162/V2513E–AVR–09/03When the device is set in ATmega161 compatibility mode, the internal address space is1,120 bytes. This implies that the fi

Strany 236

310ATmega162/V2513E–AVR–09/03Packaging Information44A 2325 Orchard Parkway San Jose, CA 95131TITLEDRAWING NO.RREV. 44A, 44-lead, 10 x 10 mm Body S

Strany 237

311ATmega162/V2513E–AVR–09/0340P6 2325 Orchard Parkway San Jose, CA 95131TITLEDRAWING NO.RREV. 40P6, 40-lead (0.600"/15.24 mm Wide) Plastic D

Strany 238

312ATmega162/V2513E–AVR–09/0344M1 2325 Orchard Parkway San Jose, CA 95131TITLEDRAWING NO.RREV. 44M1, 44-pad, 7 x 7 x 1.0 mm Body, Lead Pitch 0.50

Strany 239

313ATmega162/V2513E–AVR–09/03Erratas The revision letter in this section refers to the revision of the ATmega162 device.ATmega162, all rev. There are

Strany 240

314ATmega162/V2513E–AVR–09/03Datasheet Change Log for ATmega162Please note that the referring page numbers in this section are referred to this docu-m

Strany 241

315ATmega162/V2513E–AVR–09/0312. Added information about PWM symmetry for Timer0 on page 97 and Timer2on page 146.13. Updated Table 18 on page 47, Tab

Strany 242

316ATmega162/V2513E–AVR–09/03

Strany 243

iATmega162/V2513E–AVR–09/03Table of Contents Features...

Strany 244

iiATmega162/V2513E–AVR–09/03Extended Standby Mode ... 43Minimizing Po

Strany 245

iiiATmega162/V2513E–AVR–09/038-bit Timer/Counter2 with PWM and Asynchronous operation... 137Overview...

Strany 246

32ATmega162/V2513E–AVR–09/03Using all 64KB Locations of External MemorySince the external memory is mapped after the internal memory as shown in Figur

Strany 247

ivATmega162/V2513E–AVR–09/03IEEE 1149.1 (JTAG) Boundary-scan ... 203Features...

Strany 248

vATmega162/V2513E–AVR–09/03Packaging Information... 31044A ...

Strany 249

viATmega162/V2513E–AVR–09/03

Strany 250

Printed on recycled paper.Disclaimer: Atmel Corporation makes no warranty for the use of its products, other than those expressly contained in the Co

Strany 251

33ATmega162/V2513E–AVR–09/03System Clock and Clock OptionsClock Systems and their DistributionFigure 18 presents the principal clock systems in the AV

Strany 252

34ATmega162/V2513E–AVR–09/03Clock Sources The device has the following clock source options, selectable by Flash Fuse bits asshown below. The clock fr

Strany 253

35ATmega162/V2513E–AVR–09/03Figure 19. Crystal Oscillator ConnectionsThe Oscillator can operate in four different modes, each optimized for a specifi

Strany 254

36ATmega162/V2513E–AVR–09/03Notes: 1. These options should only be used when not operating close to the maximum fre-quency of the device, and only if

Strany 255

37ATmega162/V2513E–AVR–09/03Reset Time-out. For more information on the pre-programmed calibration value, see thesection “Calibration Byte” on page 23

Strany 256

38ATmega162/V2513E–AVR–09/03External Clock To drive the device from an external clock source, XTAL1 should be driven as shown inFigure 20. To run the

Strany 257

39ATmega162/V2513E–AVR–09/03will be output also during Reset and the normal operation of PortB will be overriddenwhen the fuse is programmed. Any cloc

Strany 258

4ATmega162/V2513E–AVR–09/03The AVR core combines a rich instruction set with 32 general purpose working registers.All the 32 registers are directly co

Strany 259

40ATmega162/V2513E–AVR–09/03The CKDIV8 Fuse determines the initial value of the CLKPS bits. If CKDIV8 is unpro-grammed, the CLKPS bits will be reset t

Strany 260

41ATmega162/V2513E–AVR–09/03Power Management and Sleep ModesSleep modes enable the application to shut down unused modules in the MCU, therebysaving p

Strany 261

42ATmega162/V2513E–AVR–09/03Extended MCU Control Register – EMCUCR• Bit 7 – SM0: Sleep Mode Select Bit 0The Sleep Mode Select bits select between the

Strany 262

43ATmega162/V2513E–AVR–09/03Power-save Mode When the SM2..0 bits are written to 011, the SLEEP instruction makes the MCU enterPower-save mode. This mo

Strany 263

44ATmega162/V2513E–AVR–09/03Minimizing Power ConsumptionThere are several issues to consider when trying to minimize the power consumption inan AVR co

Strany 264

45ATmega162/V2513E–AVR–09/03the logic level, power consumption will increase. Note that the TDI pin for the nextdevice in the scan chain contains a pu

Strany 265

46ATmega162/V2513E–AVR–09/03System Control and ResetResetting the AVR During Reset, all I/O Registers are set to their initial values, and the program

Strany 266

47ATmega162/V2513E–AVR–09/03Figure 21. Reset LogicNote: 1. The Power-on Reset will not work unless the supply voltage has been below VPOT(falling)Pow

Strany 267

48ATmega162/V2513E–AVR–09/03Figure 22. MCU Start-up, RESET Tied to VCC.Figure 23. MCU Start-up, RESET Extended ExternallyExternal Reset An External

Strany 268

49ATmega162/V2513E–AVR–09/03Brown-out Detection ATmega162 has an On-chip Brown-out Detection (BOD) circuit for monitoring the VCClevel during operatio

Strany 269

5ATmega162/V2513E–AVR–09/03ATmega161 Compatibility ModeProgramming the M161C will change the following functionality:• The extended I/O map will be co

Strany 270

50ATmega162/V2513E–AVR–09/03Figure 25. Brown-out Reset During OperationWatchdog Reset When the Watchdog times out, it will generate a short reset pul

Strany 271

51ATmega162/V2513E–AVR–09/03• Bit 2 – BORF: Brown-out Reset FlagThis bit is set if a Brown-out Reset occurs. The bit is reset by a Power-on Reset, or

Strany 272

52ATmega162/V2513E–AVR–09/03shown in Table 22. Safety level 0 corresponds to the setting in ATmega161. There is norestriction on enabling the WDT in a

Strany 273

53ATmega162/V2513E–AVR–09/03if the WDCE bit has logic level one. To disable an enabled Watchdog Timer, the follow-ing procedure must be followed:1. In

Strany 274

54ATmega162/V2513E–AVR–09/03The following code example shows one assembly and one C function for turning off theWDT. The example assumes that interrup

Strany 275

55ATmega162/V2513E–AVR–09/03Timed Sequences for Changing the Configuration of the Watchdog TimerThe sequence for changing configuration differs slight

Strany 276

56ATmega162/V2513E–AVR–09/03Interrupts This section describes the specifics of the interrupt handling as performed inATmega162. For a general explanat

Strany 277

57ATmega162/V2513E–AVR–09/03Notes: 1. When the BOOTRST Fuse is programmed, the device will jump to the Boot Loaderaddress at reset, see “Boot Loader S

Strany 278

58ATmega162/V2513E–AVR–09/03Table 26 shows Reset and Interrupt Vectors placement for the various combinations ofBOOTRST and IVSEL settings. If the pro

Strany 279

59ATmega162/V2513E–AVR–09/030x03A ldi r16,low(RAMEND)0x03B out SPL,r160x03C sei ; Enable interrupts0x03D <instr> xxx... ... ...When the BOOTRST

Strany 280

6ATmega162/V2513E–AVR–09/03Port D (PD7..PD0) Port D is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for eachbit). The Po

Strany 281

60ATmega162/V2513E–AVR–09/03When the BOOTRST Fuse is programmed, the boot section size set to 2K bytes and theIVSEL bit in the GICR Register is set be

Strany 282

61ATmega162/V2513E–AVR–09/03IVCE bit will disable interrupts, as explained in the IVSEL description above. See CodeExample below.Assembly Code Example

Strany 283

62ATmega162/V2513E–AVR–09/03I/O-PortsIntroduction All AVR ports have true Read-Modify-Write functionality when used as general digitalI/O ports. This

Strany 284

63ATmega162/V2513E–AVR–09/03Ports as General Digital I/OThe ports are bi-directional I/O ports with optional internal pull-ups. Figure 29 shows afunct

Strany 285

64ATmega162/V2513E–AVR–09/03enabled state is fully acceptable, as a high-impedant environment will not notice the dif-ference between a strong high dr

Strany 286

65ATmega162/V2513E–AVR–09/03Consider the clock period starting shortly after the first falling edge of the system clock.The latch is closed when the c

Strany 287

66ATmega162/V2513E–AVR–09/03The following code example shows how to set port B pins 0 and 1 high, 2 and 3 low, anddefine the port pins from 4 to 7 as

Strany 288

67ATmega162/V2513E–AVR–09/03Unconnected pins If some pins are unused, it is recommended to ensure that these pins have a definedlevel. Even though mos

Strany 289

68ATmega162/V2513E–AVR–09/03Table 28 summarizes the function of the overriding signals. The pin and port indexesfrom Figure 32 are not shown in the su

Strany 290

69ATmega162/V2513E–AVR–09/03Special Function IO Register – SFIOR• Bit 2 – PUD: Pull-up DisableWhen this bit is written to one, the pull-ups in the I/O

Strany 291

7ATmega162/V2513E–AVR–09/03AVR CPU CoreIntroduction This section discusses the AVR core architecture in general. The main function of theCPU core is t

Strany 292

70ATmega162/V2513E–AVR–09/03Notes: 1. ADA is short for ADdress Active and represents the time when address is output. See“External Memory Interface” o

Strany 293

71ATmega162/V2513E–AVR–09/03Alternate Functions Of Port B The Port B pins with alternate functions are shown in Table 32.The alternate pin configurati

Strany 294

72ATmega162/V2513E–AVR–09/03OC3B, Output Compare Match B output: The PB4 pin can serve as an external outputfor the Timer/Counter3 Output Compare B. T

Strany 295

73ATmega162/V2513E–AVR–09/03 Notes: 1. CKOUT is one if the CKOUT Fuse is programmed.2. clkI/O is the divided system clock.Table 33. Overriding Signal

Strany 296

74ATmega162/V2513E–AVR–09/03Alternate Functions of Port C The Port C pins with alternate functions are shown in Table 35. If the JTAG interface isenab

Strany 297

75ATmega162/V2513E–AVR–09/03• A13/TMS/PCINT13 – Port C, Bit 5A13, External memory interface address bit 13.TMS, JTAG Test Mode Select: This pin is use

Strany 298

76ATmega162/V2513E–AVR–09/03Notes: 1. PCINTn is Pin Change Interrupt Enable bit n.2. PCINTn is Pin Change Interrupt input n.Notes: 1. PCINTn is Pin Ch

Strany 299

77ATmega162/V2513E–AVR–09/03Alternate Functions of Port D The Port D pins with alternate functions are shown in Table 38.The alternate pin configurati

Strany 300

78ATmega162/V2513E–AVR–09/03• TOSC1/XCK0/OC3A – Port D, Bit 4TOSC1, Timer Oscillator pin 1: When the AS2 bit in ASSR is set (one) to enable asyn-chron

Strany 301

79ATmega162/V2513E–AVR–09/03• RXD0 – Port D, Bit 0RXD0, Receive Data (Data input pin for USART0). When the USART0 Receiver isenabled this pin is confi

Strany 302

8ATmega162/V2513E–AVR–09/03Six of the 32 registers can be used as three 16-bit indirect address register pointers forData Space addressing – enabling

Strany 303

80ATmega162/V2513E–AVR–09/03Alternate Functions of Port E The Port E pins with alternate functions are shown in Table 41.The alternate pin configurati

Strany 304

81ATmega162/V2513E–AVR–09/03Register Description for I/O-PortsPort A Data Register – PORTAPort A Data Direction Register – DDRAPort A Input Pins Addre

Strany 305

82ATmega162/V2513E–AVR–09/03Port C Input Pins Address – PINCPort D Data Register – PORTDPort D Data Direction Register – DDRDPort D Input Pins Address

Strany 306

83ATmega162/V2513E–AVR–09/03External Interrupts The External Interrupts are triggered by the INT0, INT1, INT2 pin, or any of thePCINT15..0 pins. Obser

Strany 307

84ATmega162/V2513E–AVR–09/03• Bit 1, 0 – ISC01, ISC00: Interrupt Sense Control 0 Bit 1 and Bit 0The External Interrupt 0 is activated by the external

Strany 308

85ATmega162/V2513E–AVR–09/03General Interrupt Control Register – GICR• Bit 7 – INT1: External Interrupt Request 1 EnableWhen the INT1 bit is set (one)

Strany 309

86ATmega162/V2513E–AVR–09/03General Interrupt Flag Register – GIFR• Bit 7 – INTF1: External Interrupt Flag 1When an edge or logic change on the INT1 p

Strany 310

87ATmega162/V2513E–AVR–09/03Pin Change Mask Register 1 – PCMSK1• Bit 7..0 – PCINT15..8: Pin Change Enable Mask 15..8Each PCINT15..8 bit selects whethe

Strany 311

88ATmega162/V2513E–AVR–09/038-bit Timer/Counter0 with PWMTimer/Counter0 is a general purpose, single channel, 8-bit Timer/Counter module. Themain feat

Strany 312

89ATmega162/V2513E–AVR–09/03inactive when no clock source is selected. The output from the clock select logic isreferred to as the timer clock (clkT0)

Strany 313

9ATmega162/V2513E–AVR–09/03The AVR Status Register – SREG – is defined as:• Bit 7 – I: Global Interrupt EnableThe Global Interrupt Enable bit must be

Strany 314

90ATmega162/V2513E–AVR–09/03Counter Unit The main part of the 8-bit Timer/Counter is the programmable bi-directional counter unit.Figure 34 shows a bl

Strany 315

91ATmega162/V2513E–AVR–09/03Figure 35 shows a block diagram of the output compare unit. Figure 35. Output Compare Unit, Block DiagramThe OCR0 Registe

Strany 316

92ATmega162/V2513E–AVR–09/03Using the Output Compare UnitSince writing TCNT0 in any mode of operation will block all compare matches for onetimer cloc

Strany 317

93ATmega162/V2513E–AVR–09/03The design of the output compare pin logic allows initialization of the OC0 state beforethe output is enabled. Note that s

Strany 318

94ATmega162/V2513E–AVR–09/03Figure 37. CTC Mode, Timing DiagramAn interrupt can be generated each time the counter value reaches the TOP value byusin

Strany 319

95ATmega162/V2513E–AVR–09/03non-inverted and inverted PWM outputs. The small horizontal line marks on the TCNT0slopes represent compare matches betwee

Strany 320

96ATmega162/V2513E–AVR–09/03Phase Correct PWM Mode The phase correct PWM mode (WGM01:0 = 1) provides a high resolution phase correctPWM waveform gener

Strany 321

97ATmega162/V2513E–AVR–09/03between OCR0 and TCNT0 when the counter decrements. The PWM frequency for theoutput when using phase correct PWM can be ca

Strany 322

98ATmega162/V2513E–AVR–09/03Figure 41. Timer/Counter Timing Diagram, with Prescaler (fclk_I/O/8)Figure 42 shows the setting of OCF0 in all modes exce

Strany 323 - Regional Headquarters

99ATmega162/V2513E–AVR–09/038-bit Timer/Counter Register DescriptionTimer/Counter Control Register – TCCR0• Bit 7 – FOC0: Force Output CompareThe FOC0

Komentáře k této Příručce

Žádné komentáře