8051 chap1 introduction VI XỬ LÝ

20 1 0
8051 chap1 introduction VI XỬ LÝ

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Đ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 sites.google.com/site/chithong Lê Chí Thơng ĐH Bách Khoa TP.HCM 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 acquisition Ref I Scott Mackenzie Lê Chí Thơng Grading • Quizzes and homework assignments: 20% – Homework is due at the beginning of class • Mid-term: 30% • Final: 50% Ref I Scott Mackenzie sites.google.com/site/chithong Lê Chí Thơng Đ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 Chapter Introduction to Microcontrollers Ref I Scott Mackenzie sites.google.com/site/chithong Lê Chí Thơng ĐH Bách Khoa TP.HCM Lê Chí Thơng These are … embedded systems An embedded system is a system in which a processor/microcontroller/computer is embedded to perform a specific task orLê Chítasks Ref I Scott Mackenzie Thơng Microprocessors • Integrated ALU and CU • No RAM, ROM, I/O on CPU chip itself • Example: Intel’s x86, Motorola’s 680x0 Control Unit (CU) Arithmetic Logical Unit (ALU) Central Processing Unit (CPU) CPU GeneralPurpose Microprocessor Many chips on mother’s board Data Bus RAM ROM I/O Port Timer Serial Port Address Bus General-Purpose Microprocessor System Lê Chí Thơng Ref I Scott Mackenzie sites.google.com/site/chithong ĐH Bách Khoa TP.HCM FIGURE 1–2 Lê Chí Thơng Block diagram of a microcomputer system Architecture of computers Ref I Scott Mackenzie FIGURE 1–3 Lê Chí Thông The central processing unit (CPU) Architecture of CPU PCProgram counter Ref I Scott Mackenzie sites.google.com/site/chithong Lê Chí Thơng 10 ĐH Bách Khoa TP.HCM FIGURE 1–4 Lê Chí Thông Bus activity for an opcode fetch cycle Opcode fetch, decode, execution Ref I Scott Mackenzie FIGURE 1–5 Lê Chí Thông 11 Levels of software Shell, GUI – user - hardware Utilities Booster loader, BIOS Keyboard, monitor Other hardwires Ref I Scott Mackenzie sites.google.com/site/chithong Lê Chí Thơng 12 ĐH Bách Khoa TP.HCM FIGURE 1–6 Lê Chí Thơng 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 I/O Port Serial Timer COM Port Microcontroller Ref I Scott Mackenzie sites.google.com/site/chithong A single chip Lê Chí Thơng 14 ĐH Bách Khoa TP.HCM Lê Chí Thông Microcontroller Architectures Memory Address Bus CPU Program + Data Data Bus 2n Von Neumann Architecture Memory Address Bus Fetch Bus CPU Program Address Bus Data Bus Ref I Scott Mackenzie Harvard Architecture Data Lê Chí Thơng 15 Embedded System • Embedded system: the processor is embedded into that application • An embedded product usually uses a microcontroller to one task only • In an embedded system, there is only one application software that is typically burned into ROM Ref I Scott Mackenzie sites.google.com/site/chithong Lê Chí Thơng 16 ĐH Bách Khoa TP.HCM Lê Chí Thơng Embedded System sensor Output interfaces Sensor conditioning sensor Microcontroller (uC) actuator 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: An - 1An - … A1A0 A- A- … A- m + A- m in which < Ai < r and is the radix point • The string of digits represents the power series: (∑ i=n-1 (Number)r = j=-1 ) (∑ i Ai r + i=0 j=-m (Integer Portion) Ref I Scott Mackenzie sites.google.com/site/chithong ) Aj r j Lê Chí Thơng + (Fraction Portion) 18 ĐH Bách Khoa TP.HCM Lê Chí Thơng Representation of Number Systems General Radix (Base) Digits Powers of Radix -1 -2 -3 -4 -5 Decimal Binary r 10 => r - => => r0 r1 r2 r3 r4 r5 r -1 r -2 r -3 r -4 r -5 10 100 1000 10,000 100,000 0.1 0.01 0.001 0.0001 0.00001 16 32 0.5 0.25 0.125 0.0625 0.03125 Ref I Scott Mackenzie Lê Chí Thơng 19 Decimal (Radix r = 10) 102 101 100 10-1 10-2 10-3 4x102 0x101 7x100 6x10-1 2x10-2 5x10-3 400 0.6 0.02 0.005 400 + + + 0.6 + 0.02 + 0.005 = 407.625 Binary (Radix r = 2) 1 1 22 21 20 2-1 2-2 2-3 1x22 0x21 1x20 0x2-1 1x2-2 1x2-3 0.25 0.125 101.011 B = + + + + 0.25 + 0.125 = 5.375 Ref I Scott Mackenzie sites.google.com/site/chithong Lê Chí Thơng 20 10 ĐH Bách Khoa TP.HCM Lê Chí Thơng Hexadecimal or Hex (Radix r = 16) Hexadecimal Decimal Binary Hexadecimal Decimal 0000 0001 0010 0011 0100 0101 0110 0111 A B C D E F Binary 10 11 12 13 14 15 1000 1001 1010 1011 1100 1101 1110 1111 A D 162 161 160 16-1 16-2 16-3 5x162 10x161 0x160 4x16-1 13x16-2 1x16-3 1280 160 0.25 0.0508 0.0002 5A0.4D1 H = 1280 + 160 + +Lê0.25 + 0.0508 + 0.0002 = 1440.301 Ref I Scott Mackenzie Chí Thơng 21 Converting decimal to binary 625 D = ? B :2 = :2 = :2 = :2= remainder remainder remainder remainder 0 1 0 1 B 0.625 x = 1.25 save the integer digit 0.25 x = 0.5 save the integer digit 0.5 x = 1.0 save the integer digit Ref I Scott Mackenzie sites.google.com/site/chithong Lê Chí Thơng 22 11 ĐH Bách Khoa TP.HCM Lê Chí Thông Converting decimal to hex 1480.4296875D=?H 1480 : 16 = 92 remainder 92 : 16 = remainder 12 : 16 = remainder 5 C E H 0.4296875 x 16 = 6.875 save the integer digit 0.875 x 16 = 14.0 save the integer digit 14 Ref I Scott Mackenzie Lê Chí Thông 23 Converting binary to hex 0 1 1 1 1 1 1 10 B B D E A H Converting binary to octal C H 01011001001.11101000 B Ref I Scott Mackenzie sites.google.com/site/chithong Lê Chí Thơng 24 12 ĐH Bách Khoa TP.HCM Lê Chí Thơng BCD (Binary Coded Decimal) Decimal BCD (8 1) 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 Ref I Scott Mackenzie Ex: 12 = 0001 0010 (BCD) 39 = 0011 1001 (BCD) Lê Chí Thơng 25 ASCII Code b6 b5 b4 b3b2b1b0 Hex 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1 Mackenzie 10 Ref I Scott 1111 sites.google.com/site/chithong A B C D E F 000 001 010 011 100 101 110 111 NUL SOH STX ETX EOT ENQ ACK BEL BS HT LF VT FF CR SO SI DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US SP ! ” # $ % & ’ ( ) * : + ; , < = Lê Chí Thơng > / ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ 26 DEL 13 ĐH Bách Khoa TP.HCM Lê Chí Thơng Boolean (Logical) Operations a NOT a a b a AND b 0 0 1 0 1 a b a OR b a b a XOR b 0 0 0 1 1 1 1 1 1 Ref I Scott Mackenzie Lê Chí Thơng 27 Applying Boolean Operations • 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 = (domination) – x AND = x (identity) Ref I Scott Mackenzie sites.google.com/site/chithong Lê Chí Thơng 28 14 Đ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 = x (identity) – x OR = (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 = x (identity) – x XOR = NOT x Ref I Scott Mackenzie sites.google.com/site/chithong Lê Chí Thơng 30 15 ĐH Bách Khoa TP.HCM Lê Chí Thơng Combining Bits in Separate Bytes • Bit patterns from two bytes are to be combined – The important bits of each byte must be aligned with (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 Ref I Scott Mackenzie Lê Chí Thơng 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 Ref I Scott Mackenzie sites.google.com/site/chithong Lê Chí Thơng 32 16 Đ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 – Right shift is equivalent to division by – 5CH shifted left becomes B8H • 92 * = 184 – 5CH shifted right is 2EH • 92 / = 46 (remainder if any is thrown away) Ref I Scott Mackenzie sites.google.com/site/chithong Lê Chí Thơng 34 17 ĐH Bách Khoa TP.HCM Lê Chí Thơng Multiplication Tricks • Every multiplication can be accomplished by shifting and adding – Just regroup using only multiplications by powers of and additions • 10 * n = (8 + 2) * n • =8*n+2*n – or • 10 * n = (2 * (4 + 1)) n • = * (4 * n + n) Ref I Scott Mackenzie Lê Chí Thơng 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 are usually shown in hexadecimal Ref I Scott Mackenzie sites.google.com/site/chithong Lê Chí Thơng 0000 0001 0002 0003 0004 0005 3F 2C 41 FF 00 1E Data values are usually bytes 36 18 Đ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 Ref I Scott Mackenzie sites.google.com/site/chithong ROM Lê Chí Thơng 38 19 ĐH Bách Khoa TP.HCM Lê Chí Thơng References • 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 Internet khơng trích dẫn khơng ghi tác giả Ref I Scott Mackenzie sites.google.com/site/chithong Lê Chí Thơng 39 20

Ngày đăng: 13/04/2023, 08:09

Tài liệu cùng người dùng

Tài liệu liên quan