Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem on GSM commucnication in PIC

Status
Not open for further replies.

Mani Yuvan

Member level 1
Member level 1
Joined
Jan 18, 2015
Messages
41
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Location
Tamilnadu , India
Visit site
Activity points
321
i try to sent the simple message through gsm modem but nothing to happen .please check the code and give any suggestion please.Im using sim300 module and c18 compiler


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include<p18f452.h>
 
#include"H:\RECovery RObot\header files\delay.h"
 
#pragma config OSC=HS, OSCS=OFF #
 
pragma config DEBUG=OFF, LVP=OFF, STVR=OFF
 
#pragma config WDT=OFF
 
#pragma config BOR=OFF, PWRT=ON
 
void gsm_cmd(unsigned char);
 
void tx_data(unsigned char);
 
void gsm_ready(void);
 
unsigned char enter=0X0D;
 
unsigned char end=0X1A; unsigned char b[]={"haiii.."},i;
 
unsigned char format[]={"AT+CMGF=1"};
 
unsigned char num[]={"AT+CMGS=\"952xxxxxxx\""};
 
void tx_data(unsigned char c) {
 
while(PIR1bits.TXIF==0);
 
TXREG=c; PIR1bits.TXIF=0; }
 
void gsm_ready() { for(i=0;i<9;i++)
 
{
 
gsm_cmd(format[i]);
 
delay(1);
 
} tx_data(enter);
 
delay(1000);
 
for(i=0;i<20;i++)
 
{ gsm_cmd(num[i]);
 
delay(1); } tx_data(enter);
 
delay(1000); }
 
void gsm_cmd(unsigned char c)
 
{ if(c!=0x5C) // Not to send '\' cahracter
 
{ 
while(PIR1bits.TXIF==0); TXREG=c; PIR1bits.TXIF=0; }
 
}
 
void main() {
 
TXSTA=0X20;
 
SPBRG=64;//4800 bps for 20 Mhz crystal
 
TXSTAbits.TXEN=1;
 
RCSTAbits.SPEN=1;
 
gsm_ready(); delay(2);
 
for(i=0;i<7;i++) {
 gsm_cmd(b[i]); 
delay(1);
 
}
 
tx_data(enter);
 
tx_data(0X1A);
 
delay(1000);
 
}

 
Last edited by a moderator:


Code C - [expand]
1
SPBRG=64;//4800 bps for 20 Mhz crystal




check your gsm is running with same baud rate. try with 9600 baud rate.Test your gsm with hyper terminal first.
 


Code C - [expand]
1
SPBRG=64;//4800 bps for 20 Mhz crystal




check your gsm is running with same baud rate. try with 9600 baud rate.Test your gsm with hyper terminal first.

I also try this also.but nothing to happen.Im newer to Embedded systems.And i think i m not sure the delay part.please send me the working code for c18 compiler send sms from pic18f452 controller to one number.Thanks
 

I also try this also.but nothing to happen


I mean you have set 4800 baud rate in your controller and your gsm might be set at 9600 baud rate.check your gsm first with hyper terminal.
 

I mean you have set 4800 baud rate in your controller and your gsm might be set at 9600 baud rate.check your gsm first with hyper terminal.

how to i check my gsm with Computer. And i used laptop so there is no DB9 port then how to i connect the gsm modem to computer. I also used windows7 os there is no Hyperterminal .Please any one guide me...
 

If your SIM900 modem has 5V TTL Rx and Tx pins then you can use a TTL to USB adapter to connect SIM900 to PC USB port and then send AT commands with \r\n from some serial terminal software like Termite and see the responses from modem.

You have to connect RxD of TTL2USB to Tx of SIM900 and TxD of TTL2USB to Rx of SIM900 and GND of TTL2USB to GND of SIM900.
 

If it is 5V TTL then you can interface it directly to your PIC16F or 18F.

thanks milan. i successfully receive the message and call from the gsm modem. but it repeated continuously but i'm not use the while loop just i put the task in main function but checking Proteus it repeated again & again.
 

Maybe you don't have a while(1); loop at the end of main() function and when program execution reaches the end of the main() it is resetting PIC and hence you see repeatation.
 
If your SIM300 has 5V TTL pins then use it to connect it to PIC. USB pot of GSM is only to connect to PC.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top