Discussion in "Project Help" started by    Martinv    Feb 11, 2018.
Sun Feb 11 2018, 01:06 PM
#1
Hi All

I am reading an SMS from a SIM800L module. All commands work, I can send an SMS, no problem. When I read an SMS, the module seems to respond too quickly after the CMGR.... command, before the processor is ready (STC12C5604AD). I have tried normal "linear" programming to read the serial port, as well as a serial interrupt routine. With the SMS serial data simulated via another processor, both routines works perfectly. Has anyone come across this issue before? I searched, but did not find anything on this site or any other. Thanks.

The SMS message is typically *1N# or *1F# and the "1" and "N" is filtered and stored in R1 and R2.

CALL READSMS ;This is the CMGR.......routine to the SIM800

CHKSTAR: JNB RI,CHKSTAR ;WAIT FOR *
MOV A,SBUF
MOV B,A ;SAVE A FOR LATER
CLR RI
CJNE A,#02AH,CHKSTAR ;NOT STAR CHR? then LOOP

MOV R0,#03H ;SET CHR TO GET COUNT
;READ ONLY 3 CHRS AFTER *
;ALSO EMERGENCY EXIT IS # IS NOT FOUND

LOOPER: JNB RI,LOOPER ;WAIT FOR NEXT CHR IN
MOV A,SBUF
CLR RI

DJNZ R0,DO ;DO NEXT CHR IF CHR COUNT NOT DONE
JMP DEC ;ELSE DONE, DECODE SMS

DO: MOV B,A ;SAVE A

CHKFIG: ANL A,#030H ;MASK AND CHECK IF FIGURE
CJNE A,#030H,CHKLET ;NOT A FIGURE
MOV R1,B ;SAVE FIGURE

JMP LOOPER

CHKLET: MOV A,B ;MASK AND CHECK IF LETTER
ANL A,#040H
CJNE A,#040H,CHKHASH ;NOT IN LETTER "N" OR "F" RANGE
MOV R2,B ;SAVE LETTER

JMP LOOPER

CHKHASH: MOV A,B ;WAIT FOR # THEN DONE
ANL A,#020H ;MASK AND CHECK FOR HASH
CJNE A,#023H,LOOPER

DEC: JMP DECODE
Tue Feb 13 2018, 01:12 AM
#2
Unless "READSMS" has some very long delays I doubt the SIM800L
responds too quickly.
Can you post the "READSMS" code ?
What is happening that should not happen or doesn't happen that should ?

Are you able to print debug messages ?
 Martinv like this.
Tue Feb 13 2018, 09:22 AM
#3
Thanks for the reply. The part of the main loop that must read the SMS, is as below.

WAIT2: mov a,p3 ;read P3 inputs - CHECK RI
anl a,#010h ;mask all but RI P3.4
JNZ WAIT4 ;RI GOES LOW ON RING OR SMS
;check digital inputs meantime

CALL DELAY3 ;WAIT 1 SECOND FOR SMS TO FINISH
;THEN READ SMS
CALL READSMS

JMP DECODE ;DECODE THE SMS

The read routine always reads SMS #1, as I delete all SMS's after a new SMS is received. I have also played with
longer and shorter delays after the read.

The command is AT+CMGR=1 (file types set up etc.) I can confirm the 'read' is understood by the module.
I have a terminal connected to eavesdrop on comms. The read message goes through and within microseconds,
the message is returned by the SIM800. The format is +CMGR: "REC UNREAD"......number, time etc. 'CR' 'LF'
the in the next line *1N# 'CR' 'LF' and OK.

To save on air time, I have programmed a chip with the identical SMS string. When I trigger the event via P3.4
with the second chip and the "SMS string" comes through, the decoder routine reacts perfectly. The only difference
I can think of, is that the SIM800 responds quicker, while the second chip is programmed to respond after a ~second.

Apart from the terminal to monitor port activity, I have no other debug. On an 8051 simulator it also works fine.

I must be overlooking something basic! I have tried a faster clock, it was 11 Mhz and is now 27 Mhz - no change.

Thanks Pal.



[ Edited Tue Feb 13 2018, 09:23 AM ]
Tue Feb 13 2018, 08:07 PM
#4
Can you zip and attach your full code.
Using a second chip is a good idea.
You can also use a serial program such as "Termite" to simulate the SIM800L
https://www.compuphase.com/software_termite.htm


