SlideShare a Scribd company logo
8051 Microcontroller
BY
Amruta Chintawar
Sunday, March 28, 2021 1
MCA/TE/V BY
AMRUTA CHINTAWAR
Topics Covered
• Addressing modes
• Instruction Set
• Assembler Directives
• Programming
Sunday, March 28, 2021 MCA/TE/V BY AMRUTA CHINTAWAR 2
Addressing Modes
• Ways by which source and destination
operands(data) are specified in an instruction
is called Addressing mode
• Instruction may contain 1,2 or no operand
• 8051 has 6 address spaces
– Bank register(R0-R7)
– Accumulator
– Internal RAM(00-7F & SFRs)
– External data RAM
– Program ROM
– Immediate data
Sunday, March 28, 2021 MCA/TE/V BY AMRUTA CHINTAWAR 3
Steps to Run the Program
Sunday, March 28, 2021 MCA/TE/V BY AMRUTA CHINTAWAR 4
Addressing Modes
Sunday, March 28, 2021 MCA/TE/V BY AMRUTA CHINTAWAR 5
• Immediate
• Register
• Direct
• Register Indirect
• Index addressing –Code access
Data access
Immediate addressing
Sunday, March 28, 2021 MCA/TE/V BY AMRUTA CHINTAWAR 6
• Source operand is a Constant
• When instruction is assembled,operand
comes immediately after opcode
• Immediate data is preceded by “#”
• Used to load any register including DPTR
Immediate addressing
Sunday, March 28, 2021 MCA/TE/V 7
Eg:
MOV A,#20H
MOV R0,#20H
MOV DPTR,#2000H
Sunday, March 28, 2021 7
MCA/TE/V BY AMRUTA CHINTAWAR
Register Addressing Modes
• It uses register to hold data to be
manipulated
Eg:
MOV A,R0
MOV R7,A
ADD A,R3
Sunday, March 28, 2021 MCA/TE/V BY AMRUTA CHINTAWAR 8
Direct Addressing Mode
• The data is in RAM memory location whose
address is known and which is a part of
instruction
• Address follows the opcode
Eg:
MOV A,0F0H
MOV R0,50H
MOV 50H,A
Sunday, March 28, 2021 MCA/TE/V BY AMRUTA CHINTAWAR 9
Register Indirect Addressing Mode
• Register is used as a pointer to the data
• Only R0 and R1 are used to hold address if
data is inside CPU
• In other words R2-R7 are not used to hold
RAM address
• External RAM register DPTR is used
• Register are preceded by “@”
Eg: MOV A,@R0
MOV @R1,B
Sunday, March 28, 2021 MCA/TE/V 10
Sunday, March 28, 2021 10
MCA/TE/V BY AMRUTA CHINTAWAR
Index Addressing Mode
• It is widely used in accessing data elements of
Look-up table entries located in program ROM
space of 8051
• The 16-dptr and register “A” are used to form
data element stored in On-chip ROM
• Because the data elements are stored in
program space ROM of 8051,it uses
instruction MOVC instead of MOV
• In this instruction the content of A are added
to DPTR to form the 16-bit address of the
needed data
Sunday, March 28, 2021 MCA/TE/V 11
Sunday, March 28, 2021 11
MCA/TE/V BY AMRUTA CHINTAWAR
Index Addressing Mode
Eg:
MOV A,@A+DPTR
Sunday, March 28, 2021 MCA/TE/V 12
Sunday, March 28, 2021 12
MCA/TE/V BY AMRUTA CHINTAWAR
Instruction Set
• Data Transfer
• Arithmetic
• Logical
• Branching and Looping
• Bit Control
– @Ri implies contents of memory location pointed
to by R0 or R1
– Rn refers to registers R0-R7 of the currently
selected register bank
Sunday, March 28, 2021 MCA/TE/V 13
Sunday, March 28, 2021 13
MCA/TE/V BY AMRUTA CHINTAWAR
Data Transfer
• These instructions are used to transfer data
from source operand to destination operand
• Data transfer can be done between
– Internal RAM location and an SFR location without
going through the accumulator
– Internal and external RAM by using indirect
addressing
– The upper 128 bytes of data RAM are accessed
only by indirect addressing
– SFRs are accessed only by direct addressing
Sunday, March 28, 2021 MCA/TE/V 14
Sunday, March 28, 2021 14
MCA/TE/V BY AMRUTA CHINTAWAR
Data Transfer
Sunday, March 28, 2021 MCA/TE/V 15
Mnemonic Description
MOV @Ri, direct [@Ri] = [direct]
MOV @Ri, #data [@Ri] = immediate data
MOV DPTR, #data 16 [DPTR] = immediate data
MOVC A,@A+DPTR A = Code byte from [@A+DPTR]
MOVC A,@A+PC A = Code byte from [@A+PC]
MOVX A,@Ri A = Data byte from external ram [@Ri]
MOVX A,@DPTR A = Data byte from external ram [@DPTR]
MOVX @Ri, A External[@Ri] = A
MOVX @DPTR,A External[@DPTR] = A
PUSH direct, Push into stack
POP direct Pop from stack
XCH A,Rn A = [Rn], [Rn] = A
XCH A, direct A = [direct], [direct] = A
XCH A, @Ri A = [@Rn], [@Rn] = A
XCHD A,@Ri Exchange low order digits
Sunday, March 28, 2021 15
MCA/TE/V BY AMRUTA CHINTAWAR
Arithmetic
• Instruction are used to perform various
mathematical operations like addition,
subtraction, division and Multiplication
• The appropriate status bits in the PSW are set
when specific conditions are met
Sunday, March 28, 2021 MCA/TE/V 16
Sunday, March 28, 2021 16
MCA/TE/V BY AMRUTA CHINTAWAR
Arithmetic
Sunday, March 28, 2021 MCA/TE/V 17
Sunday, March 28, 2021 17
MCA/TE/V BY AMRUTA CHINTAWAR
Logical
• Instruction are used to perform various
bitwise operation like ANDing Oring…
Sunday, March 28, 2021 MCA/TE/V 18
Sunday, March 28, 2021 18
MCA/TE/V BY AMRUTA CHINTAWAR
Logical
Sunday, March 28, 2021 MCA/TE/V 19
Sunday, March 28, 2021 19
MCA/TE/V BY AMRUTA CHINTAWAR
Boolean Variable
• Perform single bit operations
• The operations include set, clear, and, or and
complement instructions
• Also included are bit–level moves or
conditional jump instructions
• All bit accesses use direct addressing
Sunday, March 28, 2021 MCA/TE/V 20
Sunday, March 28, 2021 20
MCA/TE/V BY AMRUTA CHINTAWAR
Boolean Variable
Sunday, March 28, 2021 MCA/TE/V 21
Mnemonic Description
CLR C Clear C
CLR bit Clear direct bit
SETB C Set C
SETB bit Set direct bit
CPL C Complement c
CPL bit Complement direct bit
ANL C,bit AND bit with C
ANL C,/bit AND NOT bit with C
ORL C,bit OR bit with C
ORL C,/bit OR NOT bit with C
MOV C,bit MOV bit to C
MOV bit,C MOV C to bit
JC rel Jump if C set
JNC rel Jump if C not set
JB bit,rel Jump if specified bit set
JNB bit,rel Jump if specified bit not set
JBC bit,rel if specified bit set then clear it and jump
Sunday, March 28, 2021 21
MCA/TE/V BY AMRUTA CHINTAWAR
Branching and Looping
• Instruction are used to perform Branching and
Looping, control the flow of program
execution
• Include various conditional and unconditional
jumps or loop instruction, provide decision
making capabilities before transferring control
to other parts of the program
Sunday, March 28, 2021 MCA/TE/V 22
Sunday, March 28, 2021 22
MCA/TE/V BY AMRUTA CHINTAWAR
Branching and Looping
Sunday, March 28, 2021 MCA/TE/V 23
Mnemonic Description
ACALL addr11 Absolute subroutine call
LCALL addr16 Long subroutine call
RET Return from subroutine
RETI Return from interrupt
AJMP addr11 Absolute jump
LJMP addr16 Long jump
SJMP rel Short jump
JMP @A+DPTR Jump indirect
JZ rel Jump if A=0
JNZ rel Jump if A NOT=0
CJNE A,direct,rel
Compare and Jump if Not Equal
CJNE A,#data,rel
CJNE Rn,#data,rel
CJNE @Ri,#data,rel
DJNZ Rn,rel
Decrement and Jump if Not Zero
DJNZ direct,rel
NOP No Operation
Sunday, March 28, 2021 23
MCA/TE/V BY AMRUTA CHINTAWAR
Timer Programming
• Load Timer according to amount of delay and
crystal frequency
• Timer can be started by instruction SETB TRx
• On FFFF 0000 timer overflows and set TF=1
• On overflow CLR TRx stop timer
• Its an up counter
• Value to be loaded in Reg is subtracted from
FFFF
Sunday, March 28, 2021 MCA/TE/V 24
Sunday, March 28, 2021 24
MCA/TE/V BY AMRUTA CHINTAWAR
Timer Programming
Sunday, March 28, 2021 MCA/TE/V 25
Sunday, March 28, 2021 25
MCA/TE/V BY AMRUTA CHINTAWAR
Timer Programming
Sunday, March 28, 2021 MCA/TE/V 26
Sunday, March 28, 2021 26
MCA/TE/V BY AMRUTA CHINTAWAR
Timer Programming
• To Start Timer
– SETB TRx
– SETB TCON.4/6
– ORA TCON,#10h== 01010000
• To Stop Timer
– CLR TR0
– CLR TCON.4/6
– ANL TCON,#10101111
Sunday, March 28, 2021 MCA/TE/V 27
Sunday, March 28, 2021 27
MCA/TE/V BY AMRUTA CHINTAWAR
Timer Programming
Eg:
Q.1 calculate count to generate a delay of 10ms
with a Crystal frequency of 12Mhz
Sol: Timer clock frequency =12/12 = 1Mhz
Timer clock period =1/1Mhz = 1us
Count to generate
10ms delay =10ms/1us = 10000pulses
Sunday, March 28, 2021 MCA/TE/V 28
Sunday, March 28, 2021 28
MCA/TE/V BY AMRUTA CHINTAWAR
Timer Programming
• Timer should overflow after 10000d pulses
• Timer sets overflow flag on overflow from FFFF+1 pulse
• As timer is up counter value to be loaded in Timer is
calculated as:
FFFFh=65535d
Count=65535d-10000d+1
= 55536d=2710h
• Higher byte to be loaded in THx(27) and
Lower byte in TLx(10)
Sunday, March 28, 2021 MCA/TE/V 29
Sunday, March 28, 2021 29
MCA/TE/V BY AMRUTA CHINTAWAR
Timer Programming
*T/C starts counting from 2710 when it counts
(10000)d pulses the value it reaches is FFFFh
and on next pulse it will overflow to 0000H set
TF bit to 1
Sunday, March 28, 2021 MCA/TE/V 30
Sunday, March 28, 2021 30
MCA/TE/V BY AMRUTA CHINTAWAR
Timer Programming
Steps:
• Calculate time period of timer clock pulse
• Timer clock pulses N to generate required
delay
• Count=FFFF-Nh+1
• Load Higher byte to THx and Lower to TLx
Sunday, March 28, 2021 MCA/TE/V 31
Sunday, March 28, 2021 31
MCA/TE/V BY AMRUTA CHINTAWAR
Timer Programming
Eg:
Q.2 Generate a delay of 500us using Timer0 in mode
1,having crystal frequency of 12Mhz
Sol:Timer clock frequency=12/12=1Mhz
Timer clock period=1us
Count required =500/1us = 500d (500 pulses for 500us)
Count to be loaded=65535-500+1
= 65036d
= FE0Ch
TH0=FE and TL0=0C
Sunday, March 28, 2021 MCA/TE/V 32
Sunday, March 28, 2021 32
MCA/TE/V BY AMRUTA CHINTAWAR
Timer Programming
Configure TMOD to select Timer 0, C/T#=0
Mode 1 (16 bit timer mode) ,M1 M0=01
Its not H/W control, Gate =0
Thus the word to be loaded in TMOD =01h
After loading count Timer need to be started,
TR0=1 in TCON
On overflow TF=1
Sunday, March 28, 2021 MCA/TE/V 33
Sunday, March 28, 2021 33
MCA/TE/V BY AMRUTA CHINTAWAR
Timer Programming
MOV TMOD,#01H TIMER0,MODE1
MOV TH0,#0FEH HIGHER BYTE
MOV TL0,#0CH LOWER BYTE
SETB TR0 START TIMER
WAIT:JNB TF0,WAIT CHECK OVERFLOW
CLR TR0
CLR TF0
Sunday, March 28, 2021 MCA/TE/V 34
Sunday, March 28, 2021 34
MCA/TE/V BY AMRUTA CHINTAWAR
Timer Programming
Eg:
Q.3 Generate a square wave of 1Khz on port P2.0 using
Timer 1, crystal frequency 11.0592
Sol: Required period =1/1khz = 1ms
=500us ON and 500us OFF
Freq of Timer clock =11.0592/12 mhz
=0.9215Mhz
Time period of Timer = 1/0.9215Mhz
=1.085us
Sunday, March 28, 2021 MCA/TE/V 35
Sunday, March 28, 2021 35
MCA/TE/V BY AMRUTA CHINTAWAR
Timer Programming
Count = 500/1.085
=460.8(461)
For 461 count OFF and 461 ON
Count to be loaded =65535-461+1
=65075d
=FE33h
Load FEh in TH1 and 33h TL1
Sunday, March 28, 2021 MCA/TE/V 36
Sunday, March 28, 2021 36
MCA/TE/V BY AMRUTA CHINTAWAR
Timer Programming
MOV TMOD,#10H TIMER1,MODE1
L1: MOV TH1,#0FEH HIGHER BYTE
MOV TL1,#33H LOWER BYTE
SETB TR1 START TIMER
WAIT:JNB TF1,WAIT CHECK OVERFLOW
CLR TR1
CLR TF1
CPL P2.0 Invert bit on port
SJMP L1 repeat to generate
continuous square wave
Sunday, March 28, 2021 MCA/TE/V 37
Sunday, March 28, 2021 37
MCA/TE/V BY AMRUTA CHINTAWAR
Timer Programming
Eg:
Q.4 Generate a square wave of 10Khz on port P1.0
using Timer 0, crystal frequency 12Mhz (solve for 11.0592)
Sol: Required period =1/10khz = 100us
=50us ON and 50us OFF
Freq of Timer clock =12/12 mhz
=1Mhz
Time period of Timer = 1/1Mhz
=1
Sunday, March 28, 2021 MCA/TE/V 38
Sunday, March 28, 2021 38
MCA/TE/V BY AMRUTA CHINTAWAR
Timer Programming
Count = 50/1
=50
For 50 count OFF and 50 ON
Count to be loaded =255-50+1
=206d
=h
Load ?? in TH1 and ?? TL1
*As it is a Continuous pulse program it in Auto
reload Mode
Sunday, March 28, 2021 MCA/TE/V 39
Sunday, March 28, 2021 39
MCA/TE/V BY AMRUTA CHINTAWAR
Serial Programming
Transmission
• Set the port in particular mode
• Store the byte in SBUF
• Start Transmission
• Check Complition by checking TI flag
• Repeat the operation for next byte
*if a particular baud rate is given then
load time with the count
Sunday, March 28, 2021 MCA/TE/V 40
Sunday, March 28, 2021 40
MCA/TE/V BY AMRUTA CHINTAWAR
Serial Programming
Reception
• Set the port in particular mode
• Enable Reception
• Wait Until data byte is received in SBUF by
checking RI flag
• Read SBUF
• Clear RI
• Repeat if Next byte to be received
Sunday, March 28, 2021 MCA/TE/V 41
Sunday, March 28, 2021 41
MCA/TE/V BY AMRUTA CHINTAWAR
Serial Programming
Q.1Write a Program to Transmit ‘55h’
continuosly in mode 0
MOV SCON,#00h
REPEAT:MOV SBUF,#55H
JNB TI,WAIT
CLR TI
SJMP REPEAT
END
Sunday, March 28, 2021 MCA/TE/V 42
Sunday, March 28, 2021 42
MCA/TE/V BY AMRUTA CHINTAWAR
Serial Programming
Q.2 Write a program to receive a data byte in
mode 0.send the received byte to Port1
MOV SCON,#00H
ORA SCON,#10H
WAIT :JNB RI,WAIT
MOV A,SBUF
MOV P1,A
CLR RI
HERE: SJMP HERE
END
Sunday, March 28, 2021 MCA/TE/V 43
Sunday, March 28, 2021 43
MCA/TE/V BY AMRUTA CHINTAWAR
Serial Programming
Mode 0
• Baud rate is fixed Fosc/12
• Initialize SCON
Mode 1
• UART is designed mainly for this reason
• Frame format is compatible with COM port of PCs
• Transmission and reception rate is set by T1
• T1 is used to generate baud rate
• 11.0592 Mhz is unusual value used to generate
standard baud rates
Sunday, March 28, 2021 MCA/TE/V 44
Sunday, March 28, 2021 44
MCA/TE/V BY AMRUTA CHINTAWAR
Serial Programming
Process of generating specific baud rate:
• Crystal frequency/ 12 generate M/C cycle=921.6Khz
• Further / by 32=28800Hz given to timer1
• This value is further divided by an integer in timer 1
to get standard baud rate
Eg: 28800/3=9600
/6 =4800
/24=2400
Sunday, March 28, 2021 MCA/TE/V 45
Sunday, March 28, 2021 45
MCA/TE/V BY AMRUTA CHINTAWAR
Serial Programming
Baud rate calculation
• 11.0592(crys osc)/12=921.6
• If SMOD =0 ,921.6/32=28800HzTimer1 clock
to set Baud rate
• If SMOD=1,921.6/16=57600Hz
Sunday, March 28, 2021 MCA/TE/V 46
Sunday, March 28, 2021 46
MCA/TE/V BY AMRUTA CHINTAWAR
Serial Programming
Baud rate calculation
Ftick=Foscx2SMOD/(12x32)
• Ftick is further divide by Timer 1, and amount of
division is controlled by count loaded into its
TH1 reg.
Fbaud = Ftick/(256-TH1)
= Foscx2SMOD/12x32x(256-TH1)
To get desired baud rate approprite count to be
loaded in TH1 gien as:
TH1 = 256-{(FoscX2SMOD)/(12X32xFbaud)}
Sunday, March 28, 2021 MCA/TE/V 47
Sunday, March 28, 2021 47
MCA/TE/V BY AMRUTA CHINTAWAR
Serial Programming
Some standard baud rates:
Sunday, March 28, 2021 MCA/TE/V 48
Sunday, March 28, 2021 48
MCA/TE/V BY AMRUTA CHINTAWAR
Baud rate Count to be loaded
1200 E8
2400 F4
4800 FA
9600 FD
Serial Programming
Steps to transmit and Receive data serially:
• Timer 1 in 8-Bit auto-reload mode
• Load TH1 according to baud rate
• Configure SCON-Mode 1,REN=1 (reception)
• TR1 =1 start Timer 1
• Byte to be transmitted stored in SBUF
• TI and RI for completion of transmission and
reception resp.
• After completion of Trx and Rx TI and RI cleared
manually
• Repeat last three for transmission and for reception last two
Sunday, March 28, 2021 MCA/TE/V 49
Sunday, March 28, 2021 49
MCA/TE/V BY AMRUTA CHINTAWAR
Serial Programming
Q.1 Write a Program to Transmit “A” serially at 9600 baud rate
MOV TMOD,#20H //Timer 1,Mode 2
MOV TH1,#0FDH // 9600bps
MOV SCON,#50H //8BIT DATA,1 STOP BIT,REN enabled
SETB TR1 // START TIMER
MOV SBUF,#”A” //A IN SBUF
L1: JNB TI L1 // WAIT TILL TRANSFER
CLR TI // CLEAR TI BEFORE SENDING NEXT BYTE
Sunday, March 28, 2021 MCA/TE/V 50
Sunday, March 28, 2021 50
MCA/TE/V BY AMRUTA CHINTAWAR
Serial Programming
Q.1 Write a Program to Transmit “HAPPY” serially at 9600 baud
rate,8- bit dat,1 stop bit
MOV TMOD,#20H //Timer 1,Mode 2
MOV TH1,#0FDH // 9600bps
MOV SCON,#50H //8BIT DATA,1 STOP BIT,REN enabled
SETB TR1 // START TIMER
L1:MOV A,#”H” //H IN A
ACALL SEND
---Repeat FOR A,P,P,Y—
SJMP L1
SEND: MOV SBUF,A
L2: JNB TI L2 // WAIT TILL TRANSFER
CLR TI // CLEAR TI BEFORE SENDING NEXT BYTE
RET
Sunday, March 28, 2021 MCA/TE/V 51
Sunday, March 28, 2021 51
MCA/TE/V BY AMRUTA CHINTAWAR
Serial Programming
Q.1 Write a Program to receive bytes serially at 9600 baud rate,8-
bit dat,1 stop bit simultaneously send received byte to port 2
MOV TMOD,#20H //Timer 1,Mode 2
MOV TH1,#0FDH // 9600bps
MOV SCON,#50H //8BIT DATA,1 STOP BIT,REN enabled
SETB TR1 // START TIMER
L1: JNB RI L1 // WAIT TILL RECEPTION
MOV A, SBUF //READ AND SAVE RECEIVED CHARACTER
MOV P2,A //SEND CHARACTER TO PORT 2
CLR TI // CLEAR TI BEFORE SENDING NEXT BYTE
SJMP L1 //GO TO RECEIVE NEXT CHARACTER
END
Sunday, March 28, 2021 MCA/TE/V 52
Sunday, March 28, 2021 52
MCA/TE/V BY AMRUTA CHINTAWAR
Sunday, March 28, 2021 MCA/TE/V 53
Sunday, March 28, 2021 53
MCA/TE/V BY AMRUTA CHINTAWAR

