The 8051 Microcontroller - Chap 1: Instructor - Lê Chí Thông
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 acquisitio
Bạn đang xem tài liệu "The 8051 Microcontroller - Chap 1: Instructor - Lê Chí Thông", để tải tài liệu gốc về máy hãy click vào nút Download ở trên.
File đính kèm:
- the_8051_microcontroller_chap_1_instructor_le_chi_thong.pdf
Nội dung text: The 8051 Microcontroller - Chap 1: Instructor - Lê Chí Thông
- ĐH Bách Khoa TP.HCM Lê Chí Thông The 8051 Microcontroller Lê Chí Thông Ref. I. Scott Mackenzie, The 8051 Microcontroller Instructor Lê Chí Thông Faculty of Electrical and Electronics Engineering Ho Chi Minh City University of Technology (HCMUT) Trường Đại Học Bách Khoa - ĐHQG TP.HCM Email: chithong@gmail.com ; chithong@hcmut.edu.vn Website: sites.google.com/site/chithong Ref. I. Scott Mackenzie Lê Chí Thông 2 sites.google.com/site/chithong 1
- ĐH Bách Khoa TP.HCM Lê Chí Thông 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 Ref. I. Scott Mackenzie Lê Chí Thông 5 Chapter 1 Introduction to Microcontrollers Ref. I. Scott Mackenzie Lê Chí Thông 6 sites.google.com/site/chithong 3
- ĐH Bách Khoa TP.HCM Lê Chí Thông FIGURE 1–2 Block diagram of a microcomputer system Architecture of computers Ref. I. Scott Mackenzie Lê Chí Thông 9 FIGURE 1–3 The central processing unit (CPU) Architecture of CPU PC- Program counter Ref. I. Scott Mackenzie Lê Chí Thông 10 sites.google.com/site/chithong 5
- ĐH Bách Khoa TP.HCM Lê Chí Thông FIGURE 1–6 Detailed block diagram of a microcomputer system Ref. I. Scott Mackenzie Lê Chí Thông 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: Motorola’s 6811, Intel’s 8051, Zilog’s Z8 and PIC 16X CPU RAM ROM A single chip Serial I/O Timer COM Port Port Ref. I. Scott MackenzieMicrocontroller Lê Chí Thông 14 sites.google.com/site/chithong 7
- ĐH Bách Khoa TP.HCM Lê Chí Thông Embedded System Sensor Sensor conditioning Output Output interfaces sensor actuator sensor Microcontroller (uC) indicator sensor Ref. I. Scott Mackenzie Lê Chí Thông 17 Representation of Number Systems • Positive radix, positional number systems • A number with radix r is represented by a string of digits: A A A A A A A A n - 1 n - 2 1 0 . - 1 - 2 - m + 1 - m A r in which 0 < i < and . is the radix point . • The string of digits represents the power series: i = n - 1 j = - 1 (Number)r = i j ()()∑ Ai r + ∑ Aj r i = 0 j = - m (Integer Portion) + (Fraction Portion) Ref. I. Scott Mackenzie Lê Chí Thông 18 sites.google.com/site/chithong 9
- ĐH Bách Khoa TP.HCM Lê Chí Thông Hexadecimal or Hex (Radix r = 16) Hexadecimal Decimal Binary Hexadecimal Decimal Binary 0 0 0000 8 8 1000 1 1 0001 9 9 1001 2 2 0010 A 10 1010 3 3 0011 B 11 1011 4 4 0100 C 12 1100 5 5 0101 D 13 1101 6 6 0110 E 14 1110 7 7 0111 F 15 1111 5 A 0 . 4 D 1 16 2 16 1 16 0 . 16 -1 16 -2 16 -3 5x16 2 10x16 1 0x16 0 . 4x16 -1 13x16 -2 1x16 -3 1280 160 0 . 0.25 0.0508 0.0002 5A0.4D1 H = 1280 + 160 + 0 + 0.25 + 0.0508 + 0.0002 = 1440.301 Ref. I. Scott Mackenzie Lê Chí Thông 21 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 1 0 0 0 . 1 0 1 B 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 Ref. I. Scott Mackenzie Lê Chí Thông 22 sites.google.com/site/chithong 11
- ĐH Bách Khoa TP.HCM Lê Chí Thông BCD (Binary Coded Decimal) Decimal BCD (8 4 2 1) 0 0 0 0 0 1 0 0 0 1 Ex: 12 = 0001 0010 (BCD) 2 0 0 1 0 39 = 0011 1001 (BCD) 3 0 0 1 1 4 0 1 0 0 5 0 1 0 1 6 0 1 1 0 7 0 1 1 1 8 1 0 0 0 9 1 0 0 1 Ref. I. Scott Mackenzie Lê Chí Thông 25 ASCII Code b6 b5 b4 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 b3b2b1b0 Hex0 1 2 3 4 5 6 7 0 0 0 0 0 NUL DLE SP 0 @ P ` p 0 0 0 1 1 SOH DC1 ! 1 A Q a q 0 0 1 0 2 STX DC2 ” 2 B R b r 0 0 1 1 3 ETX DC3 # 3 C S c s 0 1 0 0 4 EOT DC4 $ 4 D T d t 0 1 0 1 5 ENQ NAK % 5 E U e u 0 1 1 0 6 ACK SYN & 6 F V f v 0 1 1 1 7 BEL ETB ’ 7 G W g w 1 0 0 0 8 BS CAN ( 8 H X h x 1 0 0 1 9 HT EM ) 9 I Y i y 1 0 1 0 A LF SUB * : J Z j z 1 0 1 1 B VT ESC + ; K [ k { 1 1 0 0 C FF FS , N ^ n ~ 26 1 1 1 1 F SI US / ? O _ o DEL sites.google.com/site/chithong 13
- ĐH Bách Khoa TP.HCM Lê Chí Thông Applying Boolean Operations • 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) Ref. I. Scott Mackenzie Lê Chí Thông 29 Applying Boolean Operations • 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 Ref. I. Scott Mackenzie Lê Chí Thông 30 sites.google.com/site/chithong 15
- ĐH Bách Khoa TP.HCM Lê Chí Thông 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 Ref. I. Scott Mackenzie Lê Chí Thông 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 – 5CH shifted right is 2EH • 92 / 2 = 46 (remainder if any is thrown away) Ref. I. Scott Mackenzie Lê Chí Thông 34 sites.google.com/site/chithong 17
- ĐH Bách Khoa TP.HCM Lê Chí Thông RAM and ROM • 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 Ref. I. Scott Mackenzie Lê Chí Thông 37 RAM and ROM RAM ROM Ref. I. Scott Mackenzie Lê Chí Thông 38 sites.google.com/site/chithong 19