Discussion in "8051 Discussion Forum" started by    Malik_Umair    May 24, 2013.
Fri May 24 2013, 02:53 AM
#1
Hello All Experts,

I have written the following assembly language code for the GSM interfacing with 89c51, I want to get SMS on my mobile when 89c51 get input. But I am unable to get any message on my cell phone. Please help me in this regard.

Program:

        ORG 0000H
        MOV P1, #00H
        
    ; GSM COMMUNICATION SOFTWARE SIMULTION  
        
        MOV TMOD,#20H           
        MOV TH1,#0FDH           
        MOV SCON,#50H           
        SETB TR1
    
        
        ;MOV P1, #0FH
        MOV P2, #00H
        
        
        
START:  MOV A, #01H
        CJNE A, #00000001B, NEXT
        SJMP ONE
NEXT:   CJNE A, #00000010B, NEXT_2
        LJMP TWO
NEXT_2: CJNE A, #00000100B, START
        LJMP THREE
 
ONE:    CLR P2.1
        LCALL DELAY
        LCALL DELAY
        LCALL DELAY
        SETB P2.1
        MOV DPTR,#MSG1
        ACALL H1
        CLR P2.1
        LCALL DELAY
        LCALL DELAY
        LCALL DELAY
        SETB P2.1
        ACALL DELAY
        MOV DPTR,#MSG2
        ACALL H1
        CLR P2.1
        LCALL DELAY
        LCALL DELAY
        LCALL DELAY
        SETB P2.1
        ACALL DELAY
        
        ;MOV DPTR,#MSG3
        ;ACALL H1
        ;CLR P2.1
        ;LCALL DELAY
        ;LCALL DELAY
        ;LCALL DELAY
        ;SETB P2.1
        ;ACALL DELAY
        
        MOV DPTR,#MSG4
        ACALL H1
        CLR P2.1
        LCALL DELAY
        LCALL DELAY
        LCALL DELAY
        SETB P2.1
        ACALL DELAY     
        MOV DPTR,#MSG5
        ACALL H1
        CLR P2.1
        LCALL DELAY
        LCALL DELAY
        LCALL DELAY
        SETB P2.1
        ACALL DELAY
        
        
        LJMP START
        
TWO:    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
        MOV DPTR,#MSG6
        ACALL H1
        ACALL DELAY
        LJMP START
        
THREE:  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
        MOV DPTR,#MSG7
        ACALL H1
        ACALL DELAY
        LJMP START
        
                
        
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,0AH
      DB 0H
MSG2: DB "AT+CMGF=1",0DH,0AH
      DB 0H
;MSG3: DB "ATE=0",0DH,0AH
;      DB 0H
MSG4: DB "AT+CMGS=",'"+92334xxxxxxx"',0DH,0AH
      DB 0H
MSG5: DB "INPUT 1 ACTIVATED",01AH
      DB 0H
MSG6: DB "INPUT 2 ACTIVATED",01AH
      DB 0H
MSG7: DB "INPUT 3 ACTIVATED",01AH
      DB 0H       
 
      END


[ Edited Fri May 24 2013, 05:40 AM ]
Fri May 24 2013, 05:46 AM
#2
I do not see any issue in your code. Few changes I would suggest:
1. remove 0A from all commands as when we press enter from hyperterminal PC only transmit 0D
2. change ATE=0 to ATE0
3. I do not know how much delay your routine generates, But make sure there is approx 1sec delay between each command.
Fri May 24 2013, 06:25 AM
#3
Hello Ajay,

1) I am not going interface it with PC hyper terminal, rather I am directly interfacing my SIM900 GSM module to 89c51. So for this I have added 0AH.

2) I did not understand about the ATE0? Will you please explain me?
3) 20ms delay I am generating.
Fri May 24 2013, 06:37 AM
#4
I have one another doubt. My GSM modem operates on maximum +4.3v and 89c51 operates on +5v. Is their any logic level problem that the GSM module is not recognizing 9600bps data on +5v level? Should I use in between MAX232 and provide +4.3v to MAX232? Please help me to get out of it successfully.
Sat May 25 2013, 06:48 PM
#5
I believe that you should look into the datasheet of your GSM modem once again and see if the pins of modem are 5V tolerant or not.

If yes then there is no requirement for max232 because 8051 works in TTL level and your GSM modem can well understand the incoming data from the MCU. Max232 converts rs232 to TTL level and vice versa.

If no then use a resistor network on each pin of GSM to lower down the 5V from 8051 to required level (eg 3V).
Sun May 26 2013, 04:18 AM
#6
Yup, pins connections were bad. Now I am receiving SMS on my mobile. But at the same time I want to receive sms to micro-controller and do some controlled jobs through MCU. Can anybody help me how to do this? Any code? or a guide line?
Mon May 27 2013, 04:35 AM
#7
I recently posted a project on this:
http://www.8051projects.net/download-d248-gsm-notice-board.html