More Related Content

PDF
8051,chapter1,architecture and peripherals
PPT
8051
PPT
PLC Training Intro
PPTX
Serial Communication in 8051
PDF
Lecture 03 basics of pic
PPT
8051 Programming Instruction Set
PDF
PPTX
Peripherals and interfacing
8051,chapter1,architecture and peripherals
8051
PLC Training Intro
Serial Communication in 8051
Lecture 03 basics of pic
8051 Programming Instruction Set
Peripherals and interfacing

What's hot (20)

PPTX
Programmable Logic Controller | Ladder Logic diagrams| Block diagram | I/O Mo...
PPT
8051 MICROCONTROLLER
PPT
8085 intro
PDF
89c5131datasheet
PPTX
PIC introduction + mapping
PDF
8051 microcontrollers ch3
PPT
AVR Fundamentals
PPT
8051 microcontroller notes continuous
PPT
An Overview of LPC2101/02/03
PDF
Lecture 2 timers, pwm, state machine IN PIC
PPTX
Embedded System Programming on ARM Cortex M3 and M4 Course
PPTX
MICROCONTROLLER 8051- Architecture & Pin Configuration
PPT
8051 archi
PDF
8085 ppi 8255 and 8155
PPTX
ATmega 16
PDF
Analog I/O in PIC16F877A
PDF
Microcontroller Instruction Set atmel
PPTX
Unit iv introduction to 8051 microcontroller ppts
DOCX
Avr report
PPTX
Interfacing with Atmega 16
Programmable Logic Controller | Ladder Logic diagrams| Block diagram | I/O Mo...
8051 MICROCONTROLLER
8085 intro
89c5131datasheet
PIC introduction + mapping
8051 microcontrollers ch3
AVR Fundamentals
8051 microcontroller notes continuous
An Overview of LPC2101/02/03
Lecture 2 timers, pwm, state machine IN PIC
Embedded System Programming on ARM Cortex M3 and M4 Course
MICROCONTROLLER 8051- Architecture & Pin Configuration
8051 archi
8085 ppi 8255 and 8155
ATmega 16
Analog I/O in PIC16F877A
Microcontroller Instruction Set atmel
Unit iv introduction to 8051 microcontroller ppts
Avr report
Interfacing with Atmega 16
Ad

