Rainbow-electronics ATtiny2313 Manual do Utilizador

Consulte online ou descarregue Manual do Utilizador para Sensores Rainbow-electronics ATtiny2313. Rainbow Electronics ATtiny2313 User Manual Manual do Utilizador

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 211
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 0
1
2543A–AVR–08/03
Features
Utilizes the AVR
®
RISC Architecture
AVR – High-performance and Low-power RISC Architecture
120 Powerful Instructions – Most Single Clock Cycle Execution
32 x 8 General Purpose Working Registers
Fully Static Operation
Data and Non-volatile Program and Data Memories
2K Bytes of In-System Self Programmable Flash
Endurance 10,000 Write/Erase Cycles
128 Bytes In-System Programmable EEPROM
Endurance: 100,000 Write/Erase Cycles
128 Bytes Internal SRAM
Programming Lock for Flash Program and EEPROM Data Security
Peripheral Features
One 8-bit Timer/Counter with Separate Prescaler
One 16-bit Timer/Counter with Separate Prescaler,
Compare, Capture Modes and Two PWM Channels
On-chip Analog Comparator
Programmable Watchdog Timer with On-chip Oscillator
USI – Universal Serial Interface
Full Duplex UART
Special Microcontroller Features
debugWIRE On-chip Debugging
In-System Programmable via SPI Port
External and Internal Interrupt Sources
Low-power Idle, Power-down, and Standby Modes
Enhanced Power-on Reset Circuit
Programmable Brown-out Detection Circuit
Internal Calibrated Oscillator
I/O and Packages
18 Programmable I/O Lines
20-pin PDIP, 20-pin SOIC, and 32-pin MLF
Operating Voltages
1.8 - 5.5V (ATtiny2313)
Speed Grades
0 - 16MHz (ATtiny2313). For Speed vs. V
CC
: See Figure 81 on page 180.
Power Consumption Estimates
Active Mode
1 MHz, 1.8V: 300 µA
32 kHz, 1.8V: 20 µA (including oscillator)
Power-down Mode
0.5 µA at 1.8V
Pin Configurations
Figure 1. Pinout ATtiny2313
(RESET/dW)PA2
(RXD)PD0
(TXD)PD1
(XTAL2)PA1
(XTAL1)PA0
(CKOUT/XCK/INT0)PD2
(INT1)PD3
(T0)PD4
(OC0B/T1)PD5
GND
20
19
18
17
16
15
14
13
12
11
1
2
3
4
5
6
7
8
9
10
VCC
PB7(UCSK/SCK/PCINT7)
PB6(DO/PCINT6)
PB5(DI/SDA/PCINT5)
PB4(OC1B/PCINT4)
PB3(OC1A/PCINT3)
PB2(OC0A/PCINT2)
PB1(AIN1/PCINT1)
PB0(AIN0/PCINT0)
PD6(ICP)
8-bit
Microcontroller
with 2K Bytes
In-System
Programmable
Flash
ATtiny2313
Preliminary
Rev. 2543A–AVR–08/03
Vista de página 0
1 2 3 4 5 6 ... 210 211

Resumo do Conteúdo

Página 1 - Pin Configurations

1 2543A–AVR–08/03Features• Utilizes the AVR® RISC Architecture• AVR – High-performance and Low-power RISC Architecture– 120 Powerful Instructions – Mo

Página 2

10ATtiny23132543A–AVR–08/03Instruction Execution TimingThis section describes the general access timing concepts for instruction execution. TheAVR CPU

Página 3

100ATtiny23132543A–AVR–08/03The Timer/Counter Overflow Flag (TOV1) is set each time the counter reaches BOT-TOM. When either OCR1A or ICR1 is used for

Página 4

101ATtiny23132543A–AVR–08/03Phase and Frequency Correct PWM ModeThe phase and frequency correct Pulse Width Modulation, or phase and frequency cor-rec

Página 5

102ATtiny23132543A–AVR–08/03The Timer/Counter Overflow Flag (TOV1) is set at the same timer clock cycle as theOCR1x Registers are updated with the dou

Página 6

103ATtiny23132543A–AVR–08/03Timer/Counter Timing DiagramsThe Timer/Counter is a synchronous design and the timer clock (clkT1) is thereforeshown as a

Página 7

104ATtiny23132543A–AVR–08/03Figure 50. Timer/Counter Timing Diagram, no PrescalingFigure 51 shows the same timing data, but with the prescaler enable

Página 8

105ATtiny23132543A–AVR–08/0316-bit Timer/Counter Register DescriptionTimer/Counter1 Control Register A – TCCR1A• Bit 7:6 – COM1A1:0: Compare Output Mo

Página 9

106ATtiny23132543A–AVR–08/03Note: 1. A special case occurs when OCR1A/OCR1B equals TOP and COM1A1/COM1B1 isset. In this case the compare match is igno

Página 10 - ATtiny2313

107ATtiny23132543A–AVR–08/03Table 46 shows the COM1x1:0 bit functionality when the WGM13:0 bits are set to thephase correct or the phase and frequency

Página 11

108ATtiny23132543A–AVR–08/03Note: 1. The CTC1 and PWM11:0 bit definition names are obsolete. Use the WGM12:0 definitions. However, the functionality a

Página 12

