Atmel ATmega 328/328P Microcontroller
Atmel ATmega 328/328P Block Diagram
Atmel ATmega 328/328P Block Diagram of the AVR Architecture
Atmel ATmega 328/328P 28-Pin PDIP Pin-Out
Pin Descriptions
Source: [ATMEGA328P]
VCC
Digital supply voltage.
GND
Ground.
Port B (PB[7:0]) XTAL1 / XTAL2 / TOSC1 / TOSC2
Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port B output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port B pins that are externally pulled low will source current if the pull-up resistors are activated. The Port B pins are tri-stated when a reset condition becomes active, even if the clock is not running.
Depending on the clock selection fuse settings, PB6 can be used as input to the inverting Oscillator amplifier and input to the internal clock operating circuit.
Depending on the clock selection fuse settings, PB7 can be used as output from the inverting Oscillator amplifier.
If the Internal Calibrated RC Oscillator is used as chip clock source, PB[7:6] is used as TOSC[2:1] input for the Asynchronous Timer/Counter2 if the AS2 bit in ASSR is set.
Port C (PC[5:0])
Port C is a 7-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The PC[5:0] output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port C pins that are externally pulled low will source current if the pull-up resistors are activated. The Port C pins are tri-stated when a reset condition becomes active, even if the clock is not running.
PC6 / RESET
If the RSTDISBL Fuse is programmed, PC6 is used as an I/O pin. Note that the electrical characteristics of PC6 differ from those of the other pins of Port C.
If the RSTDISBL Fuse is unprogrammed, PC6 is used as a Reset input. A low level on this pin for longer than the minimum pulse length will generate a Reset, even if the clock is not running. Shorter pulses are not guaranteed to generate a Reset.
The various special features of Port C are elaborated in the Alternate Functions of Port C section.
Port D (PD[7:0])
Port D is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port D output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port D pins that are externally pulled low will source current if the pull-up resistors are activated. The Port D pins are tri-stated when a reset condition becomes active, even if the clock is not running.
AVCC
AVCC is the supply voltage pin for the A/D Converter, PC[3:0], and PE[3:2]. It should be externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be connected to VCC through a low-pass filter. Note that PC[6:4] use digital supply voltage, VCC.
AREF
AREF is the analog reference pin for the A/D Converter.
Port Function Multiplexing
Sources: [ATMEGA328P], [BLUM2013]
Pin | PAD | EXTINT ADC/AC |
PCINT | OSC | T/C #0 T/C #1 |
I2C SPI USART |
Goes to Arduino |
---|---|---|---|---|---|---|---|
1 | PC6 / RESET |
PCINT14 | Reset | ||||
2 | PD0 | PCINT16 | RXD | Digital Pin 0 (RX) | |||
3 | PD1 | PCINT17 | TXD | Digital Pin 1 (TX) | |||
4 | PD2 | INT0 | PCINT18 | Digital Pin 2 | |||
5 | PD3 | INT1 | PCINT19 | OC2B | Digital Pin 3 (PWM) | ||
6 | PD4 | PCINT20 | T0 | XCK | Digital Pin 4 | ||
7 | VCC | VCC | |||||
8 | GND | GND | |||||
9 | PB6 | PCINT6 | XTAL1 / TOSC1 |
Crystal | |||
10 | PB7 | PCINT7 | XTAL2 / TOSC2 |
Crystal | |||
11 | PD5 | PCINT21 | OC0B / T1 |
Digital Pin 5 (PWM) | |||
12 | PD6 | AIN0 | PCINT22 | OC0A | Digital Pin 6 (PWM) | ||
13 | PD7 | AIN1 | PCINT23 | Digital Pin 7 | |||
14 | PB0 | PCINT0 | CLK0 | ICP1 | Digital Pin 8 | ||
15 | PB1 | PCINT1 | OC1A | Digital Pin 9 (PWM) | |||
16 | PB2 | PCINT2 | OC1B | SS | Digital Pin 10 (PWM) | ||
17 | PB3 | PCINT3 | OC2A | MOSI | Digital Pin 11 (PWM) | ||
18 | PB4 | PCINT4 | MISO | Digital Pin 12 | |||
19 | PB5 | PCINT5 | SCK | Digital Pin 13 | |||
20 | AVCC | VCC | |||||
21 | AREF | Analog Reference | |||||
22 | GND | GND | |||||
23 | PC0 | ADC0 | PCINT8 | Analog Input 0 | |||
24 | PC1 | ADC1 | PCINT9 | Analog Input 1 | |||
25 | PC2 | ADC2 | PCINT10 | Analog Input 2 | |||
26 | PC3 | ADC3 | PCINT11 | Analog Input 3 | |||
27 | PC4 | ADC4 | PCINT12 | SDA | Analog Input 4 | ||
28 | PC5 | ADC5 | PCINT13 | SCL | Analog Input 5 |
Notes
Links
- Arduino — Official website. Arduino is an open-source electronics platform based on easy-to-use hardware and software. It’s intended for anyone making interactive projects. (✓2018-02-19)
- Arduino Source Code — Github. (✓2018-02-19)
- AVRDUDE — AVR Downloader/UploaDEr. A utility to download/upload/manipulate the ROM and EEPROM contents of AVR microcontrollers using the in-system programming technique (ISP). (✓2018-02-19)
- Capacitor Guide — (✓2018-02-11)
- Exploring Arduino — Companion site for the book by Jeremy Blum. (✓2018-02-20)
- Hacking Arduino: Extending and Developing It — Arduino. (✓2018-02-19)
References
[ATMEGA328P] Atmel. “ATmega328/P Datasheet Complete”. Microchip Technology Inc. November 2016. Accessed February 5, 2018.
[BLUM2013] Blum, Jeremy. Exploring Arduino: Tools and Techniques for Engineering Wizardry. Indianapolis, Indiana: John Wiley & Sons, 2013. Print.
Things to Explore When I Have the Time
- Cornell University ECE 4760 Designing with Microcontrollers Final Projects — The AVR architecture projects are in Fall 2014 and earlier. After that they used the PIC32 microcontroller. (✓ 2018-02-19)
- OBD-II Project — An OBD-II compliant device that would communicate with any OBD-II enabled car and read back real time data as well as perform basic performance testing and diagnostics. (✓ 2018-02-19)
- Standalone AVR ISP Programmer Shield Kit — Adafruit. (✓ 2018-02-19)