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

Send SMS doesn't work

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



Joined: 22 Aug 2005
Posts: 275

View user's profile Send private message

Send SMS doesn't work
PostPosted: Thu Oct 30, 2014 12:25 am     Reply with quote

Hi to all,
I have a strange problem I can't understand. I'm working around PIC18 drive a GSM modem with AT command. It's work fine in debug mode with ICD2 and Pickit3 but after program micro it receive SMS but don't send out it.
Routine SEND_SMS() is based on old post but it's quite simple.
This is code of this Routine:
Code:

//______________________________________________________________________________
//
//                           SEND SMS
void SEND_SMS()
{
long i;

if (debug_lcd){
   lcd_putc('\f');
   printf(lcd_putc,"Send SMS");
   lcd_putc('\n');
   printf(lcd_putc,"%s",nr_tel_SMS);      // In nr_tel_SMS I have Phone numner as string follow "+YYXXXXXXXXXX"
}

   delay_ms(1000);
   counter_read=0;
   printf("AT+CMGS=\"%s\"\r",nr_tel_SMS);  // In nr_tel_SMS I have Phone numner as string follow "+39XXXXXXXXXX"
 
while(Receive_String[0]!='>'){
      delay_ms(100);                           
      i++;
       if (i>300)
         break;
   }
   counter_read=0;   
   printf("%s \n\r",testo_SMS);
   putchar(0x1A);                           
   DELAY(20);                               
}


I print out on LCD some information and seems PIC wait for a very long time ">" character. This not happened in debug mode because in some seconds SMS arrive. I disabled also WDT and other features of PIC without solve.
I use PIC18F46K22 and CCS V4.135. Can somebody suggest me what I must check ?

Thanks,
Fabri
Fabri



Joined: 22 Aug 2005
Posts: 275

View user's profile Send private message

PostPosted: Thu Oct 30, 2014 4:49 am     Reply with quote

I did some test and this is data from PIC and Modem capture with serial terminal. The program check RING and send back SMS with some text information.

In Release modem doesn't send back sms:
Code:

\0A+CMGR: 0,,0\0D                                                     
\0A\0D                                                               
\0AOK\0D                                                             
\0A\0D                                                               
\0ARING\0D                                                           
\0A\0D                                                               
\0A+CLIP: "+39XXXXXXXXXX",145,,,,0\0D                                 
\0AATH\0D                                                             
\0AOK\0D                                                             
\0AAT+CMGS="+39XXXXXXXXXX"\0D                                         
   > macchina in funzione contatore progressivo=00000  \0A



and Release when modem send back SMS:
Code:

\0AOK\0D                                                             
\0AAT+CMGR=1\0D                                                       
\0A+CMGR: 0,,0\0D                                                     
\0A\0D                                                               
\0AOK\0D                                                             
\0A\0D                                                               
\0ARING\0D                                                           
\0A\0D                                                               
\0A+CLIP: "+39XXXXXXXXXX",145,,,"No Name",0\0D                       
\0AATH\0D                                                             
\0AOK\0D                                                             
\0AAT+CMGS="+39XXXXXXXXXX"\0D                                         
   > macchina in funzione contatore progressivo=00000  \0A           
\0A                                                       \0D         
\0A+CMGS: 187\0D                                                     
\0A\0D


In release mode the modem after confirm request of text of SMS with '>' , stop to work and sometimes I need to power down.

Thanks for your suggestion.
temtronic



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

View user's profile Send private message

PostPosted: Thu Oct 30, 2014 8:56 am     Reply with quote

Without seeing a short,complete program it's hard to decide what is the problem...

possible issues..
1) 5V PIC, 3V SMS device

2) lack of 'errors' in the use rs232(....options..)

3) rcv buffer too small....

4) improper rcv ISR...

5) use of delays inside ISR

6) icd=true even though in 'release' mode

post a small program so we can see.....

Jay
Fabri



Joined: 22 Aug 2005
Posts: 275

View user's profile Send private message

PostPosted: Thu Oct 30, 2014 9:48 am     Reply with quote

Dear temtronic,

Yes, there's alot of possibility..... the firmware is quite complex but the problem is only in routine SEND_SMS(). Happens only in release firmware not in debug. After some other tests seams modem doesn't receive 0x0A command after sms text. Now I send 2 times "0x0A" and seams all going fine. This is my first experience with GSM so I don't know if send out 2 times cntrl-z command is correct.

Regards,
Fabri
Ttelmah



Joined: 11 Mar 2010
Posts: 19559

View user's profile Send private message

PostPosted: Thu Oct 30, 2014 9:52 am     Reply with quote

Add 'grounding'.
Remember the radio stuff will work completely differently with the ground present from the debug unit.
Fabri



Joined: 22 Aug 2005
Posts: 275

View user's profile Send private message

PostPosted: Thu Oct 30, 2014 10:08 am     Reply with quote

My modem isn't RS232 but RS485 so I think grounding is not important.... actually my solution is send cntrl-z two times.
hmmpic



Joined: 09 Mar 2010
Posts: 314
Location: Denmark

View user's profile Send private message

PostPosted: Thu Oct 30, 2014 11:45 am     Reply with quote

The way I do it...
Code:

fprintf(gsm,"%s%c",mess,26); //mess+ [ctrl]+Z
Fabri



Joined: 22 Aug 2005
Posts: 275

View user's profile Send private message

PostPosted: Thu Oct 30, 2014 1:44 pm     Reply with quote

Interesting.... I'll try this way.
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Thu Oct 30, 2014 3:33 pm     Reply with quote

Code:
void SEND_SMS()
{
   counter_read=0;
   printf("AT+CMGS=\"########\"\r");            // send command and cel #   
   delay_ms(1000);                           // Delay long enough for modem response
   printf("LORD JESUS ITS A FIRE!!!\n\r");         // Text to reply
   putchar(0x1A);                           // send Ctrl-z
   DELAY(20);                              // Delay a maximum of X seconds
}


Thats how i do it, but i do like your idea of polling for the > sign.
how ever make sure your modem is not sending returns or newlines prior to the > sign.

G.
_________________
CCS PCM 5.078 & CCS PCH 5.093
Fabri



Joined: 22 Aug 2005
Posts: 275

View user's profile Send private message

PostPosted: Fri Oct 31, 2014 12:08 am     Reply with quote

Polling '>' tell me when modem is ready to receive text of SMS so I can't wait a long time. Actually I test first char is '>' in case I don't receive it I'll send text after some seconds anyway.
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