Sie sind auf Seite 1von 22

Understanding Atmega328P Microcontroller

(Lecture-8)

R S Ananda Murthy

Associate Professor
Department of Electrical & Electronics Engineering,
Sri Jayachamarajendra College of Engineering,
Mysore 570 006

R S Ananda Murthy Understanding Atmega328P Microcontroller


Specific Learning Objectives

After completing this lecture the student should be able to


Mention the features of Atmega328P.
State the function of signals at different pins of
Atmega328P.
Describe the internal block diagram of Atmega328P.
Describe the CPU core architecture of Atmega328P.
Describe the flash memory, SRAM, and EEPROM in
Atmega328P.

R S Ananda Murthy Understanding Atmega328P Microcontroller


Atmega328P Features

High Performance, Low Power Atmel AVR 8-Bit


Microcontroller Family.
Advanced RISC Harvard Architecture
131 Powerful Instructions Most Single Clock Cycle
Execution
32 8 General Purpose Working Registers
Fully Static Operation (with power on, the contents of
registers remain intact even with no clock signal)
Up to 20 MIPS Throughput at 20 MHz
On-chip 2-cycle Multiplier
Operating Voltage
1.8 V to 5.5 V
Temperature Range
40 C to 85 C

R S Ananda Murthy Understanding Atmega328P Microcontroller


Atmega328P Features

High Endurance Non-volatile Memory Segments


16K 16 In-System Self-Programmable Flash program
memory. Note that the program memory is word organized.
1K 8 EEPROM. This is data memory.
2K 8 Internal SRAM. This is data memory.
Write/Erase Cycles: 10,000 Flash/100,000 EEPROM
Optional Boot Code Section with Independent Lock Bits
Programming Lock for Software Security
I/O and Packages
23 Programmable I/O Lines
28-pin PDIP, 32-lead TQFP, 28-pad QFN/MLF and 32-pad
QFN/MLF

R S Ananda Murthy Understanding Atmega328P Microcontroller


Atmega328P Features

Peripheral Features
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
Six PWM Channels
8-channel 10-bit ADC in TQFP and QFN/MLF package
6-channel 10-bit ADC in PDIP Package
Programmable Serial USART
Master/Slave SPI Serial Interface
Byte-oriented 2-wire Serial Interface (Philips I2C
compatible)
Programmable Watchdog Timer with Separate On-chip
Oscillator
On-chip Analog Comparator
Interrupt and Wake-up on Pin Change

R S Ananda Murthy Understanding Atmega328P Microcontroller


Atmega328P Features

Special Microcontroller Features


Power-on Reset and Programmable Brown-out Detection
Internal Calibrated Oscillator
External and Internal Interrupt Sources
Six Sleep Modes: Idle, ADC Noise Reduction, Power-save,
Power-down, Standby, and Extended Standby
Speed Grade
0 - 4 MHz @ 1.8 - 5.5V, 0 - 10 MHz @ 2.7 - 5.5 V, 0 -
20MHz @ 4.5 - 5.5 V
Power Consumption at 1 MHz, 1.8 V, 25 C
Active Mode: 0.2mA
Power-down Mode: 0.1A
Power-save Mode: 0.75A (Including 32kHz RTC)

R S Ananda Murthy Understanding Atmega328P Microcontroller


Types of Atmega328P Packages

28-Pin Plastic Dual In-line Package (PDIP)

R S Ananda Murthy Understanding Atmega328P Microcontroller


Types of Atmega328P Packages

32-pin Thin Quad Flat Package (TQFP)

R S Ananda Murthy Understanding Atmega328P Microcontroller


Types of Atmega328P Packages

32-pin Micro Lead Frame (MLF) or


Quad Flat No-leads (QFN) package.
A similar 28-pin package is also available.

R S Ananda Murthy Understanding Atmega328P Microcontroller


Atmega328P PDIP Pinout Details

Many pins have more than one function

R S Ananda Murthy Understanding Atmega328P Microcontroller