Similar to 8051,chapter2 (20)

PPT
4221-Microcontroller-8051 89c52 51-1.ppt
PDF
Unit3_all timer interfacing in microcontroller
PPTX
Microcontroller BEC405A-Timers and serial communication Module3.pptx
PPTX
UNIT V - INTERFACING MICROCONTROLLER (1).pptx
PDF
8051 serial communication
PPT
EC203DSD - Module 5 - 3.ppt
PPTX
Unit 1 8085 Timing diagram - lecture 5b
PDF
Unit 5
PDF
IRJET- Design and Implementation of Telemetry Encoder for Light- Weight Ballo...
PDF
8085 instructions and addressing modes
PDF
Section 1 8051 microcontroller instruction set
PPT
8085 instruction set and Programming
PDF
Radio Astronomy and electronics
PPTX
6.pptx
PDF
mca is a microcontroller and accmulator is a third year couse
PPTX
Introduction to Microprocesso programming and interfacing.pptx
PDF
Microprocessor lab
PDF
microprocessor_labbmet.pdf
PPT
The 8051 assembly language
PDF
ADC and DAC interfacing.pdf
4221-Microcontroller-8051 89c52 51-1.ppt
Unit3_all timer interfacing in microcontroller
Microcontroller BEC405A-Timers and serial communication Module3.pptx
UNIT V - INTERFACING MICROCONTROLLER (1).pptx
8051 serial communication
EC203DSD - Module 5 - 3.ppt
Unit 1 8085 Timing diagram - lecture 5b
Unit 5
IRJET- Design and Implementation of Telemetry Encoder for Light- Weight Ballo...
8085 instructions and addressing modes
Section 1 8051 microcontroller instruction set
8085 instruction set and Programming
Radio Astronomy and electronics
6.pptx
mca is a microcontroller and accmulator is a third year couse
Introduction to Microprocesso programming and interfacing.pptx
Microprocessor lab
microprocessor_labbmet.pdf
The 8051 assembly language
ADC and DAC interfacing.pdf
Ad

