Microprocessing Systems - Chapter 1: Introduction to Microcontrollers - Lê Chí Thông

• Integrates CPU, RAM, ROM, I/O ports, on a

single chip

• Sometimes called a "computer on a chip"

• Typically used in embedded applications

• Example: Motorola’s 6811, Intel’s 8051, Zilog’s Z8

and PIC 16X

pdf19 trang | Chuyên mục: Vi Xử Lý – Vi Điều Khiển | Chia sẻ: tuando | Lượt xem: 498 | Lượt tải: 0download
Tóm tắt nội dung Microprocessing Systems - Chapter 1: Introduction to Microcontrollers - Lê Chí Thông, để xem tài liệu hoàn chỉnh bạn click vào nút "TẢI VỀ" ở trên
a chip" 
• Typically used in embedded applications 
• Example: Motorola’s 6811, Intel’s 8051, Zilog’s Z8 
and PIC 16X 
 RAM ROM 
I/O 
Port 
Timer 
Serial 
COM 
Port 
Microcontroller 
CPU 
A single chip 
Microcontrollers 
12 Lê Chí Thông Ref. I. Scott Mackenzie 
ĐH Bách Khoa TP.HCM Lê Chí Thông 
sites.google.com/site/chithong 7 
CPU 
Program 
+ Data 
Address Bus 
Data Bus 
Memory 
Von Neumann 
Architecture 
CPU 
Program 
Address Bus 
Data Bus 
Harvard 
Architecture 
Memory 
Data 
Address Bus 
Fetch Bus 
0 
0 
0 
2n 
Microcontroller Architectures 
13 Lê Chí Thông Ref. I. Scott Mackenzie 
• 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 
Embedded System 
14 Lê Chí Thông Ref. I. Scott Mackenzie 
ĐH Bách Khoa TP.HCM Lê Chí Thông 
sites.google.com/site/chithong 8 
Embedded System 
Microcontroller 
(uC) 
sensor 
S
e
n
s
o
r c
o
n
d
itio
n
in
g
O
u
tp
u
t in
te
rfa
c
e
s
actuator 
indicator 
sensor 
sensor 
15 Lê Chí Thông Ref. I. Scott Mackenzie 
• Positive radix, positional number systems 
• A number with radix r is represented by a string of 
digits: 
 An - 1An - 2  A1A0 . A- 1 A- 2  A- m + 1 A- m 
in which 0 < Ai < r and . is the radix point. 
• The string of digits represents the power series: 
( ) ( ) (Number)r =   + 
j = - m 
j 
j 
i 
i = 0 
i r A r A 
 (Integer Portion) + (Fraction Portion) 
i = n - 1 j = - 1 
Representation of Number Systems 
16 Lê Chí Thông Ref. I. Scott Mackenzie 
ĐH Bách Khoa TP.HCM Lê Chí Thông 
sites.google.com/site/chithong 9 
General Decimal Binary 
Radix (Base) r 10 2 
Digits 0 => r - 1 0 => 9 0 => 1 
0 
1 
2 
3 
Powers of 4 
Radix 5 
-1 
-2 
-3 
-4 
-5 
r0 
r1 
r2 
r3 
r4 
r5 
r -1 
r -2 
r -3 
r -4 
r -5 
1 
10 
100 
1000 
10,000 
100,000 
0.1 
0.01 
0.001 
0.0001 
0.00001 
1 
2 
4 
8 
16 
32 
0.5 
0.25 
0.125 
0.0625 
0.03125 
Representation of Number Systems 
17 Lê Chí Thông Ref. I. Scott Mackenzie 
400 + 0 + 7 + 0.6 + 0.02 + 0.005 = 407.625 
4 0 7 . 6 2 5 
102 101 100 . 10-1 10-2 10-3 
4x102 0x101 7x100 . 6x10-1 2x10-2 5x10-3 
400 0 7 . 0.6 0.02 0.005 
Decimal (Radix r = 10) 
Binary (Radix r = 2) 
1 0 1 . 0 1 1 
101.011 B = 4 + 0 + 1 + 0 + 0.25 + 0.125 = 5.375 
22 21 20 . 2-1 2-2 2-3 
1x22 0x21 1x20 . 0x2-1 1x2-2 1x2-3 
4 0 1 . 0 0.25 0.125 
18 Lê Chí Thông Ref. I. Scott Mackenzie 
ĐH Bách Khoa TP.HCM Lê Chí Thông 
sites.google.com/site/chithong 10 
Hexadecimal or Hex (Radix r = 16) 
Hexadecimal Decimal Binary Hexadecimal Decimal Binary 
0 
1 
2 
3 
4 
5 
6 
7 
0 
1 
2 
3 
4 
5 
6 
7 
0000 
0001 
0010 
0011 
0100 
0101 
0110 
0111 
8 
9 
A 
B 
C 
D 
E 
F 
8 
9 
10 
11 
12 
13 
14 
15 
1000 
1001 
1010 
1011 
1100 
1101 
1110 
1111 
5 A 0 . 4 D 1 
5A0.4D1 H = 1280 + 160 + 0 + 0.25 + 0.0508 + 0.0002 = 1440.301 
162 161 160 . 16-1 16-2 16-3 
5x162 10x161 0x160 . 4x16-1 13x16-2 1x16-3 
1280 160 0 . 0.25 0.0508 0.0002 
19 Lê Chí Thông Ref. I. Scott Mackenzie 
Converting decimal to binary 
8 . 625 D = ? B 
8 : 2 = 4 remainder 0 
4 : 2 = 2 remainder 0 
2 : 2 = 1 remainder 0 
1 : 2 = 0 remainder 1 
0.625 x 2 = 1.25 save the integer digit 1 
0.25 x 2 = 0.5 save the integer digit 0 
0.5 x 2 = 1.0 save the integer digit 1 
1 0 0 0 . 1 0 1 B 
20 Lê Chí Thông Ref. I. Scott Mackenzie 
ĐH Bách Khoa TP.HCM Lê Chí Thông 
sites.google.com/site/chithong 11 
1 4 8 0 . 4 2 9 6 8 7 5 D = ? H 
1480 : 16 = 92 remainder 8 
 92 : 16 = 5 remainder 12 
 5 : 16 = 0 remainder 5 
