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

Serial communication for AT commands...
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
Lykos1986



Joined: 26 Nov 2005
Posts: 68

View user's profile Send private message

Serial communication for AT commands...
PostPosted: Tue Feb 12, 2008 6:57 pm     Reply with quote

Hello to everyone!

I am trying to set up a communication between a Telit GM862 GSM Module and a PIC 16F877. I need a serial communication 9600 8 N 1 without hardware control (like the hyper terminal). So I am typing:

#use rs232(baud=9600, xmit=PIN_C7,rcv=PIN_C6, PARITY=N, BITS=8)

Is that right?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Feb 12, 2008 9:42 pm     Reply with quote

Look at the pin definitions in the Overview section of the 16F877 data
sheet. (page 11 in the Acrobat reader).
http://ww1.microchip.com/downloads/en/DeviceDoc/30292c.pdf
What pin is assigned to the UART Tx and what pin is for Rx ?
Then look closely at your #use rs232() statement.
Guest








PostPosted: Wed Feb 13, 2008 3:09 am     Reply with quote

Yes… I know exactly what you mean! The transmit pin and receive pins they have to be opposite! But the problem is on hardware and I cannot change it that!

I think with the CCS we can use an asynchronous serial communication with any pins! Just software serial and not the hardware! How can I do that and also to be 9600 8 N 1?
KU5D



Joined: 10 Feb 2008
Posts: 46
Location: Asheville, North Carolina

View user's profile Send private message

PostPosted: Wed Feb 13, 2008 5:38 am     Reply with quote

If you're wanting a software UART,just pick the pins you wanna use and assign the thing to a stream such as:

#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7,stream=PC)

Then if you want to squirt something out the serial port:

fprintf(PC,"\r\n\This does a carriage return and linefeed...and prints this.");

This works on the 18F4520. I've never played with the 877 but I think they're similar in this respect.
_________________
Confidence is the feeling you have right before you fully understand the situation...
Lykos1986



Joined: 26 Nov 2005
Posts: 68

View user's profile Send private message

PostPosted: Wed Feb 13, 2008 8:32 am     Reply with quote

Ok… I start getting crazy with that project! I just want to take an “OK” respond from my Telit GM862 module! The problem is that I generally take an echo respond and not OK! What is happening?

I have post my code here:



Code:

#include <16F877A.h>
#fuses   XT,NOWDT,NOPUT,NOPROTECT,NOBROWNOUT,NOCPD,NOWRT,NOLVP
#use delay (clock=4000000)
#use rs232(baud=9600, xmit=PIN_C7,rcv=PIN_C6,PARITY=N, BITS=8,  stream=PC) //
#include <string.h>

#define L1   pin_c1
#define L2   pin_c2
#define F1   pin_e1
#define F2   pin_e0
#define power   pin_d7
#define module_led   pin_d6

char string1[10];
char string2[10];


void module_on()   //Turns on the GSM Module
{
output_high(power);
delay_ms(1200);
output_low(power);
}


void main()
{
input(module_led);
output_high(L2);

strcpy(string2,"OK");

while(1)
{
   if(input(F1))
   module_on();


   if (input(F2))
   {
      fprintf(PC, "AT\r\n");
      gets(string1);
      if(!strcmp(string1, string2))
      {
         output_high(L1);
      }
   }

}
}
Lykos1986



Joined: 26 Nov 2005
Posts: 68

View user's profile Send private message

PostPosted: Thu Feb 14, 2008 7:39 am     Reply with quote

Any help?
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

PostPosted: Thu Feb 14, 2008 8:06 am     Reply with quote

most modems I know turn at command echo off with the ate0 command...

But I can advise you to make a more advanced respons filter. Maybe you should try a receiving buffer or something like that? Search this forum for something like that, I have seen several good examples in the past.
Guest








PostPosted: Thu Feb 14, 2008 8:54 am     Reply with quote

the problem is that the Telit GSM Module have got no echo by defult. So... maybe is a software error...
SET



Joined: 15 Nov 2005
Posts: 161
Location: Glasgow, UK

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Thu Feb 14, 2008 9:33 am     Reply with quote

I'm doing a Telit app right now, and my GM862 does echo by default..
The other poster is correct, you have to be a bit more sophisticated, get the response from the module and then parse it.
Guest








PostPosted: Fri Feb 15, 2008 7:57 am     Reply with quote

SET wrote:
I'm doing a Telit app right now, and my GM862 does echo by default..
The other poster is correct, you have to be a bit more sophisticated, get the response from the module and then parse it.



I don’t know how much sophisticated can be the code!

I was thinking that the module after the AT command will answer me just with the OK and nothing more! I was working before using only the module (not the same) and my PCs hyper terminal. The result was as I expecting! I was sending the AT command and the module answers with OK. Of course that was happening with all the other AT commands! I was not taking something more from then module! No echo not other characters…

How I can build something like that? Something that works like the hyper terminal to my PIC?
SET



Joined: 15 Nov 2005
Posts: 161
Location: Glasgow, UK

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Feb 15, 2008 8:21 am     Reply with quote

I think you have your Tx/Rx reversed - the Telit units are a bit confusing, 'Tx' is actually the input and is therefore connected to Tx on the PIC (C6). So you can use the hardware UART.
Guest








PostPosted: Fri Feb 15, 2008 8:34 am     Reply with quote

Yes… I know that problem but I have already built my PCB. I cannot use a software UART that communicates like the windows hyper terminal?
SET



Joined: 15 Nov 2005
Posts: 161
Location: Glasgow, UK

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Feb 15, 2008 8:40 am     Reply with quote

So C7 (on the PIC) is connected to Pin 25 on the GM862?
Lykos1986



Joined: 26 Nov 2005
Posts: 68

View user's profile Send private message

PostPosted: Fri Feb 15, 2008 9:23 am     Reply with quote

Pin 25? No…


PIC pin C7 => GM863 pin 20
PIC pin C6 => GM862 pin 37


And the the pin 45 of the GM862 to the ground, because I don’t want to use hardware flow control.




PS:
I don’t use Python, just the regular serial communication and the AT Commands
SET



Joined: 15 Nov 2005
Posts: 161
Location: Glasgow, UK

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Feb 15, 2008 9:39 am     Reply with quote

Lykos1986 wrote:
Pin 25? No…


PIC pin C7 => GM863 pin 20
PIC pin C6 => GM862 pin 37


And the the pin 45 of the GM862 to the ground, because I don’t want to use hardware flow control.




PS:
I don’t use Python, just the regular serial communication and the AT Commands


Apologies that was GC864 pinout I quoted .. (we use both!).
So your correct, your hardware is reversed. The soft UART should work Ok though, assuming 'gets ' works. If you have in-circuit debug working, can you put a breakpoint after the gets to see what string1 contains?
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