Recently uploaded (20)

PDF
Basic Mud Logging Guide for educational purpose
PDF
Insiders guide to clinical Medicine.pdf
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Pharma ospi slides which help in ospi learning
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Business Ethics Teaching Materials for college
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Basic Mud Logging Guide for educational purpose
Insiders guide to clinical Medicine.pdf
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
TR - Agricultural Crops Production NC III.pdf
Microbial diseases, their pathogenesis and prophylaxis
VCE English Exam - Section C Student Revision Booklet
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Pharma ospi slides which help in ospi learning
PPH.pptx obstetrics and gynecology in nursing
2.FourierTransform-ShortQuestionswithAnswers.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
Abdominal Access Techniques with Prof. Dr. R K Mishra
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
O5-L3 Freight Transport Ops (International) V1.pdf
Business Ethics Teaching Materials for college
O7-L3 Supply Chain Operations - ICLT Program
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx

8051,chapter2

  • 1. 8051 Microcontroller BY Amruta Chintawar Sunday, March 28, 2021 1 MCA/TE/V BY AMRUTA CHINTAWAR
  • 2. Topics Covered • Addressing modes • Instruction Set • Assembler Directives • Programming Sunday, March 28, 2021 MCA/TE/V BY AMRUTA CHINTAWAR 2
  • 3. Addressing Modes • Ways by which source and destination operands(data) are specified in an instruction is called Addressing mode • Instruction may contain 1,2 or no operand • 8051 has 6 address spaces – Bank register(R0-R7) – Accumulator – Internal RAM(00-7F & SFRs) – External data RAM – Program ROM – Immediate data Sunday, March 28, 2021 MCA/TE/V BY AMRUTA CHINTAWAR 3
  • 4. Steps to Run the Program Sunday, March 28, 2021 MCA/TE/V BY AMRUTA CHINTAWAR 4
  • 5. Addressing Modes Sunday, March 28, 2021 MCA/TE/V BY AMRUTA CHINTAWAR 5 • Immediate • Register • Direct • Register Indirect • Index addressing –Code access Data access
  • 6. Immediate addressing Sunday, March 28, 2021 MCA/TE/V BY AMRUTA CHINTAWAR 6 • Source operand is a Constant • When instruction is assembled,operand comes immediately after opcode • Immediate data is preceded by “#” • Used to load any register including DPTR
  • 7. Immediate addressing Sunday, March 28, 2021 MCA/TE/V 7 Eg: MOV A,#20H MOV R0,#20H MOV DPTR,#2000H Sunday, March 28, 2021 7 MCA/TE/V BY AMRUTA CHINTAWAR
  • 8. Register Addressing Modes • It uses register to hold data to be manipulated Eg: MOV A,R0 MOV R7,A ADD A,R3 Sunday, March 28, 2021 MCA/TE/V BY AMRUTA CHINTAWAR 8
  • 9. Direct Addressing Mode • The data is in RAM memory location whose address is known and which is a part of instruction • Address follows the opcode Eg: MOV A,0F0H MOV R0,50H MOV 50H,A Sunday, March 28, 2021 MCA/TE/V BY AMRUTA CHINTAWAR 9
  • 10. Register Indirect Addressing Mode • Register is used as a pointer to the data • Only R0 and R1 are used to hold address if data is inside CPU • In other words R2-R7 are not used to hold RAM address • External RAM register DPTR is used • Register are preceded by “@” Eg: MOV A,@R0 MOV @R1,B Sunday, March 28, 2021 MCA/TE/V 10 Sunday, March 28, 2021 10 MCA/TE/V BY AMRUTA CHINTAWAR
  • 11. Index Addressing Mode • It is widely used in accessing data elements of Look-up table entries located in program ROM space of 8051 • The 16-dptr and register “A” are used to form data element stored in On-chip ROM • Because the data elements are stored in program space ROM of 8051,it uses instruction MOVC instead of MOV • In this instruction the content of A are added to DPTR to form the 16-bit address of the needed data Sunday, March 28, 2021 MCA/TE/V 11 Sunday, March 28, 2021 11 MCA/TE/V BY AMRUTA CHINTAWAR
  • 12. Index Addressing Mode Eg: MOV A,@A+DPTR Sunday, March 28, 2021 MCA/TE/V 12 Sunday, March 28, 2021 12 MCA/TE/V BY AMRUTA CHINTAWAR
  • 13. Instruction Set • Data Transfer • Arithmetic • Logical • Branching and Looping • Bit Control – @Ri implies contents of memory location pointed to by R0 or R1 – Rn refers to registers R0-R7 of the currently selected register bank Sunday, March 28, 2021 MCA/TE/V 13 Sunday, March 28, 2021 13 MCA/TE/V BY AMRUTA CHINTAWAR
  • 14. Data Transfer • These instructions are used to transfer data from source operand to destination operand • Data transfer can be done between – Internal RAM location and an SFR location without going through the accumulator – Internal and external RAM by using indirect addressing – The upper 128 bytes of data RAM are accessed only by indirect addressing – SFRs are accessed only by direct addressing Sunday, March 28, 2021 MCA/TE/V 14 Sunday, March 28, 2021 14 MCA/TE/V BY AMRUTA CHINTAWAR
  • 15. Data Transfer Sunday, March 28, 2021 MCA/TE/V 15 Mnemonic Description MOV @Ri, direct [@Ri] = [direct] MOV @Ri, #data [@Ri] = immediate data MOV DPTR, #data 16 [DPTR] = immediate data MOVC A,@A+DPTR A = Code byte from [@A+DPTR] MOVC A,@A+PC A = Code byte from [@A+PC] MOVX A,@Ri A = Data byte from external ram [@Ri] MOVX A,@DPTR A = Data byte from external ram [@DPTR] MOVX @Ri, A External[@Ri] = A MOVX @DPTR,A External[@DPTR] = A PUSH direct, Push into stack POP direct Pop from stack XCH A,Rn A = [Rn], [Rn] = A XCH A, direct A = [direct], [direct] = A XCH A, @Ri A = [@Rn], [@Rn] = A XCHD A,@Ri Exchange low order digits Sunday, March 28, 2021 15 MCA/TE/V BY AMRUTA CHINTAWAR
  • 16. Arithmetic • Instruction are used to perform various mathematical operations like addition, subtraction, division and Multiplication • The appropriate status bits in the PSW are set when specific conditions are met Sunday, March 28, 2021 MCA/TE/V 16 Sunday, March 28, 2021 16 MCA/TE/V BY AMRUTA CHINTAWAR
  • 17. Arithmetic Sunday, March 28, 2021 MCA/TE/V 17 Sunday, March 28, 2021 17 MCA/TE/V BY AMRUTA CHINTAWAR
  • 18. Logical • Instruction are used to perform various bitwise operation like ANDing Oring… Sunday, March 28, 2021 MCA/TE/V 18 Sunday, March 28, 2021 18 MCA/TE/V BY AMRUTA CHINTAWAR
  • 19. Logical Sunday, March 28, 2021 MCA/TE/V 19 Sunday, March 28, 2021 19 MCA/TE/V BY AMRUTA CHINTAWAR
  • 20. Boolean Variable • Perform single bit operations • The operations include set, clear, and, or and complement instructions • Also included are bit–level moves or conditional jump instructions • All bit accesses use direct addressing Sunday, March 28, 2021 MCA/TE/V 20 Sunday, March 28, 2021 20 MCA/TE/V BY AMRUTA CHINTAWAR
  • 21. Boolean Variable Sunday, March 28, 2021 MCA/TE/V 21 Mnemonic Description CLR C Clear C CLR bit Clear direct bit SETB C Set C SETB bit Set direct bit CPL C Complement c CPL bit Complement direct bit ANL C,bit AND bit with C ANL C,/bit AND NOT bit with C ORL C,bit OR bit with C ORL C,/bit OR NOT bit with C MOV C,bit MOV bit to C MOV bit,C MOV C to bit JC rel Jump if C set JNC rel Jump if C not set JB bit,rel Jump if specified bit set JNB bit,rel Jump if specified bit not set JBC bit,rel if specified bit set then clear it and jump Sunday, March 28, 2021 21 MCA/TE/V BY AMRUTA CHINTAWAR
  • 22. Branching and Looping • Instruction are used to perform Branching and Looping, control the flow of program execution • Include various conditional and unconditional jumps or loop instruction, provide decision making capabilities before transferring control to other parts of the program Sunday, March 28, 2021 MCA/TE/V 22 Sunday, March 28, 2021 22 MCA/TE/V BY AMRUTA CHINTAWAR
  • 23. Branching and Looping Sunday, March 28, 2021 MCA/TE/V 23 Mnemonic Description ACALL addr11 Absolute subroutine call LCALL addr16 Long subroutine call RET Return from subroutine RETI Return from interrupt AJMP addr11 Absolute jump LJMP addr16 Long jump SJMP rel Short jump JMP @A+DPTR Jump indirect JZ rel Jump if A=0 JNZ rel Jump if A NOT=0 CJNE A,direct,rel Compare and Jump if Not Equal CJNE A,#data,rel CJNE Rn,#data,rel CJNE @Ri,#data,rel DJNZ Rn,rel Decrement and Jump if Not Zero DJNZ direct,rel NOP No Operation Sunday, March 28, 2021 23 MCA/TE/V BY AMRUTA CHINTAWAR
  • 24. Timer Programming • Load Timer according to amount of delay and crystal frequency • Timer can be started by instruction SETB TRx • On FFFF 0000 timer overflows and set TF=1 • On overflow CLR TRx stop timer • Its an up counter • Value to be loaded in Reg is subtracted from FFFF Sunday, March 28, 2021 MCA/TE/V 24 Sunday, March 28, 2021 24 MCA/TE/V BY AMRUTA CHINTAWAR
  • 25. Timer Programming Sunday, March 28, 2021 MCA/TE/V 25 Sunday, March 28, 2021 25 MCA/TE/V BY AMRUTA CHINTAWAR
  • 26. Timer Programming Sunday, March 28, 2021 MCA/TE/V 26 Sunday, March 28, 2021 26 MCA/TE/V BY AMRUTA CHINTAWAR
  • 27. Timer Programming • To Start Timer – SETB TRx – SETB TCON.4/6 – ORA TCON,#10h== 01010000 • To Stop Timer – CLR TR0 – CLR TCON.4/6 – ANL TCON,#10101111 Sunday, March 28, 2021 MCA/TE/V 27 Sunday, March 28, 2021 27 MCA/TE/V BY AMRUTA CHINTAWAR
  • 28. Timer Programming Eg: Q.1 calculate count to generate a delay of 10ms with a Crystal frequency of 12Mhz Sol: Timer clock frequency =12/12 = 1Mhz Timer clock period =1/1Mhz = 1us Count to generate 10ms delay =10ms/1us = 10000pulses Sunday, March 28, 2021 MCA/TE/V 28 Sunday, March 28, 2021 28 MCA/TE/V BY AMRUTA CHINTAWAR
  • 29. Timer Programming • Timer should overflow after 10000d pulses • Timer sets overflow flag on overflow from FFFF+1 pulse • As timer is up counter value to be loaded in Timer is calculated as: FFFFh=65535d Count=65535d-10000d+1 = 55536d=2710h • Higher byte to be loaded in THx(27) and Lower byte in TLx(10) Sunday, March 28, 2021 MCA/TE/V 29 Sunday, March 28, 2021 29 MCA/TE/V BY AMRUTA CHINTAWAR
  • 30. Timer Programming *T/C starts counting from 2710 when it counts (10000)d pulses the value it reaches is FFFFh and on next pulse it will overflow to 0000H set TF bit to 1 Sunday, March 28, 2021 MCA/TE/V 30 Sunday, March 28, 2021 30 MCA/TE/V BY AMRUTA CHINTAWAR
  • 31. Timer Programming Steps: • Calculate time period of timer clock pulse • Timer clock pulses N to generate required delay • Count=FFFF-Nh+1 • Load Higher byte to THx and Lower to TLx Sunday, March 28, 2021 MCA/TE/V 31 Sunday, March 28, 2021 31 MCA/TE/V BY AMRUTA CHINTAWAR
  • 32. Timer Programming Eg: Q.2 Generate a delay of 500us using Timer0 in mode 1,having crystal frequency of 12Mhz Sol:Timer clock frequency=12/12=1Mhz Timer clock period=1us Count required =500/1us = 500d (500 pulses for 500us) Count to be loaded=65535-500+1 = 65036d = FE0Ch TH0=FE and TL0=0C Sunday, March 28, 2021 MCA/TE/V 32 Sunday, March 28, 2021 32 MCA/TE/V BY AMRUTA CHINTAWAR
  • 33. Timer Programming Configure TMOD to select Timer 0, C/T#=0 Mode 1 (16 bit timer mode) ,M1 M0=01 Its not H/W control, Gate =0 Thus the word to be loaded in TMOD =01h After loading count Timer need to be started, TR0=1 in TCON On overflow TF=1 Sunday, March 28, 2021 MCA/TE/V 33 Sunday, March 28, 2021 33 MCA/TE/V BY AMRUTA CHINTAWAR
  • 34. Timer Programming MOV TMOD,#01H TIMER0,MODE1 MOV TH0,#0FEH HIGHER BYTE MOV TL0,#0CH LOWER BYTE SETB TR0 START TIMER WAIT:JNB TF0,WAIT CHECK OVERFLOW CLR TR0 CLR TF0 Sunday, March 28, 2021 MCA/TE/V 34 Sunday, March 28, 2021 34 MCA/TE/V BY AMRUTA CHINTAWAR
  • 35. Timer Programming Eg: Q.3 Generate a square wave of 1Khz on port P2.0 using Timer 1, crystal frequency 11.0592 Sol: Required period =1/1khz = 1ms =500us ON and 500us OFF Freq of Timer clock =11.0592/12 mhz =0.9215Mhz Time period of Timer = 1/0.9215Mhz =1.085us Sunday, March 28, 2021 MCA/TE/V 35 Sunday, March 28, 2021 35 MCA/TE/V BY AMRUTA CHINTAWAR
  • 36. Timer Programming Count = 500/1.085 =460.8(461) For 461 count OFF and 461 ON Count to be loaded =65535-461+1 =65075d =FE33h Load FEh in TH1 and 33h TL1 Sunday, March 28, 2021 MCA/TE/V 36 Sunday, March 28, 2021 36 MCA/TE/V BY AMRUTA CHINTAWAR
  • 37. Timer Programming MOV TMOD,#10H TIMER1,MODE1 L1: MOV TH1,#0FEH HIGHER BYTE MOV TL1,#33H LOWER BYTE SETB TR1 START TIMER WAIT:JNB TF1,WAIT CHECK OVERFLOW CLR TR1 CLR TF1 CPL P2.0 Invert bit on port SJMP L1 repeat to generate continuous square wave Sunday, March 28, 2021 MCA/TE/V 37 Sunday, March 28, 2021 37 MCA/TE/V BY AMRUTA CHINTAWAR
  • 38. Timer Programming Eg: Q.4 Generate a square wave of 10Khz on port P1.0 using Timer 0, crystal frequency 12Mhz (solve for 11.0592) Sol: Required period =1/10khz = 100us =50us ON and 50us OFF Freq of Timer clock =12/12 mhz =1Mhz Time period of Timer = 1/1Mhz =1 Sunday, March 28, 2021 MCA/TE/V 38 Sunday, March 28, 2021 38 MCA/TE/V BY AMRUTA CHINTAWAR
  • 39. Timer Programming Count = 50/1 =50 For 50 count OFF and 50 ON Count to be loaded =255-50+1 =206d =h Load ?? in TH1 and ?? TL1 *As it is a Continuous pulse program it in Auto reload Mode Sunday, March 28, 2021 MCA/TE/V 39 Sunday, March 28, 2021 39 MCA/TE/V BY AMRUTA CHINTAWAR
  • 40. Serial Programming Transmission • Set the port in particular mode • Store the byte in SBUF • Start Transmission • Check Complition by checking TI flag • Repeat the operation for next byte *if a particular baud rate is given then load time with the count Sunday, March 28, 2021 MCA/TE/V 40 Sunday, March 28, 2021 40 MCA/TE/V BY AMRUTA CHINTAWAR
  • 41. Serial Programming Reception • Set the port in particular mode • Enable Reception • Wait Until data byte is received in SBUF by checking RI flag • Read SBUF • Clear RI • Repeat if Next byte to be received Sunday, March 28, 2021 MCA/TE/V 41 Sunday, March 28, 2021 41 MCA/TE/V BY AMRUTA CHINTAWAR
  • 42. Serial Programming Q.1Write a Program to Transmit ‘55h’ continuosly in mode 0 MOV SCON,#00h REPEAT:MOV SBUF,#55H JNB TI,WAIT CLR TI SJMP REPEAT END Sunday, March 28, 2021 MCA/TE/V 42 Sunday, March 28, 2021 42 MCA/TE/V BY AMRUTA CHINTAWAR
  • 43. Serial Programming Q.2 Write a program to receive a data byte in mode 0.send the received byte to Port1 MOV SCON,#00H ORA SCON,#10H WAIT :JNB RI,WAIT MOV A,SBUF MOV P1,A CLR RI HERE: SJMP HERE END Sunday, March 28, 2021 MCA/TE/V 43 Sunday, March 28, 2021 43 MCA/TE/V BY AMRUTA CHINTAWAR
  • 44. Serial Programming Mode 0 • Baud rate is fixed Fosc/12 • Initialize SCON Mode 1 • UART is designed mainly for this reason • Frame format is compatible with COM port of PCs • Transmission and reception rate is set by T1 • T1 is used to generate baud rate • 11.0592 Mhz is unusual value used to generate standard baud rates Sunday, March 28, 2021 MCA/TE/V 44 Sunday, March 28, 2021 44 MCA/TE/V BY AMRUTA CHINTAWAR
  • 45. Serial Programming Process of generating specific baud rate: • Crystal frequency/ 12 generate M/C cycle=921.6Khz • Further / by 32=28800Hz given to timer1 • This value is further divided by an integer in timer 1 to get standard baud rate Eg: 28800/3=9600 /6 =4800 /24=2400 Sunday, March 28, 2021 MCA/TE/V 45 Sunday, March 28, 2021 45 MCA/TE/V BY AMRUTA CHINTAWAR
  • 46. Serial Programming Baud rate calculation • 11.0592(crys osc)/12=921.6 • If SMOD =0 ,921.6/32=28800HzTimer1 clock to set Baud rate • If SMOD=1,921.6/16=57600Hz Sunday, March 28, 2021 MCA/TE/V 46 Sunday, March 28, 2021 46 MCA/TE/V BY AMRUTA CHINTAWAR
  • 47. Serial Programming Baud rate calculation Ftick=Foscx2SMOD/(12x32) • Ftick is further divide by Timer 1, and amount of division is controlled by count loaded into its TH1 reg. Fbaud = Ftick/(256-TH1) = Foscx2SMOD/12x32x(256-TH1) To get desired baud rate approprite count to be loaded in TH1 gien as: TH1 = 256-{(FoscX2SMOD)/(12X32xFbaud)} Sunday, March 28, 2021 MCA/TE/V 47 Sunday, March 28, 2021 47 MCA/TE/V BY AMRUTA CHINTAWAR
  • 48. Serial Programming Some standard baud rates: Sunday, March 28, 2021 MCA/TE/V 48 Sunday, March 28, 2021 48 MCA/TE/V BY AMRUTA CHINTAWAR Baud rate Count to be loaded 1200 E8 2400 F4 4800 FA 9600 FD
  • 49. Serial Programming Steps to transmit and Receive data serially: • Timer 1 in 8-Bit auto-reload mode • Load TH1 according to baud rate • Configure SCON-Mode 1,REN=1 (reception) • TR1 =1 start Timer 1 • Byte to be transmitted stored in SBUF • TI and RI for completion of transmission and reception resp. • After completion of Trx and Rx TI and RI cleared manually • Repeat last three for transmission and for reception last two Sunday, March 28, 2021 MCA/TE/V 49 Sunday, March 28, 2021 49 MCA/TE/V BY AMRUTA CHINTAWAR
  • 50. Serial Programming Q.1 Write a Program to Transmit “A” serially at 9600 baud rate MOV TMOD,#20H //Timer 1,Mode 2 MOV TH1,#0FDH // 9600bps MOV SCON,#50H //8BIT DATA,1 STOP BIT,REN enabled SETB TR1 // START TIMER MOV SBUF,#”A” //A IN SBUF L1: JNB TI L1 // WAIT TILL TRANSFER CLR TI // CLEAR TI BEFORE SENDING NEXT BYTE Sunday, March 28, 2021 MCA/TE/V 50 Sunday, March 28, 2021 50 MCA/TE/V BY AMRUTA CHINTAWAR
  • 51. Serial Programming Q.1 Write a Program to Transmit “HAPPY” serially at 9600 baud rate,8- bit dat,1 stop bit MOV TMOD,#20H //Timer 1,Mode 2 MOV TH1,#0FDH // 9600bps MOV SCON,#50H //8BIT DATA,1 STOP BIT,REN enabled SETB TR1 // START TIMER L1:MOV A,#”H” //H IN A ACALL SEND ---Repeat FOR A,P,P,Y— SJMP L1 SEND: MOV SBUF,A L2: JNB TI L2 // WAIT TILL TRANSFER CLR TI // CLEAR TI BEFORE SENDING NEXT BYTE RET Sunday, March 28, 2021 MCA/TE/V 51 Sunday, March 28, 2021 51 MCA/TE/V BY AMRUTA CHINTAWAR
  • 52. Serial Programming Q.1 Write a Program to receive bytes serially at 9600 baud rate,8- bit dat,1 stop bit simultaneously send received byte to port 2 MOV TMOD,#20H //Timer 1,Mode 2 MOV TH1,#0FDH // 9600bps MOV SCON,#50H //8BIT DATA,1 STOP BIT,REN enabled SETB TR1 // START TIMER L1: JNB RI L1 // WAIT TILL RECEPTION MOV A, SBUF //READ AND SAVE RECEIVED CHARACTER MOV P2,A //SEND CHARACTER TO PORT 2 CLR TI // CLEAR TI BEFORE SENDING NEXT BYTE SJMP L1 //GO TO RECEIVE NEXT CHARACTER END Sunday, March 28, 2021 MCA/TE/V 52 Sunday, March 28, 2021 52 MCA/TE/V BY AMRUTA CHINTAWAR
  • 53. Sunday, March 28, 2021 MCA/TE/V 53 Sunday, March 28, 2021 53 MCA/TE/V BY AMRUTA CHINTAWAR