Home - Search - Members
Full Version: sim 300 GSM modem interfacing to AT89C51
amit251291
Jan 3 2013, 8:14 AM
I want to interface gsm modem to at89c51. i am using assembly language programming..
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



kirangowle
Jan 5 2013, 6:18 AM
Assembly programming is slowly vanishing from Industry. So i suggest to improve your programming skills in C(which will be useful for future).
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


Ajay Bhargav
Jan 20 2013, 11:39 PM
are you facing any problem in working with GSM modems?

[Topic moved to Embedded GSM Development forum]

amit251291
Jan 21 2013, 2:24 PM
yes sir.. i want to send a message to mobile no. using GSM modem and 8051. i have prepared following code. but it is not working it seems. i am not getting any message on my cell. please suggest corrections..

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
ExperimenterUK
Jan 21 2013, 7:20 PM
Can you post your diagram so we can check it.
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.
amit251291
Jan 22 2013, 5:43 AM
i agree with you but my rest part of the code is in assembly so i preferred this language again.
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?
amit251291
Jan 22 2013, 5:48 AM
here is proteus design and code..

Attachment
Ajay Bhargav
Feb 2 2013, 11:27 PM

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?
amit251291
Feb 3 2013, 6:00 AM


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:)

abhi12ka4
May 1 2013, 4:39 PM
Hello,
I have one problem here. when i connect the battery and check the output on the hyperterminal i cannot receive a proper message of more than 8 characters. Below 8 characters its ok..Pls help anyone.
Ajay Bhargav
May 2 2013, 4:41 AM
Abhi12ka4, Please create a new thread explaining what are you trying to do and what your hardware is. only then we will be able to help.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Rickey's World © 2003 - 2007