0% found this document useful (0 votes)
16 views7 pages

Lec_03 Introduction to AVR

Uploaded by

ngocminh2532003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views7 pages

Lec_03 Introduction to AVR

Uploaded by

ngocminh2532003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

10/2/2023

7:00 AM 10/2/2023 Chapter 2

Course
ME4162: Microprocessor AVR Microcontrollers
Semester 1, 2023 Overview
Lecturer: Dr. Duong Van Lac Dr. Duong Van Lac
Department of Mechatronics, HUST
Email: [email protected]

9/17/2023 1 9/17/2023 ME4162: Microprocessor 2


1 2
Prepared by Duong Van Lac. Email: [email protected]

Topics General Purpose Microprocessors vs.


• Microcontrollers vs. Microprocessors
Microcontrollers
• General Purpose Microprocessors
• Most common microcontrollers
• AVR Features General
Purpose RAM ROM
I/O
Timer
Serial
Port Port
• AVR members Micropro
cessor
(CPU) Buses

• Microcontrollers

Microcontroller

I/O Serial
RAM ROM Timer
Port Port
CPU

Buses

9/17/2023 ME4162: Microprocessor 3 3 9/17/2023 ME4162: Microprocessor 4 4

3 4

1
10/2/2023

Most common microcontrollers Most common microcontrollers


• 8-bit microcontrollers 8051 PIC AVR ARM
8-bit for standard
Bus width 8/16/32-bit 8/32-bit 32-bit mostly also available in 64-bit
– AVR core
Communication UART, PIC, UART, USART, LIN,
UART, USART, SPI, I2C, (special UART, USART, LIN, I2C, SPI, CAN, USB,
purpose AVR support CAN, USB, Ethernet, I2S, DSP, SAI (serial audio
– PIC Protocols USART,SPI,I2C CAN, Ethernet, SPI, I2S
Ethernet) interface), IrDA
12
– HCS12 Speed Clock/instruction
cycle
4 Clock/instruction
cycle
1 clock/ instruction cycle 1 clock/ instruction cycle

– 8051 Memory
ROM, SRAM, FLA
SH
SRAM, FLASH Flash, SRAM, EEPROM Flash, SDRAM, EEPROM
RISC (Reduced Instructions Set
ISA CLSC Some feature of RISC RISC
Computer)
Memory Harvard Von Neumann
Modified Harvard Architecture Modified Harvard architecture
• 32-bit microcontrollers Architecture
Power
architecture
Average
architecture
Low Low Low
Consumption
– ARM Families 8051 variants
PIC16,PIC17, PIC18,
PIC24, PIC32
Tiny, Atmega, Xmega, special
purpose AVR
ARMv4,5,6,7 and series

– AVR32 Community Vast


NXP, Atmel,
Very Good Very Good Vast

– PIC32 Manufacturer
Silicon Labs,
Dallas, Cyprus,
Microchip Average Atmel
Apple, Nvidia, Qualcomm, Samsung
Electronics, and TI etc.
Infineon, etc.
Cost Very Low Average Average Low

• RISC (Reduced Instructions Set Computer – Máy tính với tập lệnh đơn giản hóa)
• CISC (Complex Instructions Set Computer – Máy tính với tập lệnh phức tạp)

9/17/2023 ME4162: Microprocessor 5 5 9/17/2023 ME4162: Microprocessor 6 6

5 6
Prepared by Duong Van Lac. Email: [email protected]

History of Inovation Product Range

https://en.wikipedia.org/wiki/Atmel

The PIC and AVR MCU brands represent the two dominant
architectures in the embedded design universe

9/17/2023 ME4162: Microprocessor 7 9/17/2023 ME4162: Microprocessor 8


7 8

2
10/2/2023

AVR internal architecture AVR internal architecture

28 pin
(PCINT14/RESET) PC6 1 2KBytes 28 1KBytes
PC5 (ADC5/SCL/PCINT13) Register file Program
R31 (ZH) R30 (ZL) counter
(PCINT16/RXD) PD0 2 27 PC4 (ADC4/SDA/PCINT12)
32KBytes RAM EEPROM Timers
R29 (YH)
R27 (XH)
R28 (YL)
R26 (XL)

(PCINT17/TXD) PD1 3 26 PC3 (ADC3/PCINT11) R25


R23
R24
R22
R21 R20

PROGRAM(PCINT18/INT0) PD2 4 MEGA328 25 PC2 (ADC2/PCINT10) R19


