Discussion in "8051 Discussion Forum" started by    Malik_Umair    May 24, 2013.
Wed Jun 05 2013, 09:53 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, 10:00 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, 10:02 pm ]
Thu Jun 06 2013, 12:16 pm
#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, 08:46 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, 01:00 pm
#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, 09:15 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, 11:27 am ]
Sat Jun 08 2013, 02:00 am
#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, 11:27 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, 11:00 am
#19
@Malik, Do share your final code with us
Fri Jun 21 2013, 07:50 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

Downloads

Comments

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
Bernardwarge
Tue Mar 26 2024, 11:15 am