Académique Documents
Professionnel Documents
Culture Documents
By
8051 Overview
What is 8051? 8051 is a famous microcontroller series from Intel 8 bit architecture and instruction set Easy to use and learning Widely use in many application Suitable for Embedded and Controller application
02/18/2000
Tong+
8051 Feature
8 Bit architecture Up to 64KB of external code and data 4KB of internal code, EPROM (8751), ROM (8051), Flash (8951) 128 Bytes of internal RAM 32 bits inport/output port 2 Timer/Counter 1 Serial communication (Full Duplex) 6 Sources of interrupt
02/18/2000 8051 Hardware Basic Tong+
8051 Series
02/18/2000
Tong+
8051 Series
02/18/2000
Tong+
8051 Pin
Port 0 Data and Address bus / Port Port 1 Bidirectional port Port 2 Address bus / Port Port 3 Alternate Function / Port ALE Address latch enable EA\ External memory access RST Reset PSEN\ Program strobe enable XTAL1,2 Crystal in/out
02/18/2000
Tong+
8051 Architecture
02/18/2000
Tong+
8051 Ports
02/18/2000
Tong+
8051 Ports
02/18/2000
Tong+
8051 Ports
02/18/2000
Tong+
8051 Ports
02/18/2000
Tong+
ALE
Fetch Opcode Fetch Opcode
S1
S2
S3
S4
S5
S6
02/18/2000
Tong+
T = ( C * 12 ) / CF
8051 Memory
Code Memory
External Code memory Internal Code memory 0000 - FFFFh 0000 - 0FFFh 0000 - FFFFh 00 - 1Fh 20h - 2Fh 30h - 7Fh 80h - 7Fh
Tong+
Data Memory
External Data memory Internal Data memory ? Register Bank ? Bit addressable ? Byte addressable ? Special function register
8051 Hardware Basic
02/18/2000
02/18/2000
Tong+
02/18/2000
Tong+
Overlab Memory
FFh 80h 7Fh 0
02/18/2000
Tong+
80h
80h
02/18/2000
Tong+
R1 R1 R1 R1
R2 R2 R2 R2
R3 R3 R3 R3
R4 R4 R4 R4
R5 R5 R5 R5
R6 R6 R6 R6
Bank 0 -> RS0, 1 = 00 Bank 1 -> RS0, 1 = 01 Bank 2 -> RS0, 1 = 10 Bank 3 -> RS0, 1 = 11 All bank has same name of register
02/18/2000 8051 Hardware Basic Tong+
1B 1C 1D 12 13 14 15 0A 0B 0C 0D 02 03 04 05
1E 1F 58 16 17 50 0E 0F 48 06 07 40
8051 SFR
( ) In 8052 Only
02/18/2000
Tong+
Tong+
02/18/2000
Tong+
02/18/2000
Tong+
02/18/2000
Tong+
02/18/2000
Tong+
02/18/2000
Tong+
02/18/2000
Tong+
02/18/2000
Tong+
02/18/2000
Tong+
02/18/2000
Memory
General purpose register R0 - R7 (00h - 1Fh) Bit addressable RAM (20h - 2Fh) General purpose memory (30 - 7Fh)
02/18/2000
Tong+
02/18/2000
Tong+
02/18/2000
Tong+
02/18/2000
02/18/2000
Tong+
02/18/2000
Tong+
02/18/2000
Tong+
02/18/2000
Tong+
02/18/2000
Tong+
02/18/2000
Tong+
02/18/2000
Tong+
02/18/2000
Tong+
02/18/2000
Tong+
02/18/2000
Tong+
02/18/2000
Tong+
02/18/2000
02/18/2000
Tong+
02/18/2000
Tong+
Delay Loop
;save register r0 ;save register r1 ;r0 = 00 ;r1 = 20h ;loop r1 32 times ;loop r0 256 times ;restore register r1 ;restore register r0 ;return
Tong+
02/18/2000
Duty cycle = 50% Pulse width = 17,163 uS Frequency = 58.26 Hz Cystals = 12 MHz
02/18/2000 8051 Basic Code
Tong+
ORG jmp ORG jmp Main: setb setb mov mov mov setb jmp
02/18/2000
External Interrupt
Main:
02/18/2000
Tong+
8051 Interface
C1, C2 20 - 40 pF
02/18/2000
8051 Interface
Tong+
8051 Interface
Power On Reset
02/18/2000
8051 Interface
Tong+
8051 Interface
02/18/2000
8051 Interface
Tong+
8051 Interface
External Program Memory Read Cycle
02/18/2000
8051 Interface
Tong+
8051 Interface
02/18/2000
8051 Interface
Tong+
8051 Interface
Exteranl Data Memory Read Cycle
02/18/2000
8051 Interface
Tong+
8051 Interface
Exteranl Data Memory Write Cycle
02/18/2000
8051 Interface
Tong+
8051 Interface
VCC 8051 P0 P1-P3 10K
Input/Output
Mov Mov a,P0 P1,a
02/18/2000
8051 Interface
Tong+
8051 Interface
Input with switch, Output with LED
VCC 8051 P0 P1-P3 300 LED 10K VCC
02/18/2000
8051 Interface
Tong+
8051 Interface
Matrix keyboard by scanning techinque
8051 P1.0, Row0 P1.1, Row1 P1.2, Row2 P1.3, Col0 P1.4, Col1 P1.5, Col2 1 4 7 2 5 8 3 6 9
Mov P1,#FEh Jnb P1.3,Key1 Jnb P1.4,Key2 Jnb P1.5,Key3 Mov P1,#FDh Jnb P1.3,Key4 Jnb P1.4,Key5 Jnb P1.5,Key6 Mov P1,#FBh Jnb P1.3,Key7 Jnb P1.4,Key8 Jnb P1.5,Key9
02/18/2000
8051 Interface
Tong+
8051 Interface
7-Segment Display by Scan Tecnique
8051 P1 P2.0 P2.1 P2.2 P2.3 8 Loop: 7-Segment (common Anode) Mov P1,#Num1 Mov P2,#00h Call Delay Mov P1,#Num2 Mov P2,#01h Call Delay Mov P1,#Num2 Mov P2,#01h Call Delay Mov P1,#Num2 Mov P2,#01h Call Delay Jmp Loop
Tong+
02/18/2000
8051 Interface
8051 Interface
Serial Communication Via RS-232C Port
8051
TX RX GND
PC
02/18/2000
8051 Interface
Tong+
8051 Interface
Serial Communication Via RS-232C Port
02/18/2000
8051 Interface
Tong+
Start:
ORG Jmp ORG Jmp ORG Clr Mov Mov Mov Setb Setb Setb Mov
0000H Serial_ISR: Start 0023H Serial_ISR 0040H PCON.7 ;clear SMOD SCON,#52h ;set mode TMOD,#20h;timer mode 2 TH1,#FDh ;set reload value TX_Evnt : EA ;enable all Int. REN ;enable Receive End_ISR: TR1 ;start Timer DPTR,#0000h
8051 Interface
8051 Interface
02/18/2000
8051 Interface
Baud Rate
02/18/2000
8051 Interface
Tong+
Assigment
Bubble Sort
0000h = Counter, 0001h - 00xxh = External Data (< 256 bytes) Start N = Data[0] Data = Data[1-N] For I = 1 to N-1 For J = 1 to I-1 If I > J then Swap End