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

Need help with this GSM isr please

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



Joined: 17 Apr 2008
Posts: 4
Location: USA

View user's profile Send private message MSN Messenger

Need help with this GSM isr please
PostPosted: Wed Jul 02, 2008 9:02 pm     Reply with quote

I know that there are SMS message to be retrieve because
when i first stored a message to it using hyper terminal, by
setting the modem to text mode and sent a text message to the
GSM modem, well the SMS message is stored in the location index number 1
and I'm trying to read from it by using PIC but I'm not getting anything base on my
interrupt.

i set the modem to text mode first by sending:

AT+CMGF =1 ; put modem in text mode ; modem return OK
AT+CMGR =1 ;read at index location 1 on GSM modem ; modem return OK

when I'm reading, i set my isr() to get whatever the modem is returning to the PIC and had it display on LCD
but I'm not getting anything :(


this is my code:

Code:
#int_rda
void serial_isr()
{

output_low(PIN_B5);

char_rcvd = fgetc(GSM);
   while (i != 10)
   {
   char_rcvd = fgetc(GSM);
   data[i]=char_rcvd;

   t=1;

   i++;


   }

   data[i] = 0;            // return new line shows that all character has been collected


   output_low(PIN_B4);
   disable_interrupts(int_rda);

}

void readindex(void)
{
  while(1){
      output_high(PIN_B7);

      delay_ms(1000);
      fprintf(GSM, "AT+CMGF= 1");  //set to text mode
      fprintf(GSM, "\r\n");
      delay_ms(2000);

      output_high(PIN_B6);

      fprintf(GSM, "AT+CMGS= (my number)r\n");   //write text message
      delay_ms(1000);
      fprintf(GSM, "HELLO WORLD");
      fputc(0x1A,GSM);//CTR+Z to send
      fprintf(GSM, "\r\n");
      delay_ms(100);

      output_low(PIN_B2);


      fprintf(GSM, "AT+CMGR=1");  //Read SMS at location 1
      fprintf(GSM, "\r\n");
      delay_ms(1);

      enable_interrupts(int_rda);
      delay_ms(2000);

      output_low(PIN_B6);
      delay_ms(500);


      output_low(PIN_B7);


      while(t!=1){}    // wait til interrupt


      t = 0;

      disable_interrupts(int_rda);

      delay_ms(100);

      cursor_position(0x84);

      out_lcd_string(data);    //send display reading string to LCD
      output_high(PIN_B2);
         }
}

_________________
PHIA YANG
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jul 02, 2008 10:56 pm     Reply with quote

Don't do your isr code like that. It's wrong. You should only get one
character each time the isr is called.

See some of the comments in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=34648

Also, you need to simplify your program for the first test. Make it shorter.
You should be able to write a short program (maybe 30 lines) that tests
the ability to talk to the GSM.

If you post another program, make sure it's complete. Post the
#include, #fuses, #use delay(), and #use rs232() statements.
Post the main(). The "30 lines of code" includes all these things.
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