s.k.sahoo
Junior Member level 1
Dear Sir,
Help me Please
I have written the code below in Assembly to receive data serially using serial interrupt. I want the data should save at RAM, then read from that location and finally to load at Port1.
Please correct if there are any mistakes are there.
CODE:
;****************************************************************
; My Serial_Int_Code_01 (Using Serial Interrupt)
; 1: To Receive 8 Byte of data serialy
; 2: Save at RAM Location Staring from 40H
; 3: Read data from RAM Location
; 4: Load them at Port 1
;****************************************************************
ORG 00H
LJMP MAIN
ORG 23H
LJMP SERIAL ;Jump to Serial ISR
ORG 30H
MAIN:
MOV TMOD,#20H ;Timer1 Mode2, Auto reload
MOV TH1,#-3 ;9600 baudrate with 11.0592MHz XTAL
MOV SCON,#50H ;8Bit, 1Stopbit, REN enable
MOV IE,10010000B ;Enable Serial Interrupt
SETB TR1 ;Start Timer1
MOV R0,#40H ;Destination Pointer R0=40h (Storing DATA in RAM location)
MOV R1,#8 ;Data Counter R1=8
STORE:
MOV @R0,A
INC R0
DJNZ R1,STORE
RST:
CLR A
MOV R1,#8
MOV R0,#40H
READ:
MOV A,@R0
CPL A
MOV P1,A ;Send incoming data to P1
INC R0
DJNZ R1,READ
AJMP RST
;*********************************************************************
; Serial ISR Starts
;*********************************************************************
ORG 100H
SERIAL:
JB TI,TRANS ;Jump if TI is High
MOV A,SBUF ;Other wise Receive data
CLR RI ;Clear RI since CPU doesn't
RETI ;return from ISR
TRANS:
CLR TI ;Clear TI since CPU doesn't
RETI ;return from ISR
END
Help me Please
I have written the code below in Assembly to receive data serially using serial interrupt. I want the data should save at RAM, then read from that location and finally to load at Port1.
Please correct if there are any mistakes are there.
CODE:
;****************************************************************
; My Serial_Int_Code_01 (Using Serial Interrupt)
; 1: To Receive 8 Byte of data serialy
; 2: Save at RAM Location Staring from 40H
; 3: Read data from RAM Location
; 4: Load them at Port 1
;****************************************************************
ORG 00H
LJMP MAIN
ORG 23H
LJMP SERIAL ;Jump to Serial ISR
ORG 30H
MAIN:
MOV TMOD,#20H ;Timer1 Mode2, Auto reload
MOV TH1,#-3 ;9600 baudrate with 11.0592MHz XTAL
MOV SCON,#50H ;8Bit, 1Stopbit, REN enable
MOV IE,10010000B ;Enable Serial Interrupt
SETB TR1 ;Start Timer1
MOV R0,#40H ;Destination Pointer R0=40h (Storing DATA in RAM location)
MOV R1,#8 ;Data Counter R1=8
STORE:
MOV @R0,A
INC R0
DJNZ R1,STORE
RST:
CLR A
MOV R1,#8
MOV R0,#40H
READ:
MOV A,@R0
CPL A
MOV P1,A ;Send incoming data to P1
INC R0
DJNZ R1,READ
AJMP RST
;*********************************************************************
; Serial ISR Starts
;*********************************************************************
ORG 100H
SERIAL:
JB TI,TRANS ;Jump if TI is High
MOV A,SBUF ;Other wise Receive data
CLR RI ;Clear RI since CPU doesn't
RETI ;return from ISR
TRANS:
CLR TI ;Clear TI since CPU doesn't
RETI ;return from ISR
END