R17
R18
R16 Flash program
R15 R14 memory
(PCINT19/OC2B/INT1)
ROM PD3 5 24 PC1 (ADC1/PCINT9) R13
R11
R12
R10
R9 R8
(PCINT20/XCK/T0) PD4 6 23 PC0 (ADC0/PCINT8) R7
R5
R6
R4
Program VCC 7 22 GND
R3
R1
R2
R0
Instruction
register
Bus GND Bus
8 21 AREF
CPU
(PCINT6/XTAL1/TOSC1) PB6 9 20 AVCC Instruction
decode
(PCINT7/XTAL2/TOSC2) PB7 10 19 PB5 (SCK/PCINT5)
(PCINT21/OC0B) PD5 11 18 PB4 (MISO/PCINT4)
(PCINT22/OC0A/AIN0) PD6 12 17 PB3 (MOSI/OC2A/PCINT3)
(PCINT23/AIN1) PD7 13 16 PB2 (SS/OC1B/PCINT2)
(PCINT0/CLKO/ICP1)
OSCPB0 14 Interrupt 15 PB1 (OC1A/PCINT1)Other
Ports Stack Data memory

Unit Peripherals pointer

Status
register ALU

I/O
PINS

9/17/2023 ME4162: Microprocessor 9 9/17/2023 ME4162: Microprocessor 10


9 10
Prepared by Duong Van Lac. Email: [email protected]

AVR Memory AVR Memory


◼ Modified Harvard Architecture ◼ Program Memory Map
SRAM Atmega 328: flash 16K x 16 = 32Kbytes
CPU 16 bits
FLASH

XTAL1/ Clock generation


$0000
TOSC1
Power EEPROMIF
8 MHz 1/2/4/8MHz management
Calib RC
EEPROM
Crystal Osc
and clock
XTAL2/
TOSC2
12MHz
External
32.768kHz control
Application
XOSC
RC Osc NVM
programming
Flash Section
External 1MHz int PARPROG
clock osc
D
Serial
A Programming
T
VCC Watchdog A MISO
Power Timer B MOSI
SPI SCK
Supervision U
RESET S
SS
POR/BOD &
RESET Internal
GND Reference
I/O PB[7:0]
PC[6:0]
PORTS PD[7:0]
ADC[7:0]
AREF ADC

EXTINT INT[1:0]
AIN0
AIN1 AC
Boot Flash Section 0x0FFF/0x1FFF/0x3FFF
ADCMUX
TC 0 T0
(8-bit)
RxD
TxD USART OC1A/B
ATmega88PA, ATmega168PA and ATmega328P
XCK TC 1 T1
(16-bit)
9/17/2023 SDA ME4162:
TWI
Microprocessor ICP1
11 9/17/2023 ME4162: Microprocessor 12
SCL
TC 2

11 12

3
10/2/2023

AVR Memory AVR different groups


◼ SRAM Data Memory Register File Data Address Space

◼ Registers R0
R1
$0000
$0001
• Classic AVR
◼ I/O Memory
R2
...
$0002
... – e.g. AT90S2313, AT90S4433
◼ Extended I/O Memory R29
R30
R31
$001D
$001E
$001F
• Mega
◼ Internal SRAM I/O Registers
– e.g. ATmega328, ATmega32, ATmega128
$00 $0020
8 bits
• Tiny
$01 $0021
$02 $0022
... ...
$0x0000 - $0x001F
32 Registers $3D
$3E
$005D
$005E
– e.g. ATtiny13, ATtiny25
64 I/O Registers $0x0020 - $0x005F
• Special Purpose AVR
$3F $005F

160 Ext I/O Reg. $0x0060 - $0x00FF


– e.g. AT90PWM216,AT90USB1287
CBGA
TSSOP SOIC
Internal SRAM
(512/1024/1024/2048 x 8) • XMega
$0x04FF/0x04FF/0x0FF/0x08FF – New features like DMA, DAC, crypto engine, etc.

ATmega88PA, ATmega168PA and ATmega328P


9/17/2023 ME4162: Microprocessor 13 9/17/2023 ME4162: Microprocessor 14
13 14
Prepared by Duong Van Lac. Email: [email protected]

Packaging Range Packaging Range

Optim
TFBGA-324 CTBGA-256 CTBGA-196 CBGA-100 VFBGA-49 LGA-32
15x15 mm 17x17 mm 12x12 mm 9x9 mm 5x5 mm 3.5x6.5 mm

PDIP-40 PDIP-28 PDIP-20 PDIP-14 PDIP-8 TSSOP-44 SOIC-32 SOIC-24 SOIC-20 SOIC-14 SOIC-8
13.72x52.32 mm 7.3x34.69 mm 6.6x25.74 mm 6.6x19.17 mm 6.35x9.3 mm 4.5x11.1 mm 7.51x20.73 mm 7.5x15.4 mm 7.52x12.83 mm 4x8.7 mm 4x5 mm

QFP-208 LQFP-144 TQFP-100 TQFP-64 TQFP-64 TQFP-44 LQFP-48 TQFP-32


28x28 mm 20x20 mm 14x14 mm 14x14 mm 10x10 mm 10x10 mm 7x7 mm 7x7 mm

