| ??? 10/11/11 10:41 Read: times Msg Score: -2 -1 Didn't Search First -1 Message Not Useful |
#184180 - GSM Subroutine |
Hi guys,
As regards to the below code, is there anyway to modify the code to let it receive SMS from the GSM modem & then the P89V664 controller will process it to control a Relay? Tks. ;SRT starts:
;SRT for sending commands using a GSM modem. Baud rate is 9600.
trans:
clr ti
mov sbuf,a
here1: jnb ti,here1
ret
gsmsend:
back: clr a
movc a,@a+dptr
jz label
acall trans
inc dptr
sjmp back
label: ret
;just store the AT command to be sent in ROM like:
; org 300h
; db "AT+COPS?",0dh,0
;and use the address[300h] as address for DPTR
;SRT for printing data onto LCD Data lines to P2 and command lines to 3.7,3.6,3.5
print:
back: clr a
movc a,@a+dptr
jz labelp
acall datawrt
acall delay
inc dptr
sjmp back
labelp: ret
datawrt:
mov p2,a
setb p3.7
clr p3.6
setb p3.5
acall delay
clr p3.5
ret
comndwrt:
mov p2,a
clr p3.7
clr p3.6
setb p3.5
acall delay
clr p3.5
ret
lcdinit:
clr a
mov a,#38h
acall comndwrt
acall delay
mov a,#0fh
acall comndwrt
acall delay
mov a,#01h
acall comndwrt
acall delay
mov a,#06h
acall comndwrt
acall delay
mov a,#80h
acall comndwrt
acall delay
ret
delay:
mov r2,#50
here0: mov r3,#255
here01: djnz r3,here01
djnz r2,here0
ret
;Serial RX at 9600 baud
recv:
herer: jnb ri,herer
mov a,sbuf
clr ri
ret
;Using timer to loop for 3 min.. Use R5 to change time. Writing a 1 to R5 = 1min, writing a 2 to R5 = 2min and so on..
timer_delay:
mov R5,#3h
loop3: mov R0,#60
loop2: mov R1,#20
mov TMOD,#01h
loop1: mov TH0,#4Bh
mov TL0,#0FEh
setb TR0
label1: jnb TF0,label1
clr TF0
clr TR0
djnz R1,loop1
djnz R0,loop2
djnz R5,loop3
ret
;Code to display the Cell ID to which you are connected to
org 00h
begin1: acall lcdinit
mov dptr,#500h
acall print
mov dptr,#550h
acall sinit
acall gsmsend
mov dptr,#600h
acall sinit
acall gsmsend
mov dptr,#650h
acall sinit
acall gsmsend
acall recv
acall res
acall snd_msg
wait_loop: sjmp wait_loop
trans: clr ti
mov sbuf,a
here1: jnb ti,here1
ret
;recv srt
recv:
mov R5,#26h
mov R0,#33h
zero1:
herer: jnb ri,herer
mov a,sbuf
mov @R0,a
inc R0
clr ri
djnz R5,zero1
ret
;lcd srt
res: acall lcdinit
mov A,50h
acall datawrt
acall delay
mov A,51h
acall datawrt
acall delay
mov A,52h
acall datawrt
acall delay
mov A,53h
acall datawrt
acall delay
mov A,54h
acall datawrt
acall delay
mov A,55h
acall datawrt
acall delay
ret
gsmsend:
bak: clr a
movc a,@a+dptr
jz label
acall trans
inc dptr
sjmp bak
label: ret
print:
back: clr a
movc a,@a+dptr
jz label1
acall datawrt
acall delay
inc dptr
sjmp back
label1: ret
lcdinit:mov a,#38h
acall comndwrt
acall delay
mov a,#0eh
acall comndwrt
acall delay
mov a,#01h
acall comndwrt
acall delay
mov a,#06h
acall comndwrt
acall delay
mov a,#80h
acall comndwrt
acall delay
ret
sinit: mov SCON, #50h
mov TMOD, #20h
mov TH1, #-3
setb TR1
ret
comndwrt:
mov p2,a
clr p3.7
clr p3.6
setb p3.5
acall delay
clr p3.5
ret
datawrt:
mov p2,a
setb p3.7
clr p3.6
setb p3.5
acall delay
clr p3.5
ret
delay: mov r2,#50
here0: mov r3,#255
here01: djnz r3,here01
djnz r2,here0
ret
snd_msg:mov dptr,#700h
acall sinit
acall gsmsend
acall delay
mov dptr,#750h
acall sinit
acall gsmsend
acall delay
mov dptr,#800h
acall sinit
acall gsmsend
acall sinit
mov A,50h
acall trans
acall sinit
mov A,51h
acall trans
acall sinit
mov A,52h
acall trans
acall sinit
mov A,53h
acall trans
acall sinit
mov A,54h
acall trans
acall sinit
mov A,55h
acall trans
mov dptr,#900h
acall sinit
acall gsmsend
ret
org 500h
db "init",0
org 550h
db "ATE0",0dh,0
org 600h
db "AT+CREG=2",0dh,0
org 650h
db "AT+CREG?",0dh,0
org 700h
db "AT+CSDH=1",0DH,0
org 750h
db "AT+CMGS=",22h,"9884872855",22h,0dh,0
org 800h
db "Display:",0
org 850h
db '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
org 900h
db " .",1Ah,0
END
|
| Topic | Author | Date |
| GSM Subroutine | 01/01/70 00:00 | |
| Generally Speaking | 01/01/70 00:00 | |
| here we go again | 01/01/70 00:00 | |
| is there anyway to modify the code to let it receive SMS ? | 01/01/70 00:00 | |
| Uncommented code | 01/01/70 00:00 | |
| Links to posts or links to threads | 01/01/70 00:00 | |
| RE: Links to posts or links to threads | 01/01/70 00:00 | |
| Back to thread | 01/01/70 00:00 | |
| No 'Back to Thread' here | 01/01/70 00:00 | |
| Browsing mode | 01/01/70 00:00 | |
I guess so. | 01/01/70 00:00 | |
| Browsing mode | 01/01/70 00:00 |



