problem with reading sms (gsm module sim300cz)in the other times

Status
Not open for further replies.

mansoureh*

Junior Member level 1
Joined
Nov 5, 2010
Messages
17
Helped
4
Reputation
8
Reaction score
3
Trophy points
1,283
Location
iran
Activity points
1,432
hi every body
i want to receive sms with module gsm sim300cz & then i read the sms and then for example i want to forward the text of sms to a number , at the first i can read the text & forward it but for the second time when i send sms until to read text it can not work, i try to solve this problem but i can not , i read most of the post, but i can not plz help me i am very unhappy,i put my code of my program ,please read it & tell me why it didnt work for the other times when i send a sms it can not read it?
#include "AT91SAM7x256.h"
#include "lib_AT91SAM7x256.h"
#include "delay.h"
#include "usart.h"
//#include "string.h"
#include "PIO.h"
#include "adc.h"
#include "lcd8bit.h"
#include <stdio.h>
void sms_send(void);
void delete(void);


int main(void){

unsigned char sms[250];
int k=0;
int i=0;
int j=0;

unsigned char b;
char Enter=13;
char Ctrlz=26;
char double_quote=34;

/*configuration lcd*/
lcd_rs(2,0x1);
lcd_e(2,0x2);
lcd_data(2,0x3fc);
lcd_clear();

/*configuration usart*/
USART(18432000,9600,0);
usart0_init();

/*configuration ADC*/
config_adc(0xff);


/*configuration pio*/
PORTA_OUTPUT=PA5;
PORTA_INPUT=PA29;

for(k=0;k<250;k++)
{
sms[k]=0;
}

printf("AT%c\n",Enter);
delay_ms(50);
printf("ATE0%c\n",Enter);
delay_ms(50);
printf("AT+CMGF=1%c\n",Enter);
delay_ms(50);
printf("AT+CPMS=%cME%c%c\n",double_quote,double_quote,Enter);

delay_ms(50);

delete();

while(1){
for(k=0;k<250;k++)
{
sms[k]=0;
}
printf("AT+CNMI=1,2,0,0,0%c\n",Enter);
delay_ms(50);

if(PINA(29)==0) /*CONDITION*/
{
printf("AT+CMGR=1%c\n",Enter);
while(j==0) {


b=getkey();

switch(b)
{


case 10:
if((sms[0]!=0)) {
j=1; }
break;

case 13:
if ((sms[0]!=0))
{
j=1;}
break;

default:
sms=b;
i++;


} /*END switch 1*/
} /*END while j=0 */

sms_send();
printf("%s%c",sms,Ctrlz);
SET_PORTA=PA5;
delay_ms(500);
RST_PORTA=PA5;
delay_ms(500);
SET_PORTA=PA5;
delay_ms(500);
RST_PORTA=PA5;
delay_ms(500);
j=0;


}
}
}



void sms_send(void)
{
char En=13;
char doubles=34;

/*read input data*/
printf("at%c",En);
delay_ms(500);
printf("AT+CMGF=1%c",En);
delay_ms(500);
printf("at+cmgs=%c09192484603%c%c",doubles,doubles,En);
delay_ms(100);

}

void delete(void)
{
char Ent=13;


printf("at%c",Ent);
delay_ms(500);
printf("AT+CMGD=1%c\n",Ent);
delay_ms(500);
printf("AT+CMGD=2%c\n",Ent);
delay_ms(500);
printf("AT+CMGD=3%c\n",Ent);
delay_ms(500);
printf("AT+CMGD=4%c\n",Ent);
delay_ms(500);
printf("AT+CMGD=5%c\n",Ent);
delay_ms(500);
printf("AT+CMGD=6%c\n",Ent);
delay_ms(500);
printf("AT+CMGD=7%c\n",Ent);
delay_ms(500);
printf("AT+CMGD=8%c\n",Ent);
delay_ms(500);
printf("AT+CMGD=9%c\n",Ent);
delay_ms(500);
printf("AT+CMGD=10%c\n",Ent);
delay_ms(500);
printf("AT+CMGD=11%c\n",Ent);
delay_ms(500);
printf("AT+CMGD=12%c\n",Ent);
delay_ms(500);
printf("AT+CMGD=13%c\n",Ent);
delay_ms(500);
printf("AT+CMGD=14%c\n",Ent);
delay_ms(500);
printf("AT+CMGD=15%c\n",Ent);
delay_s(2);
}
 

Hi friend,
i had few doubts, may i know which controler you are using to intrerface modem and how you are sending the commands to t6he UART of SIMCOM.
just using printf?
 

hi
i work with micro arm(at91sam7x256)
yes , i used command printf
i test my program & it works but the problem of my program is when i send sms for the first time my program can read the sms but when i again send an sms it,my program can not read it?
do you have any idea why it happen?
& do you have any program about readin sms until i undesrstand what i do wrong?
thanks
i am waiting your help ,plz help me
 

Hi friend,
Try by changing the delete() routine after the AT+CMGR=1 routine, it may work..
 

hi
thanks,i do it but it didnt work...
what i do?
 

have you checked the status of the modem in hyperterminal manually with the same sequence as your program does.
 

no, i cannot communicate with my hypertermianl, it didnt work, i test port com my computer but it didnt work.
 

void sms_send(void)
{
char En=13;
char doubles=34;

/*read input data*/
printf("at%c",En);
delay_ms(500);
printf("AT+CMGF=1%c",En);
delay_ms(500);
printf("at+cmgs=%c09192484603%c%c",doubles,doubles ,En);
delay_ms(100);

}


your output will be "09192484603"" it should be like "09192484603" this it can like this also printf("AT+CMGS=\"09192484603\"\r\n"); na?

send this AT command after initialization AT+CNMI=2,2,2,0,0 so that you no need to read from sim card try this have a nice day
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…