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

controlling GSM modem
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
prajeesh
Guest







controlling GSM modem
PostPosted: Mon Apr 17, 2006 4:47 am     Reply with quote

hi,

am trying to communicate with a GSM modem using rs232. am facing some problem while reading the response from the modem. i used #int_rda for triggering the read operation. am not able to read the response from the modem

can anyone help me in this

thanks
prajeesh
rberek



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

View user's profile Send private message

PostPosted: Mon Apr 17, 2006 5:25 am     Reply with quote

You're going to have to supply a lot more detail than this...
prajeesh
Guest







PostPosted: Mon Apr 17, 2006 5:54 am     Reply with quote

hi,

am using 16f877a and wavecom GSM modem to send sms by giving AT command (AT+CMGS="xxxx....."\r). am able to send the message, but unable to read the response from the modem... think there may be timing issues....

please provide ur suggetions,

thanks
prajeesh
rberek



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

View user's profile Send private message

PostPosted: Mon Apr 17, 2006 6:07 am     Reply with quote

Post the relevant code and your compiler version.

One thing that seems to trip up nearly everybody is that 9 times out of ten a NULL modem cable is required but is used zero times out of ten.

r.b.
Guest








PostPosted: Mon Apr 17, 2006 6:13 am     Reply with quote

#include "G:\Work\pic\work_outs\serial\serial_send.h"
#include <string.h>

#byte trisc = 0x87
#byte portc = 0x07 // defining port address
#byte trisd = 0x88
#byte portd = 0x08

#define BUFFER_SIZE 96
byte buffer[BUFFER_SIZE];
byte next_in = 0;
byte next_out = 0;
byte count = 0;

void init()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_CLOCK_DIV_2);
setup_spi(FALSE);
setup_psp(PSP_DISABLED);
setup_counters(RTCC_INTERNAL,RTCC_DIV_2);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_ccp1(CCP_OFF);
setup_ccp2(CCP_OFF);
}


void tx_data()
{
putc('A'); // Transmit "AT" through serial port
putc('T');
putc('+');
putc('C');
putc('M');
putc('G');
putc('S');
putc('=');
putc('"');
putc('+');
putc(0x39);
putc(0x31);
putc(0x39);
putc(0x38);
putc(0x39);
putc(0x34);
putc(0x35);
putc(0x32);
putc(0x34);
putc(0x35);
putc(0x39);
putc(0x36);
putc('"');
putc('\r');
putc('H');
putc('e');
putc('l');
putc('l');
putc('o');
putc(0x1A);
}

#int_rda
void rx_serial_data()
{
byte t;
count += 1; // counting total number of interrupts occured
#asm
BSF 0x08, 0
#endasm

buffer[next_in] = getc(); // get the data(single character) from serial port
t=next_in;
next_in=(next_in+1) % BUFFER_SIZE;
if(next_in==next_out)
next_in=t; // Buffer full !!
}

void check_serial_data()
{
char resp_data[] = "OK";

if(strstr(start_point, resp_data)){
#asm
BSF 0x08, 2
#endasm
}
}

void main()
{
byte i;
trisc = 0x80; // RC7 as i/p & RC6 as o/p. RC6 - Tx pin & RC7 - Rx pin
trisd = 0x00; // portd as o/p
portd = 0x00;

memset(buffer, 0, BUFFER_SIZE);
enable_interrupts(global);
enable_interrupts(int_rda); // Enable receive data available interrupt

init(); // initialize peripherals

tx_data();


delay_ms(15000);
for(i = 0; i < count; i ++){
#asm
BSF 0x08, 1
#endasm
delay_ms(500);
#asm
BCF 0x08, 1
#endasm
delay_ms(500);
}
count = 0;
check_serial_data();
}

the response data is checked at check_serial_data();

The compile version is PCW 3.094
rberek



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

View user's profile Send private message

PostPosted: Mon Apr 17, 2006 6:56 am     Reply with quote

How have you set up the RS232? What is your processor clock frequency?
What fuses have you set? What type of connection does your PIC have to the GSM modem (.i.e. straight through cable, NULL modem cable, etc).
prajeesh
Guest







PostPosted: Mon Apr 17, 2006 7:35 am     Reply with quote

hi reberk,

thanks for ur co op..

finally i got it. ...... i made mistake in the response format of AT+cmgs...

thanks, thanks a lot....

prajeesh
prajeesh
Guest







PostPosted: Mon Apr 17, 2006 7:36 am     Reply with quote

reberk,

i have used straight through cable...

prajeesh
rberek



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

View user's profile Send private message

PostPosted: Mon Apr 17, 2006 7:41 am     Reply with quote

I'm glad its working for you!

I didn't give you any assistance though. You figured it out yourself.

The more information you give when posting a question, the quicker the responses will be.

