sim 300 GSM modem interfacing to AT89C51
here i am attaching 2 programs which i tried by reffering programs available on net.. if any one is having assembly program please share it here.... I will be grateful to u all...
Thank you
Program 1:
ORG 0000H
MOV TMOD,#20H
MOV TH1,#-3
MOV SCON,#50H
SETB TR1
OK1: MOV DPTR,#0090H
ACALL ACCESS
MOV DPTR,#00A0H
ACALL ACCESS
MOV DPTR,#00b0H
ACALL ACCESS
MOV DPTR,#00C0H
ACALL ACCESS
MOV DPTR,#00d0H
ACALL ACCESS
ACCESS: CLR A
MOVC A,@A+DPTR
ACALL SEND
INC DPTR
CLR A
MOVC A,@A+DPTR
ACALL SEND
RET
SEND: MOV SBUF,A
HERE: JNB T1,HERE
CLR TI
RET
ORG 0090H
MSG1: DB "AT"
ORG 00A0H
MSG2: DB "AT+CMGF=1"
ORG 00b0H
MSG3: DB "AT+CMGS="
ORG 00C0H
MSG4: DB "34" // FOR "
ORG 00d0H
MSG5: DB '"03457343335"' // MOBILE NUMBER
ORG 00E0H
MSG6: DB "34" //FOR "
ORG 00F0H
MSG7: DB "HI" // MESSAGE TO BE SENT
ORG 0100H
MSG8: DB "26" // ctrl+z
END
Program 2:
org 00 //RESET
LJMP MAIN
ORG 0003H //External Interrupt ISR
JMP EXTERNAL_INTERRUPT
ORG 0200H
MSG00: DB "AT",0DH // Ping mobile
DB 0H
MSG01: DB "AT+CPMS=",'"ME"',0DH //Select prefered memory location for message
DB 0H
MSG02: DB "AT+CMGD=1",0DH //Delete message from index 1 of prefered memory location
DB 0H
MSG03: DB "AT+CMGR=1",0DH // Read text message
DB 0H
MSG04: DB "AT+CMGF=1",0DH //Select text mode i.e. mode 1
DB 0H
MSG05: DB "ATE=0",0DH //Turn-off echo
DB 0H
MSG06: DB "AT+CMGS=",'"03457343335"',0DH //send message
DB 0H
MSG08: DB "INTRUSION DETECTED. Suggest further action",0x1A //sms sent by mobile when intruder is detected.
DB 0H
MAIN:
CALL PERIPHERALS_INIT //Setting up timers and interrupts
CALL ECHO_OFF //Swithcing off AT command echo
CALL SELECT_TEXT_MODE
PERIPHERALS_INIT:
//Setting up Timer 1 for UART
MOV TMOD, #20H ;T1 is mode2
MOV TH1, #0fdh ;9600 baud
MOV SCON, #50H ;8b, 1stop, 1start, REN enabled
anl PCON, #07fh ;To make SMOD =0
SETB TR1 ;start T1
RET
ECHO_OFF:
MOV DPTR,#MSG05
CALL SEND_AT_COMMAND
MOV R7,#'A' //Character after which dump should be started
Call FIND_DUMP_START_CHARACTER
MOV R1,#30H //memory location to dump characters
MOV R4,#9H //number of characters to dump
CALL RECEIVE_AT_COMMAND_RESPONSE_AND_DUMP_TO_MEMORY
RET
SELECT_TEXT_MODE:
MOV R1,#10H
MOV R4,#10
MOV DPTR,#MSG04
CALL SEND_AT_COMMAND
CLR RI
MOV R7,#'O' //Character after which dump should be started
Call FIND_DUMP_START_CHARACTER
MOV R1,#30H //memory location to dump characters
MOV R4,#3 //number of characters to dump
CALL RECEIVE_AT_COMMAND_RESPONSE_AND_DUMP_TO_MEMORY
RET
SEND_SMS:
MOV R1,#10H
MOV R4,#10H
MOV DPTR,#MSG06
CALL SEND_AT_COMMAND
MOV R1,#30H //memory location to dump characters
MOV R4,#6H //number of characters to dump
CALL RECEIVE_AT_COMMAND_RESPONSE_AND_DUMP_TO_MEMORY
CALL DELAY
MOV R1,#10H
MOV R4,#40H
MOV DPTR,#MSG08
CALL SEND_AT_COMMAND
MOV R7,#'+' //Character after which dump should be started
Call FIND_DUMP_START_CHARACTER
MOV R1,#10H //memory location to dump characters
MOV R4,#10 //number of characters to dump
CALL RECEIVE_AT_COMMAND_RESPONSE_AND_DUMP_TO_MEMORY
RET
SEND_AT_COMMAND: /// Send a command to mobile from table
CLR A
MOVC A,@A+DPTR
INC DPTR
JZ EXIT1
CALL TRANSMIT_BYTE_UART
JMP SEND_AT_COMMAND
EXIT1:
RET
FIND_DUMP_START_CHARACTER:
//After a command is sent, this function checks whether a apecific
back: MOV 65H,R7 //character has been received, so that dumping to memory is started.
JNB RI,$ //This is done since blank characters are received initially after
MOV A,SBUF // sending a command. R7 carries the character to be checked.
CLR RI
CJNE A,65H,back
RET
RECEIVE_AT_COMMAND_RESPONSE_AND_DUMP_TO_MEMORY: /// dump mobile's response in uC memory
LOOP4: CALL RECEIVE_BYTE_UART
MOV @R1,A
inc R1
DJNZ R4, LOOP4
RET
TRANSMIT_BYTE_UART: //send characters to mobile
CLR TI
MOV SBUF,A
JNB TI,$
RET
RECEIVE_BYTE_UART: //receive characters from mobile
JNB RI,$
MOV A,SBUF
CLR RI
RET
EXTERNAL_INTERRUPT:
CALL SEND_SMS // Send SMS "INTRUSION DETECTED. SUGGEST FURTHER ACTION"
RETI
DELAY: // 1 Second Delay function
MOV R5,#1
DL2: MOV R6,#50
DL1: MOV R7,#20
DJNZ R7,$
DJNZ R6,DL1
DJNZ R5,DL2
RET
end
[ Edited Thu Jan 03 2013, 01:58 pm ]
Refer this for C programming or try to understand the logic how it is been done and you can develop in ASM.
http://www.8051projects.net/t41321/embedded-gsm-development/gsm-modem-8051.htm
[Topic moved to Embedded GSM Development forum]
about hardware;--
i have sim 300 modem which has max232 on it and which is further connected to rs232 connector.
This is all on that board. now when i am interfacing it to 8051 is there any need to use one more max232 between that rs232 connector (which is there on that module) and 8051 ??
code:-
ORG 0000H MOV TMOD,#20H //TIMER 1, MODE 2 MOV TH1,#-3 //9600 BAUD RATE MOV SCON,#50H //8 BIT, 1 STOP, EN ENABLED SETB TR1 MOV DPTR,#MSG1 ACALL H1 ACALL DELAY MOV DPTR,#MSG2 ACALL H1 ACALL DELAY MOV DPTR,#MSG3 ACALL H1 ACALL DELAY MOV DPTR,#MSG4 ACALL H1 ACALL DELAY STAY: SJMP STAY H1: CLR A MOVC A,@A+DPTR JZ B1 ACALL SEND INC DPTR SJMP H1 B1: RET SEND: MOV SBUF,A H2: JNB TI,H2 CLR TI RET DELAY: MOV R3,#50H HERE2: MOV R4,#50H HERE: DJNZ R4,HERE DJNZ R3,HERE2 RET ORG 300H MSG1: DB "AT",0DH DB 0H MSG2: DB "AT+CMGF=1",0DH DB 0H MSG3: DB "AT+CMGS=",'"8149111111"',0DH DB 0H MSG4: DB "TEXT",0X1A DB 0H END
[ Edited Mon Jan 21 2013, 07:55 pm ]
Also as kirangowle said, for complicated projects like this it is time to switch to C.
Free versions of good software can be found on the net.
here i have attached proteus design with program. i used my phone's gsm modem and interfaced it using compim in proteus. i got message too. so this code is working fine. you also can check it once to guide me:)
now the question is about hardware part.
I have GSM modem similar to the one attatched with this. It has RS232 female connector inbuilt on it and so it has MAX232 too. so is there any need to use one more MAX232 between this RS232 Female connector and 8051?
same discussion
http://www.8051projects.net/t58926/8051-discussion-forum/gsm-modem-interfacing-to-at89c51.htm
I have GSM modem similar to the one attatched with this. It has RS232 female connector inbuilt on it and so it has MAX232 too. so is there any need to use one more MAX232 between this RS232 Female connector and 8051?
Yes you need a MAX232 between 8051 and RS232 connector. But do confirm schematic of modem or atleast check board visually if max232 is there on board or not?
Yes you need a MAX232 between 8051 and RS232 connector. But do confirm schematic of modem or atleast check board visually if max232 is there on board or not?
Thank you well 1 more MAX232 is needed. i attached it and it worked successfully.. Thank you all for your guidance:)