Rainbow-electronics Atmega169L Manuale Utente

Navigare online o scaricare Manuale Utente per Sensori Rainbow-electronics Atmega169L. Rainbow Electronics Atmega169L User Manual Manuale Utente

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 317
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 0
1
Features
High Performance, Low Power AVR
®
8-Bit Microcontroller
Advanced RISC Architecture
130 Powerful Instructions – Most Single Clock Cycle Execution
32x8GeneralPurposeWorkingRegisters
Fully Static Operation
Up to 4 MIPS Throughput at 4 MHz
On-Chip 2-cycle Multiplier
Non-volatile Program and Data Memories
16K bytes of In-System Self-Programmable Flash
Endurance: 1,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 byte Internal SRAM
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
4x25SegmentLCDDriver
Two 8-bit Timer/Counters with Separate Prescaler and Compare Mode
One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture
Mode
Real Time Counter with Separate Oscillator
Four PWM Channels
8-channel, 10-bit ADC
Programmable Serial USART
Master/Slave SPI Serial Interface
Universal Serial Interface with Start Condition Detector
Programmable Watchdog Timer with Separate On-chip Oscillator
On-chip Analog Comparator
Interrupt and Wake-up on Pin Change
Special Microcontroller Features
Power-on Reset and Programmable Brown-out Detection
Internal Calibrated Oscillator
External and Internal Interrupt Sources
Five Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, and
Standby
I/O and Packages
53 Programmable I/O Lines and 1 Input Line
64-lead TQFP
Operating Voltage:
1.8 - 3.6V for ATmega169V
2.7 - 3.6V for ATmega169L
Temperature Range:
–-10
°Cto50°C
Speed Grade:
0 - 1 MHz for ATmega169V
0 - 4 MHz for ATmega169L
Ultra-Low Power Consumption
Active Mode:
1MHz,1.8V:300µA
32 kHz, 1.8V: 20µA (including Oscillator)
32 kHz, 1.8V: TBD (including Oscillator and LCD)
Power-down Mode:
0.5µAat1.8V
8-bit
Microcontroller
with 16K Bytes
In-System
Programmable
Flash
ATmega169V
ATmega169L
Advance
Information
Rev. 2514A–AVR–08/02
Vedere la pagina 0
1 2 3 4 5 6 ... 316 317

Sommario

Pagina 1 - Features

1Features• High Performance, Low Power AVR®8-Bit Microcontroller• Advanced RISC Architecture– 130 Powerful Instructions – Most Single Clock Cycle Exec

Pagina 2

10ATmega169V/L2514A–AVR–08/02• Bit0–C:CarryFlagThe Carry Flag C indicates a carry in an arithmetic or logic operation. See the “Instruc-tion Set Descr

Pagina 3

100ATmega169V/L2514A–AVR–08/02Timer/Counter ClockSourcesThe Timer/Counter can be clocked by an internal or an external clock source. The clocksource i

Pagina 4

101ATmega169V/L2514A–AVR–08/02how waveforms are generated on the Output Compare outputs OC1x. For more detailsabout advanced counting sequences and wa

Pagina 5

102ATmega169V/L2514A–AVR–08/02The ICR1 Register can only be written when using a Waveform Generation mode thatutilizes the ICR1 Register for defining

Pagina 6

103ATmega169V/L2514A–AVR–08/02Output Compare Units The 16-bit comparator continuously compares TCNT1 with theOutput Compare Regis-ter(OCR1x). If TCNT

Pagina 7

104ATmega169V/L2514A–AVR–08/02(Buffer or Compare) Register is only changed by a write operation (the Timer/Counterdoes not update this register automa

Pagina 8

105ATmega169V/L2514A–AVR–08/02Compare Match OutputUnitTheCompare Output mode(COM1x1:0) bits have two functions. The Waveform Gener-ator uses the COM1x

Pagina 9

106ATmega169V/L2514A–AVR–08/02Compare Output Mode andWaveform GenerationThe Waveform Generator uses the COM1x1:0 bits differently in normal, CTC, and

Pagina 10 - ATmega169V/L

107ATmega169V/L2514A–AVR–08/02Clear Timer on CompareMatch (CTC) ModeInClear Timer on CompareorCTCmode(WGM13:0=4or12),theOCR1AorICR1Register are used t

Pagina 11

108ATmega169V/L2514A–AVR–08/02Fast PWM Mode Thefast Pulse Width Modulationor fast PWM mode (WGM13:0 = 5, 6, 7, 14, or 15) pro-vides a high frequency P

Pagina 12

109ATmega169V/L2514A–AVR–08/02When changing the TOP value the program must ensure that the new TOP value ishigher or equal to the value of all of the

Pagina 13

11ATmega169V/L2514A–AVR–08/02The X-register, Y-register, andZ-registerThe registers R26..R31 have some added functions to their general purpose usage.

Pagina 14

110ATmega169V/L2514A–AVR–08/02Phase Correct PWM Mode Thephase correct Pulse Width Modulationor phase correct PWM mode (WGM13:0 = 1,2, 3, 10, or 11) pr

Pagina 15

111ATmega169V/L2514A–AVR–08/02ICF1 flag is set accordingly at the same timer clock cycle as the OCR1x Registers areupdated with the double buffer valu

Pagina 16

112ATmega169V/L2514A–AVR–08/02Phase and Frequency CorrectPWM ModeThephase and frequency correct Pulse Width Modulation,or phase and frequency cor-rect

Pagina 17

113ATmega169V/L2514A–AVR–08/02The Timer/Counter Overflow Flag (TOV1) is set at the same timer clock cycle as theOCR1x Registers are updated with the d

Pagina 18

114ATmega169V/L2514A–AVR–08/02Timer/Counter TimingDiagramsThe Timer/Counter is a synchronous design and the timer clock (clkT1)isthereforeshown as a c

Pagina 19

115ATmega169V/L2514A–AVR–08/02Figure 50. Timer/Counter Timing Diagram, no PrescalingFigure 51 shows the same timing data, but with the prescaler enabl

Pagina 20

116ATmega169V/L2514A–AVR–08/0216-bit Timer/CounterRegister DescriptionTimer/Counter1 ControlRegister A – TCCR1A• Bit 7:6 – COM1A1:0: Compare Output Mo

Pagina 21

117ATmega169V/L2514A–AVR–08/02Table 57 shows the COM1x1:0 bit functionality when the WGM13:0 bits are set to thephase correct or the phase and frequen

Pagina 22

118ATmega169V/L2514A–AVR–08/02Note: 1. The CTC1 and PWM11:0 bit definition names are obsolete. Use the WGM12:0 definitions. However, the functionality

Pagina 23

119ATmega169V/L2514A–AVR–08/02(ICF1), and this can be used to cause an Input Capture Interrupt, if this interrupt isenabled.When the ICR1 is used as T

Pagina 24

12ATmega169V/L2514A–AVR–08/02Instruction ExecutionTimingThis section describes the general access timing concepts for instruction execution. TheAVR CP

Pagina 25

120ATmega169V/L2514A–AVR–08/02A FOC1A/FOC1B strobe will not generate any interrupt nor will it clear the timer in ClearTimer on Compare match (CTC) mo

Pagina 26

121ATmega169V/L2514A–AVR–08/02Input Capture Register 1 –ICR1H and ICR1LThe Input Capture is updated with the counter (TCNT1) value each time an event

Pagina 27

122ATmega169V/L2514A–AVR–08/02Timer/Counter1 Interrupt FlagRegister – TIFR1• Bit 5 – ICF1: Timer/Counter1, Input Capture FlagThis flag is set when a c

Pagina 28

123ATmega169V/L2514A–AVR–08/028-bit Timer/Counter2with PWM andAsynchronousOperationTimer/Counter2 is a general purpose, single channel, 8-bit Timer/Co

Pagina 29

124ATmega169V/L2514A–AVR–08/02ment) its value. The Timer/Counter is inactive when no clock source is selected. Theoutput from the Clock Select logic i

