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 support@ccsinfo.com

GSM problems with AT commands

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ed_Banses



Joined: 15 Sep 2005
Posts: 15

View user's profile Send private message

GSM problems with AT commands
PostPosted: Tue Nov 22, 2005 4:14 pm     Reply with quote

Hi everybody,

I am starting a project trying to communicate a PIC16F877A with a GSM modem Fargo Maestro 100.
I want to send a message and I can do it by using a PC connected by hyper terminal with the modem.
The problem arrives when I try to connect the PIC with the MODEM, y cannot send the message, there is teh code:

#include <16f877A.h>
#device ICD=TRUE
#fuses HS,NOLVP,NOWDT,PUT
#use delay(clock=20000000)
#use rs232(baud=115200, xmit=PIN_C6, rcv=PIN_C7, bits=8, stream=GPS)

const int CR=0x0d;

void main() {

fprintf(GPS,"AT+CMGF=1");
fputc(CR,GPS);
fprintf(GPS,"AT+CMGS=\"+44788614354\"");
fputc(CR,GPS);

delay_ms(1000);
fprintf(GPS,"Hi world");

fputc(0x1A,GPS);
delay_ms(1000);
putc(CR);
}

Thanks a lot just for reading.
Looking forward any idea.
Eduardo
Ttelmah
Guest







PostPosted: Tue Nov 22, 2005 4:24 pm     Reply with quote

Add ERRORS to the RS232 statement. Though it doesn't matter at present, the UART receive side will be 'hung' after the code, since the incoming data has not been processed.

Add:
while(true);

After your last putc, otherwise the last characters will never be sent, as the PIC will run off the end, and go to sleep.

Why are you using 'putc' here, not fputc?.

Seriously, look at your hardware. Remember that the PC, generates RS232, while the PIC develops TTL serial. You need signal inversion, and level shifting to match what the PC generates.

Best Wishes
Ed_Banses



Joined: 15 Sep 2005
Posts: 15

View user's profile Send private message

PostPosted: Wed Nov 23, 2005 6:43 am     Reply with quote

Thanks a lot for the reply Ttelmah

I have just included the task in a while loop, the sms should be sended when I press a button and wait until the next time I will press it.
In addition to this I changed the last putc with a fputc.
But the application is still not working.
Could you tell me how can I add the ERRORS to the RS232 statements?
Can I use the virtual RS232 of the ICD-4000 as a monitor for the messages of the modem?
Thanks a lot.
Eduardo
arunb



Joined: 08 Sep 2003
Posts: 492
Location: India

View user's profile Send private message Send e-mail

RE:
PostPosted: Wed Nov 23, 2005 7:13 am     Reply with quote

Hi,

How are you trying to receive the data from GSM. ??

You should use the receive interrupt for this, after the interrupt has occurred , you should read the entire string...

thanks
arunb
Foppie



Joined: 16 Sep 2005
Posts: 138
Location: The Netherlands

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

PostPosted: Thu Nov 24, 2005 1:36 am     Reply with quote

Ed_Banses wrote:
Could you tell me how can I add the ERRORS to the RS232 statements?

Code:
#use rs232(baud=115200, xmit=PIN_C6, rcv=PIN_C7, bits=8, ERRORS, stream=GPS)
Ed_Banses



Joined: 15 Sep 2005
Posts: 15

View user's profile Send private message

PostPosted: Thu Nov 24, 2005 4:57 am     Reply with quote

Thanks a lot for your ideas, I will try them!!
I will tell you how is going everything.
Thanks a lot again,
Eduardo
r520m
Guest







PostPosted: Thu Nov 24, 2005 7:03 am     Reply with quote

Hi

1.- Try to use baud=9600, up to 57600.
2.- Try to comunicate PC with 16F877 using 9600 up to 57600, using max232.
If your hyperterminal receives the chars sent, your PIC is working very well. So you will can comunicate PIC to modem.
3.- If you canīt receive data from PIC on PC, the hardware UART is not workink.
4.- Try to use "force_sw" in use rs232 definition, for UART pins be have a software behavoir.

