CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Problem with receiving strings from SIM900 with INT_RDA
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Mustang1945



Joined: 07 Jul 2015
Posts: 31
Location: Ecuador

View user's profile Send private message

PostPosted: Wed Nov 18, 2015 5:33 pm     Reply with quote

ezflyr... i am not trying to get "something" to work, i have been searching for documentation of the board and it doesn't exist.

Quote:
It also has a MAX232 interface to translate the 3.6V signals from the SIM900 module UART to RS232 levels


i think you are wrong because in the link i had been posted before

http://simcom.ee/documents/SIM900/SIM900_Serial%20Port_Application%20Note_V1.03.pdf

page 8 talk about to connect directly tx and rx to max3221 and not a max232.

...then i think that the manufacturer takes the 3.6 signals...use a level translator...then we have 5v in tx and rx pins of the board, and the same 5v goes to the max232 for the rs232 connection.
temtronic



Joined: 01 Jul 2010
Posts: 9250
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Nov 18, 2015 7:25 pm     Reply with quote

if this...
Sorry, i have been busy in my job, here is the website and the pictures there are better than mine:
http://www.sainsmart.com/sim900-gprs-gsm-board-quad-band-module-kit-for-arduino-high-quality-new.html...

is the board you are working with, it does use a MAX232 to interface, making it an 'RS232' type device.
To make it interface to your PIC you WILL need to add another MAX232(or equal) between the PIC and the 'modem'. Be sure to put rx to tx, and tx to rx AND a gnd !
Providing you have the serial config correct (baud,bits,etc.) it 'should' work....

Jay
Mustang1945



Joined: 07 Jul 2015
Posts: 31
Location: Ecuador

View user's profile Send private message

PostPosted: Wed Nov 18, 2015 9:28 pm     Reply with quote

Thanks for the idea but i tried that configuration and i used getc, and it works, then i programmed the PIC to use get string and didn't work, it is the same error.

I send the sms, the program goes to the interrupt, turns on the led that indicates that I have received the correct word and stays there...never returns to main program.
Mustang1945



Joined: 07 Jul 2015
Posts: 31
Location: Ecuador

View user's profile Send private message

PostPosted: Thu Nov 19, 2015 8:14 am     Reply with quote

hi...look at this

https://s3-ap-northeast-1.amazonaws.com/sain-amzn/20/20-012-106/SIM900_A_+Module+Series+Debug+_unfinished_.pdf

this is the board i am using but if you read, they say that hardware conection with PIC is >

TX PIC...TX SIM900

RX PIC...RX SIM900

that is wrong...

i connect tx with rxsim900 and rx with txsim900 and it works.

and in the rs232 interface they say that >

TX (rs232-usb interface)...RX SIM900(rs232 interface)

RX (rs232-usb interface)...TX SIM900(rs232 interface)

in this case the connection should work but in the sim900 rs232 interface the pins are changed, i use an rs232-usb interface and the connection works with this configuration>

TX(rs232-usb interface) ...TX SIM900 (rs232 interface)

RX(rs232-usb interface)...RX SIM900 (rs232 interface)

i think i have bought the worst sim900 board , no exists documentation, and when i found something...it is wrong
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Thu Nov 19, 2015 9:46 am     Reply with quote

Hi Mustang1945,

A colleague at work recently asked me to help him build a remote temperature monitor for his vacation house. I think a GSM solution would be ideal, so I decided that this would be a good opportunity to (1) help him, and (2) help you! So, I ordered one of these Sainsmart GSM modules from Amazon for this project. Once I receive it, I will figure out the necessary connections between the Sainsmart module and the PIC, and will document my findings and post them here. I will also document a level translation circuit using commonly available components. In this way, I can help my colleague and you at the same time. Win-win! Very Happy

We are about to celebrate the Thanksgiving holidays here in the US, and I will be traveling a bit. I'm not sure when the Sainsmart module will actually arrive, so it may be as late as mid-December before I can post my findings, but I promise to do so at my earliest convenience.
_________________
John

If it's worth doing, it's worth doing in real hardware!
Mustang1945



Joined: 07 Jul 2015
Posts: 31
Location: Ecuador

View user's profile Send private message

PostPosted: Thu Nov 19, 2015 10:14 am     Reply with quote

ezflyr...thanks

i will find some time to continue doing tests with get string, as i said... i am late with my proyect, meanwhile... i will continue using getc
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Thu Nov 19, 2015 10:32 am     Reply with quote

Hi,

If you think you are actually receiving valid serial data from the GSM board then you should post some 'problem code' for us to take a look at! All my projects use the int_rda serial interrupt and the getc() functon, and I generally avoid gets() like the plague! Sometimes I implement a linear receive buffer, and sometimes I implement a circular receive buffer, depending on the data throughput.
_________________
John

If it's worth doing, it's worth doing in real hardware!
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Nov 19, 2015 3:22 pm     Reply with quote

I had a quick look at all the posted links and documents.
Please note that the board has both an RS232 level output and also a TTL level output. Perhaps this is where a lot of confusion comes from?

The TTL-level Rx and Tx signals from the modem are routed to the 3 jumpers on the board, this is your TTL-connector when the jumpers are removed. With the jumpers present the signals continue to a MAX232 and then to the larger connector, this is the RS232 level voltages.

So, to use this modem with your PIC you don't need a MAX232. Just remove the 3 jumpers and connect your PIC there. I didn't check, but most likely a 3.3V to 5V conversion is to be added.