0.4296875 x 16 = 6.875 save the integer digit 6 
0.875 x 16 = 14.0 save the integer digit 14 
5 C 8 . 6 E H 
Converting decimal to hex 
21 Lê Chí Thông Ref. I. Scott Mackenzie 
 1 1 1 0 1 1 0 1 0 1 1 1 0 1 . 0 1 1 0 1 0 1 B 0 0 0
 . 6 A H 
 2 C 9 . E 8 H 
 0 0 1 0 1 1 0 0 1 0 0 1 . 1 1 1 0 1 0 0 0 B 
 3 B 5 D 
Converting binary to hex 
Converting binary to octal 
22 Lê Chí Thông Ref. I. Scott Mackenzie 
ĐH Bách Khoa TP.HCM Lê Chí Thông 
sites.google.com/site/chithong 12 
BCD (Binary Coded Decimal) 
Decimal 
0 
1 
2 
3 
4 
5 
6 
7 
8 
9 
BCD 
(8 4 2 1) 
0 0 0 0 
0 0 0 1 
0 0 1 0 
0 0 1 1 
0 1 0 0 
0 1 0 1 
0 1 1 0 
0 1 1 1 
1 0 0 0 
1 0 0 1 
Ex: 12 = 0001 0010 (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í Thông Ref. I. Scott Mackenzie 
26 
• Force a bit or bits to zero 
– Sometimes called "masking out bits" 
• Use a "mask" byte with 
– 0's in positions to be cleared (forced to 0) 
– 1's in positions to be unchanged 
• Perform an AND with the mask 
– x AND 0 = 0 (domination) 
– x AND 1 = x (identity) 
Applying Boolean Operations 
Lê Chí Thông Ref. I. Scott Mackenzie 
ĐH Bách Khoa TP.HCM Lê Chí Thông 
sites.google.com/site/chithong 14 
27 
• Force a bit or bits to one 
– Sometimes called "setting bits" 
• Use a "mask" byte with 
– 1's in positions to be set (forced to 1) 
– 0's in positions to be unchanged 
• Perform an OR with the mask 
– x OR 0 = x (identity) 
– x OR 1 = 1 (domination) 
Applying Boolean Operations 
Lê Chí Thông Ref. I. Scott Mackenzie 
28 
• Toggle a bit or bits 
– Sometimes called "flipping or complementing 
bits" 
• Use a "mask" byte with 
– 1's in positions to be toggled (complemented) 
– 0's in positions to be unchanged 
• Perform an XOR with the mask 
– x XOR 0 = x (identity) 
– x XOR 1 = NOT x 
Applying Boolean Operations 
Lê Chí Thông Ref. I. Scott Mackenzie 
ĐH Bách Khoa TP.HCM Lê Chí Thông 
sites.google.com/site/chithong 15 
29 
• Bit patterns from two bytes are to be combined 
– The important bits of each byte must be aligned with 0 (and 
unimportant) bits in the other byte 
• The OR of the two bytes, combines them into one 
– The bold bits are the important ones: 
 00110000 
OR 00001010 
 00111010 
Combining Bits in Separate Bytes 
Lê Chí Thông Ref. I. Scott Mackenzie 
30 
• 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 
Shifting 
Lê Chí Thông Ref. I. Scott Mackenzie 
ĐH Bách Khoa TP.HCM Lê Chí Thông 
sites.google.com/site/chithong 16 
31 
• 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 
Rotating 
Lê Chí Thông Ref. I. Scott Mackenzie 
32 
• 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 
– 5CH shifted right is 2EH 
• 92 / 2 = 46 (remainder if any is thrown away) 
Application of Shifts 
Lê Chí Thông Ref. I. Scott Mackenzie 
ĐH Bách Khoa TP.HCM Lê Chí Thông 
sites.google.com/site/chithong 17 
33 
• 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) 
Multiplication Tricks 
Lê Chí Thông Ref. I. Scott Mackenzie 
• 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 
bytes or words 
0000 3F 
0001 2C 
0002 41 
0003 FF 
0004 00 
0005 1E 
Addresses 
are usually 
shown in 
hexadecimal 
Data values 
are usually 
bytes 
Memory 
34 Lê Chí Thông Ref. I. Scott Mackenzie 
ĐH Bách Khoa TP.HCM Lê Chí Thông 
sites.google.com/site/chithong 18 
35 
• RAM: Random Access Memory 
– Access time does not vary by address 
– Read & write memory 
– Typically volatile 
• ROM: Read Only Memory 
– Also a random access memory 
– Retains data even when power is removed 
RAM and ROM 
Lê Chí Thông Ref. I. Scott Mackenzie 
36 
RAM and ROM 
RAM ROM 
Lê Chí Thông Ref. I. Scott Mackenzie 
ĐH Bách Khoa TP.HCM Lê Chí Thông 
sites.google.com/site/chithong 19 
37 
References 
Lê Chí Thông 
• I. Scott Mackenzie, The 8051 Microcontroller 
• Nguyễn Trọng Luật, Bài giảng Kỹ Thuật Số 
• Các tài liệu trên Internet không trích dẫn hoặc không ghi tác 
giả 
Ref. I. Scott Mackenzie 

File đính kèm:

  • pdfmicroprocessing_systems_chapter_1_introduction_to_microcontr.pdf