[ Edited Tue Feb 13 2018, 08:17 PM ]
 Martinv like this.
Tue Feb 13 2018, 09:26 PM
#5
Mmmm feel quite silly, but learned a lot. I must READ properly! The SIM800L hardware specs indicate serial communication as '8N1' and I was running 9 bits. The terminal program is very "flexible" and reads the data correctly with both 8 or 9 bits, but the processor not! That is why the chip-to-chip test worked as well - both at 9 bits. So I changed the SMOD to an 8-bit UART config and walla! I have been around this block for two weeks flat. This piece of code is now also working, so I can link the other sections and tidy up the code. Thanks a lot for your response, it got me thinking harder. Best.
Tue Feb 13 2018, 09:43 PM
#6
Glad you sorted it.
I'm sure you will remember if future.
Nothing is 9 bit


[ Edited Tue Feb 13 2018, 09:47 PM ]
 Martinv like this.

Get Social

Information

Powered by e107 Forum System

Conversation

Sat Feb 24 2018, 09:05 AM
Aaquib
I want help for digital ic tester
ExperimenterUK
Tue Feb 20 2018, 09:31 PM
Join up.. and post your problem
Mon Feb 19 2018, 04:47 PM
ashishkumar
i needs help for my project
Mon Feb 19 2018, 04:46 PM
ashishkumar
can i join you guys
ExperimenterUK
Mon Feb 05 2018, 03:08 AM
Hi Dave. Good to see you.
DavesGarage
Wed Jan 10 2018, 01:25 AM
It's been a few years since I poked around here - Hi all...
ExperimenterUK
Tue Jan 09 2018, 12:49 AM
Hi TPS. it's been a while..
۞ TPS ۞
Mon Jan 08 2018, 12:12 AM
hello
Thu Jan 04 2018, 07:20 PM
sayyad affrid
its AT89S52
Thu Jan 04 2018, 07:20 PM
sayyad affrid
sir, i want embedded c code for ultrasonic sensor having buzzer interfaced with AT9S52

Downloads

Comments

Manojsanghavi
Sat Feb 24 2018, 12:47 PM
Daro12_76
Wed Feb 21 2018, 05:01 PM
radhikanathani
Wed Feb 21 2018, 06:55 AM
Narayani
Wed Feb 21 2018, 04:10 AM
Parth09
Tue Feb 20 2018, 07:53 AM
goutham
Mon Feb 19 2018, 02:49 AM
kks
Sun Feb 18 2018, 05:59 PM
justotemon
Sat Feb 17 2018, 07:14 AM

Online

Guests: 45, Members: 0 ...

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

Members: 37971
Newest member: Manojsanghavi
Forum Activity
Manojsanghavi Avatar
Posted By Manojsanghavi
Sat Feb 24 2018, 01:03 PM
Dear allCan someone please help me on how to progr...
Ansh12 Avatar
Posted By Ansh12
Fri Feb 23 2018, 07:10 PM
sbit E = P0^7; //E pin for LCD //use port 0sb...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Feb 23 2018, 02:43 PM
sbit NOT #definesbit E = P0^7; //E pin for LCD ...
Ansh12 Avatar
Posted By Ansh12
Fri Feb 23 2018, 01:55 PM
change your defines tosbit E = P0^7; //E pi...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Feb 23 2018, 01:12 AM
Add pull- ups for EN and RS.change your defines t...
Ansh12 Avatar
Posted By Ansh12
Thu Feb 22 2018, 01:36 AM
Can you post your Proteus files.ExperimenterUKThan...
ExperimenterUK Avatar
Posted By ExperimenterUK
Wed Feb 21 2018, 09:07 PM
The code you refer to is to drive the circuitshown...
ExperimenterUK Avatar
Posted By ExperimenterUK
Wed Feb 21 2018, 05:41 PM
Can you post your Proteus files.You will need pull...
radhikanathani Avatar
Posted By radhikanathani
Wed Feb 21 2018, 02:39 PM
I want to design a system for vehicle tracking and...
Narayani Avatar
Posted By Narayani
Wed Feb 21 2018, 04:17 AM
Hello,Your tutorial really helped me understand st...