ebook img

The 8051 Microcontroller and Embedded PDF

617 Pages·2008·4.2 MB·English
by  
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview The 8051 Microcontroller and Embedded

The 8051 Microcontroller and Embedded Systems Using Assembly and C Second Edition Muhammad Ali Mazidi Janice Gillispie Mazidi Rolin D. McKinlay CONTENTS (cid:136) Introduction to Computing (cid:136) The 8051 Microcontrollers (cid:136) 8051 Assembly Language Programming (cid:136) Branch Instructions (cid:136) I/O Port Programming (cid:136) 8051 Addressing Modes (cid:136) Arithmetic & Logic Instructions And Programs (cid:136) 8051 Programming in C (cid:136) 8051 Hardware Connection and Hex File (cid:136) 8051 Timer/Counter Programming in Assembly and C (cid:136) 8051 Serial Port Programming in Assembly and C (cid:136) Interrupts Programming in Assembly and C (cid:136) 8051 Interfacing to External Memory (cid:136) 8051 Real World Interfacing I: LCD,ADC AND SENSORS (cid:136) LCD and Keyboard Interfacing (cid:136) 8051 Interfacing with 8255 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 Numbering and coding systems (cid:137) OUTLINES Digital primer (cid:137) Inside the computer (cid:137) Department of Computer Science and Information Engineering HANEL National Cheng Kung University, TAIWAN 2 Human beings use base 10 (decimal) (cid:137) NUMBERING arithmetic AND CODING There are 10 distinct symbols, 0, 1, 2, …, SYSTEMS (cid:190) 9 Decimal and Computers use base 2 (binary) system (cid:137) Binary Number There are only 0 and 1 (cid:190) Systems These two binary digits are commonly (cid:190) referred to as bits Department of Computer Science and Information Engineering HANEL National Cheng Kung University, TAIWAN 3 Divide the decimal number by 2 (cid:137) NUMBERING repeatedly AND CODING Keep track of the remainders SYSTEMS (cid:137) Continue this process until the quotient (cid:137) Converting becomes zero from Decimal Write the remainders in reverse order (cid:137) to Binary to obtain the binary number Ex. Convert 25 to binary 10 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 25 = 11001 10 2 Department of Computer Science and Information Engineering HANEL National Cheng Kung University, TAIWAN 4 Know the weight of each bit in a binary (cid:137) NUMBERING number AND CODING Add them together to get its decimal (cid:137) SYSTEMS equivalent Converting Ex. Convert 11001 to decimal 2 from Binary to Weight: 24 23 22 21 20 Decimal Digits: 1 1 0 0 1 Sum: 16 + 8 + 0 + 0 + 1 = 25 10 Use the concept of weight to convert a (cid:137) decimal number to a binary directly Ex. Convert 39 to binary 10 32 + 0 + 0 + 4 + 2 + 1 = 39 Therefore, 39 = 100111 10 2 Department of Computer Science and Information Engineering HANEL National Cheng Kung University, TAIWAN 5 Base 16, the (cid:137) NUMBERING hexadecimalsystem, AND CODING Decimal Binary Hex is used as a 0 0000 0 SYSTEMS 1 0001 1 convenient 2 0010 2 Hexadecimal representation of 3 0011 3 4 0100 4 System binary numbers 5 0101 5 ex. 6 0110 6 (cid:190) 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 To represent a binary number as its (cid:137) NUMBERING equivalent hexadecimal number AND CODING Start from the right and group 4 bits at a (cid:190) SYSTEMS time, replacing each 4-bit binary number with its hex equivalent Converting Ex. Represent binary 100111110101 in hex between Binary and Hex 1001 1111 0101 = 9 F 5 To convert from hex to binary (cid:137) Each hex digit is replaced with its 4-bit (cid:190) 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 Convert to binary first and then (cid:137) NUMBERING convert to hex AND CODING Convert directly from decimal to hex SYSTEMS (cid:137) by repeated division, keeping track of Converting the remainders from Decimal to Hex Ex. Convert 45 to hex 10 32 16 8 4 2 1 1 0 1 1 0 1 32 + 8 + 4 + 1 = 45 45 = 0010 1101 = 2D 10 2 16 Ex. Convert 629 to hex 10 512 256 128 64 32 16 8 4 2 1 1 0 0 1 1 1 0 1 0 1 629 = 512+64+32+16+4+1 = 0010 0111 0101 = 275 10 2 16 Department of Computer Science and Information Engineering HANEL National Cheng Kung University, TAIWAN 8

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.