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.

GSM Modem Interfacing with PIC Microcontroller

Status
Not open for further replies.

sathiieesh

Newbie level 5
Joined
Feb 5, 2010
Messages
8
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
Chennai
Activity points
1,379
Hi iam attaching a code which works perfectly when i interface PIC Microcontroller with PC hyperterminal to send and receive messages... But it doesnt give any output when i connect PIC with GSM Modem... The Hardware connections is also right... when i try to send sms from PIC it works perfectly... the problem in reading the message in Sim memory.. what might be the problem... check this code ....

Code:
void sms_read();
void sms_send();
char output[70];
void main() {
     UART1_Init(9600);              // Initialize UART module at 9600 bps
     Delay_ms(100);                 // Wait for UART module to stabilize
     sms_read();
}
void sms_read()
{
UART1_Write_Text("AT\n\r");
delay_ms(500);
UART1_Write_Text("AT+CMGF=1\n\r");
delay_ms(500);
UART1_Write_Text("AT+CMGR=1\n\r");
delay_ms(500);
while (1) {
  if (UART1_Data_Ready() == 1) {          // if data is received
    UART1_Read_Text(output, "OK", 80);    // reads text until 'OK' is found
    /*UART1_Write_Text(output);             // sends back text
    delay_ms(500);
    UART1_Write_Text("\n");
    delay_ms(500);  */
    sms_send();
 }
}
}

void sms_send()
{
int i;
/*UART1_Write_Text("AT\n\r");
delay_ms(500);
UART1_Write_Text("AT+CMGF=1\n\r");
delay_ms(500); */
UART1_Write_Text("AT+CMGS=");
UART1_Write(0x22);
UART1_Write_Text("+919444721638");
UART1_Write(0x22);
UART1_Write_Text("\n\r");
delay_ms(500);
UART1_Write_Text(output);
UART1_Write(26);// send ctrl + Z

}
 

1 - You are not reading the data returned from the commands you are sending, so at best you will have garbage in your buffer, at worse the UART will lock up due to overrrun errors. You should read the response from the module and verify that it executed the command without error.

2 - The command "AT+CMGR=1" reads the message at location 1. The message may not be at location 1. You should use the list message command "AT+CMGL" to get a list of messages and their locations.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top