Discussion in "8051 Discussion Forum" started by    Malik_Umair    May 24, 2013.
Wed Jun 05 2013, 04:23 AM
#11
You do not have to call "ACALL SERIAL" just call it once when your main routine starts. Problem with interrupt is, You did not enable interrupts properly instead of loading IE directly you can enable individual bits that help you make things more readable
MOV IE, #00000100B ; instead of this

;use
SETB EX0 ; interrupt for external interrupt 0 (INT0)
SETB EA ; this is global interrupt flag
Wed Jun 05 2013, 04:30 PM
#12
Thanks Ajay for pointing out the mistake, but unfortunately still on activation of interrupt 0, it is not going to interrupt routine. I have written the following command:

MOV IE,#10000001B ; EA enabled and INT0 enabled
;OR
MOV IE,#81H


Also please guide me regarding the SMS receiving and storing it in accumulator? Is my receiving code good?


[ Edited Wed Jun 05 2013, 04:32 PM ]
Thu Jun 06 2013, 06:46 AM
#13
I do not see a reason why interrupt does not come. Check if INT0 is going low or not. receiving sms is tricky in case assembly.
Thu Jun 06 2013, 03:16 PM
#14
Tricky in what sense? The code which I have shared here does something but not perform full task. I have noticed that this code only reads the sms but is not copying it to accumulator. Also I want to inquire that if I send SMS containing 1 so is it a ASCII character or normal decimal number when received to the MCU?
Fri Jun 07 2013, 07:30 AM
#15
anything coming out of modem will be ascii. I saw the way you implemented things. CMGR command sends lot of stuff not just the sms text. format is somewhat like:

+CMGR: 1, ... "mobile number" ...
sms text
OK

I suggest not to give delay after CMGR command, you will have to read every single byte coming out of modem. And comparing with 1 is not the right way.. coz as I said there is a lot of data that comes with CMGR command. there will be lot of 1s in it.

You can do something like, prefix and postfix your sms with a special character e.g. instead of sending just 1 in sms send "*1#" where * is a prefix and # is postfix. In your code, wait till you get * and then start to store the data to memory till you get # and then discard everything else.
 Malik_Umair like this.
Fri Jun 07 2013, 03:45 PM
#16
Hello Dear Ajay,

I am very thankful to you the help you are providing me so far. I have modified a part of program you pointed out. Please view the updated program, please comment if you find any mistake in it. I have also deleted the delay after CMGR. The following is the program:

   LCALL CMGR   ; READ THE STORED MESSAGE
            ;LCALL DELAY1
            ;LCALL DELAY1
            ;LCALL DELAY1
            ;LCALL DELAY1
;*************************************************************
  		   MOV R1,#01H     ; set a check to receive * when SMS is received
  RECV:    JNB RI, RECV
           MOV A,SBUF
           CLR RI
           
           MOV B,A
           MOV A,R1
           CJNE A,#00H,PROCEED
           SJMP COMPARE
           
 PROCEED:  MOV A,B
 		   CJNE A,'*',RECV
           DJNZ R1, RECV
           
  COMPARE: MOV A,B
  		   CJNE A,'1', ERROR         ; If TRUE then make P2.1 HIGH
  		   SETB P2.1
  		   LCALL DELAY1
  		   LCALL DELAY1
  		   LCALL DELAY1
  		   LCALL DELAY1
  		   CLR P2.1
  		   SJMP DELETE
           
   ERROR:  SETB P2.2                      ; If FALSE then make P2.2 HIGH
   		   LCALL DELAY1
   		   LCALL DELAY1
   		   LCALL DELAY1
   		   LCALL DELAY1
   		   CLR P2.2
           CLR A

;**********************************************************
  DELETE:   LCALL CMGD    ; DELETE THE SMS STORED IN SIM
            LCALL DELAY1
            LCALL DELAY1
            LCALL DELAY1
            LCALL DELAY1
            LJMP START


[ Edited Sat Jun 08 2013, 05:57 AM ]
Fri Jun 07 2013, 08:30 PM
#17
I do not know if your code has errors, but I suggest this version
Hopefully it is simpler and easier to follow.
            LCALL CMGR   ;READ THE STORED MESSAGE    

WaitForStar:
           JNB RI,WaitForStar 
            MOV A,SBUF
            CLR RI 
            CJNE A,'*',WaitForStar