The getstring function is a bit difficult to use. When I remember correctly, it waits for a CR but many applications send CR/LF. This LF character becomes then the first character of your next line. You don't want this as it messes up the received text.

Have a look in the Code Library part of this forum. Several GPRS modem programs have been posted there. Study them and learn.
Mustang1945



Joined: 07 Jul 2015
Posts: 31
Location: Ecuador

View user's profile Send private message

PostPosted: Thu Nov 19, 2015 7:20 pm     Reply with quote

hi...ckielstra....sure...i know that i have 2 kinds of serial pins on the board... but you said that if i remove the 3 jumpers there is my ttl connections...but in the last pdf i posted clearly say that the 3 jumpers marked as t900,r900 and gnd are rs232 signals,no ttl.

ttl signals are near the 5v and gnd pins.
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Fri Nov 20, 2015 9:01 am     Reply with quote

ckielstra wrote:
I had a quick look at all the posted links and documents.
Please note that the board has both an RS232 level output and also a TTL level output. Perhaps this is where a lot of confusion comes from?

The TTL-level Rx and Tx signals from the modem are routed to the 3 jumpers on the board, this is your TTL-connector when the jumpers are removed. With the jumpers present the signals continue to a MAX232 and then to the larger connector, this is the RS232 level voltages.


Hi,

Clearly there is a 'MAX232' on the board as pictured, so both 'TTL' and 'RS232' levels exist on the board. I also agree that it is *likely* that each flavor of these signals can probably be accessible to the user, however, with the documentation provided I don't believe you can say that with 100% certainty. For example, the UART pins on the SIM900, Pins 9 and 10, are labelled 'TxD' and 'RxD'. The only other place on the schematic that I can find those *exact* pin names is at the MAX232 device. I don't see those exact names appear on any of the headers. Is that just a mistake or an oversight in the documentation? Further, the schematic shows all DIP headers, while the board clearly has at least one SIP header. My conclusion is that the schematic doesn't match the hardware shown 100%, and/or is very imprecise and sloppy. Therefore, any statements about the *exact* nature of the hardware is just educated speculation!
_________________
John

If it's worth doing, it's worth doing in real hardware!
Mustang1945



Joined: 07 Jul 2015
Posts: 31
Location: Ecuador

View user's profile Send private message

PostPosted: Tue Nov 24, 2015 7:23 pm     Reply with quote


SOLVED!!!


Hi all!!!... finally i have solved the problem:

I must use ATE0 command!


I had read about ATE command, and in some forums they had this problem when they sent a sms from the sim900 and in the mobile received the AT command, like:
Code:

AT+CMGS="+593980714658"
HELLO

well...i never had this problem, so... i never used ATE command.

and that is the solution, it is necessary to use ATE0 when you want to get a string (somehow the sim900 sends unnecessary data to PIC when you are getting the string and keeps the PIC in the INT_RDA).

But also have some considerations:

-TX and RX from the SIM900 board can be connected directly to PIC.

-configure the sim900 from Hyperterminal or TeraTerm, is the easiest form and you can see what are you writing, what the sim900 response is, and some of the AT commands are saved automatically in the sim900.

-buy a sim900 with the manufacturer's documentation (it saves you a lot of time).

Thanks all for your help, it makes this solution easier!
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Wed Nov 25, 2015 8:45 am     Reply with quote

Hi Mustang1945,

I sure hate to rain on your parade, but you really didn't *solve* anything, all you did was to put a band-aid on some flawed code that happened to make this work for the moment.....

Here is what I mean. You said: "somehow the sim900 sends unnecessary data to PIC when you are getting the string and keeps the PIC in the INT_RDA". From this statement, I assume that you are doing something like this:

Code:

#int_rda
void serial_isr()
{
    gets();
}


If that is the case, you are using the serial interrupt handler in a totally incorrect, and somewhat dangerous way. The handler is designed to get a single character from the PIC UART each time the handler is triggered! If you use gets() inside the handler then you can have 'odd' behavior like you have already experienced, and your PIC may 'hang' if the complete 'string' is never received! Even a transient 'noise' event may trigger your serial interrupt handler, and hang your code!

You really need to re-think your approach, and you really need to show us some code if you want/need further help! As an inexperienced PIC programmer you don't even know what you don't know, and currently your confidence level seems to be out-of-sync with your skill set!
_________________
John

If it's worth doing, it's worth doing in real hardware!
Mustang1945



Joined: 07 Jul 2015
Posts: 31
Location: Ecuador

View user's profile Send private message

PostPosted: Thu Dec 03, 2015 6:37 pm     Reply with quote

Ttelmah wrote:
OK.

Fundamental problem is that INT_RDA, says _one_ character is waiting. Just one.
gets, waits for a 'string' (actually a line terminated by a new line, which it then turns into a 'string'). So straight away your INT_RDA, will hang waiting...

What you need is an INT_RDA handler that 'builds' a string for you


This is what ezflyr is telling you INT_RDA does not magically get called when there is a complete line waiting for you, it gets called for every character.



Ttelmah
and ezflyr...

thanks for show me that i am in a mistake, i had read this comment before but i didnt pay enought attention.

now i understand that i cant use get_string inside the interrupt, i must use getc.

ezflyr... you can see the code in the page 1 ,and about the "band aid"... i really thought that i had found the problem because i made some tests and i must said that only when i used ATE0 it worked, but its true that i didnt understand why.

thanks...i appreciate your help
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group