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

Mon Nov 12 2018, 05:58 AM
Pavan_user
i have seen your replica of I2C programming using AT89C51 but i am unable to understand the "ack_bit" variable usage ...looks like it is always 1...can you elaborate how acknowledgment is working....
bgk3678
Tue Nov 06 2018, 02:36 PM
kindly any one give solution for my problem
ExperimenterUK
Mon Nov 05 2018, 09:48 PM
Pins high is the normal state. You need a program to set them low
mayengbam
Sun Nov 04 2018, 05:41 PM
hello, i am niranjoy, alll the port of my 8051 is always high, even i erase all the program. why is it so happen and what is the problem. any one please help me!
Sun Nov 04 2018, 02:16 PM
BASAVARAJ g kudamble
hi I am interfacing GSM 300 to 8051 microcontroller to receive message from mobile
ExperimenterUK
Sat Sep 29 2018, 06:28 PM
Please post questions in the forum.
Sat Sep 29 2018, 11:26 AM
Ashfaq Ch
hi i have some AT89C51RC microcontrollers already programed. some one help us to how to download from AT89C51RC and after study and edit all corractions reload to AT89C51RC controller
shshistiem
Wed Sep 12 2018, 10:58 PM
hii!! some1 please let me know how i ll get rfid code to 8051 by WEIGAND mode
DrNossberg
Tue Sep 11 2018, 08:09 PM
is there anyone here?
Mon Aug 27 2018, 07:30 AM
bun
Hello everyone´╝ü

Downloads

Comments

atalnet
Fri Nov 16 2018, 07:44 AM
genius784
Wed Nov 14 2018, 09:25 AM
katherineamt
Mon Nov 12 2018, 03:14 PM
wimac
Sun Nov 11 2018, 03:36 PM
suryanspn
Sat Nov 10 2018, 02:52 AM
RubenMarques
Tue Nov 06 2018, 06:35 PM
mayengbam
Sun Nov 04 2018, 05:36 PM
bgk3678
Sun Nov 04 2018, 02:27 PM

Online

Guests: 74, Members: 0 ...

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

Members: 38021
Newest member: atalnet
Forum Activity
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Nov 19 2018, 01:11 AM
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Nov 15 2018, 06:48 PM
Unfortunately I have no experience of LabView,but ...
katherineamt Avatar
Posted By katherineamt
Mon Nov 12 2018, 03:22 PM
I have never used LabView and I have to implement ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Nov 12 2018, 01:21 AM
wimac Avatar
Posted By wimac
Sun Nov 11 2018, 04:03 PM
bgk3678 Avatar
Posted By bgk3678
Sun Nov 11 2018, 07:25 AM
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Nov 06 2018, 06:10 PM
bgk3678 Avatar
Posted By bgk3678
Sun Nov 04 2018, 02:52 PM
bgk3678 Avatar
Posted By bgk3678
Sun Nov 04 2018, 02:48 PM
Xuenan Avatar
Posted By Xuenan
Sat Nov 03 2018, 01:08 PM
Make the 8051 frequency exactly 11.0592 MHz in pro...