  # Sách Học Vi Xử Lý Cực Hay Cho Người Bắt Đầu Học

Chia sẻ: Mai Luong | Ngày: | Loại File: PDF | Số trang:0 213
lượt xem
85

NỘI DUNG Giới thiệu cho máy tính vi điều khiển 8051 hội Hướng dẫn Ngôn ngữ Chi nhánh lập trình I / O Port Lập trình 8051 Giải quyết chế độ số học logic Hướng dẫn Chương Trình 8051 Lập trình C 8051 kết nối phần cứng và File Hex 8051 Timer / Lập trình truy cập trong hội và lập trình C 8051 Serial Port Ngắt hội và C lập trình trong hội và Giao diện C 8051 Bộ nhớ ngoài 8051 Real World Giao diện I: LCD, ADC và cảm biến màn hình LCD và bàn phím interfacing...

Chủ đề:

Bình luận(0)

## Nội dung Text: Sách Học Vi Xử Lý Cực Hay Cho Người Bắt Đầu Học

1. The 8051 Microcontroller and Embedded Systems Using Assembly and C Second Edition Muhammad Ali Mazidi Janice Gillispie Mazidi Rolin D. McKinlay CONTENTS Introduction to Computing The 8051 Microcontrollers 8051 Assembly Language Programming Branch Instructions I/O Port Programming 8051 Addressing Modes Arithmetic & Logic Instructions And Programs 8051 Programming in C 8051 Hardware Connection and Hex File 8051 Timer/Counter Programming in Assembly and C 8051 Serial Port Programming in Assembly and C Interrupts Programming in Assembly and C 8051 Interfacing to External Memory 8051 Real World Interfacing I: LCD,ADC AND SENSORS LCD and Keyboard Interfacing 8051 Interfacing with 8255
2. INTRODUCTION TO COMPUTING The 8051 Microcontroller and Embedded Systems: Using Assembly and C Mazidi, Mazidi and McKinlay Chung-Ping Young 楊中平 Home Automation, Networking, and Entertainment Lab Dept. of Computer Science and Information Engineering National Cheng Kung University, TAIWAN
3. Numbering and coding systems OUTLINES Digital primer Inside the computer Department of Computer Science and Information Engineering HANEL National Cheng Kung University, TAIWAN 2
4. Human beings use base 10 (decimal) NUMBERING arithmetic AND CODING There are 10 distinct symbols, 0, 1, 2, …, SYSTEMS 9 Computers use base 2 (binary) system Decimal and Binary Number There are only 0 and 1 Systems These two binary digits are commonly referred to as bits Department of Computer Science and Information Engineering HANEL National Cheng Kung University, TAIWAN 3
5. Divide the decimal number by 2 NUMBERING repeatedly AND CODING Keep track of the remainders SYSTEMS Continue this process until the quotient Converting becomes zero from Decimal Write the remainders in reverse order to Binary to obtain the binary number Ex. Convert 2510 to binary Quotient Remainder 25/2 = 12 1 LSB (least significant bit) 12/2 = 6 0 6/2 = 3 0 3/2 = 1 1 1/2 = 0 1 MSB (most significant bit) Therefore 2510 = 110012 Department of Computer Science and Information Engineering HANEL National Cheng Kung University, TAIWAN 4
6. Know the weight of each bit in a binary number NUMBERING AND CODING Add them together to get its decimal SYSTEMS equivalent Converting Ex. Convert 110012 to decimal from Binary to Weight: 24 23 22 21 20 Decimal Digits: 1 1 0 0 1 Sum: 16 + 8+ 0+ 0+ 1 = 2510 Use the concept of weight to convert a decimal number to a binary directly Ex. Convert 3910 to binary 32 + 0 + 0 + 4 + 2 + 1 = 39 Therefore, 3910 = 1001112 Department of Computer Science and Information Engineering HANEL National Cheng Kung University, TAIWAN 5
7. Base 16, the NUMBERING hexadecimal system, Decimal Binary Hex AND CODING is used as a 0 0000 0 SYSTEMS 1 0001 1 convenient 2 0010 2 representation of Hexadecimal 3 0011 3 4 0100 4 System binary numbers 5 0101 5 ex. 6 0110 6 7 0111 7 It is much easier to 8 1000 8 represent a string of 0s 9 1001 9 and 1s such as 10 1010 A 100010010110 as its 11 1011 B hexadecimal equivalent of 12 1100 C 896H 13 1101 D 14 1110 E 15 1111 F Department of Computer Science and Information Engineering HANEL National Cheng Kung University, TAIWAN 6
8. To represent a binary number as its NUMBERING equivalent hexadecimal number AND CODING Start from the right and group 4 bits at a SYSTEMS time, replacing each 4-bit binary number with its hex equivalent Converting between Binary Ex. Represent binary 100111110101 in hex 1001 1111 0101 and Hex = 9 F 5 To convert from hex to binary Each hex digit is replaced with its 4-bit binary equivalent Ex. Convert hex 29B to binary 2 9 B = 0010 1001 1011 Department of Computer Science and Information Engineering HANEL National Cheng Kung University, TAIWAN 7
9. Convert to binary first and then NUMBERING convert to hex AND CODING Convert directly from decimal to hex SYSTEMS by repeated division, keeping track of Converting the remainders from Decimal to Hex Ex. Convert 4510 to hex 32 16 8 4 2 1 1 0 1 1 0 1 32 + 8 + 4 + 1 = 45 4510 = 0010 11012 = 2D16 Ex. Convert 62910 to hex 512 256 128 64 32 16 8 4 2 1 1 0 0 1 1 1 0101 62910 = 512+64+32+16+4+1 = 0010 0111 01012 = 27516 Department of Computer Science and Information Engineering HANEL National Cheng Kung University, TAIWAN 8
10. Convert from hex to binary and then to NUMBERING decimal AND CODING Convert directly from hex to decimal SYSTEMS by summing the weight of all digits Converting Ex. 6B216 = 0110 1011 00102 from Hex to 1024 512 256 128 64 32 16 8 4 2 1 Decimal 1 1 0 1 0 1 1 0 010 1024 + 512 + 128 + 32 + 16 + 2 = 171410 Department of Computer Science and Information Engineering HANEL National Cheng Kung University, TAIWAN 9
11. Adding the digits together from the NUMBERING least significant digits AND CODING If the result is less than 16, write that digit SYSTEMS as the sum for that position If it is greater than 16, subtract 16 from it Addition of Hex to get the digit and carry 1 to the next Numbers digit Ex. Perform hex addition: 23D9 + 94BE 23D9 LSD: 9 + 14 = 23 23 – 16 = 7 w/ carry + 94BE 1 + 13 + 11 = 25 25 – 16 = 9 w/ carry B897 1 + 3+4=8 MSD: 2 + 9=B Department of Computer Science and Information Engineering HANEL National Cheng Kung University, TAIWAN 10
12. If the second digit is greater than the NUMBERING first, borrow 16 from the preceding AND CODING digit SYSTEMS Ex. Perform hex subtraction: 59F – 2B8 Subtraction of 59F LSD: 15 – 8 = 7 Hex Numbers – 2B8 9 + 16 – 11 = 14 = E16 2E7 5–1–2=2 Department of Computer Science and Information Engineering HANEL National Cheng Kung University, TAIWAN 11
13. The ASCII (pronounced “ask-E”) code assigns binary patterns for NUMBERING AND CODING Numbers 0 to 9 SYSTEMS All the letters of English alphabet, uppercase and lowercase ASCII Code Many control codes and punctuation marks The ASCII system uses 7 bits to represent each code Hex Symbol Hex Symbol 41 A 61 a Selected ASCII codes 42 B 62 b 43 C 63 c 44 D 64 d ... ... ... … 59 Y 79 y 5A Z 7A z Department of Computer Science and Information Engineering HANEL National Cheng Kung University, TAIWAN 12
14. Two voltage levels can be represented DIGITAL as the two digits 0 and 1 PRIMER Signals in digital electronics have two Binary Logic distinct voltage levels with built-in tolerances for variations in the voltage A valid digital signal should be within either of the two shaded areas 5 Logic 1 4 3 2 1 Logic 0 0 Department of Computer Science and Information Engineering HANEL National Cheng Kung University, TAIWAN 13
15. AND gate DIGITAL PRIMER Logic Gates Computer Science Illuminated, Dale and Lewis OR gate Computer Science Illuminated, Dale and Lewis Department of Computer Science and Information Engineering HANEL National Cheng Kung University, TAIWAN 14
16. Tri-state buffer DIGITAL Inverter PRIMER Logic Gates (cont’) Computer Science Illuminated, Dale and Lewis XOR gate Computer Science Illuminated, Dale and Lewis Department of Computer Science and Information Engineering HANEL National Cheng Kung University, TAIWAN 15
17. NAND gate DIGITAL PRIMER Logic Gates (cont’) Computer Science Illuminated, Dale and Lewis NOR gate Computer Science Illuminated, Dale and Lewis Department of Computer Science and Information Engineering HANEL National Cheng Kung University, TAIWAN 16
18. DIGITAL PRIMER Half adder Logic Design Using Gates Full adder Digital Design, Mano Department of Computer Science and Information Engineering HANEL National Cheng Kung University, TAIWAN 17
19. DIGITAL PRIMER 4-bit adder Logic Design Using Gates (cont’) Digital Design, Mano Department of Computer Science and Information Engineering HANEL National Cheng Kung University, TAIWAN 18 