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

sms
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
frustrated
Guest







sms
PostPosted: Mon Mar 27, 2006 7:41 am     Reply with quote

can anyone point out what i am doin wrong, this is really starting to bug me i am following at commands but when i blast the pic with this code it seems to work but when pic and modem are connected nothing happens, i am at a loss, any constructive comments welcome
Code:

#include <16F877.h> /* Defines chip */
#include <stdio.h>   /* this gets the printf() definition */
#use delay(clock=4000000)
#fuses hs, noprotect, nowdt, nolvp
#use rs232(baud=9600,xmit=PIN_C6, rcv=PIN_C7, stream=GSM, ERRORS)


const int CR=0x0d;
const int CZ=0x1A;

void main()

{
fprintf(GSM,"AT\r\n");
delay_ms(5000);                     /* checks are they communicating */
fprintf(GSM,"AT+CMGF=1\r\n");                /* sends an at command reay to send */
delay_ms(5000);                        /*sends a carriage return */
fprintf(GSM,"AT+CMGS=\"07712121212\"");    /* sents the following text to this number */
fputc(CR,GSM);
delay_ms(5000);
fprintf(GSM,"Hi world");                /* the text that will actually be sent */
delay_ms(5000);
fputc(CZ,GSM);                         /* sends carriage return */
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 27, 2006 1:59 pm     Reply with quote

At a minimum, you need to add a while(1) statement at the end of main().
This will prevent the PIC from executing the hidden SLEEP instruction
which is placed there by the compiler. If the PIC goes to sleep, your
"CZ" character will never be sent. Add the line shown in bold below:
Quote:

delay_ms(5000);
fprintf(GSM,"Hi world");
delay_ms(5000);
fputc(CZ,GSM);

while(1);
}


Also, you don't have to use traditional C comments. Use the // style.
You can type in code much faster that way.
frustrated
Guest







PostPosted: Tue Mar 28, 2006 12:37 pm     Reply with quote

thanks PCm but this still does not work i heard that you must send each character individually is this true, any more help on why this will not work
ckielstra



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

View user's profile Send private message

PostPosted: Tue Mar 28, 2006 3:55 pm     Reply with quote

If you connect the PIC to a PC, do you then see the expected messages?

Does the modem work when you connect it directly to a PC?
frustrated
Guest







PostPosted: Tue Mar 28, 2006 4:09 pm     Reply with quote

not quite it seems to work but when the send message command the character ">" does not come up so i know that the code isnt working, im at a total loss
ckielstra



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

View user's profile Send private message

PostPosted: Tue Mar 28, 2006 5:22 pm     Reply with quote

frustrated wrote:
not quite it seems to work but when the send message command the character ">" does not come up so i know that the code isnt working, im at a total loss
Sorry, I don't understand what you mean. You say 'it seems to work', but what is 'it'? The PIC, PC or the modem?

Try to narrow down the problem. Make 100% sure it is either the PIC or modem failing by connecting them to a PC. When you connect the PIC to a PC, and you don't see the expected messages than you know the PIC is failing. Try similar by connecting the modem to a PC.
Chicky



Joined: 04 Aug 2005
Posts: 21

View user's profile Send private message

PostPosted: Wed Mar 29, 2006 1:34 am     Reply with quote

maybe u can try this:

Code:
fprintf(GSM,"AT+CMGS=\"07712121212\"");   
fprintf("\n");  >> this is the same as CR

i use this when i interface my pic to siemens m50...
but the code is slightly diff, as i'm not using gsm modem but hp...

also try this:
Code:
printf("at+cmgs=?\r");
   delay_ms(1000);


if ur modem answer with OK, then its ready to send sms...

and why dont u use hyper terminal and simulate ur AT commands?
after successful, just convert the code to C and substitute hyperterm with PIC...

hope this help Very Happy
arunb



Joined: 08 Sep 2003
Posts: 492
Location: India

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

RE:
PostPosted: Wed Mar 29, 2006 7:17 am     Reply with quote

Hi,

If the PIC works well with the PC then it should also work with the modem..

thanks
arunb
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

Re: RE:
PostPosted: Wed Mar 29, 2006 7:19 am     Reply with quote

arunb wrote:
Hi,

If the PIC works well with the PC then it should also work with the modem..

thanks
arunb

If the PIC works with the PC then you will need a crossover cable with the modem.
frustrated
Guest







PostPosted: Wed Mar 29, 2006 8:49 am     Reply with quote

i have done all this, i used the commands specified by the manufacturer, i then made my code suitable to implement these commands. when i put the command printf and then put the command in as a string. i even modified the code to put one char in at a time, but it only enters the a command.

I also heard that the echo function was on the modem i had this disabled and still no joy, i really appreciate all ur help tho, any more suggestions tho?
khawer102



Joined: 14 Mar 2006
Posts: 9
Location: Pakistan

View user's profile Send private message MSN Messenger

PostPosted: Wed Mar 29, 2006 10:03 am     Reply with quote

I have the exact similar problem. my PIC communicates fine with the PC and my modem works fine too. but when i try to communicate modem with PIC it does not work.

i bought a gender changer which changes male-female serial cable to male-male. but it does not make any difference.

frustrated if you come up with some solution plz tell me about it too. i am working on the same and if i have any success i wil inform you about it too.
rberek



Joined: 10 Jan 2005
Posts: 207
Location: Ottawa, Canada

View user's profile Send private message

PostPosted: Wed Mar 29, 2006 10:10 am     Reply with quote

You need a null modem cable.

http://www.ccsinfo.com/forum/viewtopic.php?p=60922&highlight=#60922
frustrated
Guest







PostPosted: Wed Mar 29, 2006 12:23 pm     Reply with quote

was talking to a lectuter today he said it is probably the cable as the previous post pointed out

male(millenium dev board) female (modem)
------------------------------------------------------------------------------------

the problem he said was that the millenium board did not use a crossover cable tx pin2 was also tx on what is supposed to be the rx. he suggested making own serial cable, any wiring diagrams or other solutions appreicated.

thanks i will post a solution if it arrives
echo
Guest







PostPosted: Wed Mar 29, 2006 1:04 pm     Reply with quote

how do you cope with the acks back from the modem
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Wed Mar 29, 2006 9:49 pm     Reply with quote

frustrated wrote:
was talking to a lectuter today he said it is probably the cable as the previous post pointed out

male(millenium dev board) female (modem)
------------------------------------------------------------------------------------

the problem he said was that the millenium board did not use a crossover cable tx pin2 was also tx on what is supposed to be the rx. he suggested making own serial cable, any wiring diagrams or other solutions appreicated.

thanks i will post a solution if it arrives

NULL MODEM cable.
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 1, 2  Next
Page 1 of 2

 
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