ATmega324PB
AVR Microcontroller with Core Independent Peripherals
and PicoPower technology
Introduction
The picoPower ATmega324PB is a low-power CMOS 8-bit microcontroller based on the AVR
®
enhanced
RISC architecture. By executing powerful instructions in a single clock cycle, the ATmega324PB achieves
throughputs close to 1MIPS per MHz. This empowers system designers to optimize the device for power
consumption versus processing speed.
®
Feature
High Performance, Low Power AVR
®
8-Bit Microcontroller Family
•
Advanced RISC Architecture
– 131 Powerful Instructions
– Most Single Clock Cycle Execution
– 32 x 8 General Purpose Working Registers
– Fully Static Operation
– Up to 20 MIPS Throughput at 20MHz
– On-Chip 2-cycle Multiplier
•
High Endurance Non-Volatile Memory Segments
– 32KBytes of In-System Self-Programmable Flash Program Memory
– 1KBytes EEPROM
– 2KBytes Internal SRAM
– Write/Erase Cycles: 10,000 Flash/100,000 EEPROM
– Data Retention: 20 Years at 85°C
– Optional Boot Code Section with Independent Lock Bits
• In-System Programming by On-chip Boot Program
• True Read-While-Write Operation
– 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
– Peripheral Touch Controller (PTC)
• Capacitive Touch Buttons, Sliders and Wheels
• 32 Self-Sap Channels and 256 Mutual Cap Channels
– Two 8-bit Timer/Counters with Separate Prescaler and Compare Mode
©
2017 Microchip Technology Inc.
Datasheet Complete
DS40001908A-page 1
ATmega324PB
–
–
–
–
–
–
–
–
Three 16-bit Timer/Counters with Separate Prescaler, Compare Mode, and Capture Mode
Real Time Counter with Separate Oscillator
Ten PWM Channels
8-Channel 10-Bit ADC
• Differential Mode with Selectable Gain at 1×, 10× or 200×
Three Programmable Serial USARTs
Two Master/Slave SPI Serial Interfaces
Two Byte-oriented 2-wire Serial Interfaces (Philips I
2
C Compatible)
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 8 MHz Calibrated Oscillator
External and Internal Interrupt Sources
Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, Standby, and Extended
Standby
Clock Failure Detection Mechanism and Switch to Internal 8 MHz RC Oscillator in case of Failure
•
•
•
•
•
– Individual Serial Number to Represent a Unique ID
I/O and Packages
– 39 Programmable I/O Lines
– 44-Pin TQFP and 44-Pin QFN /MLF
Operating Voltage:
– 1.8 - 5.5V
Temperature Range:
– -40°C to 105°C
Speed Grade:
– 0 - 4MHz @ 1.8 - 5.5V
– 0 - 10MHz @ 2.7 - 5.5.V
– 0 - 20MHz @ 4.5 - 5.5V
Power Consumption at 1MHz, 1.8V, 25°C
– Active Mode: 0.24mA
– Power-Down Mode: 0.2μA
– Power-Save Mode: 1.3μA (Including 32kHz RTC)
©
2017 Microchip Technology Inc.
Datasheet Complete
DS40001908A-page 2
Table of Contents
Introduction......................................................................................................................1
Feature............................................................................................................................ 1
1. Description...............................................................................................................10
2. Configuration Summary........................................................................................... 11
3. Ordering Information ...............................................................................................12
4. Block Diagram......................................................................................................... 13
5. Pin Configurations................................................................................................... 14
5.1.
Pin Descriptions......................................................................................................................... 14
6. I/O Multiplexing........................................................................................................16
7. General Information.................................................................................................18
7.1.
7.2.
Resources.................................................................................................................................. 18
About Code Examples................................................................................................................18
8. AVR CPU Core........................................................................................................ 19
8.1.
8.2.
8.3.
8.4.
8.5.
8.6.
8.7.
8.8.
Overview.................................................................................................................................... 19
ALU – Arithmetic Logic Unit....................................................................................................... 20
Status Register...........................................................................................................................20
General Purpose Register File................................................................................................... 22
Stack Pointer.............................................................................................................................. 23
Accessing 16-bit Registers.........................................................................................................24
Instruction Execution Timing...................................................................................................... 24
Reset and Interrupt Handling..................................................................................................... 25
9. AVR Memories.........................................................................................................28
9.1.
9.2.
9.3.
9.4.
9.5.
9.6.
Overview.................................................................................................................................... 28
In-System Reprogrammable Flash Program Memory................................................................28
SRAM Data Memory.................................................................................................................. 29
EEPROM Data Memory............................................................................................................. 30
I/O Memory.................................................................................................................................31
Register Description................................................................................................................... 32
10. System Clock and Clock Options............................................................................ 38
10.1.
10.2.
10.3.
10.4.
10.5.
10.6.
Clock Systems and Their Distribution........................................................................................ 38
Clock Sources............................................................................................................................ 39
Low Frequency Crystal Oscillator...............................................................................................41
Low Power Crystal Oscillator..................................................................................................... 42
Calibrated Internal RC Oscillator................................................................................................44
128kHz Internal Oscillator.......................................................................................................... 45
©
2017 Microchip Technology Inc.
Datasheet Complete
DS40001908A-page 3
ATmega324PB
10.7. External Clock............................................................................................................................ 45
10.8. Timer/Counter Oscillator.............................................................................................................46
10.9. Clock Output Buffer.................................................................................................................... 47
10.10. System Clock Prescaler............................................................................................................. 47
10.11. Register Description................................................................................................................... 47
11. CFD - Clock Failure Detection mechanism............................................................. 50
11.1.
11.2.
11.3.
11.4.
11.5.
Overview.................................................................................................................................... 50
Features..................................................................................................................................... 50
Operations..................................................................................................................................50
Timing Diagram.......................................................................................................................... 52
Register Description................................................................................................................... 52
12. PM - Power Management and Sleep Modes...........................................................53
12.1. Sleep Modes.............................................................................................................................. 53
12.2. BOD Disable...............................................................................................................................53
12.3. Idle Mode....................................................................................................................................54
12.4. ADC Noise Reduction Mode...................................................................................................... 54
12.5. Power-Down Mode.....................................................................................................................55
12.6. Power-Save Mode......................................................................................................................55
12.7. Standby Mode............................................................................................................................ 56
12.8. Extended Standby Mode............................................................................................................ 56
12.9. Power Reduction Registers........................................................................................................56
12.10. Minimizing Power Consumption.................................................................................................56
12.11. Register Description................................................................................................................... 58
13. SCRST - System Control and Reset....................................................................... 63
13.1.
13.2.
13.3.
13.4.
13.5.
13.6.
13.7.
13.8.
13.9.
Resetting the AVR...................................................................................................................... 63
Reset Sources............................................................................................................................63
Power-on Reset..........................................................................................................................64
External Reset............................................................................................................................65
Brown-out Detection...................................................................................................................65
Watchdog System Reset............................................................................................................ 66
Internal Voltage Reference.........................................................................................................66
Watchdog Timer......................................................................................................................... 67
Register Description................................................................................................................... 69
14. INT- Interrupts..........................................................................................................73
14.1. Interrupt Vectors in ATmega324PB............................................................................................ 73
14.2. Register Description................................................................................................................... 76
15. External Interrupts................................................................................................... 78
15.1. EXINT - External Interrupts........................................................................................................ 78
16. I/O-Ports.................................................................................................................. 86
16.1.
16.2.
16.3.
16.4.
Overview.................................................................................................................................... 86
Ports as General Digital I/O........................................................................................................87
Alternate Port Functions.............................................................................................................90
Register Description................................................................................................................. 106
©
2017 Microchip Technology Inc.
Datasheet Complete
DS40001908A-page 4
ATmega324PB
17. TC0 - 8-bit Timer/Counter0 with PWM...................................................................114
17.1.
17.2.
17.3.
17.4.
17.5.
17.6.
17.7.
17.8.
17.9.
Features................................................................................................................................... 114
Overview...................................................................................................................................114
Timer/Counter Clock Sources...................................................................................................116
Counter Unit............................................................................................................................. 116
Output Compare Unit................................................................................................................117
Compare Match Output Unit.....................................................................................................119
Modes of Operation..................................................................................................................120
Timer/Counter Timing Diagrams.............................................................................................. 124
Register Description................................................................................................................. 126
18. TC1, 3, 4 - 16-bit Timer/Counter1, 3, 4 with PWM.................................................134
18.1. Features................................................................................................................................... 134
18.2. Overview.................................................................................................................................. 134
18.3. Accessing 16-bit Timer/Counter Registers............................................................................... 135
18.4. Timer/Counter Clock Sources.................................................................................................. 138
18.5. Counter Unit............................................................................................................................. 138
18.6. Input Capture Unit.................................................................................................................... 139
18.7. Compare Match Output Unit.....................................................................................................141
18.8. Output Compare Units..............................................................................................................142
18.9. Modes of Operation..................................................................................................................144
18.10. Timer/Counter Timing Diagrams.............................................................................................. 151
18.11. Register Description................................................................................................................. 153
19. Timer/Counter 0, 1, 3, 4 Prescalers.......................................................................179
19.1.
19.2.
19.3.
19.4.
Internal Clock Source............................................................................................................... 179
Prescaler Reset........................................................................................................................179
External Clock Source..............................................................................................................179
Register Description................................................................................................................. 180
20. TC2 - 8-bit Timer/Counter2 with PWM and Asynchronous Operation................... 182
20.1. Features................................................................................................................................... 182
20.2. Overview.................................................................................................................................. 182
20.3. Timer/Counter Clock Sources.................................................................................................. 184
20.4. Counter Unit............................................................................................................................. 184
20.5. Output Compare Unit............................................................................................................... 185
20.6. Compare Match Output Unit.....................................................................................................187
20.7. Modes of Operation..................................................................................................................188
20.8. Timer/Counter Timing Diagrams.............................................................................................. 192
20.9. Asynchronous Operation of Timer/Counter2............................................................................ 193
20.10. Timer/Counter Prescaler.......................................................................................................... 195
20.11. Register Description................................................................................................................. 195
21. OCM - Output Compare Modulator....................................................................... 205
21.1. Overview.................................................................................................................................. 205
21.2. Description............................................................................................................................... 205
22. SPI – Serial Peripheral Interface........................................................................... 207
©
2017 Microchip Technology Inc.
Datasheet Complete
DS40001908A-page 5