Professional Documents
Culture Documents
MPMC 8051 Interfacing
MPMC 8051 Interfacing
MICROCONTROLLERS
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 1
UNIT-V
8051 - INTERFACING
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 2
CONTENTS
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 3
Counters and Timers
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 4
Counters and Timers
• The count value to be loaded in to the
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 5
TCON Register
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 6
TMOD Register
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 7
Timer/Counter Control Logic
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 8
Timer Operation Modes
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 9
Timer Operation Modes
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 10
Serial Port Operation
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 11
SCON Register
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 12
PCON Register
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 13
Serial Data Transmission Modes
• Operates in 4 modes
• Mode 0 – Shift Register Mode
• Mode 1 – Standard UART
• Mode 2 – Multiprocessor Mode
• Mode 3 – Similar to Mode 2
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 14
Mode 0 – Shift Register Mode
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 15
Mode 1 – Standard UART
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 16
Mode 2 – Multiprocessor Mode
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 17
Mode 3
• Similar to Mode 2
• Baud rate is same as Mode 1 baud rate
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 18
ALP to Transfer “LBRCE” (4800, 8-Bit)
MOV TMOD, #20H // Timer 1 in Mode 2
MOV TH1, FAH // Baud rate 4800
MOV SCON, #50H // Serial port in Mode 1
SETB TR1 // Timer 1 Run bit is set to 1
MOV DPTR, #4000H // Memory Initialization for “LBRCE”
MOV R1, #05H // Count for “LBRCE” 5 characters
START: MOVX A, @DPTR // Get the character in to A
MOV SBUF, A // Send the character to Serial Port
HERE:JNB TI, HERE // Check the Transmitter Interrupt
CLR TI // Clear the Transmitter Interrupt
INCDPTR // Point to the next character
DJNZ R1, START // Decrement the count & jump if not “0”
END
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 19
ALP to Receive 100 bytes & Sent to P2
(9600, 8-Bit)
MOV TMOD, #20H // Timer 1 in Mode 2
MOV TH1, FDH // Baud rate 9600
MOV SCON, #50H // Serial port in Mode 1
MOV R2, #64H // Count for 100 bytes
SETB TR1 // Timer 1 Run bit is set to 1
HERE: JNB RI, HERE // Check the Receiver Interrupt
MOV A, SBUF // Receive Data from Serial Port
MOV P2, A // Send the Data to Port 2
CLR RI // Clear the Receiver Interrupt
DJNZ R2, HERE // Decrement the count & jump if not “0”
END
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 20
Interrupts
• 8051 supports 5 interrupts
• Two external interrupts
− INT0 and
− INT1
• Three internal interrupts
− Timer 0
− Timer 1
− Serial Port
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 21
IE Register
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 22
IP Register
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 23
Interrupt Vector Addresses
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 24
Reset
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 25
7-Segemnt Display Interfacing
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 26
7-Segemnt Display Interfacing
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 27
8255 Interfacing with 8051
• Interface 8255 with 8051 with starting address of C000H. Show the hardware
design. Write the instruction sequence to initialize port A as input port, port B as
output port and port C as input port in mode-0
MOV A, #99H
MOV DPTR, #C003H
MOVX @DPTR, A
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 28
8255 Interfacing with 8051
• Interface 8255 with 8051 with starting address of F004H. Show the hardware design.
Develop the instruction sequence to initialize all the ports as input ports in mode 0.
MOV A, #9BH
MOV DPTR, #F007H
MOVX @DPTR, A
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 29
Stepper Motor Interfacing
• Interface a 4-phase, 200 teeth, 9V stepper motor using 8051 microcontroller
and develop an assembly language program for rotating at a speed of 2
rotations per minute
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 30
Stepper Motor Interfacing
• Interface a 4-phase, 200 teeth, 9V stepper motor using 8051 microcontroller and develop an
assembly language program for rotating shaft 90O back and forth in 30 seconds each
continuously.
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 31
All the Best
Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 32