Skip to main content

ATmega328 Microcontroller

ATmega328 Microcontroller
ATMEGA328P is high performance, low power controller from Microchip. ATMEGA328P is an 8-bit microcontroller based on AVR RISC architecture. It is the most popular of all AVR controllers as it is used in ARDUINO boards.

ATMega328 Microcontroller Pin Configuration

ATmega328 Microcontroller Pinouts
ATMEGA328P is a 28 pin chip as shown in pin diagram above. Many pins of the chip here have more than one function. We will describe functions of each pin in below table.
Pin No.
Pin name
Description
Secondary Function
1
PC6 (RESET)
Pin6 of  PORTC
Pin by default is used as RESET pin. PC6 can only be used as I/O pin when RSTDISBL Fuse is programmed.
2
PD0 (RXD)
Pin0  of  PORTD
RXD (Data Input Pin for USART)
USART Serial Communication Interface
[Can be used for programming]
3
PD1 (TXD)
Pin1 of  PORTD
TXD (Data Output Pin for USART)
USART Serial Communication Interface
[Can be used for programming]
INT2( External Interrupt 2 Input)
4
PD2 (INT0)
Pin2  of  PORTD
External Interrupt source 0
5
PD3 (INT1/OC2B)
Pin3  of  PORTD
External Interrupt source1
OC2B(PWM - Timer/Counter2 Output Compare Match B Output)
6
PD4 (XCK/T0)
Pin4  of  PORTD
T0( Timer0 External Counter Input)
XCK ( USART External Clock I/O)
7
VCC
Connected to positive voltage
8
GND
Connected to ground
9
PB6 (XTAL1/TOSC1)
Pin6  of  PORTB
XTAL1 (Chip Clock Oscillator pin 1 or External clock input)
TOSC1 (Timer Oscillator pin 1)
10
PB7 (XTAL2/TOSC2)
Pin7  of  PORTB
XTAL2 (Chip Clock Oscillator pin 2)
TOSC2 (Timer Oscillator pin 2)
11
PD5
(T1/OC0B)
Pin5 of  PORTD
T1(Timer1 External Counter Input)
OC0B(PWM - Timer/Counter0 Output Compare Match B Output)
12
PD6 (AIN0/OC0A)
Pin6  of  PORTD
AIN0(Analog Comparator Positive I/P)
OC0A(PWM - Timer/Counter0 Output Compare Match A Output)
13
PD7 (AIN1)
Pin7  of  PORTD
AIN1(Analog Comparator Negative I/P)
14
PB0 (ICP1/CLKO)
Pin0  of  PORTB
ICP1(Timer/Counter1 Input Capture Pin)
CLKO (Divided System Clock. The divided system clock can be output on the PB0 pin)
15
PB1 (OC1A)
Pin1  of  PORTB
OC1A (Timer/Counter1 Output Compare Match A Output)
16
PB2 (SS/OC1B)
Pin2  of  PORTB
SS (SPI Slave Select Input).  This pin is low when controller acts as slave.
[Serial Peripheral Interface (SPI) for programming]
OC1B (Timer/Counter1 Output Compare Match B Output)
17
PB3 (MOSI/OC2A)
Pin3  of  PORTB
MOSI (Master Output Slave Input). When controller acts as slave, the data is received by this pin. [Serial Peripheral Interface (SPI) for programming]
OC2 (Timer/Counter2 Output Compare Match Output)
18
PB4 (MISO)
Pin4  of  PORTB
MISO (Master Input Slave Output). When controller acts as slave, the data is sent to master by this controller through this pin.
[Serial Peripheral Interface (SPI) for programming]
19
PB5 (SCK)
Pin5  of  PORTB
SCK (SPI Bus Serial Clock). This is the clock shared between this controller and other system for accurate data transfer.
[Serial Peripheral Interface (SPI) for programming]
20
AVCC
Power for Internal ADC Converter
21
AREF
Analog Reference Pin for ADC
22
GND
GROUND
23
PC0 (ADC0)
Pin0  of  PORTC
 ADC0 (ADC Input Channel 0)
24
PC1 (ADC1)
Pin1  of  PORTC
ADC1 (ADC Input Channel 1)
25
PC2 (ADC2)
Pin2  of  PORTC
 ADC2 (ADC Input Channel 2)
26
PC3 (ADC3)
Pin3  of  PORTC
 ADC3 (ADC Input Channel 3)
27
PC4 (ADC4/SDA)
Pin4  of  PORTC
ADC4 (ADC Input Channel 4)
SDA (Two-wire Serial Bus Data Input/output Line)
28
PC5 (ADC5/SCL)
Pin5  of  PORTC
ADC5 (ADC Input Channel 5)
SCL (Two-wire Serial Bus Clock Line)

Features of ATmega328 Microcontroller