109ATtiny23132543A–AVR–08/03(ICF1), and this can be used to cause an Input Capture Interrupt, if this interrupt isenabled.When the ICR1 is used as TOP

Página 13

11ATtiny23132543A–AVR–08/03There are basically two types of interrupts. The first type is triggered by an event thatsets the interrupt flag. For these

Página 14

110ATtiny23132543A–AVR–08/03A FOC1A/FOC1B strobe will not generate any interrupt nor will it clear the timer in ClearTimer on Compare match (CTC) mode

Página 15

111ATtiny23132543A–AVR–08/03Input Capture Register 1 – ICR1H and ICR1LThe Input Capture is updated with the counter (TCNT1) value each time an event o

Página 16

112ATtiny23132543A–AVR–08/03Timer/Counter Interrupt Flag Register – TIFR• Bit 7 – TOV1: Timer/Counter1, Overflow FlagThe setting of this flag is depen

Página 17

113ATtiny23132543A–AVR–08/03USART The Universal Synchronous and Asynchronous serial Receiver and Transmitter(USART) is a highly flexible serial commun

Página 18

114ATtiny23132543A–AVR–08/03The dashed boxes in the block diagram separate the three main parts of the USART(listed from the top): Clock Generator, Tr

Página 19

115ATtiny23132543A–AVR–08/03Figure 53. Clock Generation Logic, Block DiagramSignal description:txclk Transmitter clock (Internal Signal).rxclk Receiv

Página 20

116ATtiny23132543A–AVR–08/03Note: 1. The baud rate is defined to be the transfer rate in bit per second (bps)BAUD Baud rate (in bits per second, bps)f

Página 21

