ATmega165PA Atmel Corporation, ATmega165PA Datasheet

no-image

ATmega165PA

Manufacturer Part Number
ATmega165PA
Description
Manufacturer
Atmel Corporation
Datasheets

Specifications of ATmega165PA

Flash (kbytes)
16 Kbytes
Pin Count
64
Max. Operating Frequency
16 MHz
Cpu
8-bit AVR
# Of Touch Channels
16
Hardware Qtouch Acquisition
No
Max I/o Pins
54
Ext Interrupts
17
Usb Speed
No
Usb Interface
No
Spi
2
Twi (i2c)
1
Uart
1
Graphic Lcd
No
Video Decoder
No
Camera Interface
No
Adc Channels
8
Adc Resolution (bits)
10
Adc Speed (ksps)
15
Analog Comparators
1
Resistive Touch Screen
No
Temp. Sensor
No
Crypto Engine
No
Sram (kbytes)
1
Eeprom (bytes)
512
Self Program Memory
YES
Dram Memory
No
Nand Interface
No
Picopower
Yes
Temp. Range (deg C)
-40 to 85
I/o Supply Class
1.8 to 5.5
Operating Voltage (vcc)
1.8 to 5.5
Fpu
No
Mpu / Mmu
no / no
Timers
3
Output Compare Channels
4
Input Capture Channels
1
Pwm Channels
4
32khz Rtc
Yes
Calibrated Rc Oscillator
Yes

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Part Number:
ATmega165PA-AN
Manufacturer:
Atmel
Quantity:
10 000
Part Number:
ATmega165PA-AUR
Manufacturer:
Atmel
Quantity:
10 000
Features
Note:
High Performance, Low Power Atmel
Advanced RISC Architecture
High Endurance Non-volatile Memory segments
QTouch
JTAG (IEEE std. 1149.1 compliant) Interface
Peripheral Features
Special Microcontroller Features
I/O and Packages
Speed Grade:
Temperature range:
Ultra-Low Power Consumption (picoPower devices)
– 130 Powerful Instructions – Most Single Clock Cycle Execution
– 32 x 8 General Purpose Working Registers
– Fully Static Operation
– Up to 16MIPS Throughput at 16MHz (ATmega165PA/645P)
– Up to 20MIPS Throughput at 20MHz
– On-Chip 2-cycle Multiplier
– In-System Self-programmable Flash Program Memory
– EEPROM
– Internal SRAM
– Write/Erase cycles: 10,000 Flash/100,000 EEPROM
– Data retention: 20 years at 85°C/100 years at 25°C
– Optional Boot Code Section with Independent Lock Bits
– Programming Lock for Software Security
– Capacitive touch buttons, sliders and wheels
– QTouch and QMatrix acquisition
– Up to 64 sense channels
– 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
– 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
– 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
– 54/69 Programmable I/O Lines
– 64/100-lead TQFP, 64-pad QFN/MLF and 64-pad DRQFN
– ATmega 165A/165PA/645A/645P: 0 - 16MHz @ 1.8 - 5.5V
– ATmega325A/325PA/3250A/3250PA/6450A/6450P: 0 - 20MHz @ 1.8 - 5.5V
– -40°C to 85°C Industrial
– Active Mode:
– Power-down Mode: 0.1µA at 1.8V
– Power-save Mode: 0.6µA at 1.8V (Including 32kHz RTC
(ATmega165A/325A/325PA/645A/3250A/3250PA/6450A/6450P)
• 16KBytes (ATmega165A/ATmega165PA)
• 32KBytes (ATmega325A/ATmega325PA/ATmega3250A/ATmega3250PA)
• 64KBytes (ATmega645A/ATmega645P/ATmega6450A/ATmega6450P)
• 512Bytes (ATmega165A/ATmega165PA)
• 1Kbytes (ATmega325A/ATmega325PA/ATmega3250A/ATmega3250PA)
• 2Kbytes (ATmega645A/ATmega645P/ATmega6450A/ATmega6450P)
• 1KBytes (ATmega165A/ATmega165PA)
• 2KBytes (ATmega325A/ATmega325PA/ATmega3250A/ATmega3250PA)
• 4KBytes (ATmega645A/ATmega645P/ATmega6450A/ATmega6450P)
• In-System Programming by On-chip Boot Program
• True Read-While-Write Operation
• 1MHz, 1.8V: 215µA
• 32kHz, 1.8V: 8µA (including Oscillator)
1.
®
library support
Reliability Qualification results show that the projected data retention failure rate is much less than 1 PPM
over 20 years at 85°C or 100 years at 25°C.
®
AVR
®
8-Bit Microcontroller
(1)
8-bit Atmel
Microcontroller
with 16/32/64K
Bytes In-System
Programmable
Flash
ATmega165A
ATmega165PA
ATmega325A
ATmega325PA
ATmega3250A
ATmega3250PA
ATmega645A
ATmega645P
ATmega6450A
ATmega6450P
Rev 8285D–AVR–06/11

Related parts for ATmega165PA

ATmega165PA Summary of contents

Page 1

... Advanced RISC Architecture – 130 Powerful Instructions – Most Single Clock Cycle Execution – General Purpose Working Registers – Fully Static Operation – 16MIPS Throughput at 16MHz (ATmega165PA/645P) – 20MIPS Throughput at 20MHz (ATmega165A/325A/325PA/645A/3250A/3250PA/6450A/6450P) – On-Chip 2-cycle Multiplier • ...

Page 2

... ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 1. Pin Configurations 1.1 Pinout - TQFP and QFN/MLF Figure 1-1. 64A (TQFP)and 64M1 (QFN/MLF) Pinout ATmega165A/ATmega165PA/ATmega325A/ATmega325PA/ATmega645A/ATmega645P DNC 1 (RXD/PCINT0) PE0 2 (TXD/PCINT1) PE1 3 (XCK/AIN0/PCINT2) PE2 4 (AIN1/PCINT3) PE3 5 (USCK/SCL/PCINT4) PE4 6 (DI/SDA/PCINT5) PE5 7 (DO/PCINT6) PE6 8 (CLKO/PCINT7) PE7 9 (SS/PCINT8) PB0 10 (SCK/PCINT9) PB1 11 (MOSI/PCINT10) PB2 ...

Page 3

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 1.2 Pinout - 100A (TQFP) Figure 1-2. Pinout ATmega3250A/ATmega3250PA/ATmega6450A/ATmega6450P 1 DNC 2 (RXD/PCINT0) PE0 3 (TXD/PCINT1) PE1 4 (XCK/AIN0/PCINT2) PE2 (AIN1/PCINT3) PE3 5 6 (USCK/SCL/PCINT4) PE4 7 (DI/SDA/PCINT5) PE5 8 (DO/PCINT6) PE6 9 (CLKO/PCINT7) PE7 VCC 10 11 GND ...

Page 4

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 2. Overview The ATmega165A/165PA/325A/325PA/3250A/3250PA/645A/645P/6450A/6450P is a low-power CMOS 8-bit microcon- troller based on the AVR enhanced RISC architecture. By executing powerful instructions in a single clock cycle, this microcontroller achieves throughputs approaching 1 MIPS per MHz allowing the system ...

Page 5

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P The ATmega165A/165PA/325A/325PA/3250A/3250PA/645A/645P/6450A/6450P provides the following features: 16K/32K/64K bytes of In-System Programmable Flash with Read-While-Write capabilities, 512/1K/2K bytes EEPROM, 1K/2K/4K byte SRAM, 54/69 general purpose I/O lines, 32 general purpose working registers, a JTAG interface for Boundary-scan, On-chip Debugging support ...

Page 6

... ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 2.2 Comparison Between ATmega165A/165PA/325A/325PA/3250A/3250PA/645A/645P/6450A/6450P Table 2-1. Differences between: ATmega165A/165PA/325A/325PA/3250A/3250PA/645A/645P/6450A/6450P Device ATmega165A ATmega165PA ATmega325A ATmega325PA ATmega3250A ATmega3250PA ATmega645A ATmega645P ATmega6450A ATmega6450P 2.3 Pin Descriptions 2.3.1 VCC Digital supply voltage. 2.3.2 GND Ground. 2.3.3 Port A (PA7:PA0) Port 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port A output buffers have symmetrical drive characteristics with both high sink and source capability ...

Page 7

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 2.3.5 Port C (PC7:PC0) Port 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port C output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port ...

Page 8

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Port G also serves the functions of various special features of the ATmega165A/165PA/325A/325PA/3250A/3250PA/645A/645P/6450A/6450P as listed on 84. 2.3.10 Port H (PH7:PH0) Port 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port ...

Page 9

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 3. Resources A comprehensive set of development tools, application notes and datasheets are available for download on http://www.atmel.com/avr. 4. Data Retention Reliability Qualification results show that the projected data retention failure rate is much less than 1 PPM over ...

Page 10

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 7. AVR CPU Core 7.1 Introduction This section discusses the AVR core architecture in general. The main function of the CPU core is to ensure correct program execution. The CPU must therefore be able to access memories, perform calculations, ...

Page 11

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P ical ALU operation, two operands are output from the Register File, the operation is executed, and the result is stored back in the Register File – in one clock cycle. Six of the 32 registers can be used as ...

Page 12

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P The Status Register is not automatically stored when entering an interrupt routine and restored when returning from an interrupt. This must be handled by software. 7.4.1 SREG – AVR Status Register The SREG is defined as: Bit 0x3F (0x5F) ...

Page 13

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 7.5 General Purpose Register File The Register File is optimized for the AVR Enhanced RISC instruction set. In order to achieve the required performance and flexibility, the following input/output schemes are supported by the Register File: • One 8-bit ...

Page 14

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Figure 7-3. X-register Y-register Z-register In the different addressing modes these address registers have functions as fixed displacement, automatic increment, and automatic decrement (see the instruction set reference for details). 7.6 Stack Pointer The Stack is mainly used for ...

Page 15

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 7.6.1 SPH and SPL – Stack Pointer Bit 0x3E (0x5E) 0x3D (0x5D) Read/Write Initial Value 7.7 Instruction Execution Timing This section describes the general access timing concepts for instruction execution. The AVR CPU is driven by the CPU clock ...

Page 16

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 7.8 Reset and Interrupt Handling The AVR provides several different interrupt sources. These interrupts and the separate Reset Vector each have a separate program vector in the program memory space. All interrupts are assigned individual enable bits which must ...

Page 17

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Assembly Code Example in r16, SREG cli sbi EECR, EEMWE sbi EECR, EEWE out SREG, r16 C Code Example char cSREG; cSREG = SREG; /* store SREG value */ /* disable interrupts during timed sequence */ __disable_interrupt(); EECR |= ...

Page 18

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 8. AVR Memories This section describes the different memories in the ATmega165A/165PA/325A/325PA/3250A/3250PA/645A/645P/6450A/6450P. The AVR archi- tecture has two main memory spaces, the Data Memory and the Program Memory space. In addition, the ATmega165A/165PA/325A/325PA/3250A/3250PA/645A/645P/6450A/6450P fea- tures an EEPROM Memory for ...

Page 19

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Figure 8-1. 8.2 SRAM Data Memory Figure 8-2 on page 20 The ATmega165A/165PA/325A/325PA/3250A/3250PA/645A/645P/6450A/6450P is a complex microcontroller with more peripheral units than can be supported within the 64 locations reserved in the Opcode for the IN and OUT instructions. ...

Page 20

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Figure 8-2. 8.2.1 Data Memory Access Times This section describes the general access timing concepts for internal memory access. The internal data SRAM access is performed in two clk 20. Figure 8-3. 8285D–AVR–06/11 Data Memory Data Memory X 8 ...

Page 21

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 8.3 EEPROM Data Memory The ATmega165A/165PA/325A/325PA/3250A/3250PA/645A/645P/6450A/6450P contains 512 bytes of data EEPROM memory organized as a separate data space, in which single bytes can be read and written. The EEPROM has an endurance of at least 100,000 ...

Page 22

... Flash Boot Loader is present in the software. If such code is present, the EEPROM write function must also wait for any ongoing SPM command to finish. 8285D–AVR–06/11 EEPROM Programming Time Number of Calibrated RC Oscillator Cycles 1. 3.3 applies to ATmega165A/ATmega165PA Table 8-1 lists the typical pro- Typical Programming Time 27 072 3.3/3.4ms ...

Page 23

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Assembly Code Example EEPROM_write: C Code Example void EEPROM_write(unsigned int uiAddress, unsigned char ucData The next code examples show assembly and C functions for reading the EEPROM. The exam- ples assume that interrupts are controlled so that ...

Page 24

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Assembly Code Example EEPROM_read: C Code Example unsigned char EEPROM_read(unsigned int uiAddress 8.3.2 EEPROM Write During Power-down Sleep Mode When entering Power-down sleep mode while an EEPROM write operation is active, the EEPROM write operation will continue, ...

Page 25

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P be used reset occurs while a write operation is in progress, the write operation will be com- pleted provided that the power supply voltage is sufficient. 8.4 I/O Memory The I/O space definition is shown in All ...

Page 26

... ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 8.6 Register Description 8.6.1 EEARH and EEARL – EEPROM Address Register ATmega165A/ATmega165PA Bit 0x22 (0x42) 0x21 (0x41) Read/Write Initial Value • Bits 15:9 – Reserved These bits are reserved and will always read as zero. • Bits 8:0 – EEAR8:0: EEPROM Address The EEPROM Address Registers – ...

Page 27

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P • Bits 7:0 – EEDR7:0: EEPROM Data For the EEPROM write operation, the EEDR Register contains the data to be written to the EEPROM in the address given by the EEAR Register. For the EEPROM read operation, the EEDR ...

Page 28

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 8.6.7 GPIOR0 – General Purpose I/O Register 0 Bit 0x1E (0x3E) Read/Write Initial Value 8285D–AVR–06/ MSB R/W R/W R/W R LSB R/W R/W R/W R ...

Page 29

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 9. System Clock and Clock Options 9.1 Clock Systems and their Distribution Figure 9-1 on page 29 of the clocks need not be active at a given time. In order to reduce power consumption, the clocks to modules not ...

Page 30

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 9.1.4 Asynchronous Timer Clock – clk The Asynchronous Timer clock allows the Asynchronous Timer/Counter to be clocked directly from an external clock or an external 32kHz clock crystal. The dedicated clock domain allows using this Timer/Counter as a real-time ...

Page 31

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 9.3 Default Clock Source The device is shipped with CKSEL = “0010”, SUT = “10”, and CKDIV8 programmed. The default clock source setting is the Internal RC Oscillator with longest start-up time and an initial system clock prescaling of ...

Page 32

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 9.5 Crystal Oscillator XTAL1 and XTAL2 are input and output, respectively inverting amplifier which can be con- figured for use as an On-chip Oscillator, as shown in ceramic resonator may be used. C1 and C2 should always ...

Page 33

... These options are intended for use with ceramic resonators and will ensure frequency stability at start-up. They can also be used with crystals when not operating close to the maximum fre- quency of the device, and if frequency stability at start-up is not important for the application. Maximum ESR Recommendation for 32.768kHz Watch Crystal ATmega165A/ATmega165PA Crystal CL (pF) 6 ...

Page 34

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Table 9-8. Note: Table 9-9. Capacitance for Low-Frequency Crystal Oscillator Device ATmega165A/PA/325A/PA/3250A/PA/645 A/P/6450A/P The capacitance (Ce + Ci) needed at each TOSC pin can be calculated by using: where optional external capacitors as described in Ci ...

Page 35

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 9.7 External Clock To drive the device from an external clock source, XTAL1 should be driven as shown in 9-3. To run the device on an external clock, the CKSEL Fuses must be programmed to “0000”. Figure 9-3. When ...

Page 36

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 9.8 Timer/Counter Oscillator ATmega169P uses the same crystal oscillator for Low-frequency Oscillator and Timer/Counter Oscillator. See crystal requirements. ATmega169P share the Timer/Counter Oscillator Pins (TOSC1 and TOSC2) with XTAL1 and XTAL2. When using the Timer/Counter Oscillator, the system clock ...

Page 37

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 9.11 Register Description 9.11.1 OSCCAL – Oscillator Calibration Register Bit (0x66) Read/Write Initial Value • Bits 7:0 – CAL7:0: Oscillator Calibration Value The Oscillator Calibration Register is used to trim the Calibrated Internal RC Oscillator to remove process variations ...

Page 38

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P To avoid unintentional changes of clock frequency, a special write procedure must be followed to change the CLKPS bits: 1. Write the Clock Prescaler Change Enable (CLKPCE) bit to one and all other bits in CLKPR to zero. 2. ...

Page 39

... To save power possible to disable the BOD by software for some of the sleep- modes, see same level as when BOD is globally disabled by fuses. If BOD is disabled in software, the BOD 8285D–AVR–06/11 presents the different clock systems in the 1. BOD disable is only available for ATmega165PA/325PA/3250PA/645P/6450P Oscillators ( ...

Page 40

... MCU. Refer to for details. 8285D–AVR–06/11 61. Writing this bit to one turns off the BOD in relevant sleep 61. 1. BOD disable only available in picoPower devices ATmega165PA/325PA/3250PA/645P/6450P. , while allowing the other clocks to run. FLASH , clk I/O ...

Page 41

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P When waking up from Power-down mode, there is a delay from the wake-up condition occurs until the wake-up becomes effective. This allows the clock to restart and become stable after having been stopped. The wake-up period is defined by ...

Page 42

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P conversion will be an extended conversion. Refer to 214 for details on ADC operation. 10.10.2 Analog Comparator When entering Idle mode, the Analog Comparator should be disabled if not used. When entering ADC Noise Reduction mode, the Analog Comparator ...

Page 43

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 10.10.7 JTAG Interface and On-chip Debug System If the On-chip debug system is enabled by the OCDEN Fuse and the chip enter Power down or Power save sleep mode, the main clock source remains enabled. In these sleep modes, ...

Page 44

... Standby mode is only recommended for use with external crystals or resonators (1) (1) JTD BODS BODSE R/W R/W R Only available in the picoPower devices ATmega165PA/325PA/3250PA/645P/6450P. 39. Writing to the BODS bit is controlled by a timed sequence and an enable bit – SM2 SM1 SM0 R R/W R/W R ...

Page 45

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P The BODS bit is active three clock cycles after it is set. A sleep instruction must be executed while BODS is active in order to turn off the BOD for the actual sleep mode. The BODS bit is automatically ...

Page 46

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 11. System Control and Reset 11.1 Resetting the AVR During reset, all I/O Registers are set to their initial values, and the program starts execution from the Reset Vector. The instruction placed at the Reset Vector must be a ...

Page 47

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Figure 11-1. Reset Logic BODLEVEL [2..0] 11.2.1 Power-on Reset A Power-on Reset (POR) pulse is generated by an On-chip detection circuit. The detection level is defined below the detection level. The POR circuit can be used ...

Page 48

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Figure 11-3. MCU Start-up, RESET Extended Externally TIME-OUT INTERNAL 11.2.2 External Reset An External Reset is generated by a low level on the RESET pin. Reset pulses longer than the minimum pulse width (see reset, even if the clock ...

Page 49

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 11.2.3 Brown-out Detection ATmega165A/165PA/325A/325PA/3250A/3250PA/645A/645P/6450A/6450P has an On-chip Brown-out Detection (BOD) circuit for monitoring the fixed trigger level. The trigger level for the BOD can be selected by the BODLEVEL Fuses. The trigger level has a hysteresis ...

Page 50

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 11.3 Internal Voltage Reference ATmega165A/165PA/325A/325PA/3250A/3250PA/645A/645P/6450A/6450P features an inter- nal bandgap reference. This reference is used for Brown-out Detection, and it can be used as an input to the Analog Comparator or the ADC. 11.3.1 Voltage Reference Enable Signals and ...

Page 51

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Figure 11-7. Watchdog Timer 11.4.1 Timed Sequences for Changing the Configuration of the Watchdog Timer The sequence for changing configuration differs slightly between the two safety levels. Separate procedures are described for each level. 11.4.1.1 Safety Level 1 In ...

Page 52

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Assembly Code Example WDT_off: C Code Example void WDT_off(void Note: 8285D–AVR–06/11 (1) ; Reset WDT wdr ; Write logical one to WDCE and WDE in r16, WDTCR ori r16, (1<<WDCE)|(1<<WDE) out WDTCR, r16 ; Turn off WDT ...

Page 53

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 11.5 Register Description 11.5.1 MCUSR – MCU Status Register The MCU Status Register provides information on which reset source caused an MCU reset. Bit 0x35 (0x55) Read/Write Initial Value • Bit 4 – JTRF: JTAG Reset Flag This bit ...

Page 54

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P • Bit 3 – WDE: Watchdog Enable When the WDE is written to logic one, the Watchdog Timer is enabled, and if the WDE is written to logic zero, the Watchdog Timer function is disabled. WDE can only be ...

Page 55

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 12. Interrupts ...

Page 56

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Table 12-2 on page 56 tions of BOOTRST and IVSEL settings. If the program never enables an interrupt source, the Interrupt Vectors are not used, and regular program code can be placed at these locations. This is also the ...

Page 57

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 0x0031 0x0032 0x0033 ... When the BOOTRST Fuse is unprogrammed, the Boot section size set to 2K bytes and the IVSEL bit in the MCUCR Register is set before any interrupts are enabled, the most typical and general program ...

Page 58

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P ; 0x1C2E 0x1C2F 0x1C30 0x1C31 0x1C32 0x1C33 The most typical and general program setup for the Reset and Interrupt Vector Addresses in ATmega325A/325PA/3250A/3250PA/625A/645P/6450A/6450P is: Address 0x0000 0x0002 0x0004 0x0006 0x0008 0x000A 0x000C 0x000E 0x0010 0x0012 0x0014 0x0016 0X0018 0x001A ...

Page 59

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Address Labels Code 0x0000 0x0001 0x0002 0x0003 0x0004 0x0005 ; .org 0x3802/0x7802 0x3804/0x7804 0x3806/0x7806 ... 0x1C2C When the BOOTRST Fuse is programmed and the Boot section size set to 4K bytes, the most typical and general program setup for ...

Page 60

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 12.2 Moving Interrupts Between Application and Boot Space The General Interrupt Control Register controls the placement of the Interrupt Vector table, see ”MCUCR – MCU Control Register” on page To avoid unintentional changes of Interrupt Vector tables, a special ...

Page 61

... IVSEL is written. Setting the IVCE bit will disable interrupts, as explained in the description in Space” on page 8285D–AVR–06/ (1) (1) JTD BODS BODSE R Only available in the picoPower devices ATmega165PA/325PA/3250PA/645P/6450P. for details. 60. See Code Example PUD – – IVSEL R R ” ...

Page 62

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 13. External Interrupts The External Interrupts are triggered by the INT0 pin or any of the PCINT30:0 pins that, if enabled, the interrupts will trigger even if the INT0 or PCINT30:0 pins are configured as outputs. This feature provides ...

Page 63

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Figure 13-1. Pin Change Interrupt 8285D–AVR–06/11 pin_lat PCINT( pin_sync LE clk PCINT(0) in PCMSK(x) clk PCINT(n) pin_lat pin_sync pcint_in_(n) pcint_syn pcint_setflag PCIF pcint_in_(0) 0 pcint_syn pcint_setflag x clk PCIF 63 ...

Page 64

... The rising edge of INT0 generates an interrupt request (1) (1) PCIE3 PCIE2 PCIE1 This bit is a reserved bit in ATmega165A/ATmega165PA/ATmega325A/ATmega325PA/ATmega645A/ATmega645P and should always be written to zero. 1. This bit is a reserved bit in ATmega165A/ATmega165PA/ATmega325A/ATmega325PA/ATmega645A/ATmega645P and should always be written to zero – – – ISC01 R ...

Page 65

... PCIF3 PCIF2 PCIF1 R/W R/W R This bit is a reserved bit in ATmega165A/ATmega165PA/ATmega325A/ATmega325PA/ATmega645A/ATmega645P and should always be written to zero. 1. This bit is a reserved bit in ATmega165A/ATmega165PA/ATmega325A/ATmega325PA/ATmega645A/ATmega645P and should always be written to zero PCIF0 – – – R ...

Page 66

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P • Bit 4 – PCIF0: Pin Change Interrupt Flag 0 When a logic change on any PCINT7:0 pin triggers an interrupt request, PCIF0 becomes set (one). If the I-bit in SREG and the PCIE0 bit in EIMSK are set ...

Page 67

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 13.2.7 PCMSK0 – Pin Change Mask Register 0 Bit (0x6B) Read/Write Initial Value • Bit 7:0 – PCINT7:0: Pin Change Enable Mask 7:0 Each PCINT7:0 bit selects whether pin change interrupt is enabled on the corresponding I/O pin. If ...

Page 68

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 14. I/O-Ports 14.1 Overview All AVR ports have true Read-Modify-Write functionality when used as general digital I/O ports. This means that the direction of one port pin can be changed without unintentionally changing the direction of any other pin ...

Page 69

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 14.2 Ports as General Digital I/O The ports are bi-directional I/O ports with optional internal pull-ups. tional description of one I/O-port pin, here generically called Pxn. Figure 14-2. General Digital I/O Note: 14.2.1 Configuring the Pin Each port pin ...

Page 70

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 14.2.2 Toggling the Pin Writing a logic one to PINxn toggles the value of PORTxn, independent on the value of DDRxn. Note that the SBI instruction can be used to toggle one single bit in a port. 14.2.3 Switching ...

Page 71

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Figure 14-3. Synchronization when Reading an Externally Applied Pin value INSTRUCTIONS Consider the clock period starting shortly after the first falling edge of the system clock. The latch is closed when the clock is low, and goes transparent when ...

Page 72

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P values are read back again, but as previously discussed, a nop instruction is included to be able to read back the value recently assigned to some of the pins. Assembly Code Example C Code Example unsigned char i; Note: ...

Page 73

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 14.2.6 Unconnected Pins If some pins are unused recommended to ensure that these pins have a defined level. Even though most of the digital inputs are disabled in the deep sleep modes as described above, float- ing ...

Page 74

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 14.3 Alternate Port Functions Most port pins have alternate functions in addition to being general digital I/Os. shows how the port pin control signals from the simplified alternate functions. The overriding signals may not be present in all port ...

Page 75

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Table 14-2. Signal Name PUOE PUOV DDOE DDOV PVOE PVOV PTOE DIEOE DIEOV DI AIO The following subsections shortly describe the alternate functions for each port, and relate the overriding signals to the alternate function. Refer to the alternate ...

Page 76

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 14.3.1 Alternate Functions of Port B The Port B pins with alternate functions are shown in Table 14-3. Port Pin PB7 PB6 PB5 PB4 PB3 PB2 PB1 PB0 The alternate pin configuration is as follows: • OC2A/PCINT15, Bit 7 ...

Page 77

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P • MISO/PCINT11 – Port B, Bit 3 MISO: Master Data input, Slave Data output pin for SPI. When the SPI is enabled as a Master, this pin is configured as an input regardless of the setting of DDB3. When ...

Page 78

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Table 14-4. Signal Name PUOE PUOV DDOE DDOV PVOE PVOV PTOE DIEOE DIEOV DI AIO Table 14-5. Signal Name PUOE PUOV DDOE DDOV PVOE PVOV PTOE DIEOE DIEOV DI AIO 8285D–AVR–06/11 Overriding Signals for Alternate Functions in PB7:PB4 PB7/OC2A/ ...

Page 79

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 14.3.2 Alternate Functions of Port D The Port D pins with alternate functions are shown in Table 14-6. Port Pin PD7 PD6 PD5 PD4 PD3 PD2 PD1 PD0 The alternate pin configuration is as follows: • INT0 – Port ...

Page 80

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 14.3.3 Alternate Functions of Port E The Port E pins with alternate functions are shown in Table 14-8. Port Pin PE7 PE6 PE5 PE4 PE3 PE2 PE1 PE0 • PCINT7 – Port E, Bit 7 PCINT7, Pin Change Interrupt ...

Page 81

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P • XCK/AIN0/PCINT2 – Port E, Bit 2 XCK, USART External Clock. The Data Direction Register (DDE2) controls whether the clock is output (DDE2 set) or input (DDE2 cleared). The XCK pin is active only when the USART oper- ates ...

Page 82

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Table 14-10. Overriding Signals for Alternate Functions in PE3:PE0 Signal Name PUOE PUOV DDOE DDOV PVOE PVOV PTOE DIEOE DIEOV DI AIO Note: 14.3.4 Alternate Functions of Port F The Port F has an alternate function as analog input ...

Page 83

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P • TDO, ADC6 – Port F, Bit 6 ADC6, Analog to Digital Converter, Channel 6 TDO, JTAG Test Data Out: Serial output data from Instruction Register or Data Register. When the JTAG interface is enabled, this pin can not ...

Page 84

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Table 14-13. Overriding Signals for Alternate Functions in PF3:PF0 Signal Name PUOE PUOV DDOE DDOV PVOE PVOV PTOE DIEOE DIEOV DI AIO 14.3.5 Alternate Functions of Port G The alternate pin configuration is as follows: Table 14-14. Port G ...

Page 85

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Table 14-14 shown in Table 14-15. Overriding Signals for Alternate Functions in PG4:PG3 Signal Name PUOE PUOV DDOE DDOV PVOE PVOV PTOE DIEOE DIEOV DI AIO 14.3.6 Alternate Functions of Port H Port H is only present in ATmega3250A/3250PA/6450A/6450P. ...

Page 86

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P • PCINT21 – Port H, Bit 5 PCINT21, Pin Change Interrupt Source 21: The PH5 pin can serve as an external interrupt source. • PCINT20 – Port H, Bit 4 PCINT20, Pin Change Interrupt Source 20: The PH4 pin ...

Page 87

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Table 14-18. Overriding Signals for Alternate Functions in PH3:PH0 Signal Name PUOE PUOV DDOE DDOV PVOE PVOV PTOE DIEOE DIEOV DI AIO 14.3.7 Alternate Functions of Port J Port J is only present in ATmega3250A/3250PA/6450A/6450P. The alternate pin configuration ...

Page 88

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P • PCINT27 – Port J, Bit 3 PCINT27, Pin Change Interrupt Source 27: The PE27 pin can serve as an external interrupt source. • PCINT26 – Port J, Bit 2 PCINT26, Pin Change Interrupt Source 26: The PE26 pin ...

Page 89

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Table 14-21. Overriding Signals for Alternate Functions in PJ3:PJ0 Signal Name PUOE PUOV DDOE DDOV PVOE PVOV PTOE DIEOE DIEOV DI AIO 8285D–AVR–06/11 PJ3/PCINT27 PJ2/PCINT26 – – ...

Page 90

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 14.4 Register Description 14.4.1 MCUCR – MCU Control Register Bit 0x35 (0x55) Read/Write Initial Value • Bit 4 – PUD: Pull-up Disable When this bit is written to one, the pull-ups in the I/O ports are disabled even if ...

Page 91

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 14.4.8 PORTC – Port C Data Register Bit 0x08 (0x28) Read/Write Initial Value 14.4.9 DDRC – Port C Data Direction Register Bit 0x07 (0x27) Read/Write Initial Value 14.4.10 PINC – Port C Input Pins Address Bit 0x06 (0x26) Read/Write ...

Page 92

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 14.4.16 PINE – Port E Input Pins Address Bit 0x0C (0x2C) Read/Write Initial Value 14.4.17 PORTF – Port F Data Register Bit 0x11 (0x31) Read/Write Initial Value 14.4.18 DDRF – Port F Data Direction Register Bit 0x10 (0x30) Read/Write ...

Page 93

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 14.4.24 DDRH – Port H Data Direction Register Bit (0xD9) Read/Write Initial Value 14.4.25 PINH – Port H Input Pins Address Bit (0xD8) Read/Write Initial Value 14.4.26 PORTJ – Port J Data Register Bit (0xDD) Read/Write Initial Value 14.4.27 ...

Page 94

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 15. 8-bit Timer/Counter0 with PWM 15.1 Features • Single Compare Unit Counter • Clear Timer on Compare Match (Auto Reload) • Glitch-free, Phase Correct Pulse Width Modulator (PWM) • Frequency Generator • External Event Counter • 10-bit Clock Prescaler ...

Page 95

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P The definitions in Table 15-1. BOTTOM MAX TOP 15.2.2 Registers The Timer/Counter (TCNT0) and Output Compare Register (OCR0A) are 8-bit registers. Inter- rupt request (abbreviated to Int.Req. in the figure) signals are all visible in the Timer Interrupt Flag ...

Page 96

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Signal description (internal signals): count direction clear clk top bottom Depending of the mode of operation used, the counter is cleared, incremented, or decremented at each timer clock (clk selected by the Clock Select bits (CS02:0). When no clock ...

Page 97

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Figure 15-3. Output Compare Unit, Block Diagram The OCR0A Register is double buffered when using any of the Pulse Width Modulation (PWM) modes. For the normal and Clear Timer on Compare (CTC) modes of operation, the double buff- ering ...

Page 98

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P The setup of the OC0A should be performed before setting the Data Direction Register for the port pin to output. The easiest way of setting the OC0A value is to use the Force Output Com- pare (FOC0A) strobe bits ...

Page 99

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P A change of the COM0A1:0 bits state will have effect at the first compare match after the bits are written. For non-PWM modes, the action can be forced to have immediate effect by using the FOC0A strobe bits. 15.7 ...

Page 100

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Figure 15-5. CTC Mode, Timing Diagram TCNTn OCn (Toggle) Period An interrupt can be generated each time the counter value reaches the TOP value by using the OCF0A Flag. If the interrupt is enabled, the interrupt handler routine can ...

Page 101

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Figure 15-6. Fast PWM Mode, Timing Diagram TCNTn OCn OCn Period The Timer/Counter Overflow Flag (TOV0) is set each time the counter reaches MAX. If the inter- rupt is enabled, the interrupt handler routine can be used for updating ...

Page 102

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P has lower maximum operation frequency than single slope operation. However, due to the sym- metric feature of the dual-slope PWM modes, these modes are preferred for motor control applications. The PWM resolution for the phase correct PWM mode is ...

Page 103

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P output will be continuously low and if set equal to MAX the output will be continuously high for non-inverted PWM mode. For inverted PWM the output will have the opposite logic values. At the very start of period 2 ...

Page 104

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Figure 15-10. Timer/Counter Timing Diagram, Setting of OCF0A, with Prescaler (f clk clk (clk TCNTn OCRnx OCFnx Figure 15-11 Figure 15-11. Timer/Counter Timing Diagram, Clear Timer on Compare Match mode, with Pres- clk clk (clk TCNTn (CTC) OCRnx OCFnx ...

Page 105

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 15.9 Register Description 15.9.1 TCCR0A – Timer/Counter Control Register A Bit 0x24 (0x44) Read/Write Initial Value • Bit 7 – FOC0A: Force Output Compare A The FOC0A bit is only active when the WGM00 bit specifies a non-PWM mode. ...

Page 106

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P When OC0A is connected to the pin, the function of the COM0A1:0 bits depends on the WGM01:0 bit setting. are set to a normal or CTC mode (non-PWM). Table 15-3. COM0A1 Table 15-4 mode. Table ...

Page 107

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Table 15-6. CS02 external pin modes are used for the Timer/Counter0, transitions on the T0 pin will clock the counter even if the pin is configured as an output. This ...

Page 108

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A compare match in Timer/Counter0 occurs, i.e., when the OCF0A bit is set in the Timer/Coun- ter 0 Interrupt Flag Register – TIFR0. • Bit 0 – TOIE0: Timer/Counter0 Overflow Interrupt Enable When the TOIE0 bit is written ...

Page 109

... Timer/Counter1 counter value and so on. A simplified block diagram of the 16-bit Timer/Counter is shown ATmega165A/ATmega165PA/ATmega325A/ATmega325PA/ATmega645A/ATmega645P” on page 2. CPU accessible I/O Registers, including I/O bits and I/O pins, are shown in bold. The device-specific I/O Register and bit locations are listed in the 130 ...

Page 110

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Figure 16-1. 16-bit Timer/Counter Block Diagram Note: 16.2.1 Registers The Timer/Counter (TCNT1), Output Compare Registers (OCR1A/B), and Input Capture Regis- ter (ICR1) are all 16-bit registers. Special procedures must be followed when accessing the 16- bit registers. These procedures ...

Page 111

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P The Input Capture Register can capture the Timer/Counter value at a given external (edge trig- gered) event on either the Input Capture pin (ICP1 the Analog Comparator pins - Analog Comparator” on page Canceler) for reducing the ...

Page 112

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 16-bit register is written by the CPU, the high byte stored in the temporary register, and the low byte written are both copied into the 16-bit register in the same clock cycle. When the low byte of a 16-bit ...

Page 113

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Assembly Code Example TIM16_ReadTCNT1: C Code Example unsigned int TIM16_ReadTCNT1( void ) { } Note: The assembly code example returns the TCNT1 value in the r17:r16 register pair. The following code examples show how atomic write ...

Page 114

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Assembly Code Example TIM16_WriteTCNT1: C Code Example void TIM16_WriteTCNT1( unsigned int Note: The assembly code example requires that the r17:r16 register pair contains the value to be writ- ten to TCNT1. 16.3.1 Reusing the Temporary ...

Page 115

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 16.5 Counter Unit The main part of the 16-bit Timer/Counter is the programmable 16-bit bi-directional counter unit. Figure 16-2 Figure 16-2. Counter Unit Block Diagram Signal description (internal signals): Count Direction Clear clk TOP BOTTOM The 16-bit counter is ...

Page 116

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 16.6 Input Capture Unit The Timer/Counter incorporates an Input Capture unit that can capture external events and give them a time-stamp indicating time of occurrence. The external signal indicating an event, or mul- tiple events, can be applied via ...

Page 117

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P For more information on how to access the 16-bit registers refer to on page 16.6.1 Input Capture Trigger Source The main trigger source for the Input Capture unit is the Input Capture pin (ICP1). Timer/Counter1 can alternatively use the ...

Page 118

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 16.7 Output Compare Units The 16-bit comparator continuously compares TCNT1 with the Output Compare Register (OCR1x). If TCNT equals OCR1x the comparator signals a match. A match will set the Output Compare Flag (OCF1x) at the next timer clock ...

Page 119

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P abled the CPU will access the OCR1x directly. The content of the OCR1x (Buffer or Compare) Register is only changed by a write operation (the Timer/Counter does not update this register automatically as the TCNT1 and ICR1 Register). Therefore ...

Page 120

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Figure 16-5. Compare Match Output Unit, Schematic COMnx1 COMnx0 FOCnx clk The general I/O port function is overridden by the Output Compare (OC1x) from the Waveform Generator if either of the COM1x1:0 bits are set. However, the OC1x pin ...

Page 121

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 16.9 Modes of Operation The mode of operation, i.e., the behavior of the Timer/Counter and the Output Compare pins, is defined by the combination of the Waveform Generation mode (WGM13:0) and Compare Output mode (COM1x1:0) bits. The Compare Output ...

Page 122

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Figure 16-6. CTC Mode, Timing Diagram TCNTn OCnA (Toggle) Period An interrupt can be generated at each time the counter value reaches the TOP value by either using the OCF1A or ICF1 Flag according to the register used to ...

Page 123

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P imum resolution is 16-bit (ICR1 or OCR1A set to MAX). The PWM resolution in bits can be calculated by using the following equation: In fast PWM mode the counter is incremented until the counter value matches either one of ...

Page 124

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Using the ICR1 Register for defining TOP works well when using fixed TOP values. By using ICR1, the OCR1A Register is free to be used for generating a PWM output on OC1A. However, if the base PWM frequency is ...

Page 125

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P TOP and changes the count direction. The TCNT1 value will be equal to TOP for one timer clock cycle. The timing diagram for the phase correct PWM mode is shown on shows phase correct PWM mode when OCR1A or ...

Page 126

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P The actual OC1x value will only be visible on the port pin if the data direction for the port pin is set as output (DDR_OC1x). The PWM waveform is generated by setting (or clearing) the OC1x Register at the ...

Page 127

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Figure 16-9. Phase and Frequency Correct PWM Mode, Timing Diagram TCNTn OCnx OCnx Period The Timer/Counter Overflow Flag (TOV1) is set at the same timer clock cycle as the OCR1x Registers are updated with the double buffer value (at ...

Page 128

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P The extreme values for the OCR1x Register represents special cases when generating a PWM waveform output in the phase and frequency correct PWM mode. If the OCR1x is set equal to BOTTOM the output will be continuously low and ...

Page 129

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Figure 16-12. Timer/Counter Timing Diagram, no Prescaling (PC and PFC PWM) Figure 16-13 Figure 16-13. Timer/Counter Timing Diagram, with Prescaler (f and ICF n 8285D–AVR–06/11 clk I/O clk Tn (clk /1) I/O TCNTn TOP - 1 (CTC and FPWM) ...

Page 130

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 16.11 Register Description 16.11.1 TCCR1A – Timer/Counter1 Control Register A Bit (0x80) Read/Write Initial Value • Bit 7:6 – COM1A[1:0]: Compare Output Mode for Unit A • Bit 5:4 – COM1B[1:0]: Compare Output Mode for Unit B The COM1A[1:0] ...

Page 131

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Table 16-4 correct or the phase and frequency correct, PWM mode. Table 16-4. COM1A1/COM1B1 Note: • Bit 1:0 – WGM1[1:0]: Waveform Generation Mode Combined with the WGM1[3:2] bits found in the TCCR1B Register, these bits control the count- ing ...

Page 132

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Table 16-5. Waveform Generation Mode Bit Description WGM12 WGM11 Mode WGM13 (CTC1) (PWM11 ...

Page 133

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P When the ICR1 is used as TOP value (see description of the WGM1[3:0] bits located in the TCCR1A and the TCCR1B Register), the ICP1 is disconnected and consequently the Input Cap- ture function is disabled. • Bit 5 – ...

Page 134

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P A FOC1A/FOC1B strobe will not generate any interrupt nor will it clear the timer in Clear Timer on Compare match (CTC) mode using OCR1A as TOP. The FOC1A/FOC1B bits are always read as zero. 16.11.4 TCNT1H and TCNT1L – ...

Page 135

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 16.11.7 ICR1H and ICR1L – Input Capture Register 1 Bit (0x87) (0x86) Read/Write Initial Value The Input Capture is updated with the counter (TCNT1) value each time an event occurs on the ICP1 pin (or optionally on the Analog ...

Page 136

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 16.11.9 TIFR1 – Timer/Counter1 Interrupt Flag Register Bit 0x16 (0x36) Read/Write Initial Value • Bit 5 – ICF1: Timer/Counter1, Input Capture Flag This flag is set when a capture event occurs on the ICP1 pin. When the Input Capture ...

Page 137

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 17. Timer/Counter0 and Timer/Counter1 Prescalers Timer/Counter1 and Timer/Counter0 share the same prescaler module, but the Timer/Counters can have different prescaler settings. The description below applies to both Timer/Counter1 and Timer/Counter0. 17.1 Prescaler Reset The prescaler is free running, i.e., ...

Page 138

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Each half period of the external clock applied must be longer than one system clock cycle to ensure correct sampling. The external clock must be guaranteed to have less than half the sys- tem clock frequency (f sampling, the ...

Page 139

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 17.4 Register Description 17.4.1 GTCCR – General Timer/Counter Control Register Bit 0x23 (0x43) Read/Write Initial Value • Bit 7 – TSM: Timer/Counter Synchronization Mode Writing the TSM bit to one activates the Timer/Counter Synchronization mode. In this mode, the ...

Page 140

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 18. 8-bit Timer/Counter2 with PWM and Asynchronous Operation 18.1 Features • Single Compare Unit Counter • Clear Timer on Compare Match (Auto Reload) • Glitch-free, Phase Correct Pulse Width Modulator (PWM) • Frequency Generator • 10-bit Clock Prescaler • ...

Page 141

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P The Timer/Counter can be clocked internally, via the prescaler, or asynchronously clocked from the TOSC1/2 pins, as detailed later in this section. The asynchronous operation is controlled by the Asynchronous Status Register (ASSR). The Clock Select logic block controls ...

Page 142

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Signal description (internal signals): count direction clear clk top bottom Depending on the mode of operation used, the counter is cleared, incremented, or decremented at each timer clock (clk selected by the Clock Select bits (CS2[2:0]). When no clock ...

Page 143

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Figure 18-3. Output Compare Unit, Block Diagram The OCR2A Register is double buffered when using any of the Pulse Width Modulation (PWM) modes. For the Normal and Clear Timer on Compare (CTC) modes of operation, the double buffering is ...

Page 144

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P The setup of the OC2A should be performed before setting the Data Direction Register for the port pin to output. The easiest way of setting the OC2A value is to use the Force Output Com- pare (FOC2A) strobe bit ...

Page 145

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P on the OC2A Register performed on the next compare match. For compare output actions in the non-PWM modes refer to Table 18-4 on page A change of the COM2A[1:0] bits state will have effect at the ...

Page 146

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Figure 18-5. CTC Mode, Timing Diagram TCNTn OCnx (Toggle) Period An interrupt can be generated each time the counter value reaches the TOP value by using the OCF2A Flag. If the interrupt is enabled, the interrupt handler routine can ...

Page 147

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P inverted PWM outputs. The small horizontal line marks on the TCNT2 slopes represent compare matches between OCR2A and TCNT2. Figure 18-6. Fast PWM Mode, Timing Diagram TCNTn OCnx OCnx Period The Timer/Counter Overflow Flag (TOV2) is set each time ...

Page 148

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P The counter counts repeatedly from BOTTOM to MAX and then from MAX to BOTTOM. In non- inverting Compare Output mode, the Output Compare (OC2A) is cleared on the compare match between TCNT2 and OCR2A while upcounting, and set on ...

Page 149

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P The N variable represents the prescale factor (1, 8, 32, 64, 128, 256, or 1024). The extreme values for the OCR2A Register represent special cases when generating a PWM waveform output in the phase correct PWM mode. If the ...

Page 150

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Figure 18-9. Timer/Counter Timing Diagram, with Prescaler (f Figure 18-10 Figure 18-10. Timer/Counter Timing Diagram, Setting of OCF2A, with Prescaler (f Figure 18-11 Figure 18-11. Timer/Counter Timing Diagram, Clear Timer on Compare Match mode, with Pres- 8285D–AVR–06/11 clk I/O ...

Page 151

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 18.9 Asynchronous operation of the Timer/Counter 18.9.1 Asynchronous Operation of Timer/Counter2 When Timer/Counter2 operates asynchronously, some considerations must be taken. • Warning: When switching between asynchronous and synchronous clocking of Timer/Counter2, the Timer Registers TCNT2, OCR2A, and TCCR2A might ...

Page 152

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P • Description of wake up from Power-save or ADC Noise Reduction mode when the timer is clocked asynchronously: When the interrupt condition is met, the wake up process is started on the following cycle of the timer clock, that ...

Page 153

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 18.10 Timer/Counter Prescaler Figure 18-12. Prescaler for Timer/Counter2 TOSC1 The clock source for Timer/Counter2 is named clk system I/O clock clk clocked from the TOSC1 pin. This enables use of Timer/Counter2 as a Real Time Counter (RTC). When AS2 ...

Page 154

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 18.11 Register Description 18.11.1 TCCR2A – Timer/Counter Control Register A Bit (0xB0) Read/Write Initial Value • Bit 7 – FOC2A: Force Output Compare A The FOC2A bit is only active when the WGM bits specify a non-PWM mode. However, ...

Page 155

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Table 18-3. COM2A1 Table 18-4 PWM mode. Table 18-4. COM2A1 Note: Table 18-5 correct PWM mode. Table 18-5. COM2A1 Note: 8285D–AVR–06/11 Compare Output Mode, non-PWM Mode COM2A0 Description 0 0 Normal ...

Page 156

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P • Bit 2:0 – CS2[2:0]: Clock Select The three Clock Select bits select the clock source to be used by the Timer/Counter, see 18-6. Table 18-6. CS22 18.11.2 TCNT2 – Timer/Counter ...

Page 157

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 18.11.4 TIMSK2 – Timer/Counter2 Interrupt Mask Register Bit (0x70) Read/Write Initial Value • Bit 1 – OCIE2A: Timer/Counter2 Output Compare Match A Interrupt Enable When the OCIE2A bit is written to one and the I-bit in the Status Register ...

Page 158

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P • Bit 3 – AS2: Asynchronous Timer/Counter2 When AS2 is written to zero, Timer/Counter2 is clocked from the I/O clock, clk written to one, Timer/Counter2 is clocked from a crystal Oscillator connected to the Timer Oscil- lator 1 (TOSC1) ...

Page 159

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 19. SPI – Serial Peripheral Interface 19.1 Features • Full-duplex, Three-wire Synchronous Data Transfer • Master or Slave Operation • LSB First or MSB First Data Transfer • Seven Programmable Bit Rates • End of Transmission Interrupt Flag • ...

Page 160

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P communication cycle when pulling low the Slave Select SS pin of the desired Slave. Master and Slave prepare the data to be sent in their respective shift Registers, and the Master generates the required clock pulses on the SCK ...

Page 161

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Table 19-1. Pin MOSI MISO SCK SS Note: The following code examples show how to initialize the SPI as a Master and how to perform a simple transmission. DDR_SPI in the examples must be replaced by the actual Data ...

Page 162

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Assembly Code Example SPI_MasterInit: SPI_MasterTransmit: Wait_Transmit: C Code Example void SPI_MasterInit(void void SPI_MasterTransmit(char cData Note: 8285D–AVR–06/11 (1) ; Set MOSI and SCK output, all others input ldi r17,(1<<DD_MOSI)|(1<<DD_SCK) out DDR_SPI,r17 ; Enable SPI, Master, set ...

Page 163

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P The following code examples show how to initialize the SPI as a Slave and how to perform a simple reception. Assembly Code Example SPI_SlaveInit: SPI_SlaveReceive: C Code Example void SPI_SlaveInit(void char SPI_SlaveReceive(void Note: 8285D–AVR–06/11 (1) ...

Page 164

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 19.3 SS Pin Functionality 19.3.1 Slave Mode When the SPI is configured as a Slave, the Slave Select (SS) pin is always input. When SS is held low, the SPI is activated, and MISO becomes an output if configured ...

Page 165

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 19.4 Data Modes There are four combinations of SCK phase and polarity with respect to serial data, which are determined by control bits CPHA and CPOL. The SPI data transfer formats are shown in 19-3 and nal, ensuring sufficient ...

Page 166

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 19.5 Register Description 19.5.1 SPCR – SPI Control Register Bit 0x2C (0x4C) Read/Write Initial Value • Bit 7 – SPIE: SPI Interrupt Enable This bit causes the SPI interrupt to be executed if SPIF bit in the SPSR Register ...

Page 167

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P The relationship between SCK and the Oscillator Clock frequency f table: Table 19-5. SPI2X 19.5.2 SPSR – SPI Status Register Bit 0x2D (0x4D) Read/Write Initial Value • Bit 7 – SPIF: SPI Interrupt Flag When a serial transfer is ...

Page 168

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 19.5.3 SPDR – SPI Data Register Bit 0x2E (0x4E) Read/Write Initial Value The SPI Data Register is a read/write register used for data transfer between the Register File and the SPI Shift Register. Writing to the register initiates data ...

Page 169

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 20. USART 20.1 Features • Full Duplex Operation (Independent Serial Receive and Transmit Registers) • Asynchronous or Synchronous Operation • Master or Slave Clocked Synchronous Operation • High Resolution Baud Rate Generator • Supports Serial Frames with 5, 6, ...

Page 170

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Figure 20-1. USART Block Diagram Note: The dashed boxes in the block diagram separate the three main parts of the USART (listed from the top): Clock Generator, Transmitter and Receiver. Control Registers are shared by all units. The Clock ...

Page 171

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 20.2.1 AVR USART vs. AVR UART – Compatibility The USART is fully compatible with the AVR UART regarding: • Bit locations inside all USART Registers. • Baud Rate Generation. • Transmitter Operation. • Transmit Buffer Functionality. • Receiver Operation. ...

Page 172

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Signal description: txclk rxclk xcki xcko fosc 20.3.1 Internal Clock Generation – The Baud Rate Generator Internal clock generation is used for the asynchronous and the synchronous master modes of operation. The description in this section refers to The ...

Page 173

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Setting this bit will reduce the divisor of the baud rate divider from effectively doubling the transfer rate for asynchronous communication. Note however that the Receiver will in this case only use half the number of ...

Page 174

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 20.4 Frame Formats A serial frame is defined to be one character of data bits with synchronization bits (start and stop bits), and optionally a parity bit for error checking. The USART accepts all 30 combinations of the following ...

Page 175

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A used, the parity bit is located between the last data bit and first stop bit of a serial frame. 20.5 USART Initialization The USART has to be initialized before any communication can take place. The ...

Page 176

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Assembly Code Example USART_Init: C Code Example #define FOSC 1843200// Clock Speed #define BAUD 9600 #define MYUBRR FOSC/16/BAUD-1 void main( void ) { } void USART_Init( unsigned int ubrr Note: More advanced initialization routines can be made ...

Page 177

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 20.6 Data Transmission – The USART Transmitter The USART Transmitter is enabled by setting the Transmit Enable (TXENn) bit in the UCSRnB Register. When the Transmitter is enabled, the normal port operation of the TxD pin is overrid- den ...

Page 178

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P show a transmit function that handles 9-bit characters. For the assembly code, the data to be sent is assumed to be stored in registers R17:R16. Assembly Code Example USART_Transmit: C Code Example void USART_Transmit( unsigned int data ) { ...

Page 179

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 20.6.3 Transmitter Flags and Interrupts The USART Transmitter has two flags that indicate its state: USART Data Register Empty (UDREn) and Transmit Complete (TXCn). Both flags can be used for generating interrupts. The Data Register Empty (UDREn) Flag indicates ...

Page 180

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 20.7 Data Reception – The USART Receiver The USART Receiver is enabled by writing the Receive Enable (RXENn) bit in the UCSRnB Register to one. When the Receiver is enabled, the normal pin operation of the RxD pin is ...

Page 181

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 20.7.2 Receiving Frames with 9 Data Bits If 9-bit characters are used (UCSZ=7) the ninth bit must be read from the RXB8n bit in UCSRnB before reading the low bits from the UDRn. This rule applies to the FEn, ...

Page 182

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Assembly Code Example USART_Receive: USART_ReceiveNoError: C Code Example unsigned int USART_Receive( void ) { } Note: The receive function example reads all the I/O Registers into the Register File before any com- putation is done. This gives an optimal ...

Page 183

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 20.7.3 Receive Compete Flag and Interrupt The USART Receiver has one flag that indicates the Receiver state. The Receive Complete (RXCn) Flag indicates if there are unread data present in the receive buf- fer. This flag is one when ...

Page 184

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 20.7.5 Parity Checker The Parity Checker is active when the high USART Parity mode (UPM1n) bit is set. Type of Par- ity Check to be performed (odd or even) is selected by the UPM0n bit. When enabled, the Parity ...

Page 185

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 20.8 Asynchronous Data Reception The USART includes a clock recovery and a data recovery unit for handling asynchronous data reception. The clock recovery logic is used for synchronizing the internally generated baud rate clock to the incoming asynchronous serial ...

Page 186

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Figure 20-6. Sampling of Data and Parity Bit The decision of the logic level of the received bit is taken by doing a majority voting of the logic value to the three samples in the center of the received ...

Page 187

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A slow Table 20-2 that Normal Speed mode has higher toleration of baud rate variations. Table 20-2. # (Data+Parity Bit) Table 20-3. # (Data+Parity Bit) The recommendations of the maximum receiver baud rate ...

Page 188

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P exact division of the system frequency to get the baud rate wanted. In this case an UBRRn value that gives an acceptable low error can be used if possible. 20.9 Multi-processor Communication Mode Setting the Multi-processor Communication mode (MPCMn) ...

Page 189

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 20.10 Examples of Baud Rate Setting For standard crystal and resonator frequencies, the most commonly used baud rates for asyn- chronous operation can be generated by using the UBRRn settings in values which yield an actual baud rate differing ...

Page 190

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Table 20-5. Examples of UBRRn Settings for Commonly Used Oscillator Frequencies (Continued 3.6864MHz osc Baud U2Xn = 0 U2Xn = 1 Rate (bps) UBRRn Error UBRRn 2400 95 0.0% 191 4800 47 0.0% 95 9600 23 0.0% ...

Page 191

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Table 20-6. Examples of UBRRn Settings for Commonly Used Oscillator Frequencies (Continued 8.0000MHz osc Baud U2Xn = 0 U2Xn = 1 Rate (bps) UBRRn Error UBRRn 2400 207 0.2% 416 4800 103 0.2% 207 9600 51 0.2% ...

Page 192

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Table 20-7. Examples of UBRRn Settings for Commonly Used Oscillator Frequencies (Continued 16.0000MHz osc Baud U2Xn = 0 U2Xn = 1 Rate (bps) UBRRn Error UBRRn 2400 416 -0.1% 832 4800 207 0.2% 416 9600 103 0.2% ...

Page 193

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 20.11 Register Description 20.11.1 UDRn – USART I/O Data Register Bit (0xC6) Read/Write Initial Value The USART Transmit Data Buffer Register and USART Receive Data Buffer Registers share the same I/O address referred to as USART Data Register or ...

Page 194

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P UDREn is set after a reset to indicate that the Transmitter is ready. • Bit 4 – FEn: Frame Error n This bit is set if the next character in the receive buffer had a Frame Error when received. ...

Page 195

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P • Bit 5 – UDRIEn: USART Data Register Empty Interrupt Enable Writing this bit to one enables interrupt on the UDREn Flag. A Data Register Empty interrupt will be generated only if the UDRIEn bit is written to one, ...

Page 196

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Receiver will generate a parity value for the incoming data and compare it to the UPM0n setting mismatch is detected, the UPEn Flag in UCSRnA will be set. Table 20-9. • Bit 3 – USBSn: Stop Bit ...

Page 197

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 20.11.5 UBRRnL and UBRRnH – USART Baud Rate Registers Bit (0xC5) (0xC4) Read/Write Initial Value • Bit 15:12 – Reserved These bits are reserved for future use. For compatibility with future devices, these bit must be written to zero ...

Page 198

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P 21. USI – Universal Serial Interface 21.1 Features • Two-wire Synchronous Data Transfer (Master or Slave) • Three-wire Synchronous Data Transfer (Master or Slave) • Data Received Interrupt • Wakeup from Idle Mode • In Two-wire Mode: Wake-up from ...

Page 199

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P The 4-bit counter can be both read and written via the data bus, and can generate an overflow interrupt. Both the Serial Register and the counter are clocked simultaneously by the same clock source. This allows the counter to ...

Page 200

ATmega165A/PA/325A/PA/3250A/PA/645A/P/6450A/P Figure 21-3. Three-wire Mode, Timing Diagram CYCLE USCK USCK The Three-wire mode timing is shown in USCK cycle reference. One bit is shifted into the USI Shift Register (USIDR) for each of these cycles. The USCK timing is shown ...

Related keywords