Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 32

MICROPROCESSORS AND

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

 Modes of timer operation,


 Serial port operation,
 Interrupt structure of 8051,
 Interfacing of Seven segment Displays,
 Stepper Motor

Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 3
Counters and Timers

• Two 16-Bit up counters T0 & T1


• Can be used as Timers (Internal) or Counters (External)
• Timers are divided into two 8-bit registers (timer low and timer high)

Friday, June 17, 2022 Department of Electronics and Communication Engineering, LBRCE 4
Counters and Timers
• The count value to be loaded in to the

Timer = 2n – Required count.


• Example:

To count 10 pulses by using 8-bit Timer is:


28 – 10 = 256 – 10 = 246 is the value to be loaded in to the Timer.
Timers/Counters are increment in nature, count cannot be decremented.

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

• 4 programmable modes for serial data communication


• Special function registers SBUF, SCON and PCON are used for
serial communication
• SBUF is used to hold the data
• SCON controls the data communication
• PCON controls the data rate

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

• IE: To enable or disable the interrupts


• IP: To set the interrupt priorities

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

MOV R0, #08H // No. of Characters to be Displayed


MOV R1, #7FH // LED selection pattern for one LED
MOV DPTR, #5000H // Memory pointer for characters
AGAIN: MOV P3, R1 // Send the selection pattern to Port 3
MOVX A, @DPTR // Send the character to A
MOV P1, A // Send the character to Port 1
LCALL DELAY // Invoke the delay
MOV A, R1 // Selection pattern into A for rotation
RR A // Rotate Right the selection pattern
MOV R1, A // Save the new pattern in R1
INC DPTR // Point the next character
DJNZ R0, AGAIN // Decrement the count, jump if not “0”
END

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

You might also like