you can see how sms receive is working in this project.
Tue May 28 2013, 09:36 AM
#8
Hi Ajay,

The code is in C language and I hardly understand only few basic commands of C. I am good in Assembly. Will you please translate that code in Assembly so that I can also understand and extract my concerned commands and their syntax?
Wed May 29 2013, 04:21 AM
#9
it will be a complex to transfer that logic to ASM. I would suggest you do an alternative approach. Fix a location for reading sms, e.g. you read only location #1 for reading sms. To read SMS you will send AT+CMGR=1
if there is no new sms on that location you will get only "OK" from modem, but If there is a new sms you will get response starting with "+CMGR:" and after reading SMS delete that SMS using AT+CMGD=1 so that new sms comes in same location. that's a simplest way of reading SMS and is fairly simple to implement it in assembly.
Tue Jun 04 2013, 08:53 AM
#10
Hi Ajay,

I am really thankful to you regarding helping me in GSM code. The sending porting is working (if put alone). I have written the following code for sending and receiving the SMS through GSM module. But I am having problem in the interrupt routine (I think). My aim is that in normal mode the GSM and micro-controller will remain in receiving mode means it receive SMS and act upon accordingly but when the external interrupt INT0 comes it goes to sending mode and sends the SMS to pre-defined number. I have written the code but it is not working. Please guide me in this program.

CODE:

;***********************************************************************************************
;       Program for Sending SMS through GSM network using
;       SIM900D and AT89C51
;***********************************************************************************************
;       Upon wake-up goto MAIN, avoid using memory space, allocated
;       to interrupt vector table
;***********************************************************************************************
           ORG 0000H
            LJMP MAIN

 ;**********************************************************************************************
 ;       ISR for External Interrupt 0 to send Message for
 ;       particular activated input
 ;**********************************************************************************************
            ORG 0003H
 CHECK:     JNB P1.0, CHECK
            ACALL SERIAL
            ACALL DELAY1
            ACALL DELAY1
            ACALL DELAY1
            ACALL DELAY1
            ACALL CMGF
            ACALL DELAY1
            ACALL DELAY1
            ACALL DELAY1 
            ACALL DELAY1    
            ACALL CNMI
            ACALL DELAY1
            ACALL DELAY1 
            ACALL DELAY1 
            ACALL DELAY1    
            ACALL CMGS
            ACALL DELAY1
            ACALL DELAY1 
            ACALL DELAY1 
            ACALL DELAY1    
            ACALL SALAM
            ACALL THIEF        
            ACALL DELAY1
            ACALL DELAY1 
            ACALL DELAY1 
            ACALL DELAY1
            RETI
;***********************************************************************************************
;         The MAIN program for initilization
;***********************************************************************************************
MAIN:       ORG 0030H
		MOV P1,#00H
		MOV P2,#00H
		ACALL DELAY1
            ACALL DELAY1
            ACALL DELAY1
            ACALL DELAY1
            SETB P1.0
 START:     MOV IE, #00000100B
            ACALL SERIAL
            ACALL DELAY1
            ACALL DELAY1
            ACALL DELAY1
            ACALL DELAY1
 	    LCALL CMGF
            LCALL DELAY1
            LCALL DELAY1
            LCALL DELAY1
            LCALL DELAY1
            LCALL CSMS   ; SET TO PHASE 1
            LCALL DELAY1
            LCALL DELAY1
            LCALL DELAY1
            LCALL DELAY1
            LCALL CNMI_READ  ; SET TO DISPLAY +CMTI INDICATION WHEN SMS IS RECEIVED
            LCALL DELAY1
            LCALL DELAY1
            LCALL DELAY1
            LCALL DELAY1
            LCALL CPMS   ; SET THE READ & WRITE STORAGE TO SIM
            LCALL DELAY1
            LCALL DELAY1
            LCALL DELAY1
            LCALL DELAY1
            LCALL CMGR   ; READ THE STORED MESSAGE
            LCALL DELAY1
            LCALL DELAY1
            LCALL DELAY1
            LCALL DELAY1
;**********************************************************************************************
  RECV:    JNB RI, RECV
           MOV A,SBUF
           CLR RI
           CJNE A,'1',ERROR
           SETB P2.1
           CLR A

;***********************************************************************************************
            LCALL CMGD    ; DELETE THE SMS STORED IN SIM
            LCALL DELAY1
            LCALL DELAY1
            LCALL DELAY1
            LCALL DELAY1
            LJMP START
 ;**********************************************************************************************
  ERROR:    SETB P2.2
            LCALL DELAY1
            LCALL DELAY1
            LCALL DELAY1
            LCALL DELAY1
            CLR P2.2
            LJMP START