5.- If 4 point not works, try use another pins of PIC...

6.- IN your code there is not rutine for receive data from modem, example, send AT<CR>, modem answers with AT....may be modem is working, but the code have faults...

An question:

Modem works in RS232 or TTL levesl?



Sorry for my bad english


Bye
r520m
Guest







PostPosted: Thu Nov 24, 2005 7:18 am     Reply with quote

Hi again:

from www.fargo.com

Code:
Fargo Maestro 100 (GSM and GPRS Class 10)

The connection is made easily through the RS 232 interface.

Interface Connections:
-SIM holder
-15 pin Sub-D connector (serial and audio connection)
-4-pin power supply connector (micro-FIT 3.0)
-SMA antenna connector (50 ohm




It seems Maestro use RS232 levels, in fact, PIC use TTL levels...

So, you must use a level shifter first, like a MAX232 chip...you will get the glory with him.

A test, measure TX and RX pin respect ground...you will get + and - levels..thats mean you must use MAX232..

DB-15 pinout http://www.aggsoft.com/rs232-pinout-cable/modem-db9-to-db15.htm

- TX (12)
- RX (13)
- System Groung (1,8,15)


Bye
Ed_Banses



Joined: 15 Sep 2005
Posts: 15

View user's profile Send private message

PostPosted: Sat Nov 26, 2005 6:16 am     Reply with quote

Thanks a lot for your responses.
Unfortunately I am still without communication :(
I wrote the next code in order to check the communication with the modem:

Code:

#include <16f877A.h>
#device ICD=TRUE
#fuses HS,NOWDT,NOPROTECT,NOLVP

#use delay(clock=20000000)

#use rs232(baud=115200, xmit=PIN_C6, rcv=PIN_C7, bits=8, ERRORS, stream=GSM)
#use rs232(DEBUGGER, stream=DEBUG)
#define PUSH_BUTTON PIN_A4

const int CR=0x0d;
char escrito[40];
byte c;

wait_for_one_press()
{
   while(input(PUSH_BUTTON));
   delay_ms(200);
   while(!input(PUSH_BUTTON));
}

void main() {
   while(TRUE){

      wait_for_one_press();
      fprintf(GSM,"AT");
      fputc(CR,GSM);
      fgets(escrito,GSM);
      fprintf(DEBUG, "\r\n\%s",escrito);

   }

}

The problem is that I cannot receive the "OK" from the modem, PIC is trying to read the response but nothing arrives to it.
I checked with hyperterminal and everything looks fine.
I would appreciate any idea about it.
Many thanks in advance
Eduardo
r520m
Guest







PostPosted: Sat Nov 26, 2005 11:54 am     Reply with quote

First, tell us what are you doing, do you use max232 bettwen PIC and your modem?

Bye
Ed_Banses



Joined: 15 Sep 2005
Posts: 15

View user's profile Send private message

PostPosted: Sat Nov 26, 2005 12:18 pm     Reply with quote

Well, I am using the evaluation board of CCS for the PIC16F877 microcontroller.
Mainly is the PIC connected to a MAX232 and y connected the Max In/Out to the MODEM.
Thanks a lot.
Regards,
Eduardo
Ttelmah
Guest







PostPosted: Sat Nov 26, 2005 3:23 pm     Reply with quote

A couple of obvious questions at this point. Ae you connecting the ground wire as well?. It is needed.
Are you sure you have the TX/RX connected the right way round?. Remember that the if the PIC is normally connected to the PC, it'll have it's 'TX' pin, connected to the PC's 'RX' pin, and vice versa. The Modem will be the same (they are both technically wired as DCE devices). You will actually need a 'null modem' cable, to allow the units to connect to each other.

Best Wishes
Victor



Joined: 27 Oct 2003
Posts: 12

View user's profile Send private message

PostPosted: Mon Nov 28, 2005 2:00 am     Reply with quote

To read incoming sms, I can use AT+CMGL, but I must poll it often.
Can I get any trigger message if there is new incoming SMS?
I am using TC35i.

Thank you.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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