Professional Documents
Culture Documents
HCM
L Ch Thng-www.tinyurl.com/thongchile
Instructor
L Ch Thng Faculty of Electrical and Electronics Engineering Ho Chi Minh City University of Technology (i Hc Bch Khoa TP.HCM) Email: chithong@gmail.com; chithong@hcmut.edu.vn Website: www.tinyurl.com/thongchile
L Ch Thng
L Ch Thng-www.tinyurl.com/thongchile
Objectives
Introduction fundamentals and applications of microprocessors and microcomputers. Architecture, the instruction set, and applications of 8051 microcontroller family Basic applications of microprocessors, such as input/output, analog-digital conversion (ADC), and digital-analog conversion (DAC), and data acquisition.
L Ch Thng
Grading
Quizzes and homework assignments: 20%
Homework is due at the beginning of class
L Ch Thng
L Ch Thng-www.tinyurl.com/thongchile
Textbooks
The 8051 Microcontroller, 2nd Edition, I. Scott MacKenzie, Prentice-Hall, 1995 The 8051 Microcontroller: Architecture, Programming, and Applications, Kenneth J. Ayala, West Publishing Company
L Ch Thng
L Ch Thng
L Ch Thng-www.tinyurl.com/thongchile
These are
embedded systems
An embedded system is a system in which a processor/microcontroller/computer is embedded to perform a specific task or Ch Thng tasks Ref. I. Scott Mackenzie L
Microprocessors
Integrated ALU and CU No RAM, ROM, I/O on CPU chip itself Example: Intels x86, Motorolas 680x0
Control Unit (CU)
CPU
GeneralPurpose Microprocessor
RAM
ROM
I/O Port
Timer
Address Bus
Ref. I. Scott Mackenzie
L Ch Thng-www.tinyurl.com/thongchile
FIGURE 12
Architecture of computers
L Ch Thng
FIGURE 13
Architecture of CPU
PCProgram counter
L Ch Thng
10
L Ch Thng-www.tinyurl.com/thongchile
FIGURE 14
L Ch Thng
11
FIGURE 15
Levels of software
Utilities
L Ch Thng
12
L Ch Thng-www.tinyurl.com/thongchile
FIGURE 16
L Ch Thng
13
Microcontrollers
Integrates CPU, RAM, ROM, I/O ports, on a single chip Sometimes called a "computer on a chip" Typically used in embedded applications Example: Motorolas 6811, Intels 8051, Zilogs Z8 and PIC 16X
CPU I/O Port RAM ROM Serial Timer COM Port
L Ch Thng
A single chip
Microcontroller
14
L Ch Thng-www.tinyurl.com/thongchile
Microcontroller Architectures
Memory
Program + Data
2n Memory
Program
Harvard Architecture
Data
L Ch Thng 15
Embedded System
Embedded system: the processor is embedded into that application. An embedded product usually uses a microcontroller to do one task only. In an embedded system, there is only one application software that is typically burned into ROM
L Ch Thng
16
L Ch Thng-www.tinyurl.com/thongchile
Embedded System
Sensor conditioning
Output interfaces
sensor
actuator
sensor
Microcontroller (uC)
indicator
sensor
L Ch Thng
17
i=n-1
Ai r i +
+
L Ch Thng
) (
j=-1
Aj r j
)
18
i=0
j=-m
(Integer Portion)
Ref. I. Scott Mackenzie
(Fraction Portion)
L Ch Thng-www.tinyurl.com/thongchile
Decimal 10 0 => 9 1 10 100 1000 10,000 100,000 0.1 0.01 0.001 0.0001 0.00001
L Ch Thng
r 0 => r - 1 r0 r1 r2 r3 r4 r5 r -1 r -2 r -3 r -4 r -5
0
101 0x101 0
7
100 7x100 7
.
. . .
6
10-1 6x10-1 0.6
2
10-2 2x10-2 0.02
5
10-3 5x10-3 0.005
0
21 0x21 0
1
20 1x20 1
.
. . .
0
2-1 0x2-1 0
1
2-2 1x2-2 0.25
1
2-3 1x2-3 0.125
10
L Ch Thng-www.tinyurl.com/thongchile
5
162 5x162 1280
A
161 10x161 160
0
160 0x160 0
.
. . .
4
16-1 4x16-1 0.25
D
16-2 13x16-2 0.0508
1
16-3 1x16-3 0.0002
5A0.4D1 H = 1280 + 160 + 0 +L0.25 + 0.0508 + 0.0002 = 1440.301 Ref. I. Scott Mackenzie Ch Thng 21
11
L Ch Thng-www.tinyurl.com/thongchile
5 C 8 . 6 E H 0.4296875 x 16 = 6.875 save the integer digit 6 0.875 x 16 = 14.0 save the integer digit 14
L Ch Thng
23
0 0 1 1 1 0 1 1 0 1 0 1 1 1 0 1 . 0 1 1 0 1 0 10 B 3 B 5 D . 6 A H
0 01011001001.11101000 B
Ref. I. Scott Mackenzie L Ch Thng 24
12
L Ch Thng-www.tinyurl.com/thongchile
Ex:
L Ch Thng
25
ASCII Code
b6 b5 b4 000 b3b2b1b0 Hex 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 Ref. I. Scott Mackenzie 1111 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 NUL SOH STX ETX EOT ENQ ACK BEL BS HT LF VT FF CR SO SI 001 1 DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US 010 2 011 3 100 4 @ A B C D E F G H I J K L M N O 101 5 P Q R S T U V W X Y Z [ \ ] ^ _ 110 6 ` a b c d e f g h i j k l m n o 111 7 p q r s t u v w x y z { | } ~ 26 DEL
13
L Ch Thng-www.tinyurl.com/thongchile
b 0 1 0 1
b 0 1 0 1
a AND b 0 0 0 1
a XOR b 0 1 1 0
27
b 0 1 0 1
a OR b 0 1 1 1
L Ch Thng
a 0 0 1 1
L Ch Thng
28
14
L Ch Thng-www.tinyurl.com/thongchile
L Ch Thng
29
15
L Ch Thng-www.tinyurl.com/thongchile
L Ch Thng
31
Shifting
Move bits in a byte to the left or right
11011100 shifted left is 10111000 11011100 shifted right is 01101110
In these examples, a zero (0) was brought in to fill the vacated position
Variations on the basic shift fill this position differently
L Ch Thng
32
16
L Ch Thng-www.tinyurl.com/thongchile
Rotating
Move bits in a byte to the left or right in a circular pattern
11011100 rotated left is 10111001 11011100 rotated right is 01101110
In these examples, the bit shifted out is used to fill the vacated position
There are some variations of this behavior as well
L Ch Thng
33
Application of Shifts
When a byte (or word) is interpreted numerically (as a binary representation of a number)
Left shift is equivalent to multiplication by 2 Right shift is equivalent to division by 2 5CH shifted left becomes B8H
92 * 2 = 184
L Ch Thng
34
17
L Ch Thng-www.tinyurl.com/thongchile
Multiplication Tricks
Every multiplication can be accomplished by shifting and adding
Just regroup using only multiplications by powers of 2 and additions
10 * n = (8 + 2) * n =8*n+2*n
or
10 * n = (2 * (4 + 1)) n = 2 * (4 * n + n)
L Ch Thng
35
Memory
A computer system component that allows the storage and retrieval of data Main memory is usually called RAM Memory is usually organized as a table of Addresses bytes or words
Ref. I. Scott Mackenzie L Ch Thng
3F 2C 41 FF 00 1E
Data values are usually bytes
36
18
L Ch Thng-www.tinyurl.com/thongchile
L Ch Thng
37
L Ch Thng
38
19
L Ch Thng-www.tinyurl.com/thongchile
References
I. Scott Mackenzie, The 8051 Microcontroller Nguy n Tr ng Lu t, Bi gi ng K Thu t S Cc ti li u trn Internet khng trch d n ho c khng ghi tc gi
L Ch Thng
39
20