Introduction To MCS-51 By Charoen Vongchumyen • Department of Computer Engineering • Faculty of Engineering • KMIT�Ladkrabang
8051 Hardware Basic 8051 Hardware Basic Content Content • Overview • Overview • Architechture • Architechture • Memory map • Memory map • Register • Register • Interrupt • Interrupt • Timer/Counter • Timer/Counter • Serial communication • Serial communication 8051 Hardware Basic Tong+ 8051 Hardware Basic Tong+ 02/18/2000 02/18/2000
8051 Overview 8051 Overview What is 8051? What is 8051? • 8051 is a famous • 8051 is a famous microcontroller microcontroller series from Intel series from Intel • 8 bit architecture and instruction set • 8 bit architecture and instruction set • Easy to use and learning • Easy to use and learning • Widely use in many application • Widely use in many application • Suitable for Embedded and Controller application • Suitable for Embedded and Controller application 8051 Hardware Basic Tong+ 8051 Hardware Basic Tong+ 02/18/2000 02/18/2000
8051 Feature 8051 Feature • 8 Bit architecture • 8 Bit architecture • Up to 64KB of external code and data • Up to 64KB of external code and data • 4KB of internal code, EPROM (8751), ROM (8051), Flash (8951) • 4KB of internal code, EPROM (8751), ROM (8051), Flash (8951) • 128 Bytes of internal RAM • 128 Bytes of internal RAM • 32 bits • 32 bits inport inport/output port /output port • 2 Timer/Counter • 2 Timer/Counter • 1 Serial communication (Full Duplex) • 1 Serial communication (Full Duplex) • 6 Sources of interrupt • 6 Sources of interrupt 8051 Hardware Basic Tong+ 8051 Hardware Basic Tong+ 02/18/2000 02/18/2000
8051 Series 8051 Series 8051 Hardware Basic Tong+ 8051 Hardware Basic Tong+ 02/18/2000 02/18/2000
8051 Series 8051 Series 8051 Hardware Basic Tong+ 8051 Hardware Basic Tong+ 02/18/2000 02/18/2000
8051 Pin 8051 Pin � Data and Address bus / Port Port 0 � Data and Address bus / Port Port 0 � Bidirectional Port 1 � Bidirectional port port Port 1 Port 2 � � Address bus / Port Address bus / Port Port 2 Port 3 � � Alternate Function / Port Alternate Function / Port Port 3 ALE � � Address latch enable Address latch enable ALE EA\ � � External memory access External memory access EA\ � Reset RST � RST Reset � Program strobe enable PSEN\ � PSEN\ Program strobe enable � Crystal in/out XTAL1,2 � XTAL1,2 Crystal in/out 8051 Hardware Basic Tong+ 8051 Hardware Basic Tong+ 02/18/2000 02/18/2000
8051 Architecture 8051 Architecture 8051 Hardware Basic Tong+ 8051 Hardware Basic Tong+ 02/18/2000 02/18/2000
8051 Ports 8051 Ports 8051 Hardware Basic Tong+ 8051 Hardware Basic Tong+ 02/18/2000 02/18/2000
8051 Ports 8051 Ports 8051 Hardware Basic Tong+ 8051 Hardware Basic Tong+ 02/18/2000 02/18/2000
8051 Ports 8051 Ports 8051 Hardware Basic Tong+ 8051 Hardware Basic Tong+ 02/18/2000 02/18/2000
8051 Ports 8051 Ports 8051 Hardware Basic Tong+ 8051 Hardware Basic Tong+ 02/18/2000 02/18/2000
8051 Machine Cycles 8051 Machine Cycles P1 P1 P2 P2 P1 P1 P2 P2 P1 P1 P2 P2 P1 P1 P2 P2 P1 P1 P2 P2 P1 P1 P2 P2 Clock Clock State 1 State 1 State 2 State 2 State 3 State 3 State 4 State 4 State 5 State 5 State 6 State 6 S1 S2 S3 S4 S5 S6 S1 S2 S3 S4 S5 S6 ALE ALE Fetch Opcode Fetch Opcode Fetch Opcode Opcode Fetch S1 S2 S3 S4 S5 S6 S1 S2 S3 S4 S5 S6 8051 Hardware Basic Tong+ 8051 Hardware Basic Tong+ 02/18/2000 02/18/2000
8051 Machince Machince Cycles Cycles ( Con � � t 8051 (Con t) ) T = ( C * 12 ) / CF T = ( C * 12 ) / CF C = Machine Cycle of instrution instrution C = Machine Cycle of CF = Crystal Frequency CF = Crystal Frequency Such as Such as ADD A,R1 -> use 1 Machine Cycle ADD A,R1 -> use 1 Machine Cycle XTAL 12 MHz -> use 1 uSec uSec XTAL 12 MHz -> use 1 XTAL 16 MHz XTAL 16 MHz -> use 0.75 uSec -> use 0.75 uSec Note* Sometime we use XTAL 11.0592 Note* Sometime we use XTAL 11.0592 of of serial communication serial communication 8051 Hardware Basic Tong+ 8051 Hardware Basic Tong+ 02/18/2000 02/18/2000
8051 Memory 8051 Memory Code Memory Code Memory • External Code memory • External Code memory 0000 - FFFFh FFFFh 0000 - • Internal Code memory • Internal Code memory 0000 - 0FFFh 0000 - 0FFFh Data Memory Data Memory • External Data memory • External Data memory 0000 - FFFFh FFFFh 0000 - • Internal Data memory • Internal Data memory ? Register Bank ? Register Bank 00 - 1Fh 00 - 1Fh ? Bit addressable ? Bit addressable 20h - 2Fh 20h - 2Fh ? Byte addressable ? Byte addressable 30h - 7Fh 30h - 7Fh ? Special function register ? Special function register 80h - 7Fh 80h - 7Fh 8051 Hardware Basic Tong+ 8051 Hardware Basic Tong+ 02/18/2000 02/18/2000
8051 Code Memory 8051 Code Memory FFFFh External code memory External code memory 1000h 0FFFh Internal code External code Internal code External code EA\ = 1 EA\ = 0 EA\ = 1 EA\ = 0 0000h 8051 Hardware Basic Tong+ 8051 Hardware Basic Tong+ 02/18/2000 02/18/2000
8051 External Code Fetches 8051 External Code Fetches 8051 Hardware Basic Tong+ 8051 Hardware Basic Tong+ 02/18/2000 02/18/2000
8051 Data Memory 8051 Data Memory FFFFh Overlab Overlab Memory Memory External Data External Data Memory Memory FFh Special Function Special Function Register Register 80h 7Fh Internal Data Internal Data RAM RAM 0000 0 8051 Hardware Basic Tong+ 8051 Hardware Basic Tong+ 02/18/2000 02/18/2000
8051 Internal Data Memory 8051 Internal Data Memory 7Fh FFh FFh 7Fh FFh FFh Byte Addressable Byte Addressable RAM RAM Extend RAM Extend RAM 20h 20h Special Function Special Function Access by Access by Bit Addressable Bit Addressable Register Register Indirect addressing Indirect addressing RAM RAM 20h 20h only only Bank 3 Bank 3 18h 18h Bank 2 Bank 2 10h 10h Bank 1 Bank 1 8h 8h Bank 0 Bank 0 0 80h 80h 0 80h 80h 8051 Hardware Basic Tong+ 8051 Hardware Basic Tong+ 02/18/2000 02/18/2000
8051 Register Bank 8051 Register Bank R0 R1 R2 R3 R4 R5 R6 R7 R0 R1 R2 R3 R4 R5 R6 R7 Bank 3 18h - 1Fh Bank 3 18h - 1Fh R0 R1 R2 R3 R4 R5 R6 R7 R0 R1 R2 R3 R4 R5 R6 R7 Bank 2 10h - 17h Bank 2 10h - 17h R0 R0 R1 R1 R2 R2 R3 R3 R4 R4 R5 R5 R6 R6 R7 R7 Bank 1 08h - 0Fh Bank 1 08h - 0Fh R0 R1 R2 R3 R4 R5 R6 R7 R0 R1 R2 R3 R4 R5 R6 R7 Bank 0 00h - 07h Bank 0 00h - 07h Bank 0 -> RS0, 1 = 00 Bank 0 -> RS0, 1 = 00 Bank 1 -> RS0, 1 = 01 Bank 1 -> RS0, 1 = 01 Bank 2 -> RS0, 1 = 10 Bank 2 -> RS0, 1 = 10 Bank 3 -> RS0, 1 = 11 Bank 3 -> RS0, 1 = 11 All bank has same name of register All bank has same name of register 8051 Hardware Basic Tong+ 8051 Hardware Basic Tong+ 02/18/2000 02/18/2000
8051 Bit Addressable RAM 8051 Bit Addressable RAM 38 39 3A 3B 3C 3D 3E 3F 78 79 7A 7B 7C 7D 7E 7F 38 39 3A 3B 3C 3D 3E 3F 78 79 7A 7B 7C 7D 7E 7F 2Eh 2Fh 2Eh 2Fh 2Ch 2Dh 2Ch 2Dh 30 31 32 33 34 35 36 37 70 71 72 73 74 75 76 77 30 31 32 33 34 35 36 37 70 71 72 73 74 75 76 77 2Ah 2Ah 2Bh 2Bh 28 29 2A 2B 2C 2D 2E 2F 68 69 6A 6B 66 6D 6E 6F 28 29 2A 2B 2C 2D 2E 2F 68 69 6A 6B 66 6D 6E 6F 28h 29h 28h 29h 20 21 22 23 24 25 26 27 20 21 22 23 24 25 26 27 60 61 62 63 64 65 66 67 60 61 62 63 64 65 66 67 26h 26h 27h 27h 18 19 1A 1B 1C 1D 1E 1F 58 59 5A 5B 5C 5D 5E 5F 18 19 1A 1B 1C 1D 1E 1F 58 59 5A 5B 5C 5D 5E 5F 24h 25h 24h 25h 10 11 12 13 14 15 16 17 10 11 12 13 14 15 16 17 50 51 52 53 54 55 56 57 50 51 52 53 54 55 56 57 22h 23h 22h 23h 08 09 0A 0B 0C 0D 0E 0F 48 49 4A 4B 4C 4D 4E 4F 08 09 0A 0B 0C 0D 0E 0F 48 49 4A 4B 4C 4D 4E 4F 20h 21h 20h 00 01 02 03 04 05 06 07 40 41 42 43 44 45 46 47 21h 00 01 02 03 04 05 06 07 40 41 42 43 44 45 46 47 Bit addressable Bit addressable Byte addressable Byte addressable 8051 Hardware Basic Tong+ 8051 Hardware Basic Tong+ 02/18/2000 02/18/2000
8051 SFR SFR 8051 ( � ) In 8052 Only 8051 Hardware Basic Tong+ 8051 Hardware Basic Tong+ 02/18/2000 02/18/2000
Recommend
More recommend