Pagina 30

125ATmega169V/L2514A–AVR–08/02top Signalizes that TCNT2 has reached maximum value.bottom Signalizes that TCNT2 has reached minimum value (zero).Depend

Pagina 31

126ATmega169V/L2514A–AVR–08/02The OCR2A Register is double buffered when using any of the Pulse Width Modulation(PWM) modes. For the Normal and Clear

Pagina 32

127ATmega169V/L2514A–AVR–08/02Compare Match OutputUnitThe Compare Output mode (COM2A1:0) bits have two functions. The Waveform Gener-ator uses the COM

Pagina 33

128ATmega169V/L2514A–AVR–08/02Modes of Operation The mode of operation, i.e., the behavior of the Timer/Counter and the Output Comparepins, is defined

Pagina 34

129ATmega169V/L2514A–AVR–08/02compare match. The counter will then have to count to its maximum value (0xFF) andwrap around starting at 0x00 before th

Pagina 35

13ATmega169V/L2514A–AVR–08/02moved to the start of the Boot Flash section by programming the BOOTRST Fuse, see“Boot Loader Support – Read-While-Write

Pagina 36

130ATmega169V/L2514A–AVR–08/02The Timer/Counter Overflow Flag (TOV2) is set each time the counter reaches MAX. Ifthe interrupt is enabled, the interru

Pagina 37

131ATmega169V/L2514A–AVR–08/02Figure 58. Phase Correct PWM Mode, Timing DiagramThe Timer/Counter Overflow Flag (TOV2) is set each time the counter rea

Pagina 38

132ATmega169V/L2514A–AVR–08/02Timer/Counter TimingDiagramsThe following figures show the Timer/Counter in synchronous mode, and the timer clock(clkT2)

Pagina 39

133ATmega169V/L2514A–AVR–08/02Figure 61. Timer/Counter Timing Diagram, Setting of OCF2A, with Prescaler (fclk_I/O/8)Figure 62 shows the setting of OCF

Pagina 40

134ATmega169V/L2514A–AVR–08/028-bit Timer/CounterRegister DescriptionTimer/Counter ControlRegister A– TCCR2A• Bit 7 – FOC2A: Force Output Compare AThe

Pagina 41

135ATmega169V/L2514A–AVR–08/02• Bit 5:4 – COM2A1:0: Compare Match Output Mode AThese bits control the Output Compare pin (OC2A) behavior. If one or bo

Pagina 42

136ATmega169V/L2514A–AVR–08/02• Bit 2:0 – CS22:0: Clock SelectThe three Clock Select bits select the clock source to be used by the Timer/Counter, see

Pagina 43

137ATmega169V/L2514A–AVR–08/02Asynchronous operationof the Timer/CounterAsynchronous StatusRegister – ASSR• Bit 4 – EXCLK: Enable External Clock Input

Pagina 44

138ATmega169V/L2514A–AVR–08/02Asynchronous Operation ofTimer/Counter2When Timer/Counter2 operates asynchronously, some considerations must be taken.•

Pagina 45

139ATmega169V/L2514A–AVR–08/02• Description of wake up from Power-save or Extended Standby mode when the timeris clocked asynchronously: When the inte

Pagina 46

14ATmega169V/L2514A–AVR–08/02When using the SEI instruction to enable interrupts, the instruction following SEI will beexecuted before any pending int

Pagina 47

140ATmega169V/L2514A–AVR–08/02Timer/Counter2 Interrupt FlagRegister – TIFR2• Bit 1 – OCF2A: Output Compare Flag 2 AThe OCF2A bit is set (one) when a c

Pagina 48

141ATmega169V/L2514A–AVR–08/02Timer/Counter Prescaler Figure 63. Prescaler for Timer/Counter2The clock source for Timer/Counter2 is named clkT2S.clkT2

Pagina 49

142ATmega169V/L2514A–AVR–08/02Serial PeripheralInterface – SPIThe Serial Peripheral Interface (SPI) allows high-speed synchronous data transferbetween

Pagina 50

143ATmega169V/L2514A–AVR–08/02When configured as a Master, the SPI interface has no automatic control of the SS line.This must be handled by user soft

Pagina 51

144ATmega169V/L2514A–AVR–08/02The following code examples show how to initialize the SPI as a Master and how to per-form a simple transmission. DDR_SP

Pagina 52

145ATmega169V/L2514A–AVR–08/02The following code examples show how to initialize the SPI as a Slave and how to per-form a simple reception.Note: 1. Th

Pagina 53

146ATmega169V/L2514A–AVR–08/02SS Pin FunctionalitySlave Mode When the SPI is configured as a Slave, the Slave Select (SS) pin is always input. WhenSSi

Pagina 54

147ATmega169V/L2514A–AVR–08/02• Bit 4 – MSTR: Master/Slave SelectThis bit selects Master SPI mode when written to one, and Slave SPI mode when written

Pagina 55 - DATA B U S

148ATmega169V/L2514A–AVR–08/02SPI Status Register – SPSR• Bit 7 – SPIF: SPI Interrupt FlagWhen a serial transfer is complete, the SPIF flag is set. An

Pagina 56

149ATmega169V/L2514A–AVR–08/02Data Modes There are four combinations of SCK phase and polarity with respect to serial data,which are determined by con

Pagina 57

15ATmega169V/L2514A–AVR–08/02AVR ATmega169MemoriesThis section describes the different memories in the ATmega169. The AVR architecturehas two main mem

Pagina 58

150ATmega169V/L2514A–AVR–08/02USART The Universal Synchronous and Asynchronous serial Receiver and Transmitter(USART) is a highly flexible serial comm

Pagina 59

151ATmega169V/L2514A–AVR–08/02The dashed boxes in the block diagram separate the three main parts of the USART(listed from the top): Clock Generator,

Pagina 60

152ATmega169V/L2514A–AVR–08/02Figure 69. Clock Generation Logic, Block DiagramSignal description:txclk Transmitter clock (Internal Signal).rxclk Recei

Pagina 61

