Professional Documents
Culture Documents
PT 1
PT 1
Part I--Introduction
Jason J. Gu
Department of Electrical and Computer Engineering
Dalhousie University
Outline
1
I: Introduction of the Computer
2
von Neumann architecture
Computer Categories
Mainframe computers
Original means huge size, now means very
fast, high reliable, extensive I/O, Backward
Compatible
Minicomputers
Smaller than Mainframe, appeared in 1960s
Microcomputers
Uses a microprocessor as its CPU
Supercomputers
Super fast, using multiple processor
3
Computer Hardware Organization
4
An ALU Example
The Microprocessor
10
5
The Microcontroller (MCU)
11
12
6
IV: Memory
13
14
7
Semiconductor Memory (cont’d.)
Read-only memory
Nonvolatile
Only allows data to be read (some exceptions)
Types: mask-programmed read-only memory
(MROM), programmable read-only memory
(PROM), erasable programmable read-only
memory (EPROM), electrically erasable
programmable read-only memory (EEPROM),
flash memory
15
Memory-System Operation
16
8
FIGURE 1.4 Block diagram of a simplified memory system
17
Read operation
Processor sends memory address of location to be
accessed; applies logic 1 (high voltage) to RD signal
and logic 0 to WR signal
Memory system decodes address; address contents
sent to data bus; read by processor
18
9
Memory-System Operation (cont’d.)
Write operation
Processor: data placed on data bus, address placed
on address bus; logic 1 applied to WR signal, logic 0
to RD signal
Memory system: address decoded; value on data bus
written to location
19
V: Program Execution
20
10
Program Execution (cont’d.)
21
22
11
FIGURE 1.6 A simplified block diagram of the program
counter (PC) of an 8-bit microcontroller
23
24
12
Program Execution (cont’d.)
25
26
13
VI: Introduction to AVR Microcontroller
27
28
14
The AVR Memory Space (cont’d.)
29
30
15
The AVR CPU Register
31
32
16
The AVR CPU Register (cont’d.)
The extended indirect register (EIND):
supports extended indirect subroutine call
and indirect jump in devices with program
memory larger than 128 kB
33
34
17
Figure 2.9 The SREG register
35
36
18
X: AVR Addressing Modes
1. Register direct mode: five bits used to
specify register to be worked on
Example:
sub r0,r1 ;r0←[r0]-[r1]
or r2,r3 ;r2←[r2]|[r3]
inc r4 ;r4←[r4]+1
Note:
[ ] to refer to the content of a register or a mem location
mem(addr) refer to a data memory location
pmem(addr) refer to a program memory location
37
38
19
AVR Addressing Modes
39
40
20
AVR Addressing Modes (cont’d.)
41
42
21
AVR Addressing Modes (cont’d.)
43
44
22
AVR Addressing Modes (cont’d.)
9. Program memory with post-increment
using the LPM Z+ and ELPM Z+ instructions
LPM Z+: uses Z pointer to specify program
memory location to access; Z pointer
incremented after the access
ELPM Z+: uses concatenation of RAMPZ and Z
for program memory access; Z pointer
incremented after the access
example:
lpm r0,Z+ ; r0←[[Z]] ;Z←[Z]+1
elpm r1,Z+ ; r1←[[RAMPZ:Z]]; Z←Z+1
Electrical and Computer Engineering
Dalhousie University 45
45
46
23
AVR Addressing Modes (cont’d.)
47
48
24
A Sample of AVR Instructions
49
50
25
Table 2.1 Instructions to transfer data from data memory to register
51
52
26
Table 2.2 Instructions to store the contents of a register in data memory
53
Table 2.3 Instructions to transfer data between a register and the program memory
54
27
A Sample of AVR Instructions (cont’d.)
Addition instruction
Note:
Adiw rd,k; this instruction adds the constant k (0-63) to the register pair rd+1:rd and
place the results in the register pair rd+1:rd , rd can only be 24,26,28,30
55
Subtract instructions
Note:
sbiw rd,k; this instruction subtract the constant k (0-63) from the register pair
rd+1:rd and place the results in the register pair rd+1:rd , rd can only be 24,26,28,30
56
28
Electrical and Computer Engineering
Dalhousie University 57
57
29