Docsity

mazzidi-the 8051 microcontroller and embedded system, Study Guides, Projects, Research of Microcontrollers

Partial preview of the text

Download mazzidi-the 8051 microcontroller and embedded system and more Study Guides, Projects, Research Microcontrollers in PDF only on Docsity!

The 8051 Microcontroller and Embedded Using Assembly and C Muhammad Ali Mazidi Janice Gillispie Mazidi Second EditionSystems CONTENTS ˆ ˆ Introduction to ComputingThe 8051 Microcontrollers^ Rolin D. McKinlay ˆ ˆ ˆ ˆ^ ˆ ˆ ˆ ˆ^^8051 Branch InstructionsI/O Port Programming (^8051) Arithmetic & Logic Instructions 805180518051 Assembly Language ProgrammingAddressing ModesProgramming in CHardware Connection and Hex FileTimer/Counter Programming And Programs in Assembly and C ˆ ˆ ˆ ˆ^ ˆ ˆ^^8051 Interrupts Programming (^8051) 8051 Real World Interfacing I: LCD,ADC AND SENSORSLCD and Keyboard 8051 Serial Port ProgrammingInterfacing to External MemoryInterfacing with 8255 Interfacing in Assembly and C^ in Assembly and C

‰^ OUTLINES HANEL

Numbering and coding systems ‰ Digital primer ‰ Inside the computer

‰^ NUMBERINGAND CODINGSYSTEMSDecimal andBinary NumberSystems HANEL

Human beings use base 10 (

decimal)

arithmetic^ ¾^ There are 10 distinct symbols, 0, 1, 2,

9 ‰ Computers use base 2 (

binary) system

¾^ There are only 0 and 1 ¾^ These two binary digits are commonlyreferred to as

bits

‰^ NUMBERINGAND CODINGSYSTEMSConvertingfrom Binary toDecimal HANEL

Know the weight of each bit in a binarynumber ‰ Add them together to get its decimalequivalentEx. Convert 11001 ‰ Use the concept of weight to convert adecimal number to a binary directly

to decimal 2 Weight:^

4 3 22

2 1 22

(^02)

Digits:^

Sum:^

16 +^ 8 +^

0 +^ 0 +^

1 = 25^10

Ex. Convert 39

to binary (^10) 32 + 0 + 0 + 4 + 2 + 1 = 39 Therefore, 39

‰^ NUMBERINGAND CODINGSYSTEMSHexadecimalSystem HANEL

Base 16, thehexadecimal system,is used as aconvenientrepresentation ofbinary numbers^ ¾^ ex.It is much easier torepresent a string of 0sand 1s such as100010010110 as itshexadecimal equivalent of896H

F 1111 15

E 1110 14

D 1101 13

C 1100 12

B 1011 11

A 1010 10

(^91001) 9

(^81000) 8

(^70111) 7

(^60110) 6

(^50101) 5

(^40100) 4

(^30011) 3

(^20010) 2

(^10001) 1

(^00000) 0

HexBinary Decimal

‰^ NUMBERINGAND CODINGSYSTEMSConvertingfrom Decimalto Hex HANEL

Convert to binary first and thenconvert to hex ‰ Convert directly from decimal to hexby repeated division, keeping track ofthe remaindersEx. Convert 45^10

to hex 32 16 8 4 2

45 = 0010 1101^10

= 2D^2

Ex. Convert 629

to hex 10 512 256 128 64

629 =^ 512+64+32+16+4+1^10

‰^ NUMBERINGAND CODINGSYSTEMSConvertingfrom Hex toDecimal HANEL

Convert from hex to binary and then todecimal ‰ Convert directly from hex to decimalby summing the weight of all digitsEx. 6B2= 0110 1011 0010^16

2 1024 512 256

10

‰^ NUMBERINGAND CODINGSYSTEMSSubtraction ofHex Numbers HANEL

If the second digit is greater than thefirst, borrow 16 from the precedingdigitEx. Perform hex subtraction: 59F – 2B859F^ LSD: 15 – 8 = 7– 2B^

9 + 16 – 11 = 14 = E

16 2E^

‰^ NUMBERINGAND CODINGSYSTEMSASCII Code HANEL

The ASCII (pronounced

“ask-E”) code

assigns binary patterns for^ ¾^ Numbers 0 to 9^ ¾^ All the letters of English alphabet,uppercase and lowercase^ ¾^ Many control codes and punctuationmarks ‰ The ASCII system uses 7 bits torepresent each code

z7A Z5A

y 79 Y 59

…... ......

d 64 D 44

c 63 C 43

b 62 B 42

a 61 A 41

SymbolHex SymbolHex Selected ASCII codes

‰^ DIGITALPRIMERLogic Gates HANEL

AND gate Computer Science Illuminated, Dale and Lewis ‰ OR gate Computer Science Illuminated, Dale and Lewis

‰^ DIGITALPRIMERLogic Gates(cont’) HANEL

Tri-state buffer ‰ Inverter Computer Science Illuminated, Dale and Lewis ‰ XOR gate Computer Science Illuminated, Dale and Lewis

Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN

DIGITALPRIMERLogic DesignUsing Gates^ HANEL

Half adder Full adder

Digital Design, Mano

Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN

DIGITALPRIMERLogic DesignUsing Gates(cont’)^ HANEL

4-bit adder

Digital Design, Mano