117ATtiny23132543A–AVR–08/03Synchronous Clock Operation When synchronous mode is used (UMSEL = 1), the XCK pin will be used as either clockinput (Slav

Página 22

118ATtiny23132543A–AVR–08/03Sp Stop bit, always high.IDLE No transfers on the communication line (RxD or TxD). An IDLE line must behigh.The frame form

Página 23

119ATtiny23132543A–AVR–08/03The following simple USART initialization code examples show one assembly and oneC function that are equal in functionalit

Página 24

12ATtiny23132543A–AVR–08/03When using the SEI instruction to enable interrupts, the instruction following SEI will beexecuted before any pending inter

Página 25

120ATtiny23132543A–AVR–08/03Data Transmission – The USART TransmitterThe USART Transmitter is enabled by setting the Transmit Enable (TXEN) bit in the

Página 26

121ATtiny23132543A–AVR–08/03Sending Frames with 9 Data BitIf 9-bit characters are used (UCSZ = 7), the ninth bit must be written to the TXB8 bit inUCS

Página 27

122ATtiny23132543A–AVR–08/03Transmitter Flags and InterruptsThe USART Transmitter has two flags that indicate its state: USART Data RegisterEmpty (UDR

Página 28

123ATtiny23132543A–AVR–08/03Data Reception – The USART ReceiverThe USART Receiver is enabled by writing the Receive Enable (RXEN) bit in theUCSRB Regi

Página 29

124ATtiny23132543A–AVR–08/03Receiving Frames with 9 Data BitsIf 9-bit characters are used (UCSZ=7) the ninth bit must be read from the RXB8 bit inUCSR

Página 30

125ATtiny23132543A–AVR–08/03extended I/O. Typically “LDS” and “STS” combined with “SBRS”, “SBRC”, “SBR”, and“CBR”.The receive function example reads a

Página 31

126ATtiny23132543A–AVR–08/03Parity Checker The Parity Checker is active when the high USART Parity mode (UPM1) bit is set. Typeof Parity Check to be p

Página 32

127ATtiny23132543A–AVR–08/03Asynchronous Clock RecoveryThe clock recovery logic synchronizes internal clock to the incoming serial frames. Fig-ure 56

Página 33

128ATtiny23132543A–AVR–08/03Figure 58 shows the sampling of the stop bit and the earliest possible beginning of thestart bit of the next frame.Figure

Página 34

129ATtiny23132543A–AVR–08/03The recommendations of the maximum receiver baud rate error was made under theassumption that the Receiver and Transmitter

Página 35

13ATtiny23132543A–AVR–08/03AVR ATtiny2313 MemoriesThis section describes the different memories in the ATtiny2313. The AVR architecturehas two main me

Página 36

130ATtiny23132543A–AVR–08/03Multi-processor Communication ModeSetting the Multi-processor Communication mode (MPCM) bit in UCSRA enables a fil-tering

Página 37

131ATtiny23132543A–AVR–08/03USART Register DescriptionUSART I/O Data Register – UDRThe USART Transmit Data Buffer Register and USART Receive Data Buff

Página 38

132ATtiny23132543A–AVR–08/03• Bit 5 – UDRE: USART Data Register EmptyThe UDRE flag indicates if the transmit buffer (UDR) is ready to receive new data

Página 39

133ATtiny23132543A–AVR–08/03USART Control and Status Register B – UCSRB• Bit 7 – RXCIE: RX Complete Interrupt EnableWriting this bit to one enables in

Página 40

134ATtiny23132543A–AVR–08/03USART Control and Status Register C – UCSRC• Bit 6 – UMSEL: USART Mode SelectThis bit selects between asynchronous and syn

Página 41

135ATtiny23132543A–AVR–08/03• Bit 2:1 – UCSZ1:0: Character SizeThe UCSZ1:0 bits combined with the UCSZ2 bit in UCSRB sets the number of data bits(Char

Página 42

136ATtiny23132543A–AVR–08/03Examples of Baud Rate SettingFor standard crystal and resonator frequencies, the most commonly used baud rates forasynchro

Página 43

137ATtiny23132543A–AVR–08/03Table 58. Examples of UBRR Settings for Commonly Used Oscillator Frequencies (Continued)Baud Rate (bps)fosc = 3.6864 MHz

Página 44

138ATtiny23132543A–AVR–08/03Table 59. Examples of UBRR Settings for Commonly Used Oscillator Frequencies (Continued)Baud Rate (bps)fosc = 8.0000 MHz

Página 45

139ATtiny23132543A–AVR–08/03Table 60. Examples of UBRR Settings for Commonly Used Oscillator Frequencies(Continued)Baud Rate (bps)fosc = 16.0000 MHzU

Página 46

14ATtiny23132543A–AVR–08/03Register File, the next 64 location the standard I/O memory, and the next 128 locationsaddress the internal data SRAM.The f

Página 47

140ATtiny23132543A–AVR–08/03Universal Serial Interface – USIThe Universal Serial Interface, or USI, provides the basic hardware resources neededfor se

Página 48

141ATtiny23132543A–AVR–08/03The Two-wire clock control unit can generate an interrupt when a start condition isdetected on the Two-wire bus. It can al

Página 49

142ATtiny23132543A–AVR–08/03The Three-wire mode timing is shown in Figure 61. At the top of the figure is a USCKcycle reference. One bit is shifted in

Página 50

143ATtiny23132543A–AVR–08/03The following code demonstrates how to use the USI module as a SPI Master with max-imum speed (fsck = fck/2):SPITransfer_F

Página 51

144ATtiny23132543A–AVR–08/03Note that the first two instructions is for initialization only and needs only to be executedonce.These instructions sets

Página 52

145ATtiny23132543A–AVR–08/03Figure 63. Two-wire Mode, Typical Timing DiagramReferring to the timing diagram (Figure 63.), a bus transfer involves the

Página 53

146ATtiny23132543A–AVR–08/03Start Condition Detector The start condition detector is shown in Figure 64. The SDA line is delayed (in the rangeof 50 to

Página 54

147ATtiny23132543A–AVR–08/03Note that the corresponding Data Direction Register to the pin must be set to one forenabling data output from the Shift R

Página 55

148ATtiny23132543A–AVR–08/03Note that even when no wire mode is selected (USIWM1..0 = 0) the external clock input(USCK/SCL) are can still be used by t

Página 56

149ATtiny23132543A–AVR–08/03Note: 1. The DI and USCK pins are renamed to Serial Data (SDA) and Serial Clock (SCL)respectively to avoid confusion betwe

Página 57

15ATtiny23132543A–AVR–08/03Data Memory Access Times This section describes the general access timing concepts for internal memory access.The internal

Página 58

150ATtiny23132543A–AVR–08/03• Bit 3..2 – USICS1..0: Clock Source SelectThese bits set the clock source for the Shift Register and counter. The data ou

Página 59

151ATtiny23132543A–AVR–08/03Analog Comparator The Analog Comparator compares the input values on the positive pin AIN0 and nega-tive pin AIN1. When th

Página 60

152ATtiny23132543A–AVR–08/03ing the corresponding interrupt handling vector. Alternatively, ACI is cleared by writing alogic one to the flag.• Bit 3 –

Página 61

153ATtiny23132543A–AVR–08/03debugWIRE On-chip Debug SystemFeatures • Complete Program Flow Control• Emulates All On-chip Functions, Both Digital and A

Página 62

154ATtiny23132543A–AVR–08/03• Capacitors inserted on the RESET pin must be disconnected when using debugWire.• All external reset sources must be disc

Página 63

155ATtiny23132543A–AVR–08/03Self-Programming the FlashThe device provides a Self-Programming mechanism for downloading and uploadingprogram code by th

Página 64

156ATtiny23132543A–AVR–08/03Addressing the Flash During Self-ProgrammingThe Z-pointer is used to address the SPM commands.Since the Flash is organized

Página 65

157ATtiny23132543A–AVR–08/03Store Program Memory Control and Status Register – SPMCSRThe Store Program Memory Control and Status Register contains the

Página 66

158ATtiny23132543A–AVR–08/03EEPROM Write Prevents Writing to SPMCSRNote that an EEPROM write operation will block all software programming to Flash.Re

Página 67

159ATtiny23132543A–AVR–08/03Preventing Flash Corruption During periods of low VCC, the Flash program can be corrupted because the supply volt-age is t

Página 68

16ATtiny23132543A–AVR–08/03The EEPROM Address Register• Bit 7 – Res: Reserved BitThis bit is reserved in the ATtiny2313 and will always read as zero.•

Página 69

160ATtiny23132543A–AVR–08/03Memory ProgrammingProgram And Data Memory Lock BitsThe ATtiny2313 provides two Lock bits which can be left unprogrammed (“

Página 70

161ATtiny23132543A–AVR–08/03Fuse Bits The ATtiny2313 has three Fuse bytes. Table 68 and Table 69 describe briefly the func-tionality of all the fuses

Página 71

162ATtiny23132543A–AVR–08/03Note: 1. The default value of SUT1..0 results in maximum start-up time for the default clocksource. See Table 15 on page 3

Página 72

163ATtiny23132543A–AVR–08/03Parallel Programming Parameters, Pin Mapping, and CommandsThis section describes how to parallel program and verify Flash

Página 73

164ATtiny23132543A–AVR–08/03Table 71. Pin Values Used to Enter Programming ModePin Symbol ValueXA1 Prog_enable[3] 0XA0 Prog_enable[2] 0BS1 Prog_enabl

Página 74

165ATtiny23132543A–AVR–08/03Serial Programming Pin MappingParallel ProgrammingEnter Programming Mode The following algorithm puts the device in parall

Página 75

166ATtiny23132543A–AVR–08/03Programming the Flash The Flash is organized in pages, see Table 74 on page 164. When programming theFlash, the program da

Página 76

167ATtiny23132543A–AVR–08/03I. Repeat B through H until the entire Flash is programmed or until all data has beenprogrammed.J. End Page Programming1.

Página 77

168ATtiny23132543A–AVR–08/03Programming the EEPROM The EEPROM is organized in pages, see Table 75 on page 164. When programmingthe EEPROM, the program

Página 78

169ATtiny23132543A–AVR–08/03Reading the EEPROM The algorithm for reading the EEPROM memory is as follows (refer to “Programming theFlash” on page 166

Página 79

17ATtiny23132543A–AVR–08/03• Bit 3 – EERIE: EEPROM Ready Interrupt EnableWriting EERIE to one enables the EEPROM Ready Interrupt if the I-bit in SREG

Página 80

170ATtiny23132543A–AVR–08/03Programming the Lock Bits The algorithm for programming the Lock bits is as follows (refer to “Programming theFlash” on pa

Página 81

171ATtiny23132543A–AVR–08/03Reading the Calibration Byte The algorithm for reading the Calibration byte is as follows (refer to “Programming theFlash”

Página 82

172ATtiny23132543A–AVR–08/03Figure 76. Parallel Programming Timing, Reading Sequence (within the Same Page)with Timing Requirements(1)Note: 1. The ti

Página 83

173ATtiny23132543A–AVR–08/03Notes: 1. tWLRH is valid for the Write Flash, Write EEPROM, Write Fuse bits and Write Lockbits commands.2. tWLRH_CE is v

Página 84

174ATtiny23132543A–AVR–08/03Serial Programming AlgorithmWhen writing serial data to the ATtiny2313, data is clocked on the rising edge of SCK.When rea

Página 85

175ATtiny23132543A–AVR–08/03Data Polling EEPROM When a new byte has been written and is being programmed into EEPROM, reading theaddress location bein

Página 86

176ATtiny23132543A–AVR–08/03Note: a = address high bits, b = address low bits, H = 0 - Low byte, 1 - High Byte, o = data out, i = data in, x = don’t c

Página 87

177ATtiny23132543A–AVR–08/03Note: 1. 2 tCLCL for fck < 12 MHz, 3 tCLCL for fck >= 12 MHzTable 80. Serial Programming Characteristics, TA = -40°

Página 88

178ATtiny23132543A–AVR–08/03Electrical CharacteristicsAbsolute Maximum Ratings*Notes: 1. All DC Characteristics contained in this data sheet are based

Página 89

179ATtiny23132543A–AVR–08/034. Although each I/O port can sink more than the test conditions (10 mA at VCC = 5V, 5 mA at VCC = 3V) under steady statec

Página 90

18ATtiny23132543A–AVR–08/03Erase To erase a byte, the address must be written to EEAR. If the EEPMn bits are 0b01, writ-ing the EEPE (within four cycl

Página 91

180ATtiny23132543A–AVR–08/03External Clock Drive WaveformsFigure 80. External Clock Drive WaveformsExternal Clock DriveFigure 81. Maximum Frequency

Página 92

181ATtiny23132543A–AVR–08/03ATtiny2313 Typical Characteristics – Preliminary DataThe following charts show typical behavior. These figures are not tes

Página 93

182ATtiny23132543A–AVR–08/03Figure 83. Active Supply Current vs. Frequency (1 - 16 MHz)Figure 84. Active Supply Current vs. VCC (Internal RC Oscilla

Página 94 - Compare Match Output

183ATtiny23132543A–AVR–08/03Figure 85. Active Supply Current vs. VCC (Internal RC Oscillator, CKDIV8Programmed, 1.0 MHz)Idle Supply Current Figure 86

Página 95

184ATtiny23132543A–AVR–08/03Figure 87. Idle Supply Current vs. Frequency (1 - 16 MHz)Figure 88. Idle Supply Current vs. VCC (Internal RC Oscillator,

Página 96 - (Toggle)

185ATtiny23132543A–AVR–08/03Figure 89. Idle Supply Current vs. VCC (Internal RC Oscillator, CKDIV8 Programmed,1.0 MHz)Power-down Supply Current Figur

Página 97

186ATtiny23132543A–AVR–08/03Figure 91. Power-down Supply Current vs. VCC (Watchdog Timer Enabled)Pin Pull-up Figure 92. I/O Pin Pull-up Resistor Cur

Página 98

187ATtiny23132543A–AVR–08/03Figure 93. I/O Pin Pull-up Resistor Current vs. Input Voltage (VCC = 2.7V)Figure 94. I/O Pin Pull-up Resistor Current vs

Página 99

188ATtiny23132543A–AVR–08/03Figure 95. Reset Pull-up Resistor Current vs. Reset Pin Voltage (VCC = 5V)Figure 96. Reset Pull-up Resistor Current vs.

Página 100

189ATtiny23132543A–AVR–08/03Figure 97. Reset Pull-up Resistor Current vs. Reset Pin Voltage (VCC = 1.8V)Pin Thresholds and hysteresisFigure 98. I/O

Página 101 - 2543A–AVR–08/03

19ATtiny23132543A–AVR–08/03The following code examples show one assembly and one C function for writing to theEEPROM. The examples assume that interru

Página 102

190ATtiny23132543A–AVR–08/03Figure 99. I/O Pin Input Threshold Voltage vs. VCC (VIL, I/O Pin Read as “0”)Figure 100. I/O Pin Input Hysteresis vs. VC

Página 103 - Diagrams

191ATtiny23132543A–AVR–08/03Figure 101. Reset Input Threshold Voltage vs. VCC (VIH,Reset Pin Read as “1”)Figure 102. Reset Input Threshold Voltage v

Página 104

192ATtiny23132543A–AVR–08/03BOD Thresholds and Analog Comparator OffsetFigure 103. BOD Thresholds vs. Temperature (BOD Level is 4.3V)Figure 104. BOD

Página 105

193ATtiny23132543A–AVR–08/03Figure 105. BOD Thresholds vs. Temperature (BOD Level is 1.8V)Figure 106. Bandgap Voltage vs. VCC BOD THRESHOLDS vs. TEM

Página 106

194ATtiny23132543A–AVR–08/03Figure 107. Analog Comparator Offset Voltage vs. Common Mode Voltage (VCC = 5V)Figure 108. Analog Comparator Offset Volt

Página 107

195ATtiny23132543A–AVR–08/03Current Consumption of Peripheral UnitsFigure 109. Brownout Detector Current vs. VCC Figure 110. Analog Comparator Curre

Página 108

196ATtiny23132543A–AVR–08/03Figure 111. Programming Current vs. VCC Current Consumption in Reset and Reset PulsewidthFigure 112. Reset Supply Curren

Página 109

197ATtiny23132543A–AVR–08/03Figure 113. Reset Supply Current vs. VCC (1 - 20 MHz, Excluding Current Through TheReset Pull-up)Figure 114. Minumum Res

Página 110

198ATtiny23132543A–AVR–08/03Register SummaryAddress Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Page0x3F (0x5F) SREG I T H S V N Z C 70x3E (0

Página 111

199ATtiny23132543A–AVR–08/03Note: 1. For compatibility with future devices, reserved bits should be written to zero if accessed. Reserved I/O memory a

Página 112

2ATtiny23132543A–AVR–08/03Overview The ATtiny2313 is a low-power CMOS 8-bit microcontroller based on the AVRenhanced RISC architecture. By executing p

Página 113 - DATA BUS

20ATtiny23132543A–AVR–08/03The next code examples show assembly and C functions for reading the EEPROM. Theexamples assume that interrupts are control

Página 114

200ATtiny23132543A–AVR–08/03Instruction Set SummaryMnemonics Operands Description Operation Flags #ClocksARITHMETIC AND LOGIC INSTRUCTIONSADD Rd, Rr A

Página 115

201ATtiny23132543A–AVR–08/03ROR Rd Rotate Right Through Carry Rd(7)←C,Rd(n)← Rd(n+1),C←Rd(0) Z,C,N,V 1ASR Rd Arithmetic Shift Right Rd(n) ← Rd(n+1), n

Página 116

202ATtiny23132543A–AVR–08/03Ordering Information(1)Note: 1. This device can also be supplied in wafer form. Please contact your local Atmel sales offi

Página 117

203ATtiny23132543A–AVR–08/03Packaging Information20P3 2325 Orchard Parkway San Jose, CA 95131TITLEDRAWING NO.RREV. 20P3, 20-lead (0.300"/7.62

Página 118

204ATtiny23132543A–AVR–08/0320S2325 Orchard ParkwaySan Jose, CA 95131TITLEDRAWING NO.RREV. 20S2, 20-lead, 0.300" Wide Body, Plastic GullWing Sm

Página 119

205ATtiny23132543A–AVR–08/0332M1-A 2325 Orchard Parkway San Jose, CA 95131TITLEDRAWING NO.RREV. 32M1-A, 32-pad, 5 x 5 x 1.0 mm Body, Lead Pitch 0.

Página 120

206ATtiny23132543A–AVR–08/03

Página 121

iATtiny23132543A–AVR–08/03Table of Contents Features...

Página 122

iiATtiny23132543A–AVR–08/03Timed Sequences for Changing the Configuration of the Watchdog Timer ... 44Interrupts...

Página 123

iiiATtiny23132543A–AVR–08/03USART Register Description ... 131Examples of Bau

Página 124

21ATtiny23132543A–AVR–08/03I/O Memory The I/O space definition of the ATtiny2313 is shown in “Register Summary” on page198.All ATtiny2313 I/Os and per

Página 125

ivATtiny23132543A–AVR–08/03Packaging Information... 20320P3 ...

Página 126

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

Página 127

22ATtiny23132543A–AVR–08/03System Clock and Clock OptionsClock Systems and their DistributionFigure 11 presents the principal clock systems in the AVR

Página 128

23ATtiny23132543A–AVR–08/03Clock Sources The device has the following clock source options, selectable by Flash Fuse bits asshown below. The clock fro

Página 129

24ATtiny23132543A–AVR–08/03Crystal Oscillator XTAL1 and XTAL2 are input and output, respectively, of an inverting amplifier which canbe configured for

Página 130

25ATtiny23132543A–AVR–08/03Notes: 1. These options should only be used when not operating close to the maximum fre-quency of the device, and only if f

Página 131

26ATtiny23132543A–AVR–08/03When this Oscillator is selected, start-up times are determined by the SUT Fuses asshown in Table 7.Note: 1. The device is

Página 132

27ATtiny23132543A–AVR–08/03External Clock To drive the device from an external clock source, XTAL1 should be driven as shown inFigure 13. To run the d

Página 133

28ATtiny23132543A–AVR–08/03128 kHz Internal OscillatorThe 128 kHz Internal Oscillator is a low power Oscillator providing a clock of 128 kHz.The frequ

Página 134

29ATtiny23132543A–AVR–08/03frequency than the maximum frequency of the device at the present operating condi-tions. The device is shipped with the CKD

Página 135

3ATtiny23132543A–AVR–08/03The AVR core combines a rich instruction set with 32 general purpose working registers.All the 32 registers are directly con

Página 136

30ATtiny23132543A–AVR–08/03Power Management and Sleep ModesSleep modes enable the application to shut down unused modules in the MCU, therebysaving po

Página 137

31ATtiny23132543A–AVR–08/03Idle Mode When the SM1..0 bits are written to 00, the SLEEP instruction makes the MCU enterIdle mode, stopping the CPU but

Página 138

32ATtiny23132543A–AVR–08/03Minimizing Power ConsumptionThere are several issues to consider when trying to minimize the power consumption inan AVR con

Página 139

33ATtiny23132543A–AVR–08/03Port Pins When entering a sleep mode, all port pins should be configured to use minimum power.The most important is then to

Página 140

34ATtiny23132543A–AVR–08/03System Control and ResetResetting the AVR During reset, all I/O Registers are set to their initial values, and the program

Página 141

35ATtiny23132543A–AVR–08/03Notes: 1. Values are guidelines only. Actual values are TBD.2. The Power-on Reset will not work unless the supply voltage h

Página 142

36ATtiny23132543A–AVR–08/03Figure 16. MCU Start-up, RESET Extended ExternallyExternal Reset An External Reset is generated by a low level on the RESE

Página 143

37ATtiny23132543A–AVR–08/03Note: 1. VBOT may be below nominal minimum operating voltage for some devices. Fordevices where this is the case, the devic

Página 144

38ATtiny23132543A–AVR–08/03Watchdog Reset When the Watchdog times out, it will generate a short reset pulse of one CK cycle dura-tion. On the falling

Página 145

39ATtiny23132543A–AVR–08/03Internal Voltage ReferenceATtiny2313 features an internal bandgap reference. This reference is used for Brown-out Detection

Página 146

4ATtiny23132543A–AVR–08/03Pin DescriptionsVCC Digital supply voltage.GND Ground.Port A (PA2..PA0) Port A is a 3-bit bi-directional I/O port with inter

Página 147

40ATtiny23132543A–AVR–08/03Watchdog Timer The Watchdog Timer is clocked from an On-chip Oscillator which runs at 128 kHz. Bycontrolling the Watchdog T

Página 148

41ATtiny23132543A–AVR–08/03• Bit 6 – WDIE: Watchdog Timeout Interrupt EnableWhen this bit is written to one, WDE is cleared, and the I-bit in the Stat

Página 149

42ATtiny23132543A–AVR–08/03• Bits 5, 2..0 – WDP3..0: Watchdog Timer Prescaler 3, 2, 1, and 0The WDP3..0 bits determine the Watchdog Timer prescaling w

Página 150

43ATtiny23132543A–AVR–08/03The following code example shows one assembly and one C function for turning off theWDT. The example assumes that interrupt

Página 151

44ATtiny23132543A–AVR–08/03Timed Sequences for Changing the Configuration of the Watchdog TimerThe sequence for changing configuration differs slightl

Página 152

45ATtiny23132543A–AVR–08/03Interrupts This section describes the specifics of the interrupt handling as performed inATtiny2313. For a general explanat

Página 153

46ATtiny23132543A–AVR–08/03The most typical and general program setup for the Reset and Interrupt VectorAddresses in ATtiny2313 is:Address Labels Code

Página 154

47ATtiny23132543A–AVR–08/03I/O-PortsIntroduction All AVR ports have true Read-Modify-Write functionality when used as general digitalI/O ports. This m

Página 155

48ATtiny23132543A–AVR–08/03Note that enabling the alternate function of some of the port pins does not affect the useof the other pins in the port as

Página 156

49ATtiny23132543A–AVR–08/03Toggling the Pin Writing a logic one to PINxn toggles the value of PORTxn, independent on the value ofDDRxn. Note that the

Página 157

5ATtiny23132543A–AVR–08/03AVR CPU CoreIntroduction This section discusses the AVR core architecture in general. The main function of theCPU core is to

Página 158

50ATtiny23132543A–AVR–08/03Consider the clock period starting shortly after the first falling edge of the system clock.The latch is closed when the cl

Página 159

51ATtiny23132543A–AVR–08/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 i

Página 160

52ATtiny23132543A–AVR–08/03Alternate Port Functions Most port pins have alternate functions in addition to being general digital I/Os. Figure25 shows

Página 161

53ATtiny23132543A–AVR–08/03The following subsections shortly describe the alternate functions for each port, andrelate the overriding signals to the a

Página 162

54ATtiny23132543A–AVR–08/03MCU Control Register – MCUCR• Bit 7 – PUD: Pull-up DisableWhen this bit is written to one, the pull-ups in the I/O ports ar

Página 163

55ATtiny23132543A–AVR–08/03PCINT6: Pin Change Interrupt Source 6. The PB6 pin can serve as an external interruptsource.• DI/SDA/PCINT5 - Port B, Bit 5

Página 164

56ATtiny23132543A–AVR–08/03• AIN1/PCINT1 – Port B, Bit 1AIN1: Analog Comparator Negative input and ADC6: ADC input channel 6. Configurethe port pin as

Página 165

57ATtiny23132543A–AVR–08/03 Alternate Functions of Port D The Port D pins with alternate functions are shown in Table 29.The alternate pin configurati

Página 166

58ATtiny23132543A–AVR–08/03• T0 – Port D, Bit 4CKOUT: System Clock OutputT0: Timer/Counter0 External Counter Clock input is enabled by setting (one) t

Página 167

59ATtiny23132543A–AVR–08/03 Table 31. Overriding Signals for Alternate Functions in PD3..PD0Signal Name PD3/INT1PD2/INT0/XCK/CKOUT PD1/TXD PD0/RXDPUO

Página 168

6ATtiny23132543A–AVR–08/03the operation is executed, and the result is stored back in the Register File – in oneclock cycle.Six of the 32 registers ca

Página 169

60ATtiny23132543A–AVR–08/03Register Description for I/O-PortsPort A Data Register – PORTAPort A Data Direction Register – DDRAPort A Input Pins Addres

Página 170

61ATtiny23132543A–AVR–08/03External Interrupts The External Interrupts are triggered by the INT0 pin, INT1 pin or any of the PCINT15..0pins. Observe t

Página 171

62ATtiny23132543A–AVR–08/03• Bit 1, 0 – ISC01, ISC00: Interrupt Sense Control 0 Bit 1 and Bit 0The External Interrupt 0 is activated by the external p

Página 172

63ATtiny23132543A–AVR–08/03External Interrupt Flag Register – EIFR• Bit 7 – INTF1: External Interrupt Flag 1When an edge or logic change on the INT1 p

Página 173

64ATtiny23132543A–AVR–08/038-bit Timer/Counter0 with PWMTimer/Counter0 is a general purpose 8-bit Timer/Counter module, with two independentOutput Com

Página 174

65ATtiny23132543A–AVR–08/03Compare pins (OC0A and OC0B). See “Output Compare Unit” on page 66. for details.The Compare Match event will also set the C

Página 175

66ATtiny23132543A–AVR–08/03Depending of the mode of operation used, the counter is cleared, incremented, or dec-remented at each timer clock (clkT0).

Página 176

67ATtiny23132543A–AVR–08/03The OCR0x Registers are double buffered when using any of the Pulse Width Modula-tion (PWM) modes. For the normal and Clear

Página 177

68ATtiny23132543A–AVR–08/03Compare Match Output UnitThe Compare Output mode (COM0x1:0) bits have two functions. The Waveform Gener-ator uses the COM0x

Página 178

69ATtiny23132543A–AVR–08/03Modes of Operation The mode of operation, i.e., the behavior of the Timer/Counter and the Output Comparepins, is defined by

Página 179

7ATtiny23132543A–AVR–08/03Status Register The Status Register contains information about the result of the most recently executedarithmetic instructio

Página 180

70ATtiny23132543A–AVR–08/03to OCR0A is lower than the current value of TCNT0, the counter will miss the CompareMatch. The counter will then have to co

Página 181

71ATtiny23132543A–AVR–08/03Figure 31. Fast PWM Mode, Timing DiagramThe Timer/Counter Overflow Flag (TOV0) is set each time the counter reaches TOP. I

Página 182

72ATtiny23132543A–AVR–08/03Phase Correct PWM Mode The phase correct PWM mode (WGM02:0 = 1 or 5) provides a high resolution phasecorrect PWM waveform g

Página 183

73ATtiny23132543A–AVR–08/03and TCNT0 when the counter decrements. The PWM frequency for the output whenusing phase correct PWM can be calculated by th

Página 184

74ATtiny23132543A–AVR–08/03Figure 34. Timer/Counter Timing Diagram, with Prescaler (fclk_I/O/8)Figure 35 shows the setting of OCF0B in all modes and

Página 185

75ATtiny23132543A–AVR–08/038-bit Timer/Counter Register DescriptionTimer/Counter Control Register A – TCCR0A• Bits 7:6 – COM0A1:0: Compare Match Outpu

Página 186

76ATtiny23132543A–AVR–08/03Table 37 shows the COM0A1:0 bit functionality when the WGM02:0 bits are set tophase correct PWM mode.Note: 1. A special cas

Página 187

77ATtiny23132543A–AVR–08/03Table 40 shows the COM0B1:0 bit functionality when the WGM02:0 bits are set tophase correct PWM mode.Note: 1. A special cas

Página 188

78ATtiny23132543A–AVR–08/03Timer/Counter Control Register B – TCCR0B• Bit 7 – FOC0A: Force Output Compare AThe FOC0A bit is only active when the WGM b

Página 189

79ATtiny23132543A–AVR–08/03If external pin modes are used for the Timer/Counter0, transitions on the T0 pin willclock the counter even if the pin is c

Página 190

8ATtiny23132543A–AVR–08/03• Bit 0 – C: Carry FlagThe Carry Flag C indicates a carry in an arithmetic or logic operation. See the “Instruc-tion Set Des

Página 191

80ATtiny23132543A–AVR–08/03• Bit 1 – TOIE0: Timer/Counter0 Overflow Interrupt EnableWhen the TOIE0 bit is written to one, and the I-bit in the Status

Página 192

81ATtiny23132543A–AVR–08/03Timer/Counter0 and Timer/Counter1 PrescalersTimer/Counter1 and Timer/Counter0 share the same prescaler module, but theTimer

Página 193

82ATtiny23132543A–AVR–08/03the edge detector uses sampling, the maximum frequency of an external clock it candetect is half the sampling frequency (Ny

Página 194

83ATtiny23132543A–AVR–08/0316-bit Timer/Counter1 The 16-bit Timer/Counter unit allows accurate program execution timing (event man-agement), wave gene

Página 195

84ATtiny23132543A–AVR–08/03Figure 39. 16-bit Timer/Counter Block Diagram(1)Note: 1. Refer to Figure 1 on page 1 for Timer/Counter1 pin placement and

Página 196

85ATtiny23132543A–AVR–08/03The Input Capture Register can capture the Timer/Counter value at a given external(edge triggered) event on either the Inpu

Página 197

86ATtiny23132543A–AVR–08/03Accessing 16-bit RegistersThe TCNT1, OCR1A/B, and ICR1 are 16-bit registers that can be accessed by the AVRCPU via the 8-bi

Página 198

87ATtiny23132543A–AVR–08/03Therefore, when both the main code and the interrupt code update the temporary regis-ter, the main code must disable the in

Página 199

88ATtiny23132543A–AVR–08/03The following code examples show how to do an atomic write of the TCNT1 Registercontents. Writing any of the OCR1A/B or ICR

Página 200

89ATtiny23132543A–AVR–08/03Timer/Counter Clock SourcesThe Timer/Counter can be clocked by an internal or an external clock source. The clocksource is

Página 201

9ATtiny23132543A–AVR–08/03The X-register, Y-register, and Z-registerThe registers R26..R31 have some added functions to their general purpose usage.Th

Página 202

90ATtiny23132543A–AVR–08/03how waveforms are generated on the Output Compare outputs OC1x. For more detailsabout advanced counting sequences and wavef

Página 203

91ATtiny23132543A–AVR–08/03The ICR1 Register can only be written when using a Waveform Generation mode thatutilizes the ICR1 Register for defining the

Página 204

92ATtiny23132543A–AVR–08/03Output Compare Units The 16-bit comparator continuously compares TCNT1 with the Output Compare Regis-ter (OCR1x). If TCNT e

Página 205

93ATtiny23132543A–AVR–08/03(Buffer or Compare) Register is only changed by a write operation (the Timer/Counterdoes not update this register automatic

Página 206

94ATtiny23132543A–AVR–08/03Compare Match Output UnitThe Compare Output mode (COM1x1:0) bits have two functions. The Waveform Gener-ator uses the COM1x

Página 207

95ATtiny23132543A–AVR–08/03Compare Output Mode and Waveform GenerationThe Waveform Generator uses the COM1x1:0 bits differently in normal, CTC, and PW

Página 208

96ATtiny23132543A–AVR–08/03Clear Timer on Compare Match (CTC) ModeIn Clear Timer on Compare or CTC mode (WGM13:0 = 4 or 12), the OCR1A or ICR1Register

Página 209

97ATtiny23132543A–AVR–08/03Fast PWM Mode The fast Pulse Width Modulation or fast PWM mode (WGM13:0 = 5, 6, 7, 14, or 15) pro-vides a high frequency PW

Página 210

98ATtiny23132543A–AVR–08/03When changing the TOP value the program must ensure that the new TOP value ishigher or equal to the value of all of the Com

Página 211 - Regional Headquarters

99ATtiny23132543A–AVR–08/03Phase Correct PWM Mode The phase correct Pulse Width Modulation or phase correct PWM mode (WGM13:0 = 1,2, 3, 10, or 11) pro

Comentários a estes Manuais

Sem comentários