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

using AT commands

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



Joined: 17 Apr 2006
Posts: 2
Location: India

View user's profile Send private message

using AT commands
PostPosted: Tue Apr 18, 2006 1:19 am     Reply with quote

Hi all,

am working with PIC16f877 and ccs pcw 3.094

am trying to read sms using command AT+CMGR=1 from a wavecom GSM modem. The message stored in the index 1 is "Hi". so what am trying to do is to read the sms using the AT command and read the response from the modem. the response will have the message along with additional info. so i will be checking for "Hi" and if the read is seccessful, an LED glows (connected to portd.2)

for reading the serial port i used #INT_RDA interrupt. a count is declared to get the total number of interrupts occured..

am facing some issues....please help me in resolving it.

the code written by me is given below

#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 90
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('R');
putc('=');
putc(0x31);
putc('\r');

}

#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(60000);
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 was able to send an sms using AT commands and got the correct response back...(read through serail port)

thanks,prajeesh
_________________
Prajeesh
c/o Mobax Networks
Coimbatore
India
ckielstra



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

View user's profile Send private message

PostPosted: Tue Apr 18, 2006 1:41 am     Reply with quote

Some remarks:

1) When posting code use the 'code' button, this helps to preserve the format of your source code and makes it much easier for us to read your program.

2) Instead of many separate putc commands your code will be much easier to read when you combine them into a single printf command.
Instead of
Code:
putc('A'); // Transmit "AT" through serial port
putc('T');
putc('+');
putc('C');
putc('M');
putc('G');
putc('R');
putc('=');
putc(0x31);
putc('\r');
This becomes
Code:
// Transmit "AT" through serial port
printf('AT+CMGR=1\r');


Quote:
am facing some issues....please help me in resolving it.
We are not very good in reading your mind, it helps when you explain what the issues are you are facing.
lover_w40
Guest







help
PostPosted: Wed Jan 24, 2007 5:24 pm     Reply with quote

i m doing the same think can you explain me code
if you got teh solution, plz give us the source
thanks
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

Re: using AT commands
PostPosted: Fri Jan 26, 2007 8:26 am     Reply with quote

prajeesh wrote:

am facing some issues....please help me in resolving it.


I think one of your problems might be the you don't have any error handling, what do you do when the response from the modem is ERROR instead of "\r\n\r\nOK\r\n"?
You should always keep in mind that other responses are possible...

furthermore, are you sending in TEXT or PDU mode?

Cheers, Jos
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