153ATmega169V/L2514A–AVR–08/02Note: 1. The baud rate is defined to be the transfer rate in bit per second (bps)BAUD Baud rate (in bits per second, bps

Pagina 62

154ATmega169V/L2514A–AVR–08/02Synchronous Clock Operation When synchronous mode is used (UMSEL = 1), the XCK pin will be used as either clockinput (Sl

Pagina 63

155ATmega169V/L2514A–AVR–08/02Sp Stop bit, always high.IDLE No transfers on the communication line (RxD or TxD). An IDLE line must behigh.The frame fo

Pagina 64

156ATmega169V/L2514A–AVR–08/02The following simple USART initialization code examples show one assembly and oneC function that are equal in functional

Pagina 65

157ATmega169V/L2514A–AVR–08/02Data Transmission – TheUSART TransmitterThe USART Transmitter is enabled by setting theTransmit Enable(TXEN) bit in theU

Pagina 66

158ATmega169V/L2514A–AVR–08/02Sending Frames with 9 DataBitIf 9-bit characters are used (UCSZ = 7), the ninth bit must be written to the TXB8 bit inUC

Pagina 67

159ATmega169V/L2514A–AVR–08/02Transmitter Flags andInterruptsThe USART Transmitter has two flags that indicate its state: USART Data RegisterEmpty (UD

Pagina 68

16ATmega169V/L2514A–AVR–08/02SRAM Data Memory Figure 9 shows how the ATmega169 SRAM Memory is organized.The ATmega169 is a complex microcontroller wit

Pagina 69

160ATmega169V/L2514A–AVR–08/02Data Reception – TheUSART ReceiverThe USART Receiver is enabled by writing the Receive Enable (RXEN) bit in theUCSRB Reg

Pagina 70

161ATmega169V/L2514A–AVR–08/02Receiving Frames with 9 DataBitsIf 9-bit characters are used (UCSZ=7) the ninth bit must be read from the RXB8 bit inUCS

Pagina 71

162ATmega169V/L2514A–AVR–08/02The receive function example reads all the I/O Registers into the Register File beforeany computation is done. This give

Pagina 72

163ATmega169V/L2514A–AVR–08/02Parity Checker The Parity Checker is active when the high USART Parity mode (UPM1) bit is set. Typeof Parity Check to be

Pagina 73

164ATmega169V/L2514A–AVR–08/02Asynchronous ClockRecoveryThe clock recovery logic synchronizes internal clock to the incoming serial frames. Fig-ure 72

Pagina 74

165ATmega169V/L2514A–AVR–08/02Figure 74 shows the sampling of the stop bit and the earliest possible beginning of thestart bit of the next frame.Figur

Pagina 75

166ATmega169V/L2514A–AVR–08/02The recommendations of the maximum receiver baud rate error was made under theassumption that the Receiver and Transmitt

Pagina 76

167ATmega169V/L2514A–AVR–08/02Multi-processorCommunication ModeSetting the Multi-processor Communication mode (MPCM) bit in UCSRA enables a fil-tering

Pagina 77

168ATmega169V/L2514A–AVR–08/02USART RegisterDescriptionUSART I/O Data Register –UDRThe USART Transmit Data Buffer Register and USART Receive Data Buff

Pagina 78 - 8-bit Timer/Counter0

169ATmega169V/L2514A–AVR–08/02• Bit 5 – UDRE: USART Data Register EmptyThe UDRE flag indicates if the transmit buffer (UDR) is ready to receive new da

Pagina 79 - Timer/Counter Clock

17ATmega169V/L2514A–AVR–08/02Data Memory Access Times This section describes the general access timing concepts for internal memory access.The interna

Pagina 80 - DATA BU S

170ATmega169V/L2514A–AVR–08/02USART Control and StatusRegister B – UCSRB• Bit 7 – RXCIE: RX Complete Interrupt EnableWriting this bit to one enables i

Pagina 81

171ATmega169V/L2514A–AVR–08/02USART Control and StatusRegister C – UCSRC• Bit 6 – UMSEL: USART Mode SelectThis bit selects between asynchronous and sy

Pagina 82 - Compare Match Output

172ATmega169V/L2514A–AVR–08/02• Bit 2:1 – UCSZ1:0: Character SizeThe UCSZ1:0 bits combined with the UCSZ2 bit in UCSRB sets the number of data bits(Ch

Pagina 83

173ATmega169V/L2514A–AVR–08/02Examples of Baud RateSettingFor standard crystal and resonator frequencies, the most commonly used baud rates forasynchr

Pagina 84

174ATmega169V/L2514A–AVR–08/02Table 80. Examples of UBRR Settings for Commonly Used Oscillator Frequencies (Continued)BaudRate(bps)fosc= 3.6864 MHz fo

Pagina 85

175ATmega169V/L2514A–AVR–08/02Table 81. Examples of UBRR Settings for Commonly Used Oscillator Frequencies (Continued)BaudRate(bps)fosc= 8.0000 MHz fo

Pagina 86

176ATmega169V/L2514A–AVR–08/02Table 82. Examples of UBRR Settings for Commonly Used Oscillator Frequencies (Continued)BaudRate(bps)fosc= 16.0000 MHz f

Pagina 87

177ATmega169V/L2514A–AVR–08/02Universal SerialInterface – USIThe Universal Serial Interface, or USI, provides the basic hardware resources neededfor s

Pagina 88

178ATmega169V/L2514A–AVR–08/02The Two-wire clock control unit can generate an interrupt when a start condition isdetected on the Two-wire bus. It can

Pagina 89

179ATmega169V/L2514A–AVR–08/02The Three-wire mode timing is shown in Figure 77. At the top of the figure is a USCKcycle reference. One bit is shifted

Pagina 90

18ATmega169V/L2514A–AVR–08/02The EEPROM AddressRegister – EEARH and EEARL• Bits 15..9 – Res: Reserved BitsThese bits are reserved bits in the ATmega16

Pagina 91

180ATmega169V/L2514A–AVR–08/02The following code demonstrates how to use the USI module as a SPI Master with max-imum speed (fsck = fck/2):SPITransfer

Pagina 92

181ATmega169V/L2514A–AVR–08/02Note that the first two instructions is for initialization only and needs only to be executedonce.These instructions set

Pagina 93

182ATmega169V/L2514A–AVR–08/02Figure 79. Two-wire Mode, Typical Timing DiagramReferring to the timing diagram (Figure 79.), a bus transfer involves th

Pagina 94

183ATmega169V/L2514A–AVR–08/02Start Condition Detector The start condition detector is shown in Figure 80. The SDA line is delayed (in the rangeof 50

Pagina 95

184ATmega169V/L2514A–AVR–08/02Note that the corresponding Data Direction Register to the pin must be set to one forenabling data output from the Shift

Pagina 96

185ATmega169V/L2514A–AVR–08/02Note that even when no wire mode is selected (USIWM1..0 = 0) the external clock input(USCK/SCL) are can still be used by

Pagina 97

186ATmega169V/L2514A–AVR–08/02Note: 1. The DI and USCK pins are renamed toSerial Data(SDA) andSerial Clock(SCL)respectively to avoid confusion between

Pagina 98

187ATmega169V/L2514A–AVR–08/02• Bit 3..2 – USICS1..0: Clock Source SelectThese bits set the clock source for the Shift Register and counter. The data

Pagina 99

188ATmega169V/L2514A–AVR–08/02Analog Comparator The Analog Comparator compares the input values on the positive pin AIN0 and nega-tive pin AIN1. When

Pagina 100

189ATmega169V/L2514A–AVR–08/02• Bit 6 – ACBG: Analog Comparator Bandgap SelectWhen this bit is set, a fixed bandgap reference voltage replaces the pos

Pagina 101

19ATmega169V/L2514A–AVR–08/02• Bit 1 – EEWE: EEPROM Write EnableTheEEPROMWriteEnableSignalEEWEisthewritestrobetotheEEPROM.Whenaddress and data are cor

Pagina 102

190ATmega169V/L2514A–AVR–08/02Analog ComparatorMultiplexed InputIt is possible to select any of the ADC7..0 pins to replace the negative input to the

Pagina 103

191ATmega169V/L2514A–AVR–08/02Analog to DigitalConverterFeatures • 10-bit Resolution• 0.5 LSB Integral Non-linearity• ± 2 LSB Absolute Accuracy• TBD -

Pagina 104

192ATmega169V/L2514A–AVR–08/02Figure 82. Analog to Digital Converter Block SchematicOperation The ADC converts an analog input voltage to a 10-bit dig

Pagina 105

193ATmega169V/L2514A–AVR–08/02The ADC generates a 10-bit result which is presented in the ADC Data Registers,ADCH and ADCL. By default, the result is

Pagina 106

194ATmega169V/L2514A–AVR–08/02conversion must be started by writing a logical one to the ADSC bit in ADCSRA. In thismode the ADC will perform successi

Pagina 107

195ATmega169V/L2514A–AVR–08/02In Free Running mode, a new conversion will be started immediately after the conver-sion completes, while ADSC remains h

Pagina 108

196ATmega169V/L2514A–AVR–08/02Figure 88. ADC Timing Diagram, Free Running ConversionDifferential Channels When using differential channels, certain as

Pagina 109

197ATmega169V/L2514A–AVR–08/02Changing Channel orReference SelectionThe MUXn and REFS1:0 bits in the ADMUX Register are single buffered through a tem-

Pagina 110

198ATmega169V/L2514A–AVR–08/02ADC Voltage Reference The reference voltage for the ADC (VREF) indicates the conversion range for the ADC.Single ended c

Pagina 111

199ATmega169V/L2514A–AVR–08/02Analog Input Circuitry The analog input circuitry for single ended channels is illustrated in Figure 89. An analogsource

Pagina 112

2ATmega169V/L2514A–AVR–08/02Pin Configurations Figure 1. Pinout ATmega169Disclaimer Typical values contained in this data sheet are based on simulatio

Pagina 113

20ATmega169V/L2514A–AVR–08/02The following code examples show one assembly and one C function for writing to theEEPROM. The examples assume that inter

Pagina 114

200ATmega169V/L2514A–AVR–08/02Analog Noise CancelingTechniquesDigital circuitry inside and outside the device generates EMI which might affect theaccu

Pagina 115

201ATmega169V/L2514A–AVR–08/02ADC Accuracy Definitions An n-bit single-ended ADC converts a voltage linearly between GND and VREFin 2nsteps (LSBs). Th

Pagina 116

202ATmega169V/L2514A–AVR–08/02Figure 93. Integral Non-linearity (INL)• Differential Non-linearity (DNL): The maximum deviation of the actual code widt

Pagina 117

203ATmega169V/L2514A–AVR–08/02ADC Conversion ResultAfter the conversion is complete (ADIF is high), the conversion result can be found inthe ADC Resul

Pagina 118

204ATmega169V/L2514A–AVR–08/02Example: ADMUX = 0xFB (ADC3 - ADC2, 1.1V reference, left adjusted result)Voltage on ADC3 is 300 mV, voltage on ADC2 is 5

Pagina 119

205ATmega169V/L2514A–AVR–08/02• Bits 4:0 – MUX4:0: Analog Channel Selection BitsThe value of these bits selects which combination of analog inputs are

Pagina 120

206ATmega169V/L2514A–AVR–08/02ADC Control and StatusRegister A – ADCSRA• Bit 7 – ADEN: ADC EnableWriting this bit to one enables the ADC. By writing i

Pagina 121

207ATmega169V/L2514A–AVR–08/02• Bits 2:0 – ADPS2:0: ADC Prescaler Select BitsThese bits determine the division factor between the XTAL frequency and t

Pagina 122

208ATmega169V/L2514A–AVR–08/02• ADC9:0: ADC Conversion ResultThese bits represent the result from the conversion, as detailed in “ADC ConversionResult

Pagina 123

209ATmega169V/L2514A–AVR–08/02LCD Controller The LCD Controller/driver is intended for monochrome passive liquid crystal display(LCD) with up to four

Pagina 124

21ATmega169V/L2514A–AVR–08/02The next code examples show assembly and C functions for reading the EEPROM. Theexamples assume that interrupts are contr

Pagina 125

210ATmega169V/L2514A–AVR–08/02Figure 96. Block Diagram LCD ModuleLCD Clock Cources The LCD Controller can be clocked by an internal synchronous or an

Pagina 126

211ATmega169V/L2514A–AVR–08/02Addressing COM0 starts a frame by driving opposite phase with large amplitude out onCOM0 compared to none addressed COM

Pagina 127

212ATmega169V/L2514A–AVR–08/02Figure 98. Driving a LCD with One Common Terminal1/2Dutyand1/2Bias For LCD with two common terminals (1/2 duty) a more c

Pagina 128

213ATmega169V/L2514A–AVR–08/021/3Dutyand1/3Bias 1/3 bias is usually recommended for LCD with three common terminals (1/3 duty).Waveform is shown in Fi

Pagina 129

214ATmega169V/L2514A–AVR–08/02Low Power Waveform To reduce toggle activity and hence power consumption a low power waveform can beselected by writing

Pagina 130

215ATmega169V/L2514A–AVR–08/02LCD UsageLCD Initialization Prior to enabling the LCD some initialization must be preformed. The initialization pro-cess

Pagina 131

216ATmega169V/L2514A–AVR–08/02Note: 1. The example code assumes that the part specific header file is included.Assembly Code Example(1)LCD_Init:; Use

Pagina 132

217ATmega169V/L2514A–AVR–08/02Before a re-initialization is done, the LCD controller/driver should be disabledUpdating the LCD Display memory (LCDDR0,

Pagina 133

218ATmega169V/L2514A–AVR–08/02Note: 1. The example code assumes that the part specific header file is included.Assembly Code Example(1)LCD_disable:; W

Pagina 134

219ATmega169V/L2514A–AVR–08/02LCD Control and StatusRegister A – LCDCRA• Bit 7 – LCDEN: LCD EnableWriting this bit to one enables the LCD Controller/D

Pagina 135

22ATmega169V/L2514A–AVR–08/02I/O Memory The I/O space definition of the ATmega169 is shown in “Register Summary” on page302.All ATmega169 I/Os and per

Pagina 136

220ATmega169V/L2514A–AVR–08/02LCD Control and StatusRegister B – LCDCRB• Bit 7 – LCDCS: LCD Clock SelectWhen this bit is written to zero, the system c

Pagina 137

221ATmega169V/L2514A–AVR–08/02• Bits 2:0 – LCDPM2:0: LCD Port MaskThe LCDPM2:0 bits determine the number of port pins to be used as segment drivers.Th

Pagina 138

222ATmega169V/L2514A–AVR–08/02• Bit 3 – Res: Reserved BitThis bit is reserved bit in the ATmega169 and will always read as zero.• Bits 2:0 – LCDCD2:0:

Pagina 139

223ATmega169V/L2514A–AVR–08/02LCD Contrast ControlRegister – LCDCCR• Bits 7:4 – Res: Reserved BitsThese bits are reserved bits in the ATmega169 and wi

Pagina 140

224ATmega169V/L2514A–AVR–08/02LCD Memory Mapping Write a LCD memory bit to one and the corresponding segment will be energized (visi-ble). Unused LCD

Pagina 141

225ATmega169V/L2514A–AVR–08/02JTAG Interface andOn-chip DebugSystemFeatures • JTAG (IEEE std. 1149.1 Compliant) Interface• Boundary-scan Capabilities

Pagina 142

226ATmega169V/L2514A–AVR–08/02The IEEE std. 1149.1 also specifies an optional TAP signal; TRST – Test ReSeT –which is not provided.When the JTAGEN Fus

Pagina 143

227ATmega169V/L2514A–AVR–08/02Figure 105. TAP Controller State DiagramTAP Controller The TAP controller is a 16-state finite state machine that contro

Pagina 144

228ATmega169V/L2514A–AVR–08/02state. The Exit-IR, Pause-IR, and Exit2-IR states are only used for navigating thestate machine.• At the TMS input, appl

Pagina 145

229ATmega169V/L2514A–AVR–08/02A list of the On-chip Debug specific JTAG instructions is given in “On-chip Debug Spe-cific JTAG Instructions” on page 2

Pagina 146

23ATmega169V/L2514A–AVR–08/02System Clock andClock OptionsClock Systems and theirDistributionFigure 11 presents the principal clock systems in the AVR

Pagina 147

230ATmega169V/L2514A–AVR–08/02On-chip Debug RelatedRegister in I/O MemoryOn-chip Debug Register –OCDRThe OCDR Register provides a communication channe

Pagina 148

231ATmega169V/L2514A–AVR–08/02IEEE 1149.1 (JTAG)Boundary-scanFeatures • JTAG (IEEE std. 1149.1 compliant) Interface• Boundary-scan Capabilities Accord

Pagina 149 - 2514A–AVR–08/02

232ATmega169V/L2514A–AVR–08/02Bypass Register The Bypass Register consists of a single Shift Register stage. When the Bypass Regis-ter is selected as

Pagina 150

233ATmega169V/L2514A–AVR–08/02Reset Register The Reset Register is a test data register used to reset the part. Since the AVR tri-statesPort Pins when

Pagina 151

234ATmega169V/L2514A–AVR–08/02EXTEST; 0x0 Mandatory JTAG instruction for selecting the Boundary-scan Chain as data register fortesting circuitry exter

Pagina 152

235ATmega169V/L2514A–AVR–08/02Boundary-scan RelatedRegister in I/O MemoryMCU Control Register –MCUCRThe MCU Control Register contains control bits for

Pagina 153

236ATmega169V/L2514A–AVR–08/02Figure 108. Boundary-scan Cell for Bi-directional Port Pin with Pull-up Function.DQ DQG0101DQ DQG01010101DQ DQG01Port Pi

Pagina 154

237ATmega169V/L2514A–AVR–08/02Figure 109. General Port Pin Schematic DiagramScanning the RESET Pin The RESET pin accepts 5V active low logic for stand

Pagina 155

238ATmega169V/L2514A–AVR–08/02Scanning the Clock Pins The AVR devices have many clock options selectable by fuses. These are: Internal RCOscillator, E

Pagina 156

239ATmega169V/L2514A–AVR–08/02Scanning the AnalogComparatorThe relevant Comparator signals regarding Boundary-scan are shown in Figure 112.The Boundar

Pagina 157

24ATmega169V/L2514A–AVR–08/02ADC Clock – clkADCThe ADC is provided with a dedicated clock domain. This allows halting the CPU andI/O clocks in order t

Pagina 158

240ATmega169V/L2514A–AVR–08/02Scanning the ADC Figure 114 shows a block diagram of the ADC with all relevant control and observe sig-nals. The Boundar

Pagina 159

241ATmega169V/L2514A–AVR–08/02Table 105. Boundary-scan Signals for the ADC(1)SignalNameDirectionas Seenfrom theADC DescriptionRecommen-ded Inputwhen n

Pagina 160

242ATmega169V/L2514A–AVR–08/02G10 Input Enable 10x gain 0 0G20 Input Enable 20x gain 0 0GNDEN Input Ground the negativeinput to comparatorwhen true00H

Pagina 161

243ATmega169V/L2514A–AVR–08/02Note: 1. Incorrect setting of the switches in Figure 114 will make signal contention and maydamage the part. There are s

Pagina 162

244ATmega169V/L2514A–AVR–08/02As an example, consider the task of verifying a 1.5V ± 5% input signal at ADC channel 3when the power supply is 5.0V and

Pagina 163

245ATmega169V/L2514A–AVR–08/02ATmega169 Boundary-scan OrderTable 107 shows the Scan order between TDI and TDO when the Boundary-scan chainis selected

Pagina 164

246ATmega169V/L2514A–AVR–08/02168 MUXEN_3 ADC167 MUXEN_2166 MUXEN_1165 MUXEN_0164 NEGSEL_2163 NEGSEL_1162 NEGSEL_0161 PASSEN160 PRECH159 ST158 VCCREN1

Pagina 165

247ATmega169V/L2514A–AVR–08/02132 PB0.Control Port B131 PB0.Pullup_Enable130 PB1.Data129 PB1.Control128 PB1.Pullup_Enable127 PB2.Data126 PB2.Control12

Pagina 166

248ATmega169V/L2514A–AVR–08/0296 EXTCLK (XTAL1) Clock input and Osillators for the mainclock(Observe-only)95 OSCCK94 RCCK93 OSC32CK92 PD0.Data Port D9

Pagina 167

249ATmega169V/L2514A–AVR–08/0260 PC0.Pullup_Enable Port C59 PC1.Data58 PC1.Control57 PC1.Pullup_Enable56 PC2.Data55 PC2.Control54 PC2.Pullup_Enable53

Pagina 168

25ATmega169V/L2514A–AVR–08/02Crystal Oscillator XTAL1 and XTAL2 are input and output, respectively, of an inverting amplifier which canbe configured f

Pagina 169

250ATmega169V/L2514A–AVR–08/02Boundary-scanDescription LanguageFilesBoundary-scan Description Language (BSDL) files describe Boundary-scan capabledevi

Pagina 170

251ATmega169V/L2514A–AVR–08/02Boot Loader Support– Read-While-WriteSelf-ProgrammingThe Boot Loader Support provides a real Read-While-Write Self-Progr

Pagina 171

252ATmega169V/L2514A–AVR–08/02Note that the user software can never read any code that is located inside the RWWsection during a Boot Loader software

Pagina 172

253ATmega169V/L2514A–AVR–08/02Figure 115. Read-While-Write vs. No Read-While-WriteRead-While-Write(RWW) SectionNo Read-While-Write (NRWW) SectionZ-poi

Pagina 173

254ATmega169V/L2514A–AVR–08/02Figure 116. Memory SectionsNote: 1. The parameters in the figure above are given in Table 113 on page 263.Boot Loader Lo

Pagina 174

255ATmega169V/L2514A–AVR–08/02Note: 1. “1” means unprogrammed, “0” means programmedNote: 1. “1” means unprogrammed, “0” means programmedEntering the B

Pagina 175

256ATmega169V/L2514A–AVR–08/02Store Program MemoryControl and Status Register –SPMCSRThe Store Program Memory Control and Status Register contains the

Pagina 176

257ATmega169V/L2514A–AVR–08/02• Bit 1 – PGERS: Page EraseIf this bit is written to one at the same time as SPMEN, the next SPM instruction withinfour

Pagina 177

258ATmega169V/L2514A–AVR–08/02Figure 117. Addressing the Flash During SPM(1)Note: 1. The different variables used in Figure 117 are listed in Table 11

Pagina 178

259ATmega169V/L2514A–AVR–08/02Performing Page Erase bySPMTo execute Page Erase, set up the address in the Z-pointer, write “X0000011” toSPMCSR and exe

Pagina 179

26ATmega169V/L2514A–AVR–08/02Notes: 1. These options should only be used when not operating close to the maximum fre-quency of the device, and only if

Pagina 180

260ATmega169V/L2514A–AVR–08/02Setting the Boot Loader LockBits by SPMTo set the Boot Loader Lock bits, write the desired data to R0, write “X0001001”

Pagina 181

261ATmega169V/L2514A–AVR–08/02When reading the Extended Fuse byte, load 0x0002 in the Z-pointer. When an LPMinstruction is executed within three cycle

Pagina 182

262ATmega169V/L2514A–AVR–08/02Simple Assembly CodeExample for a Boot Loader;-the routine writes one page of data from RAM to Flash; the first data loc

Pagina 183

263ATmega169V/L2514A–AVR–08/02ret; re-enable the RWW sectionldi spmcrval, (1<<RWWSRE) | (1<<SPMEN)call Do_spmrjmp ReturnDo_spm:; check for

Pagina 184

264ATmega169V/L2514A–AVR–08/02Note: 1. Z15:Z14: always ignoredZ0: should be zero for all SPM commands, byte select for the LPM instruction.See “Addres

Pagina 185

265ATmega169V/L2514A–AVR–08/02MemoryProgrammingProgram And DataMemory Lock BitsThe ATmega169 provides six Lock bits which can be left unprogrammed (“1

Pagina 186

266ATmega169V/L2514A–AVR–08/02Notes: 1. Program the Fuse bits and Boot Lock bits before programming the LB1 and LB2.2. “1” means unprogrammed, “0” mea

Pagina 187

267ATmega169V/L2514A–AVR–08/02Note: 1. The SPIEN Fuse is not accessible in serial programming mode.2. The default value of BOOTSZ1..0 results in maxim

Pagina 188

268ATmega169V/L2514A–AVR–08/02Latching of Fuses The fuse values are latched when the device enters programming mode and changes ofthe fuse values will

Pagina 189

269ATmega169V/L2514A–AVR–08/02Table 121. Pin Name MappingSignal Name inProgramming Mode Pin Name I/O FunctionRDY/BSYPD1 O0: Device is busy programming

Pagina 190

27ATmega169V/L2514A–AVR–08/02Note: 1. These options should only be used if frequency stability at start-up is not important forthe applicationCalibrat

Pagina 191

270ATmega169V/L2514A–AVR–08/02Serial Programming PinMappingTable 124. Command Byte Bit CodingCommand Byte Command Executed1000 0000 Chip Erase0100 000

Pagina 192

271ATmega169V/L2514A–AVR–08/02Parallel ProgrammingEnter Programming Mode The following algorithm puts the device in parallel programming mode:1. Apply

Pagina 193

272ATmega169V/L2514A–AVR–08/021. SetXA1,XA0to“00”. This enables address loading.2. Set BS1 to “0”. This selects low address.3. Set DATA = Address low

Pagina 194

273ATmega169V/L2514A–AVR–08/02Figure 119. Addressing the Flash Which is Organized in Pages(1)Note: 1. PCPAGE and PCWORD are listed in Table 125 on pag

Pagina 195

274ATmega169V/L2514A–AVR–08/02K: Repeat 3 through 5 until the entire buffer is filled.L: Program EEPROM page1. Set BS to “0”.2. Give WRa negative puls

Pagina 196

275ATmega169V/L2514A–AVR–08/02Programming the Fuse LowBitsThe algorithm for programming the Fuse Low bits is as follows (refer to “Programmingthe Flas

Pagina 197

276ATmega169V/L2514A–AVR–08/02Reading the Fuse and LockBitsThe algorithm for reading the Fuse and Lock bits is as follows (refer to “Programmingthe Fl

Pagina 198

277ATmega169V/L2514A–AVR–08/02Parallel ProgrammingCharacteristicsFigure 124. Parallel Programming Timing, Including some General TimingRequirementsFig

Pagina 199

278ATmega169V/L2514A–AVR–08/02Figure 126. Parallel Programming Timing, Reading Sequence (within the Same Page)with Timing Requirements(1)Note: 1. The

Pagina 200

279ATmega169V/L2514A–AVR–08/02Notes: 1. tWLRHis valid for the Write Flash, Write EEPROM, Write Fuse bits and Write Lockbits commands.2. tWLRH_CEis val

Pagina 201

28ATmega169V/L2514A–AVR–08/02Oscillator Calibration Register– OSCCAL• Bits 6..0 – CAL6..0: Oscillator Calibration ValueWriting the calibration byte to

Pagina 202

280ATmega169V/L2514A–AVR–08/02Serial ProgrammingAlgorithmWhen writing serial data to the ATmega169, data is clocked on the rising edge of SCK.When rea

Pagina 203

281ATmega169V/L2514A–AVR–08/02Data Polling EEPROM When a new byte has been written and is being programmed into EEPROM, reading theaddress location be

Pagina 204

282ATmega169V/L2514A–AVR–08/02Note: a = address high bits, b = address low bits, H = 0 - Low byte, 1 - High Byte, o = data out, i = data in, x = don’t

Pagina 205

283ATmega169V/L2514A–AVR–08/02Serial ProgrammingCharacteristicsFigure 129. Serial Programming TimingNote: 1. 2 tCLCLfor fck<12MHz,3tCLCLfor fck>

Pagina 206

284ATmega169V/L2514A–AVR–08/02The Run-Test/Idle state of the TAP controller is used to generate internal clocks. It canalso be used as an idle state b

Pagina 207

285ATmega169V/L2514A–AVR–08/02PROG_COMMANDS (0x5) The AVR specific public JTAG instruction for entering programming commands via theJTAG port. The 15-

Pagina 208

286ATmega169V/L2514A–AVR–08/02Reset Register The Reset Register is a Test Data Register used to reset the part during programming. Itis required to re

Pagina 209

287ATmega169V/L2514A–AVR–08/02Programming CommandRegisterThe Programming Command Register is a 15-bit register. This register is used to seri-ally shi

Pagina 210

288ATmega169V/L2514A–AVR–08/02Table 132. JTAG Programming InstructionSeta = address high bits, b = address low bits, H = 0 - Low byte, 1 - High Byte,

Pagina 211

289ATmega169V/L2514A–AVR–08/025d. Read Data Byte 0110011_bbbbbbbb0110010_000000000110011_00000000xxxxxxx_xxxxxxxxxxxxxxx_xxxxxxxxxxxxxxx_oooooooo6a. E

Pagina 212

29ATmega169V/L2514A–AVR–08/02External Clock To drive the device from an external clock source, XTAL1 should be driven as shown inFigure 13. To run the

Pagina 213

290ATmega169V/L2514A–AVR–08/02Notes: 1. This command sequence is not required if the seven MSB are correctly set by the previous command sequence (whi

Pagina 214

291ATmega169V/L2514A–AVR–08/02Figure 133. State Machine Sequence for Changing/Reading the Data WordFlash Data Byte Register The Flash Data Byte Regist

Pagina 215

292ATmega169V/L2514A–AVR–08/02including the first read byte. This ensures that the first data is captured from the firstaddress set up by PROG_COMMAND

Pagina 216

293ATmega169V/L2514A–AVR–08/02Programming the Flash 1. Enter JTAG instruction PROG_COMMANDS.2. Enable Flash write using programming instruction 2a.3.

Pagina 217

294ATmega169V/L2514A–AVR–08/02gram counter after each word is read. Note that Capture-DR comes before theshift-DR state. Hence, the first byte which i

Pagina 218

295ATmega169V/L2514A–AVR–08/02Reading the Fuses and LockBits1. Enter JTAG instruction PROG_COMMANDS.2. Enable Fuse/Lock bit read using programming ins

Pagina 219

296ATmega169V/L2514A–AVR–08/02Electrical CharacteristicsAbsolute Maximum Ratings*Operating Temperature ... -55°Cto+125°

Pagina 220

297ATmega169V/L2514A–AVR–08/02Note: 1. “Max” means the highest value where the pin is guaranteed to be read as low2. “Min” means the lowest value wher

Pagina 221

298ATmega169V/L2514A–AVR–08/02External Clock DriveWaveformsFigure 135. External Clock Drive WaveformsExternal Clock DriveSPI TimingCharacteristicsSee

Pagina 222

299ATmega169V/L2514A–AVR–08/02Figure 136. SPI Interface Timing Requirements (Master Mode)Figure 137. SPI Interface Timing Requirements (Slave Mode)MOS

Pagina 223

3ATmega169V/L2514A–AVR–08/02OverviewThe ATmega169 is a low-power CMOS 8-bit microcontroller based on the AVR enhanced RISC architecture. By executingp

Pagina 224

30ATmega169V/L2514A–AVR–08/02Timer/Counter Oscillator ATmega169 share the Timer/Counter Oscillator Pins (TOSC1 and TOSC2) with XTAL1and XTAL2. This me

Pagina 225

300ATmega169V/L2514A–AVR–08/02ADC Characteristics – Preliminary DataLCD Controller Characteristics – Preliminary DataTable 135. ADC CharacteristicsSym

Pagina 226

301ATmega169V/L2514A–AVR–08/02ATmega169 TypicalCharacteristics –Preliminary DataThe following charts show typical behavior. These figures are not test

Pagina 227

302ATmega169V/L2514A–AVR–08/02Register SummaryAddress Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Page(0xFF) Reserved – – – – – – – –(0xFE) L

Pagina 228

303ATmega169V/L2514A–AVR–08/02(0xBF) Reserved – – – – – – – –(0xBE) Reserved – – – – – – – –(0xBD) Reserved – – – – – – – –(0xBC) Reserved – – – – – –

Pagina 229

304ATmega169V/L2514A–AVR–08/02(0x7D) Reserved – – – – – – – –(0x7C) ADMUX REFS1 REFS0 ADLAR MUX4 MUX3 MUX2 MUX1 MUX0 204(0x7B) ADCSRB ADHSM ACME ADTS2

Pagina 230

305ATmega169V/L2514A–AVR–08/02Note: 1. For compatibility with future devices, reserved bits should be written to zero if accessed. Reserved I/O memory

Pagina 231

306ATmega169V/L2514A–AVR–08/02Instruction Set SummaryMnemonics Operands Description Operation Flags #ClocksARITHMETIC AND LOGIC INSTRUCTIONSADD Rd, Rr

Pagina 232

307ATmega169V/L2514A–AVR–08/02BRIE k Branch if Interrupt Enabled if ( I = 1) then PC ← PC + k + 1 None 1/2BRID k Branch if Interrupt Disabled if ( I =

Pagina 233

308ATmega169V/L2514A–AVR–08/02POP Rd Pop Register from Stack Rd ← STACK None 2MCU CONTROL INSTRUCTIONSNOP No Operation None 1SLEEP Sleep (see specific

Pagina 234

309ATmega169V/L2514A–AVR–08/02Ordering InformationNote: This device can also be supplied in wafer form. Please contact your local Atmel sales office f

Pagina 235

31ATmega169V/L2514A–AVR–08/02frequency than the maximum frequency of the device at the present operating condi-tions. The device is shipped with the C

Pagina 236

310ATmega169V/L2514A–AVR–08/02Packaging Information64APIN 1 ID0.80(0.0315) BSC16.25(0.640)SQSQ15.75(0.620)0.45(0.018)0.30(0.012)14.10(0.555)13.90(0.54

Pagina 237

iATmega169V/L2514A–AVR–08/02Table of ContentsFeatures...

Pagina 238

iiATmega169V/L2514A–AVR–08/02System Control and Reset... 36Internal Voltage Reference ..

Pagina 239

iiiATmega169V/L2514A–AVR–08/02Modes of Operation ... 128Timer/C

Pagina 240

ivATmega169V/L2514A–AVR–08/02JTAG Interface and On-chip Debug System ... 225Overview...

Pagina 241

vATmega169V/L2514A–AVR–08/02ADC Characteristics – Preliminary Data... 300LCD Controller Charac

Pagina 242

viATmega169V/L2514A–AVR–08/02

Pagina 243

Printed on recycled paper.© Atmel Corporation 2002.Atmel Corporation makes no warranty for the use of its products, other than those expressly contain

Pagina 244

32ATmega169V/L2514A–AVR–08/02Power Managementand Sleep ModesSleep modes enable the application to shut down unused modules in the MCU, therebysaving p

Pagina 245

33ATmega169V/L2514A–AVR–08/02Idle Mode When the SM2..0 bits are written to 000, the SLEEP instruction makes the MCU enterIdle mode, stopping the CPU b

Pagina 246

34ATmega169V/L2514A–AVR–08/02The LCD controller and Timer/Counter2 can be clocked both synchronously and asyn-chronously in Power-save mode. The clock

Pagina 247

35ATmega169V/L2514A–AVR–08/02Brown-out Detector If the Brown-out Detector is not needed by the application, this module should be turnedoff. If the Br

Pagina 248

36ATmega169V/L2514A–AVR–08/02System Control andResetResetting the AVR During reset, all I/O Registers are set to their initial values, and the program

Pagina 249

37ATmega169V/L2514A–AVR–08/02Figure 14. Reset LogicNotes: 1. Values are guidelines only. Actual values are TBD.2. The Power-on Reset will not work unl

Pagina 250

38ATmega169V/L2514A–AVR–08/02Power-on Reset A Power-on Reset (POR) pulse is generated by an On-chip detection circuit. The detec-tion level is defined

Pagina 251

39ATmega169V/L2514A–AVR–08/02External Reset An External Reset is generated by a low level on the RESET pin. Reset pulses longerthan the minimum pulse

Pagina 252

4ATmega169V/L2514A–AVR–08/02The AVR core combines a rich instruction set with 32 general purpose working registers.All the 32 registers are directly c

Pagina 253

40ATmega169V/L2514A–AVR–08/02When the BOD is enabled, and VCCdecreases to a value below the trigger level (VBOT-in Figure 18), the Brown-out Reset is

Pagina 254

41ATmega169V/L2514A–AVR–08/02• Bit 3 – WDRF: Watchdog Reset FlagThis bit is set if a Watchdog Reset occurs. The bit is reset by a Power-on Reset, or b

Pagina 255

42ATmega169V/L2514A–AVR–08/02Watchdog Timer The Watchdog Timer is clocked from a separate On-chip Oscillator which runs at1 MHz. This is the typical v

Pagina 256

43ATmega169V/L2514A–AVR–08/02Watchdog Timer ControlRegister – WDTCR• Bits 7..5 – Res: Reserved BitsThese bits are reserved bits in the ATmega169 and w

Pagina 257

44ATmega169V/L2514A–AVR–08/02The following code example shows one assembly and one C function for turning off theWDT. The example assumes that interru

Pagina 258

45ATmega169V/L2514A–AVR–08/02Interrupts This section describes the specifics of the interrupt handling as performed inATmega169. For a general explana

Pagina 259

46ATmega169V/L2514A–AVR–08/02Table 23 shows reset and Interrupt Vectors placement for the various combinations ofBOOTRST and IVSEL settings. If the pr

Pagina 260

47ATmega169V/L2514A–AVR–08/02When the BOOTRST Fuse is unprogrammed, the Boot section size set to 2K bytes andthe IVSEL bit in the MCUCR Register is se

Pagina 261

48ATmega169V/L2514A–AVR–08/02When the BOOTRST Fuse is programmed, the Boot section size set to 2K bytes and theIVSEL bit in the MCUCR Register is set

Pagina 262

49ATmega169V/L2514A–AVR–08/02• Bit 0 – IVCE: Interrupt Vector Change EnableThe IVCE bit must be written to logic one to enable change of the IVSEL bit

Pagina 263

5ATmega169V/L2514A–AVR–08/02Pin DescriptionsVCC Digital supply voltage.GND Ground.Port A (PA7..PA0) Port A is an 8-bit bi-directional I/O port with in

Pagina 264

50ATmega169V/L2514A–AVR–08/02I/O-PortsIntroduction All AVR ports have true Read-Modify-Write functionality when used as general digitalI/O ports. This

Pagina 265

51ATmega169V/L2514A–AVR–08/02Note that enabling the alternate function of some of the port pins does not affect the useof the other pins in the port a

Pagina 266

52ATmega169V/L2514A–AVR–08/02Toggling the Pin Writing a logic one to PINxn toggles the value of PORTxn, independent on the value ofDDRxn. Note that th

Pagina 267

53ATmega169V/L2514A–AVR–08/02Consider the clock period starting shortly after the first falling edge of the system clock.The latch is closed when the

Pagina 268

54ATmega169V/L2514A–AVR–08/02The 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

Pagina 269

55ATmega169V/L2514A–AVR–08/02Alternate Port Functions Most port pins have alternate functions in addition to being general digital I/Os. Figure25 show

Pagina 270

56ATmega169V/L2514A–AVR–08/02The following subsections shortly describe the alternate functions for each port, andrelate the overriding signals to the

Pagina 271

57ATmega169V/L2514A–AVR–08/02MCU Control Register –MCUCR• Bit 4 – PUD: Pull-up DisableWhen this bit is written to one, the pull-ups in the I/O ports a

Pagina 272

58ATmega169V/L2514A–AVR–08/02Alternate Functions of Port B The Port B pins with alternate functions are shown in Table 29.The alternate pin configurat

Pagina 273

59ATmega169V/L2514A–AVR–08/02• OC1B/PCINT14, Bit 6OC1B, Output Compare Match B output: The PB6 pin can serve as an external outputfor the Timer/Counte

Pagina 274

6ATmega169V/L2514A–AVR–08/02resistors are activated. The Port F pins are tri-stated when a reset condition becomesactive, even if the clock is not run

Pagina 275

60ATmega169V/L2514A–AVR–08/02• SCK/PCINT9 – Port B, Bit 1SCK: Master Clock output, Slave Clock input pin for SPI channel. When the SPI isenabled as a

Pagina 276

61ATmega169V/L2514A–AVR–08/02Alternate Functions of Port C The Port C has an alternate function as the SEG5:12 for the LCD ControllerTable 31. Overrid

Pagina 277

62ATmega169V/L2514A–AVR–08/02Table 33 and Table 34 relate the alternate functions of Port C to the overriding signalsshown in Figure 25 on page 55.Tab

Pagina 278

63ATmega169V/L2514A–AVR–08/02Alternate Functions of Port D The Port D pins with alternate functions are shown in Table 35.The alternate pin configurat

Pagina 279

64ATmega169V/L2514A–AVR–08/02Table 36 and Table 37 relates the alternate functions of Port D to the overriding signalsshown in Figure 25 on page 55.Ta

Pagina 280

65ATmega169V/L2514A–AVR–08/02Alternate Functions of Port E The Port E pins with alternate functions are shown in Table 38.• PCINT7 – Port E, Bit 7PCIN

Pagina 281

66ATmega169V/L2514A–AVR–08/02• XCK/AIN0/PCINT2 – Port E, Bit 2XCK, USART External Clock. The Data Direction Register (DDE2) controls whether theclock

Pagina 282

67ATmega169V/L2514A–AVR–08/02Note: 1. AIN0D and AIN1D is described in “Digital Input Disable Register 0 – DIDR0” on page190.Alternate Functions of Por

Pagina 283

68ATmega169V/L2514A–AVR–08/02• TCK, ADC6 – Port F, Bit 6ADC6, Analog to Digital Converter, Channel 6.TDO, JTAG Test Data Out: Serial output data from

Pagina 284

69ATmega169V/L2514A–AVR–08/02Alternate Functions of Port G The alternate pin configuration is as follows:The alternate pin configuration is as follows

Pagina 285

7ATmega169V/L2514A–AVR–08/02AVR CPU CoreIntroduction This section discusses the AVR core architecture in general. The main function of theCPU core is

Pagina 286

70ATmega169V/L2514A–AVR–08/02• SEG4 – Port G, Bit 2SEG4, LCD front plane 4• SEG13 – Port G, Bit 1SEG13, Segment driver 13• SEG14 – Port G, Bit 0SEG14,

Pagina 287

71ATmega169V/L2514A–AVR–08/02Table 46. Overriding Signals for Alternate Functions in PG3:0SignalName PG3/T1/SEG24 PG2/SEG4 PG1/SEG13 PG0/SEG14PUOE LCD

Pagina 288

72ATmega169V/L2514A–AVR–08/02Register Description forI/O-PortsPort A Data Register – PORTAPort A Data Direction Register– DDRAPort A Input Pins Addres

Pagina 289

73ATmega169V/L2514A–AVR–08/02Port C Input Pins Address –PINCPort D Data Register – PORTDPort D Data Direction Register– DDRDPort D Input Pins Address

Pagina 290

74ATmega169V/L2514A–AVR–08/02Port F Input Pins Address –PINFPort G Data Register – PORTGPort G Data Direction Register– DDRGPort G Input Pins Address

Pagina 291

75ATmega169V/L2514A–AVR–08/02External Interrupts The External Interrupts are triggered by the INT0 pin or any of the PCINT15..0 pins.Observe that, if

Pagina 292

76ATmega169V/L2514A–AVR–08/02External Interrupt MaskRegister – EIMSK• Bit 7 – PCIE1: Pin Change Interrupt Enable 1When the PCIE1 bit is set (one) and

Pagina 293

77ATmega169V/L2514A–AVR–08/02• Bit 0 – INTF0: External Interrupt Flag 0When an edge or logic change on the INT0 pin triggers an interrupt request, INT

Pagina 294

78ATmega169V/L2514A–AVR–08/028-bit Timer/Counter0with PWMTimer/Counter0 is a general purpose, single channel, 8-bit Timer/Counter module. Themain feat

Pagina 295

79ATmega169V/L2514A–AVR–08/02event will also set the Compare Flag (OCF0A) which can be used to generate an OutputCompare interrupt request.Definitions

Pagina 296

8ATmega169V/L2514A–AVR–08/02the operation is executed, and the result is stored back in the Register File – in oneclock cycle.Six of the 32 registers

Pagina 297

80ATmega169V/L2514A–AVR–08/02Depending of the mode of operation used, the counter is cleared, incremented, or dec-remented at each timer clock (clkT0)

Pagina 298

81ATmega169V/L2514A–AVR–08/02The OCR0A Register is double buffered when using any of the Pulse Width Modulation(PWM) modes. For the normal and Clear T

Pagina 299

82ATmega169V/L2514A–AVR–08/02Compare Match OutputUnitThe Compare Output mode (COM0A1:0) bits have two functions. The Waveform Gener-ator uses the COM0

Pagina 300

83ATmega169V/L2514A–AVR–08/02Modes of Operation The mode of operation, i.e., the behavior of the Timer/Counter and the Output Comparepins, is defined

Pagina 301

84ATmega169V/L2514A–AVR–08/02to OCR0A is lower than the current value of TCNT0, the counter will miss the comparematch. The counter will then have to

Pagina 302

85ATmega169V/L2514A–AVR–08/02The Timer/Counter Overflow Flag (TOV0) is set each time the counter reaches MAX. Ifthe interrupt is enabled, the interrup

Pagina 303

86ATmega169V/L2514A–AVR–08/02Figure 32. Phase Correct PWM Mode, Timing DiagramThe Timer/Counter Overflow Flag (TOV0) is set each time the counter reac

Pagina 304

87ATmega169V/L2514A–AVR–08/02Timer/Counter TimingDiagramsThe Timer/Counter is a synchronous design and the timer clock (clkT0)isthereforeshown as a cl

Pagina 305

88ATmega169V/L2514A–AVR–08/02Figure 36 shows the setting of OCF0A and the clearing of TCNT0 in CTC mode.Figure 36. Timer/Counter Timing Diagram, Clear

Pagina 306

89ATmega169V/L2514A–AVR–08/02Note: 1. The CTC0 and PWM0 bit definition names are now obsolete. Use the WGM01:0 def-initions. However, the functionalit

Pagina 307

9ATmega169V/L2514A–AVR–08/02Status Register The Status Register contains information about the result of the most recently executedarithmetic instruct

Pagina 308

90ATmega169V/L2514A–AVR–08/02Table 52 shows the COM0A1:0 bit functionality when the WGM01:0 bits are set tophase correct PWM mode.Note: 1. A special c

Pagina 309

91ATmega169V/L2514A–AVR–08/02Output Compare Register A –OCR0AThe Output Compare Register A contains an 8-bit value that is continuously comparedwith t

Pagina 310

92ATmega169V/L2514A–AVR–08/02Timer/Counter0 andTimer/Counter1PrescalersTimer/Counter1 and Timer/Counter0 share the same prescaler module, but theTimer

Pagina 311

93ATmega169V/L2514A–AVR–08/02the edge detector uses sampling, the maximum frequency of an external clock it candetect is half the sampling frequency (

Pagina 312

94ATmega169V/L2514A–AVR–08/0216-bitTimer/Counter1 The 16-bit Timer/Counter unit allows accurate program execution timing (event man-agement), wave gen

Pagina 313

95ATmega169V/L2514A–AVR–08/02Figure 39. 16-bit Timer/Counter Block Diagram(1)Note: 1. Refer to Figure 1 on page 2, Table 28 on page 58, and Table 34 o

Pagina 314

96ATmega169V/L2514A–AVR–08/02also set the Compare Match Flag (OCF1A/B) which can be used to generate an OutputCompare interrupt request.The Input Capt

Pagina 315

97ATmega169V/L2514A–AVR–08/02Accessing 16-bitRegistersThe TCNT1, OCR1A/B, and ICR1 are 16-bit registers that can be accessed by the AVRCPU via the 8-b

Pagina 316

98ATmega169V/L2514A–AVR–08/02Therefore, when both the main code and the interrupt code update the temporary regis-ter, the main code must disable the

Pagina 317 - 2514A–AVR–08/02 0M

99ATmega169V/L2514A–AVR–08/02The following code examples show how to do an atomic write of the TCNT1 Registercontents. Writing any of the OCR1A/B or I

Commenti su questo manuale

Nessun commento