WaitForCode:                           ;the next char is a command
           JNB RI,WaitForCode
            MOV A,SBUF
            CLR RI
            CJNE A,'1', ERROR    ; If TRUE then make P2.1 HIGH
            SETB P2.1
            Sjmp CommonExit
            
ERROR:  
	     SETB P2.2          ; If FALSE then make P2.2 HIGH
   
           

CommonExit:

            LCALL DELAY1
            LCALL DELAY1
            LCALL DELAY1
            LCALL DELAY1

             CLR P2.1
             CLR P2.2

             LCALL CMGD    ; DELETE THE SMS STORED IN SIM
             LCALL DELAY1
             LCALL DELAY1
             LCALL DELAY1
             LCALL DELAY1
             LJMP START





 Malik_Umair like this.
Tags read sms modem assemblysms read gsm modem assemblyread sms using assembly
Sat Jun 08 2013, 05:57 AM
#18
well I was thinking the other way..

	MSG equ	70H ;place to store sms
	
	LCALL SMSREAD ; call to SMS read routine
	
SMSREAD:
	LCALL READBYTE	;read character
	CJNE A, #'*', SMSREAD
	
	; * receieved start reading SMS
	MOV R7, #15 ;read only upto 15 bytes
	MOV R0, #MSG ;load pointer
READMSG:
	LCALL READBYTE
	CJNE A, #'#', STOREMSG
	SJMP MSGREADDONE

STOREMSG:
	MOV @R0, A
	INC R0 ;next location
	DJNZ R7, READMSG
	
MSGREADDONE:
	;either you received # or
	;15 character read, discard everything else
	;process your msg here
	
	;Read Byte routine
READBYTE:
	JNB RI, READBYTE
	MOV A, SBUF
	CLR RI
	RET


this way you can even send long msgs like "*LIGHT1 ON#" or "*LIGHT1 OFF#" this will give you better control and makes more interactive with hardware.
 Malik_Umair like this.
Tags read sms modem assemblysms read gsm modem assemblyread sms using assembly
Fri Jun 21 2013, 05:30 AM
#19
@Malik, Do share your final code with us
Fri Jun 21 2013, 02:20 PM
#20
Hello Ajay, I have planned it very earlier that once I am done I will post the entire project at this forum. Because this is the first forum where I have posted my problem and got helpful replies. Problem is I am still not able to receive the SMS and process the SMS. the sending portion of the code is perfectly fine and working. I will soon post the problem statement here.

Get Social

Information

Powered by e107 Forum System

Conversation

Sat May 15 2021, 11:47 AM
Derek Wolcott
Geometric Energy Corporation announced the dogecoin-funded mission on Sunday, with DOGE-1 representing a 40 kilogram cube satellite flying as a payload on a Falcon 9 rocket.
Thu May 13 2021, 07:18 PM
Rufus
Pretty section of content. I just stumbled upon your weblog and in accession capital to assert that I get actually enjoyed account your blog posts. Any way I will be subscribing to your augment and even I achievement you access consistently quickly. https://mkfinstitute.com Trisha Trisha
Wed May 12 2021, 01:23 PM
Jed Roan
Now you can promote your site all over the internet for FREE: http://www3.listofsitesthatacceptfreeads.club
Wed May 12 2021, 08:20 AM
Edgardo
If some one wants to be updated with most recent technologies afterward he must be visit this web page and be up to date every day. annual credit report https://creditscoresetf.com
Wed May 12 2021, 06:11 AM
Laurinda
Great website. A lot of useful information here. I'm sending it to some pals ans also sharing in delicious. And of course, thanks on your effort! annual credit report https://creditscorecheckn.com

Downloads

Comments

Mirza123
Thu Jun 25 2020, 03:46 PM
eunicelove124
Mon Jun 22 2020, 03:03 PM
cerouno
Tue Jun 16 2020, 05:10 PM
Marce
Sat Jun 13 2020, 09:43 PM
Davidthils
Thu May 21 2020, 12:44 PM
Jakeror
Thu May 21 2020, 01:28 AM
motorCar
Wed May 20 2020, 07:05 PM
Vordrync
Wed May 20 2020, 11:52 AM

Online

Guests: 110, Members: 0 ...

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

Members: 38215
Newest member: Mirza123