Chapter 1 The AVR Microcontroller and Embedded Systems Using Assembly and C
Chapter 1 The AVR Microcontroller and Embedded Systems Using Assembly and C
Introduction to Computing
Chapter 0
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
Topics
www. Micro Digital Ed. com BIHE university
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
Output
E.g. LCD, printer, hands of a robot
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
Memory
www. Micro Digital Ed. com BIHE university
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
Memory characteristics
www. Micro Digital Ed. com BIHE university
Capacity
The number of bits that a memory can store.
E.g. 128 Kbits, 256 Mbits
Organization
E.g. a 128 x 4 memory has 128 locations, 4 bits each
128 locations
4 bits
0 1 2
Access time
How long it takes to get data from memory
127
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
Semiconductor memories
www. Micro Digital Ed. com BIHE university
ROM
Mask ROM PROM (Programmable
ROM)
RAM
)Static RAM( SRAM
)Dynamic RAM( DRAM Nonvolatile ( NV-RAM )RAM
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
Memory\ROM\
www. Micro Digital Ed. com
Mask ROM
BIHE university
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
Memory\ROM\
www. Micro Digital Ed. com
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
Memory\ROM\
www. Micro Digital Ed. com
UV-EPROM
You can shine ultraviolet (UV) radiation to erase it Erasing takes up to 20 minutes The entire contents of ROM are erased
2764
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
Memory\ROM\
Erased Electrically
VCC WE NC
8K x 8
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
Memory\ROM\
www. Micro Digital Ed. com
Flash ROM
BIHE university
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
Semiconductor memories
www. Micro Digital Ed. com BIHE university
ROM
Mask ROM PROM (Programmable
ROM)
RAM
)Static RAM( SRAM
)Dynamic RAM( DRAM Nonvolatile ( NV-RAM )RAM
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
Memory\RAM\
www. Micro Digital Ed. com
2K x 8
SRAM
Disadvantages:
High power consumption Expensive
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
Memory\RAM\
www. Micro Digital Ed. com
Disadvantages:
Slower Refresh needed
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
Memory\RAM\
www. Micro Digital Ed. com
Disadvantage:
Expensive
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
Tasks:
It should execute instructions
It should recall the instructions one after another and execute them
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
VCC
WE
OE CS
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
BIHE university
GND 8 D0-D7
VCC
CPU
n A0-An-1 WE OE CS
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
Mouse
Network
CPU
Keyboard
Graphic Card
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
Sound Card
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
Address bus
Data bus
Control bus Read
Write
CPU
I/O 0
I/O 1 I/O 2 I/O n
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
CPU
n 8
I/O 0
VCC
I/O 1
I/O 2
I/O n
VCC
WE OE CS
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
VCC
0 1 2
WE
OE
Address bus
Data bus
Write Control bus Read
CPU
I/O 0 I/O 1
I/O 2 I/O n
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
CS
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
VCC
0 1 ..
A0-An-1
GND
D0-D7
63
WE
OE
Address bus
Data bus
Write Read Control bus IO/MEM
CPU
I/O 0 I/O 1
I/O 2 I/O n
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
CS
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
Connecting I/Os and Memory to CPU using bus (Memory Mapped I/O)
www. Micro Digital Ed. com BIHE university
0 1 ..
A0-An-1
GND
D0-D7
WE
OE
15
VCC
Logic circuit
Address bus
CPU
a7 a6 a5 a4 a3 a2 a1 a0
I/O 17
a4 I/O a5 18 a6 a7
CS
I/O n CS
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
a11 a10 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0
a8 a9 a10 a11
CS
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
CPU
Instruction decoder
C D
registers
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
0 1
VCC
2 3 4 5
BIHE university
A0-An-1
GND
D0-D7
WE
OE
Logic circuit
ALU
CPU
PC:
1 0
A B C
D
Inst. Dec.
registers
I/O 16
I/O 17
CS
I/O 18
I/O n
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
0 1
VCC
2 3 4 5
BIHE university
A0-An-1
GND
D0-D7
WE
OE
Logic circuit
ALU
CPU
PC:
1
31
A B C
9
D
Inst. Dec.
registers
I/O 16
I/O 17
CS
I/O 18
I/O n
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
0 1
VCC
2 3 4 5
BIHE university
A0-An-1
GND
D0-D7
WE
OE
6 Address bus 17
Logic circuit
Data bus
Write Control bus Read
ALU
CPU
PC:
1 2 3
9 A B
D
Inst. Dec.
registers
I/O 16
I/O 17
CS
I/O 18
I/O n
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
0 1
VCC
2 3 4 5
BIHE university
A0-An-1
GND
D0-D7
WE
OE
7
Eh
Logic circuit
ALU
CPU
PC:
4 3 5
A 9 B C
E 5
D
Inst. Dec.
registers
I/O 16
I/O 17
CS
I/O 18
I/O n
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
Opcode
Operand Instruction
Opcode
Operand
Instruction
Operation Code 000
0011 0001
1100 0100 0010 0110 1000 0001 1110 1010 0000 0000 0000 0101 0 1 2 3 4 5 6 7 31h C4h 26h 81h EAh 0h 5h
100
101 110 111
A A + register (x)
AAx Register (xH) Register (xL) [x] A
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.
Code Memory
Code Memory
Data Memory
Data bus
CPU
Harvard architecture
AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi
2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.