ATMEGA328P – Simplified Features
CPU
8-bit AVR
Number of Pins
28
Operating Voltage (V)
+1.8 V TO +5.5V
Number of programmable  I/O lines
23
Communication Interface
Master/Slave SPI Serial Interface(17,18,19 PINS) [Can be used for programming this controller]
Programmable Serial USART(2,3 PINS) [Can be used for programming this controller]
Two-wire Serial Interface(27,28  PINS)[Can be used to connect peripheral devices like Servos, sensors and memory devices]
JTAG Interface
Not available
ADC Module
6channels, 10-bit resolution ADC
Timer Module
Two 8-bit counters with Separate Prescaler and compare mode, One 16-bit counter with Separate Prescaler,compare mode and capture mode.
Analog Comparators
1(12,13 PINS)
DAC Module
Nil
PWM channels
6
External Oscillator
0-4MHz @ 1.8V to 5.5V
0-10MHz @ 2.7V to 5.5V
0-20MHz @ 4.5V to 5.5V
Internal Oscillator
8MHz  Calibrated Internal Oscillator
Program Memory Type
Flash
Program Memory or Flash memory
32Kbytes[10000 write/erase cycles]
CPU Speed
1MIPS for 1MHz
RAM
2Kbytes Internal SRAM
EEPROM
1Kbytes EEPROM
Watchdog Timer
Programmable Watchdog Timer with Separate On-chipOscillator
Program Lock
Yes
Power Save Modes
Six Modes[Idle, ADC Noise Reduction, Power-save, Power-down, Standby and Extended Standby]
Operating Temperature
-40°C to +105°C(+105 being absolute maximum, -40 being absolute minimum)

ATMEGA328P Replacements

ATMEGA328P Alternatives 

ATMEGA16ATMEGA32, ATMEGA8535

How to Use ATMega328 Microcontroller using Arduino

How to Use ATMega328 Microcontroller using Arduino
Since ATmega328P is used in Arduino Uno and Arduino nano boards, you can directly replace the arduino board with ATmega328 chip. For that first you need to install the Arduino bootloader into the chip (Or you can also buy a chip with bootloader – ATMega328P-PU). This IC with bootloader can be placed on Arduino Uno board and burn the program into it. Once Arduino program is burnt into the IC, it can be removed and used in place of Arduino board, along with a Crystal oscillator and other components as required for the project. Below is the pin mapping between Arduino Uno and ATmega328P chip.

Comments

Popular posts from this blog

7400 - Quad Two Input NAND Gate

7400 - Quad Two Input NAND Gate 74LS00 is part of the 74XXYY IC series. 74xxyy integrated circuits are logical gates of digital electronics. The 74LS00 IC has four NAND gates(NAND Gate is the combination of AND and NOT Gate). In addition, each door has two entrances. Hence the name QUAD TWO INPUT NAND GATE.     Pin Diagram of 7400 IC 74LS00 is a 14-pin device. The chip is available in different packages and is chosen according to the needs.  The description of each pin is given below. Pin Number Description 1 A1-INPUT1 of GATE 1 2 B1-INPUT2 of GATE 1 3 Y1-OUTPUT of GATE1 4 A2-INPUT1 of GATE 2 5 B2-INPUT2 of GATE 2 6 Y2-OUTPUT of GATE2 9 A3-INPUT1 of GATE 3 10 B3-INPUT2 of GATE 3 8 Y3-OUTPUT of GATE3 12 A4-INPUT1 of GATE 4 13 B4-INPUT2 of GATE 4 11 Y4-OUTPUT of GATE4 7 GND- Connected to ground 14 VCC-Connected to positive voltage to provide smdksmkm power to all four gates Internal Ci

Arduino Code Basics - C, Pins

Code Basics -Arduino C The Arduino uses a slightly reduced C/C++ programming language. In this recipe, we will remember a few basics of C/C++. Ensure that you have Arduino IDE Installed on your Laptop/PC. Here is a simple example of basic Arduino C/C++ manipulating two variables: // Global Variables  int var1 = 10;  int var2 = 20; void setup() {   // Only execute once when the Arduino boots   var2 = 5;   // var2 becomes 5 once the Arduino boots } void loop(){   // Code executes top-down and repeats continuously   if (var1 > var2) {  // If var1 is greater than var2 var2++; // Increment var2 by 1   } else {  // If var1 is NOT greater than var2     var2 = 0; // var2 becomes 0   }  } When we upload a sketch to the board, the Arduino software first compiles the code. If there is an error in the code, it will write it in the Status Display area and will stop the upload. If no errors are found, it will begin writing the compiled co

RGB Led Fading effect using Arduino

The RGB LED can emit different colors by mixing the 3 basic colors red, green and blue. So, it actually consists of 3 separate red, green and blue LEDs, packaged in one box. This is why it has 4 leads, one for each of the 3 colors and a common cathode or anode depending on the type of RGB LED. In this tutorial I will use a common cathode. Components required for this Project : RGB Led - Buy Arduino Uno - Buy Breadboard and Jumpers - Buy Circuit Diagram Above is the circuit diagram of the RGB Led and Arduino Uno , As you can see the ground pin  of the RGB LED is connected to the ground of the Arduino and other 3 pins of RGB Led are connected to the PWM Pins of Arduino Uno (9, 10, 11). Code int ledPin = 9;  int ledPin1 = 10; int ledPin2 = 11; void setup() {} void loop() {   for (int fadeValue = 0 ; fadeValue <= 255; fadeValue += 5)    {     analogWrite(ledPin, fadeValue);     delay(20);   }   for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -