Microcontroller › PIC › GSM sim900D interfacing with PIC18f548 problem in receiving message
- This topic has 0 replies, 1 voice, and was last updated 9 years, 3 months ago by Muhammad Ateeb Akmal.
Viewing 1 post (of 1 total)
-
AuthorPosts
-
May 15, 2015 at 5:12 pm #3677Muhammad Ateeb AkmalParticipant
hi
I am working on GSM 900D interfacing with PIC18f548. I am facing problem that I can get the message from the module. as I send at+cmgr=1;
(1=location) i didnot get the message. while this is working properly with the computer as I send this comand by connecting GSM module with my PC.
I also can not get the OK message when I send AT through TX port.
here is my code.
#pragma config OSC = HS, OSCS = OFF#pragma config PWRT = OFF, BOR = ON, BORV = 27#pragma config WDT = OFF, LVP=OFF#pragma config DEBUG = OFF, STVR = OFF#include <P18F458.h>#include<stdio.h>#include <stdlib.h>#define ldata PORTD#define rs PORTBbits.RB0#define rw PORTBbits.RB1#define en PORTBbits.RB2#define busy PORTDbits.RD7void Delay(unsigned int DE);void LDelay(unsigned int DE);void lcdready(void);void lcdcmd(unsigned char);void lcddata(unsigned char);void lcd_int(void);void main(void){unsigned char x,z,y,AT[]="ATr";unsigned char ATCMGF[]="AT+CMGF=1";unsigned char ATCMGR[]="AT+CMGR=1r";unsigned char ATCMGL[]="AT+CMGL="ALL"";unsigned char ATCMGD[]="AT+CMGD=1r";unsigned char ATD[]="ATD+923038310147;";unsigned char ATH[]="ATHr";unsigned char recno;unsigned char rec[40];TXSTA=0x20;RCSTA=0x90;SPBRG=19;TRISD=0;TRISB=0;RCSTAbits.SPEN=1;TXSTAbits.TXEN=1;RCSTAbits.CREN=1;PIE1bits.RCIE=1; //Enable Reception interruptlcd_int();lcddata('1');LDelay(60);for(z=0;z<4;z++){while(PIR1bits.TXIF==0);TXREG=AT[z];}LDelay(5);while(PIR1bits.RCIF==0);rec[0]=RCREG;while(PIR1bits.RCIF==0);rec[1]=RCREG;lcd_int();for(y=0;y<=2;y++){lcddata(rec[y]);}LDelay(18);lcd_int();lcddata('2');for(z=0;z<9;z++){while(PIR1bits.TXIF==0);TXREG=ATCMGF[z];}while(PIR1bits.TXIF==0);TXREG=0X0D;LDelay(20);lcd_int();lcddata('3');for(z=0;z<17;z++){while(PIR1bits.TXIF==0);TXREG=ATD[z];}while(PIR1bits.TXIF==0);TXREG=0X0D;LDelay(110);for(z=0;z<5;z++){while(PIR1bits.TXIF==0);TXREG=ATH[z];}LDelay(30);lcd_int();lcddata('5');for(z=0;z<13;z++){while(PIR1bits.TXIF==0);TXREG=ATCMGL[z];}while(PIR1bits.TXIF==0);TXREG=0X0D;LDelay(40);lcd_int();lcddata('6');for(z=0;z<11;z++){while(PIR1bits.TXIF==0);TXREG=ATCMGR[z];}LDelay(40);lcd_int();lcddata('7');for(x=0;x<=40;x++){while(PIR1bits.RCIF==0);rec[x]=RCREG;}lcd_int();for(y=0;y<x;y++){if(y==15)lcdcmd(0xC0);lcddata(rec[y]);}LDelay(20);lcd_int();lcddata('8');for(z=0;z<11;z++){while(PIR1bits.TXIF==0);TXREG=ATCMGD[z];}// while(PIR1bits.TXIF==0);// TXREG=0X0D;LDelay(20);while(1);}void lcdcmd(unsigned char value){ldata = value;rs = 0;rw = 0;en = 1;Delay(1);en = 0;}void lcddata(unsigned char value){ldata = value;rs = 1;rw = 0;en = 1;Delay(1);en = 0;}void lcdready(){TRISD = 0xFF;rs = 0;rw = 1;do{en = 1;Delay(1);en = 0;}while(busy==1);TRISD = 0;}void Delay(unsigned int itime){unsigned int i, j;for(i=0;i<itime;i++)for(j=0;j<135;j++);}void LDelay(unsigned int itime){unsigned int i, j,k;for(i=0;i<itime;i++)for(j=0;j<255;j++)for(k=0;k<255;k++);}void lcd_int(void){Delay(50);en = 0;Delay(250);lcdcmd(0x38);Delay(250);lcdcmd(0x0E);lcdready();lcdcmd(0x01);lcdready();lcdcmd(0x06);lcdready();lcdcmd(0x80);} -
AuthorPosts
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.