Discussion in "Project Help" started by    Martinv    Feb 11, 2018.
Sun Feb 11 2018, 06:36 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, 06:42 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, 02:52 pm
#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, 02:53 pm ]
Wed Feb 14 2018, 01:37 am
#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 Wed Feb 14 2018, 01:47 am ]
 Martinv like this.
Wed Feb 14 2018, 02:56 am
#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.
Wed Feb 14 2018, 03:13 am
#6
Glad you sorted it.
I'm sure you will remember if future.
Nothing is 9 bit


[ Edited Wed Feb 14 2018, 03:17 am ]
 Martinv like this.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Richardgar
Sat Apr 20 2024, 11:05 am
AntoniaRoons
Fri Apr 19 2024, 09:59 pm
carpinteyrowrl
Fri Apr 19 2024, 02:51 pm
DonaldJAX
Fri Apr 19 2024, 01:08 pm
Lewisuhakeply
Thu Apr 18 2024, 06:00 pm
Darrellciz
Thu Apr 18 2024, 11:07 am
Charlessber
Thu Apr 18 2024, 09:29 am
BartonSem
Thu Apr 18 2024, 04:56 am