QFN-64 DRQFN-64 QFN-48 QFN-44 DRQFN-44 QFN-32 QFN-28 QFN-20 QFN-20 DRDFN-18 DFN-10
9x9 mm 7x7 mm 7x7 mm 7x7 mm 5x5 mm 5x5 mm 4x4 mm 4x4 mm 3x3 mm 3.5x6.5 mm 3x3 mm

9/17/2023 ME4162: Microprocessor 15 9/17/2023 ME4162: Microprocessor 16


15 16

4
10/2/2023

Let’s get familiar with the AVR part numbers Application Oriented

ATmega128

Atmel group
Flash =128K Remote Access Control LCD Control USB Connectivity

ATtiny44 AT90S4433

Atmel
Flash =4K Atmel Classic
Tiny Flash =4K
group group

Motor Control Lighting AVR Wireless 2.4 GHz

9/17/2023 ME4162: Microprocessor 17 17 9/17/2023 ME4162: Microprocessor 18


17 18
Prepared by Duong Van Lac. Email: [email protected]

Chapter 2 Topics
◼ AVR Pins
◼ AVR simplest connections
◼ What is inside a hex file?
◼ Loading a hex file into flash

AVR Microcontrollers
Hardware Connections
Dr. Duong Van Lac
Department of Mechatronics, HUST

9/17/2023 ME4162: Microprocessor 19 9/17/2023 ME4162: Microprocessor 20


19 20

5
10/2/2023

ATmega328 pins AVR simplest connection


Clears all the Vcc
registers and
restart the 28 pin ATmega328
execution of (PCINT14/RESET) PC6 1 28 PC5 (ADC5/SCL/PCINT13) 7
program (PCINT16/RXD) PD0 2 27 PC4 (ADC4/SDA/PCINT12) VCC
Vcc 20
Provides supply (PCINT17/TXD) PD1 3 26 PC3 (ADC3/PCINT11) AVCC
4 MEGA328
voltage to the (PCINT18/INT0) PD2 25 PC2 (ADC2/PCINT10)
(PCINT19/OC2B/INT1) PD3 5 24 PC1 (ADC1/PCINT9)
chip.
These It should
pins are be (PCINT20/XCK/T0) PD4 6 23 PC0 (ADC0/PCINT8) 10K
22pF
Reference 10
usedconnected
to connectto +5 VCC 7 22 GND Supply voltage for XTAL1
GND 8 21 AREF voltage for ADC
external crystal ADC. Connect it 16MHz
(PCINT6/XTAL1/TOSC1) PB6 9 20 AVCC 1
or RC oscillator (PCINT7/XTAL2/TOSC2) PB7 10 19 PB5 (SCK/PCINT5) to VCC RESET
9
XTAL2
(PCINT21/OC0B) PD5 11 18 PB4 (MISO/PCINT4)
(PCINT22/OC0A/AIN0) PD6 12 17 PB3 (MOSI/OC2A/PCINT3) Reset 22pF
(PCINT23/AIN1) PD7 13 16 PB2 (SS/OC1B/PCINT2) Button
(PCINT0/CLKO/ICP1) PB0 14 15 PB1 (OC1A/PCINT1) 8
GND
22
GND

9/17/2023 ME4162: Microprocessor 21 9/17/2023 ME4162: Microprocessor 22


21 22
Prepared by Duong Van Lac. Email: [email protected]

AVR Programming ISP (ICSP) socket

◼ Parallel programming
◼ ISP
◼ SPI
◼ JTAG
◼ Boot loader

9/17/2023 ME4162: Microprocessor 23 9/17/2023 ME4162: Microprocessor 24


23 24

6
10/2/2023

Arduino Uno Programming Tools


AVR Studio
• Front end for all AVR tools
• C and assembly source level debugging
• Includes Atmel macro assembler
• Supports third party compilers
• Free GCC-AVR C-compiler included
• Freely available from
• http://www.atmel.com

Compilers Starter kits Programmers

IAR Systems® STK500 AVR Dragon


CodeVision -expansion cards AVRISP mkII AVRISP mkII
ImageCraft® STK600 JTAGICE mkII
-expansion cards AVR ONE!
GCC-AVR
STK1000
Rowley -expansion cards

AVR ONE

9/17/2023 ME4162: Microprocessor 25 9/17/2023 ME4162: Microprocessor 26


25 26
Prepared by Duong Van Lac. Email: [email protected]

Inside a HEX file Atmel AVRISP STK500 USB ISP


Programmer
This isType of line:
a 16-bit address; The
loader 00: therethe
places arefirst
more
bytelines
of to come after This line.
Each
howlinemanystarts
bytes
01: this is the last line
with data
area in
colon. into this memory
Real
the line.Segment address address.
Data Checksum
It can 02:
address 64k locations

Atmel AVRISP STK500

9/17/2023 ME4162: Microprocessor 27 9/17/2023 ME4162: Microprocessor 28


27 28

You might also like