Atmega328P PDIP Signals

R S Ananda Murthy Understanding Atmega328P Microcontroller


Atmega328P 32-TQFP Signals

R S Ananda Murthy Understanding Atmega328P Microcontroller


Atmega328P 32-MLF Signals

R S Ananda Murthy Understanding Atmega328P Microcontroller


Pin Descriptions of Atmega328P

Vcc Supply voltage.


GND Ground.
Port B (PB7:0) XTAL1/XTAL2/TOSC1/TOSC2 8-bit
bi-directional I/O port with internal pull-up resistors.
Across PB7 and PB6 external oscillator or quartz crystal
should be connected to generate chip clock signal if
internal oscillator is not used.
PB7 and PB6 is used as TOSC2...1 input for the
Asynchronous Timer/Counter2 if the AS2 bit in ASSR is
set, when internal chip clock is used.

R S Ananda Murthy Understanding Atmega328P Microcontroller


Pin Descriptions of Atmega328P

Port C (PC5:0) These are six lines of 7-bit bi-directional


I/O port with internal pull-up resistors.
PC6/RESET Depending upon how the chip is
programmed, this pin can be used as an I/O pin or as input
to reset the MCU.
Port D (PD7:0) 8-bit bi-directional I/O port with internal
pull-up resistors.

R S Ananda Murthy Understanding Atmega328P Microcontroller


Pin Descriptions of Atmega328P

AVcc supply voltage pin for the A/D Converter, PC3:0,


and ADC7:6. 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.
AREF the analog reference pin for the A/D Converter.
ADC7:6 (TQFP and QFN/MLF Package Only) in the
TQFP and QFN/MLF package, ADC7:6 serve as analog
inputs to the A/D converter. These pins are powered from
the analog supply and serve as 10-bit ADC channels.

R S Ananda Murthy Understanding Atmega328P Microcontroller


Atmega328P Internal Block Diagram

R S Ananda Murthy Understanding Atmega328P Microcontroller


Atmega328P CPU Core Architecture

R S Ananda Murthy Understanding Atmega328P Microcontroller


Flash Program Memory in Atmega328P 16K16
Hex Address D15 D14 . . . . . . . . . . . D 2 D 1 D 0
$0000 Bootloader is a
program executed by
the MCU to write code
Application Program
into the flash memory
Section
16 K = 16384 or read the code from
Locations program memory.
16 Bits

Size of bootloader
Bootloader Section section is configurable
$3FFF using fuse bits

Can endure at least 10,000 write/erase cycles. Nonvolatile.


Uses little endian arrangement of bytes.
Since the program memory address has 14 bits, the
Program Counter width is also 14 bits.
Bootloader can be protected using lock bits.
R S Ananda Murthy Understanding Atmega328P Microcontroller
SRAM Data Memory in Atmega328P Volatile

8 Bits
Hex Addresses D 7 . . . . . . . . . . . .D 2 D 1 D 0

Stores operands and results


0x0000 - 0x001F 32 Registers (GPRs)
of arithmetic/logical operations

0x0020 - 0x005F 64 I/O Registers (SFRs) Used to access peripherals

0x0060 - 0x00FF 160 Ext I/O Registers Used to access extra peripherals

0x0100 - 0x08FF 2048 x 8 Scratch Pad Used to store temporary data

R S Ananda Murthy Understanding Atmega328P Microcontroller


EEPROM in Atmega328P

Size is 1 K8.
It is organized as a separate data space, in which single
bytes can be read and written.
Can endure at least 100,000 write/erase cycles.
Non-volatile storage for program specific data, constants,
etc.
Requires special write sequence to store data.
Should be accessed using EEPROM Address Register,
EEPROM Data Register and EEPROM Control Register.

R S Ananda Murthy Understanding Atmega328P Microcontroller


License

This work is licensed under a


Creative Commons Attribution 4.0 International License.

R S Ananda Murthy Understanding Atmega328P Microcontroller

Das könnte Ihnen auch gefallen