;***********************************************************************************************
;   Subroutine for Sending one byte out of serial port
;***********************************************************************************************
  TRAIN:    MOV SBUF,A
  HERE:     JNB TI,HERE
            CLR TI
            RET
;***********************************************************************************************
;   Subroutine for initializing the serial port with 9600BPS
;***********************************************************************************************
    SERIAL: MOV TMOD,#20H
            MOV TH1,#0FDH
            MOV SCON,#50H
            SETB TR1
            RET
;***********************************************************************************************
;   Subroutine for CSMS
;***********************************************************************************************
    CSMS:  MOV DPTR,#TABLE6
           MOV R7,#10
    LOOOP: MOV A,#0
           MOVC A,@A+DPTR
           INC DPTR
           LCALL TRAIN
           DJNZ R7,LOOOP
           RET
;***********************************************************************************************
;   Subroutine for CNMI_READ
;***********************************************************************************************
 CNMI_READ: MOV DPTR,#TABLE7
            MOV R7,#18
    LOP:    MOV A,#0
            MOVC A,@A+DPTR
            INC DPTR
            ACALL TRAIN
            DJNZ R7,LOP
            RET
 ;**********************************************************************************************
 ;  Subroutine for CPMS
 ;**********************************************************************************************
   CPMS:   MOV DPTR,#TABLE8
           MOV R7,#18
   LOOOOP: MOV A,#0
           MOVC A,@A+DPTR
           INC DPTR
           LCALL TRAIN
           DJNZ R7,LOOOOP
           RET
;***********************************************************************************************
; Subroutine for CMGR
;***********************************************************************************************
    CMGR:   MOV DPTR,#TABLE9
            MOV R7,#10
    BACK:  MOV A,#0
            MOVC A,@A+DPTR
            INC DPTR
            ACALL TRAIN
            DJNZ R7,BACK
            RET
;***********************************************************************************************
;   Subroutine for CMGD
;***********************************************************************************************
   CMGD:   MOV DPTR,#TABLE10
           MOV R7,#10
   BACK1:  MOV A,#0
           MOVC A,@A+DPTR
           INC DPTR
           ACALL TRAIN
           DJNZ R7,BACK1
           RET
;***********************************************************************************************
;   Subroutine for CMGF
;***********************************************************************************************
    CMGF:   MOV DPTR,#TABLE1
            MOV R7,#10
    LOOP1:  MOV A,#0
            MOVC A,@A+DPTR
            INC DPTR
            ACALL TRAIN
        ;   ACALL DELAY
            DJNZ R7,LOOP1
            RET
;***********************************************************************************************
;   Subroutine for CNMI
;***********************************************************************************************
    CNMI:   MOV DPTR,#TABLE2
            MOV R7,#18
    LOOP2:  MOV A,#0
            MOVC A,@A+DPTR
            INC DPTR
            ACALL TRAIN
        ;   ACALL DELAY
            DJNZ R7,LOOP2
            RET
;***********************************************************************************************
;   Subroutine for CMGS
;***********************************************************************************************
    CMGS:   MOV DPTR,#TABLE3
            MOV R7,#22
    LOOP3:  MOV A,#0
            MOVC A,@A+DPTR
            INC DPTR
            ACALL TRAIN
        ;   ACALL DELAY
            DJNZ R7,LOOP3
            RET
;***********************************************************************************************
;   Subroutine for SALAM
;***********************************************************************************************
    SALAM:  MOV DPTR,#TABLE4
            MOV R7,#18
    LOOP4:  MOV A,#0
            MOVC A,@A+DPTR
            INC DPTR
            ACALL TRAIN
        ;   ACALL DELAY
            DJNZ R7,LOOP4 
            RET
;***********************************************************************************************
;   Subroutine for THIEF
;***********************************************************************************************
    THIEF:  MOV DPTR,#TABLE5
            MOV R7,#31
    LOOP5:  MOV A,#0
            MOVC A,@A+DPTR
            INC DPTR
            ACALL TRAIN
        ;   ACALL DELAY
            DJNZ R7,LOOP5 
            RET
;***********************************************************************************************
;   Subroutine for delay
;***********************************************************************************************
  DELAY:    MOV R0,#50
  RELOAD:   MOV R1,#50
  WAIT:     DJNZ R1,WAIT
            DJNZ R0,RELOAD
            RET
;***********************************************************************************************
;   Subroutine for LARGE delay
;***********************************************************************************************
  DELAY1:   MOV R0,#255
  RELOAD1:  MOV R1,#255
  WAIT1:    DJNZ R1,WAIT1
            DJNZ R0,RELOAD1
            RET  
