Discussion in "Embedded GSM Development" started by    amit251291    Jan 3, 2013.
Thu Jan 03 2013, 01:44 pm
#1
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



[ Edited Thu Jan 03 2013, 01:58 pm ]
Sat Jan 05 2013, 11:48 am
#2
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
 amit251291 like this.
Mon Jan 21 2013, 05:09 am
#3
are you facing any problem in working with GSM modems?

[Topic moved to Embedded GSM Development forum]
Mon Jan 21 2013, 07:54 pm
#4
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


[ Edited Mon Jan 21 2013, 07:55 pm ]
Tue Jan 22 2013, 12:50 am
#5
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.
Tue Jan 22 2013, 11:13 am
#6
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?
Tue Jan 22 2013, 11:18 am
#7
here is proteus design and code..

Attachment
Sun Feb 03 2013, 04:57 am
#9

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?
Sun Feb 03 2013, 11:30 am
#10


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

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Michailqfh
Fri Mar 29 2024, 01:53 am
Bobbyerilar
Thu Mar 28 2024, 08:08 am
pb58
Thu Mar 28 2024, 05:54 am
Clarazkafup
Thu Mar 28 2024, 02:24 am
Walterkic
Thu Mar 28 2024, 01:19 am
Davidusawn
Wed Mar 27 2024, 08:30 pm
Richardsop
Tue Mar 26 2024, 10:33 pm
Stevencog
Tue Mar 26 2024, 04:26 pm