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

Sun May 20 2018, 06:01 PM
justinb
how to write and execute a program that read the keypad button and display the number on 7 segment on intel8051 at89s52 in assembly language?
Sun May 20 2018, 05:56 PM
justinb
how to write and execute a program that read the keypad button and diplay the number on 7 segment ?
Sun May 20 2018, 01:44 PM
StephenTitly
https://coindump.biz/?ref=0110ce0e15d11860f5c787dd7668239a
Thu May 17 2018, 02:36 PM
HAMZA TAJ
sir iwant to ask about controller of three phase supply by using back to back thyristor instead of triac....will u give me some guideline?
Sat Apr 28 2018, 08:54 PM
ashutosh jain
IR Remote Switch using TV remote (RC5 Protocol) is not working properly. opp1 & opp2 is in problem.plz help
ExperimenterUK
Sat Apr 28 2018, 04:09 AM
@kaiserslautern Post in forum
Wed Apr 25 2018, 03:09 PM
kaiserslautern
Hello everyone, using software uart is a very good idea for a second serial port. Thank you so much. I would kindly like to know how to connect this port to the PC?
ExperimenterUK
Sun Apr 22 2018, 03:50 AM
This is a community site. Feel free to help anyone needing advice
hareeshchamiyar
Thu Mar 29 2018, 06:47 PM
please help me for the configuration bits for dspic30f2010
hareeshchamiyar
Thu Mar 29 2018, 06:45 PM
can any one using dspic30f2010.

Downloads

Comments

bdmehta
Tue May 22 2018, 02:30 AM
kmag1953
Sun Apr 29 2018, 07:09 PM
udiwonder
Sat Apr 28 2018, 12:41 PM
pirpiri
Sat Apr 21 2018, 03:35 PM
Pater
Fri Apr 20 2018, 02:38 PM
jamiel
Sat Apr 14 2018, 12:47 AM
akrepkral76
Wed Apr 04 2018, 07:51 PM
samanthaeaves
Mon Apr 02 2018, 06:27 AM

Online

Guests: 35, Members: 0 ...

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

Members: 37998
Newest member: bdmehta
Forum Activity
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon May 14 2018, 10:17 PM
So the main problem is that I am not getting Analo...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon May 14 2018, 09:40 PM
Hi sir after checking all the connection i...
Pater Avatar
Posted By Pater
Mon May 14 2018, 05:36 PM
Basically my project is based on Data Acquisition ...
LAMBO Avatar
Posted By LAMBO
Sun May 13 2018, 02:13 PM
Hi sir after checking all the connection i...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon May 07 2018, 07:27 PM
This design should be fine.Choose a frequency betw...
Pater Avatar
Posted By Pater
Mon May 07 2018, 01:28 PM
Sorry for late reply as exams were on,Based on my ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu May 03 2018, 03:32 PM
If the circuit works with a light bulb, the probl...
LAMBO Avatar
Posted By LAMBO
Thu May 03 2018, 08:04 AM
Hi sir as u mentioned above everthing is working...
ExperimenterUK Avatar
Posted By ExperimenterUK
Wed May 02 2018, 08:28 PM
Thanks for the video clip, it's a good idea.Electr...
LAMBO Avatar
Posted By LAMBO
Wed May 02 2018, 10:53 AM
Hi sir did the changes as per instructions. ...