| Author |
Message |
jaime
Joined: 15 Jul 2005 Posts: 39 Helped: 2 Location: Porto-Portugal
|
25 Nov 2005 15:22 PIC AT Command and CCS |
|
|
|
|
Hello
I'm trying to connect my pic to my siemens c45 in C.
I would like to do an interrupt by the rx pin to read the data from the phone.
I Know that the phone send OK (in hex: 0D 0A 4F 4B 0D 0A
I have to use a rotine with getc because this string dont finish with 0D(CR), so i cant use gets.
How can i do this?
Thanks
Jaime
|
|
| Back to top |
|
 |
gidimiz
Joined: 03 Feb 2005 Posts: 428 Helped: 77
|
25 Nov 2005 16:31 PIC AT Command and CCS |
|
|
|
|
Hi,
When sending AT Command you can also at add the 0x0D at the end there is not problem. I dont know how to use CCS, im more of the h*tech compiler, but just send the AT and wait for the OK. Use a good program to sniff the data line ( with a buffer to the PC ). I love to use the Docklight that you can find on the web. Has many features that are very useful when working with Modem and MCU.
If you found my answer useful, click on the button that says Helped me. ( NO points will be taken from you! )
Good luck.
|
|
| Back to top |
|
 |
jaime
Joined: 15 Jul 2005 Posts: 39 Helped: 2 Location: Porto-Portugal
|
25 Nov 2005 17:10 Re: PIC AT Command and CCS |
|
|
|
|
Thanks for the reply
I have no problem sending at commands.
My problem is receivind data. I need to see one routine that reveivs at commands.
I konw that i have to wait for the OK. But how do I know that i'm receiving an OK?
thanks
|
|
| Back to top |
|
 |
Tohu
Joined: 09 Jun 2004 Posts: 97 Helped: 12
|
26 Nov 2005 8:44 Re: PIC AT Command and CCS |
|
|
|
|
Hi,
why you can't use getc, this not a connection with NL/CR byte, getc read your receive buffer and get the value to a variable :
buffer[n]=getc(); this in RSRX int subroutine
when you recive he will be writen to the variable buffer[].
0A this is a new line. If your modem return always 0A or 0D after string , den you can use both of them to end of the mesage, you will have one flag start package, flag end package.
temp=getc();
if((temp==0x0A || temp==0x0D) & start package)
{
start package=false;
end package = true;
}
else
{
buffer[x]=temp;
x++;
}
in your program you will check end package, and when it's a true you will read data from buffer and make x=0 anf end ackage=false :
if(end package)
{
end package=false
if(buffer[0]='O' && buffer[1]='K' && x==1)
{
do something;
}
}
|
|
| Back to top |
|
 |
jaime
Joined: 15 Jul 2005 Posts: 39 Helped: 2 Location: Porto-Portugal
|
26 Nov 2005 13:54 PIC AT Command and CCS |
|
|
|
|
I understand what you mean but i dont realy see the first part of the program working.
if((temp==0x0A || temp==0x0D) & start package)
i think the program never enter in this condition. There's no start package=true and temp only gets one of the condition 0x0A or 0x0D... do you agree?
Like i said i understand what you mean but i dont know who to do it, so help me a litle more
You got the points!!!
Thanks
|
|
| Back to top |
|
 |
Google AdSense

|
26 Nov 2005 13:54 Ads |
|
|
|
|
|
|
| Back to top |
|
 |
Tohu
Joined: 09 Jun 2004 Posts: 97 Helped: 12
|
26 Nov 2005 19:34 Re: PIC AT Command and CCS |
|
|
|
|
Hi,
when i write this last night i was a very sleeply and see that i forgot something:
#INT_RDA
void RDA_IRS(void)
{
char temp;
temp=getc();
if((temp==0x0A||temp==0x0D) && package_start)
{
package_start=0;
package_end=1;
}
else
{
if(temp!=0x0A && temp!=0x0D)
{
package_start=1;
buffer[n]=temp;
n++;
}
}
}
this is a package receive.
if(package_end)
{
package_end=0;
if(buffer[0]=='O' && buffer[1]=='K' && n==2)
{
printf("Hello");
n=0;
}
}
and this is check the package, thi is swork, but .... this is only idea, when you have a communication, you must implement this in the communication protocol, because i suppose that you must receive and transmit data to the modem.
|
|
| Back to top |
|
 |