THe question about the cable is because one of the main causes of problems on this forum, as far as RS232 communication is concerned, is that people try to get two devices to talk to each other when each device was designed to talk to a PC. When they talk to each other, they need a NULL modem cable.
prajeesh
Guest







PostPosted: Mon Apr 17, 2006 8:11 am     Reply with quote

hi reberk,

i would like to know some details about doing "Higher studies" in canada. am from india... can i have ur mail id pls...if u dont mind....

thanks,
prajeesh
rberek



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

View user's profile Send private message

PostPosted: Mon Apr 17, 2006 9:18 am     Reply with quote

Sorry but I don't give out that info. Besides, I graduated university 19 years ago and have no current info on the subject.

Good luck...
khawer102



Joined: 14 Mar 2006
Posts: 9
Location: Pakistan

View user's profile Send private message MSN Messenger

PostPosted: Mon Apr 17, 2006 1:15 pm     Reply with quote

hey prajeesh
i woas working on the same thing. PIC18F452 and GSM modem. i can send the commands to the modem but i am having problem getting the response.

can you plz give me your code for recieving response.

thank you
khawer
prajeesh
Guest







PostPosted: Mon Apr 17, 2006 11:23 pm     Reply with quote

hi khawer,

this is my code....

#include "G:\Work\pic\work_outs\serial\serial_send.h"
#include <string.h>

#byte trisc = 0x87
#byte portc = 0x07 // defining port address
#byte trisd = 0x88
#byte portd = 0x08

#define BUFFER_SIZE 40
byte buffer[BUFFER_SIZE];
byte next_in = 0;
byte next_out = 0;
byte count = 0;

void init()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_CLOCK_DIV_2);
setup_spi(FALSE);
setup_psp(PSP_DISABLED);
setup_counters(RTCC_INTERNAL,RTCC_DIV_2);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_ccp1(CCP_OFF);
setup_ccp2(CCP_OFF);
}

void tx_ate0()
{
putc('A');
putc('T');
putc('E');
putc(0x30);
putc('\r');
}

void tx_data()
{
tx_ate0();

putc('A'); // Transmit "AT" through serial port
putc('T');
putc('+');
putc('C');
putc('M');
putc('G');
putc('S');
putc('=');
putc('"');
putc('+');
putc(0x39);
putc(0x31);
putc(0x39);
putc(0x38);
putc(0x39);
putc(0x34);
putc(0x35);
putc(0x32);
putc(0x34);
putc(0x35);
putc(0x39);
putc(0x36);
putc('"');
putc('\r');
putc('H');
putc('e');
putc('l');
putc('l');
putc('o');
putc(0x1A);
}

#int_rda
void rx_serial_data()
{
byte t;
count += 1; // counting total number of interrupts occured
#asm
BSF 0x08, 0
#endasm

buffer[next_in] = getc(); // get the data(single character) from serial port
t=next_in;
next_in=(next_in+1) % BUFFER_SIZE;
if(next_in==next_out)
next_in=t; // Buffer full !!
}

void check_serial_data()
{
char resp_data[] = "\r\n\r\nOK\r\n";

if(strstr(buffer, resp_data)){
#asm
BSF 0x08, 2
#endasm
}
}

void main()
{
byte i;
trisc = 0x80; // RC7 as i/p & RC6 as o/p. RC6 - Tx pin & RC7 - Rx pin
trisd = 0x00; // portd as o/p
portd = 0x00;

memset(buffer, 0, BUFFER_SIZE);
enable_interrupts(global);
enable_interrupts(int_rda); // Enable 'receive data available' interrupt

init(); // initialize peripherals

tx_data();

delay_ms(15000);
for(i = 0; i < count; i ++){
#asm
BSF 0x08, 1
#endasm
delay_ms(500);
#asm
BCF 0x08, 1
#endasm
delay_ms(500);
}
count = 0;
check_serial_data();
}

i have used an LED to blink, when i get the correct response from the modem. i sent an sms using GSM modem and PIC
prajeesh
Guest







PostPosted: Mon Apr 17, 2006 11:24 pm     Reply with quote

hi reberk,

its ok...thanks for ur help...

prajeesh
khawer102



Joined: 14 Mar 2006
Posts: 9
Location: Pakistan

View user's profile Send private message MSN Messenger

PostPosted: Tue Apr 18, 2006 4:29 pm     Reply with quote

Hi Prajeesh

i used ur code for reading the response from the modem.
i also tried using AT+CMGR=1 for reading the SMS stored at sim location 1 and it works just fine. except that i have not been able to understand the format with which the modem sends the response. I read ur other Post in which you stated that you wanted to read "Hi" from the returing string. i am sure you can make your own function for checking if the complete string has "Hi" in it.

i also wanted to thank you for the code that you gave me. it was of a lot of help.

i would also like to know what project you have been working on which invloves PIC and GSM modem. can we chat on MSN. if you dont mind that happening

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
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