//###########################SETTING LCD MODULE###################################################// LCD module connections
sbit LCD_RS at RB5_bit;
sbit LCD_EN at RB4_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB5_bit;
sbit LCD_EN_Direction at TRISB4_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;// End LCD module connections//##############################################################################//############################################################################################char initializeGsmModule[]="AT";char noEcho[]="ATE0";char textMode[]="AT+CMGF=1";char charMode[]="AT+CSCS="GSM"";char setParametersOfCharMode[]="AT+CSMP=17,167,0,0";char sendSMSToThisMobileNumber[]="AT+CMGS="+201124247733"";char sendAnyReceivedSmsCommand[]="AT+CNMI=2,2,0,0,0";char deleteAllSmsCommand[]="AT+CMGD=1,4";char changeGSMBaudRateCommand[]="AT+IPR=9600";char saveCurrentConfigurationInEEPROMCommand[]="AT&W";char sendAllReceivedSmsCommand[]="AT+CMGL="ALL"";char testSMSToSend[]="Congratulations Sir , i am not a real phone . I am ur new product smartX from my creator";char ctrlPlusZ=0x1A;char enter=0x0D;char receivedSmS[50];char receivedSmSDigitchar[]=".......";char*receivedDigit;unsignedint i=0;unsignedint receivedSmSDigitint=0;unsignedint toggledDoneFlag=0;//######################################################################################################################################//##################################### Read Data from GSM Module Using UART Protocol ################################################################################void ReceiveSmsString(char*stringPointer3){while(UART1_Data_Ready()==1){*stringPointer3=UART1_Read();
stringPointer3++;}//Delay_ms(1000);}//######################################################################################################################################//#####################################Send Data to GSM Module Using UART Protocol ################################################################################void SendStringToModem1(char*stringPointer4){while(UART1_Tx_Idle()==0){}while(*stringPointer4)UART1_Write(*stringPointer4++);
UART1_Write(enter);
Delay_ms(100);}//######################################################################################################################################void SendStringToModem2(char*stringPointer5){while(UART1_Tx_Idle()==0){}while(*stringPointer5)UART1_Write(*stringPointer5++);
UART1_Write(ctrlPlusZ);
Delay_ms(100);}//###############################################################################//###############################################################################void main(){
ADCON1=0b00001111;
CMCON =0b00000111;//.........................
TRISA=0;
TRISD=0;//.........................
TRISE.B0=0;
TRISE.B1=0;
TRISE.B2=0;//.........................
TRISC.B3=1;
TRISC.B4=1;//.........................
LATA=0;
LATD=0;
LATE.B0=0;
LATE.B1=0;
LATE.B2=0;//.........................
UART1_Init(115200);
Lcd_Init();
delay_ms(500);
SendStringToModem1(initializeGsmModule);
SendStringToModem1(noEcho);
SendStringToModem1(textMode);
SendStringToModem1(charMode);
SendStringToModem1(setParametersOfCharMode);
SendStringToModem1(sendAnyReceivedSmsCommand);
SendStringToModem1(saveCurrentConfigurationInEEPROMCommand);
SendStringToModem1(deleteAllSmsCommand);
Delay_ms(1000);while(1){
ReceiveSmsString(receivedSmS);
Lcd_Out(1,1,receivedSmS);}}
- - - Updated - - -
Just for ur knowledge i test the part of the code who is responsible for sending sms to a phone number and it works and send a valid sms to the give phone number , so where is the wrong stuff in receiving the sms ?
i test the part of the code who is responsible for sending sms to a phone number and it works and send a valid sms to the give phone number , so where is the wrong stuff in receiving the sms ?