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.

Reading msg string from sim900 into PIC

Status
Not open for further replies.

Kishor_B

Newbie level 6
Newbie level 6
Joined
Mar 2, 2014
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
83
hello guys, I am trying to read msg from sim900 into PIC. i have tried all other features like calling, sending msg..by using PIC.. everything worked perfectly.. but when i tried to read msg using AT+CMGF=1 command.. i could not received msg string.. any suggestions ?
 

AT+CMGF command only sets the message format (text or PDU). You need to issue AT+CMGR = 1 command in order to read message string.
 

Ooops.. I post AT+CMGF by mistake.. I used AT+CMGR.. bt no string is received. i have used interrupt to receive the string..
 

code:





/* Main.c file generated by New Project wizard
*
* Created: Tue Jan 14 2014
* Processor: PIC16F877A
* Compiler: HI-TECH C for PIC10/12/16
*/

#include <pic.h>
#include <htc.h>
#include <string.h>
#include <stdio.h>
#include <conio.h>


#define data PORTD
#define rs RB5
#define en RB6


//LCD functions----------------------------------------------
//void delay(int n);

void lcdcmd( char value);
void lcddata( char value);
void lcdinit(void);
void lcd_display(int m);
void lcd_disp_cmd(unsigned char value);
void lcd_disp_data(unsigned char value);


void tx(unsigned char str)
{
while(!TXIF);
TXREG=str;
}

void send(char *str)
{
int j;

j=0;
while(str[j]!='\0')
{
tx(str[j]);
j++;
}
}

char read()
{
char a;

while(RCIF==0);
a=RCREG;
return a;

}
void main(void)
{

// Write your code here

TRISB=0x00;
TRISD=0x00;
TRISC=0x81; // RC7,RC6 set to usart mode(INPUT)
TXSTA=0x20;
SPBRG=0x20;
TXSTAbits.TXEN=1;
RCSTA=0x90; // Enable Serial Port & Continuous Receive
INTCONbits.GIE=1;
INTCONbits.PEIE=1;
lcdinit();
char ch1[5],ch[]="AT\r";
int i;

send(ch);

for(i=0;i<4;i++)
{
ch1=read;
if(ch1=='K')
break;
}


i=0;
while(i<4)
{
lcd_disp_data(ch1);
i++;
}

while(1);


}
void lcdinit(void)
{
en=0;

__delay_ms(450);
lcd_disp_cmd(0x02);
__delay_ms(450);
lcd_disp_cmd(0x28); // 4-bt mode
__delay_ms(450);
lcd_disp_cmd(0x0C);// Display on, cursor on
__delay_ms(150);
// lcdcmd(0x0F);
//delay(15);
//lcd_disp_cmd(0x01);// clear lcd
__delay_ms(150);
lcd_disp_cmd(0x06);
__delay_ms(150);
lcd_disp_cmd(0x80);
__delay_ms(150);
}
void lcdcmd(unsigned char value)
{
data= value;
rs= 0;
// rw= 0;
en= 1;

__delay_ms(15);
en= 0;


}
void lcddata(unsigned char value)
{
data= value;
rs= 1;
// rw=0;
en= 1;

__delay_ms(15);
en= 0;

}
void lcd_disp_data(unsigned char value)
{
char data_value1;
data_value1=value&0xF0;
lcddata(data_value1);
data_value1=((value<<4)&0xF0);
lcddata(data_value1);

}
void lcd_disp_cmd(unsigned char value)
{
char cmd_value1;
cmd_value1 = value & 0xF0;

lcdcmd(cmd_value1);
cmd_value1 = ((value<<4) & 0xF0);

lcdcmd(cmd_value1);

}


i am trying to get a response from sim900 and store it in a string and display it on lcd..
there is no any problem with lcd code..
reception from sim900 is not doing well..its a garbage value.. I am attaching an image of result..plz go through it also.. thank u :)
 

Attachments

  • post.jpg
    post.jpg
    186.5 KB · Views: 117

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top