Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

asembly code for 89c51 using RS232

Status
Not open for further replies.

vanbayhoang

Newbie level 6
Joined
Oct 31, 2009
Messages
13
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
HVB
Activity points
1,345
help me conect to rs232?

please can any one provide me asembly code with89c51 using RS232!
 

Naveed Ahmed

Member level 4
Joined
Aug 31, 2008
Messages
77
Helped
9
Reputation
18
Reaction score
9
Trophy points
1,288
Location
Singapore
Activity points
1,862
Re: help me conect to rs232?

;====================================================================================
;= =
;= IN THE NAME OF ALLAH =
;====================================================================================
;to SEND sms
;------------------------------------------------------------------------------------
;--------------------------BYTE ASSIGNMENT-------------------------------------------
;------------------------------------------------------------------------------------

;------------------------------------------------------------------------------------
;--------------------------PORT ASSIGNMENT-------------------------------------------
;------------------------------------------------------------------------------------
LED1 EQU P2
LED2 EQU P0

;------------------------------------------------------------------------------------
ORG 00H
;------------------------------------------------------------------------------------
JMP INIT
;------------------------------------------------------------------------------------

;------------------------------------------------------------------------------------
ORG 23H

JMP S0ISR

;------------------------------------------------------------------------------------

;------------------------------------------------------------------------------------
ORG 30H



;======================================================================================

INIT:
MOV LED1,#00
MOV LED2,#00
MOV B,#00

MOV TMOD,#20H ;SELECTING MODE 2 (8 BIT AUTO RELOAD) OF TIMER1.
MOV TH1,#-3 ;9600 BAUD RATE FOR SERIAL COMM.
MOV SCON,#50H ;SELECTING MODE 1 (8 BIT DATA,1 STOP & 1 START BIT) , FOR SERIAL COMM
SETB TR1

CALL PAUSE
CALL PAUSE

;==========================================================================================

MAIN:
CALL SEND_SMS

JMP MAIN









;===================================================================================

SEND_SMS:


CALL ATC
CALL CARRET
CALL PAUSE
CALL CMGF
CALL CARRET
CALL PAUSE
CALL CMGS
CALL CARRET
CALL PAUSE
CALL SMS_MESSAGE
CALL PAUSE
CALL CTRZ

MOV A,B
CPL A
MOV B,A
MOV LED1,B

RET

;===================================================================================
SMS_MESSAGE:
MOV DPTR,#SMSMSG
CALL CONF

RET


;===================================================================================
S0ISR:


CLR RI
MOV A, SBUF

MOV @R0,A
INC R0

RETI


;======================================================================================
NOWDEL:

ACALL ATC
ACALL CARRET

ACALL CMGD
ACALL CARRET
RET
;====================================================================================
ATC: MOV R2,#00
MOV A,#00
MOV DPTR,#MES9
CLR TI

STRING9:
MOVC A,@A+DPTR
MOV SBUF,A
JNB TI,$
CLR TI
ACALL DELAY
INC R2
MOV A,R2
CJNE R2,#2,STRING9
RET

;=====================================================================================
CARRET:
MOV R2,#00
MOV A,#00
MOV DPTR,#CAR
CLR TI

STRING3:
MOVC A,@A+DPTR
MOV SBUF,A
JNB TI,$
CLR TI
ACALL DELAY
INC R2
MOV A,R2
CJNE R2,#2,STRING3
RET
;===========================================================================================

CMGF:
MOV R2,#00
MOV A,#00
MOV DPTR,#MES6
CLR TI

STRING6:
MOVC A,@A+DPTR
MOV SBUF,A
JNB TI,$
CLR TI
ACALL DELAY
INC R2
MOV A,R2
CJNE R2,#9,STRING6
RET

;==============================================================================================

CMGS:
MOV R2,#00
MOV A,#00
MOV DPTR,#MES15
CLR TI

STRING15:
MOVC A,@A+DPTR
MOV SBUF,A
JNB TI,$
CLR TI
ACALL DELAY
INC R2
MOV A,R2
CJNE R2,#21,STRING15
RET
;==============================================================================================

CPMS:
MOV R2,#00
MOV A,#00
MOV DPTR,#MES17
CLR TI

STRING17:
MOVC A,@A+DPTR
MOV SBUF,A
JNB TI,$
CLR TI
ACALL DELAY
INC R2
MOV A,R2
CJNE R2,#12,STRING17
RET

;===============================================================================================

CMGR:
MOV R2,#00
MOV A,#00
MOV DPTR,#MES7
CLR TI

STRING7:
MOVC A,@A+DPTR
MOV SBUF,A
JNB TI,$
CLR TI
ACALL DELAY
INC R2
MOV A,R2
CJNE R2,#9,STRING7
RET
;===============================================================================================
CMGD:
MOV R2,#00
MOV A,#00
MOV DPTR,#MES8
CLR TI

STRING8:
MOVC A,@A+DPTR
MOV SBUF,A
JNB TI,$
CLR TI
ACALL DELAY
INC R2
MOV A,R2
CJNE R2,#9,STRING8
RET
;===============================================================================================

CTRZ:
MOV R2,#00
MOV A,#00
MOV DPTR,#MSG16
CLR TI

STRING16:
MOVC A,@A+DPTR
MOV SBUF,A
JNB TI,$
CLR TI
ACALL DELAY
INC R2
MOV A,R2
CJNE R2,#1,STRING16
RET

;================================================================================================
CONF:
MOV R2,#00
MOV A,#00
CLR TI

STRING10:

MOVC A,@A+DPTR
CJNE A,#2AH,TRANS
RET

TRANS: MOV SBUF,A
JNB TI,$
CLR TI
CALL DELAY
INC R2
MOV A,R2
JMP STRING10;
;===============================================================================
DELAY:
MOV R4,#100
HERE2:
MOV R3,#255
HERE:
DJNZ R3,HERE
DJNZ R4,HERE2
RET

;================================================================

CLRMEM:
MOV R0,#84H
DOAGAIN:
MOV @R0,#0H
INC R0
CJNE R0,#0FCH,DOAGAIN
RET


;================================================================

PAUSE:
MOV R7,#64
COOLIT: ACALL DELAY
DJNZ R7,COOLIT
RET
;===================================================================



;================================================================
;= =
;= =
;= LOOK UP TABLE =
;= =
;= =
;================================================================

MES6: DB "AT+CMGF=1","*"

MES7: DB "AT+CMGR=1","*"

MES8: DB "AT+CMGD=1","*"

MES9: DB "AT","*"

MES15: DB "AT+CMGS=",022H,"03333184821",022H,0

MSG16: DB 01AH,"*"

MES17: DB "AT+CPMS=",022H,"ME",022H,0

CAR: DB 0DH,0AH,"*"

SMSMSG: DB "CHECKING OF SMS TRANSMISSION","*"



END



Regards
Naveed Khowaja
 

vanbayhoang

Newbie level 6
Joined
Oct 31, 2009
Messages
13
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
HVB
Activity points
1,345
help me conect to rs232?

thank-you for your help!
have fun!
 

Naveed Ahmed

Member level 4
Joined
Aug 31, 2008
Messages
77
Helped
9
Reputation
18
Reaction score
9
Trophy points
1,288
Location
Singapore
Activity points
1,862
Re: help me conect to rs232?

You Are welcome...

Thanks

Regards
Naveed Khowaja
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top