;***********************************************************************************************
;   Lookup Tables
;***********************************************************************************************
  TABLE1:   DB "AT+CMGF=1",0Dh
  TABLE2:   DB "AT+CNMI=2,2,0,0,0",0Dh
  TABLE3:   DB 'AT+CMGS="0331xxxxxx"',0Dh
  TABLE4:   DB "ASSALAM-O-ALAIKUM",0Dh
  TABLE5:   DB "GSM is working",1Ah
  TABLE6:   DB "AT+CSMS=0",0Dh
  TABLE7:   DB "AT+CNMI=2,1,0,0,0",0Dh
  TABLE8:   DB "AT+CPMS=","SM","SM",0Dh
  TABLE9:   DB "AT+CMGR=1",0Dh
  TABLE10:  DB "AT+CMGD=1",0Dh

            END


[ Edited Tue Jun 04 2013, 06:04 PM ]

Get Social

Information

Powered by e107 Forum System

Conversation

Thu Nov 21 2019, 12:30 PM
raj2555
how to interface 8051 microcontroller with NRF24L01+ module
ExperimenterUK
Sat Oct 12 2019, 10:23 PM
Log in.. then post your code in the 8051 forum
Sat Oct 12 2019, 10:18 AM
Bhadra Sajikumar
i am doing a countdown timer with 8051 for my project, unfortunately our professor had to take a leave of absence before he could teach us most of it.. can someone explain the .asm code of it for me?
Mon Sep 23 2019, 07:37 AM
Nathaniel
I am doing a project for my schools wireless security system with cameras,sensors and spot lights using 8051 micro controller, could you help me out with the design and its source code.
Wed Sep 18 2019, 08:48 PM
Caryn Kover
Thank you for your time,
ExperimenterUK
Mon Aug 05 2019, 07:09 PM
@Ismail ..post in forum, give details
Mon Aug 05 2019, 04:33 PM
Ismail balghmi
Hello. Please I won't download
ExperimenterUK
Wed Jul 24 2019, 12:47 AM
@BUSTER123 Please post in the forum
Tue Jul 23 2019, 06:13 PM
BUSTER123
hello! newbie here. i am kind of a guy who hates using ready - made existing libraries, so this helped a lot as i was trying to control and write to a character lcd display. however, i can't figure out how to set the cursor position. for example, i want to set it to the 5th column in the first row, so position 5. so according to the table, i am sending 10000101 on the 8 data lines of the lcd (register select pulled low). the cursor does not move there however. and i cant move the cursor left or right too. is it something wrong that i am doing? thank you.
ExperimenterUK
Thu Jul 11 2019, 07:55 PM
@ramos https://www.theengineeringprojects.com/2017/09/l298-motor-driver-library-proteus.html

Downloads

Comments

nabiha_anaya
Sun Dec 08 2019, 09:16 AM
ananyagupta
Tue Dec 03 2019, 07:53 AM
wells
Mon Nov 25 2019, 08:25 PM
auwal
Tue Nov 19 2019, 03:13 PM
ANKITPATEL
Mon Nov 18 2019, 11:00 AM
Casmir
Wed Nov 13 2019, 06:25 AM
DeepakBGattani
Mon Nov 11 2019, 01:31 PM
Jeanbusatta
Sun Nov 10 2019, 04:42 AM

Online

Guests: 66, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38108
Newest member: nabiha_anaya
Forum Activity
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Dec 10 2019, 04:49 PM
ilylily07 Avatar
Posted By ilylily07
Sun Dec 08 2019, 01:24 PM
Hi .im humbly ask for your advice as i wrongly pur...
nabiha_anaya Avatar
Posted By nabiha_anaya
Sun Dec 08 2019, 09:19 AM
My teacher assign me a project on "voice control h...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Nov 29 2019, 04:24 AM
" Is it possible to interface a fingerprint scanne...
ilylily07 Avatar
Posted By ilylily07
Thu Nov 28 2019, 03:50 PM
You will not find any code for an 8051 as no one w...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Nov 26 2019, 05:44 PM
You will not find any code for an 8051 as no one w...
ilylily07 Avatar
Posted By ilylily07
Tue Nov 26 2019, 04:13 AM
I tracked down a OV7670 data sheet.The OV7670 puts...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Nov 26 2019, 12:08 AM
I tracked down a OV7670 data sheet.The OV7670 puts...
ilylily07 Avatar
Posted By ilylily07
Mon Nov 25 2019, 04:38 PM
The 8051 has too little memory to do anything us...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Nov 19 2019, 10:44 PM
The 8051 has too little memory to do anything us...