View previous topic :: View next topic |
Author |
Message |
gorilla135
Joined: 14 Mar 2006 Posts: 8
|
pic to gsm modem |
Posted: Wed Mar 22, 2006 7:18 am |
|
|
iam having a problem communicating a PIC 16f877 with a gsm modem, the problem is that the modem only works with 115200 baud rate, the code works perfectly when i connect the modem via hyperterminal but when i connect it to the PIC which has a lower baud rate it wont work. can anyone help please. thanks |
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Mar 22, 2006 7:46 am |
|
|
Have you tried setting the modem to a lower baud rate?
AT+IPR=9600
and then make this change permanent with:
AT&w |
|
![](templates/subSilver/images/spacer.gif) |
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Wed Mar 22, 2006 8:31 am |
|
|
Post your PIC code. I find it hard to believe that the modem will not talk slower than that! |
|
![](templates/subSilver/images/spacer.gif) |
gorilla135
Joined: 14 Mar 2006 Posts: 8
|
|
Posted: Wed Mar 22, 2006 8:41 am |
|
|
#include <16F877.h> /* Defines chip */
#include <stdio.h> /* this gets the printf() definition */
#use delay(clock=4000000)
#fuses hs, noprotect, nowdt, nolvp
#use rs232(baud=9600,xmit=PIN_C6, rcv=PIN_C7, stream=GSM, ERRORS)
const int CR=0x0d;
void main()
{
fprintf(GSM,"AT\r\n"); /* checks are they communicating */
fprintf(GSM,"AT+CMGF=1\r\n"); /* sends an at command reay to send */
fputc(CR,GSM);
delay_ms(1000); /*sends a carriage return */
fprintf(GSM,"AT+CMGS=\"07749960685\""); /* sents the following text to this number */
fprintf(GSM,"\r\n"); /* cariage */
fputc(CR,GSM);
delay_ms(1000);
fprintf(GSM,"Hi world\r\n"); /* the text that will actually be sent */
/* sends CTRL Z */
delay_ms(1000);
fprintf(GSM,"\r\n");
fputc(0x1A,GSM); /* sends carriage return */
} |
|
![](templates/subSilver/images/spacer.gif) |
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Wed Mar 22, 2006 8:51 am |
|
|
You aren't waiting for the responses back from the modem. |
|
![](templates/subSilver/images/spacer.gif) |
gorilla135
Joined: 14 Mar 2006 Posts: 8
|
|
Posted: Wed Mar 22, 2006 9:03 am |
|
|
do i just put in a few delays or what, |
|
![](templates/subSilver/images/spacer.gif) |
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
![](templates/subSilver/images/spacer.gif) |
gorilla135
Joined: 14 Mar 2006 Posts: 8
|
|
Posted: Wed Mar 22, 2006 9:33 am |
|
|
been searching for a day or two now. i just want the pic to send a text message at the minute then when i get that to work i want it to read a text message in and using the string compare function carry out a few operations if the command is correct, |
|
![](templates/subSilver/images/spacer.gif) |
|