ckshivaram
Advanced Member level 6
- Joined
- Apr 21, 2008
- Messages
- 5,060
- Helped
- 2,150
- Reputation
- 4,306
- Reaction score
- 2,088
- Trophy points
- 1,403
- Location
- villingen (Germany) / Bangalore
- Activity points
- 30,087
check this sample program.. bit lengthy , but see only sms receive part...
AT+CPMS="SM" //sim memory
AT+CPMS="ME" //phone memory..
void gsm_receive()
{
while(rx_data()!='+'); // wait till + symbol comes through UART as the sender number will have a + in the beginning of mobile no.
while(rx_data()!='\"');
for(count=0;count<13;count++) //if + is there then wait for read 12 digit mobile number including 91 so +91xxx is read.
{
phone_num[count]=rx_data(); // store every digit of phone number received into array.
}
phone_num[count]='\0';
while(rx_data()!='\n'); //new line
for(count=0;count<5;count++) // message to be received is a max of 5 characters
{
message[count]=rx_data(); // receive the sms and store in message array
if(message[count]=='\r')
break;
}
}
Code:void gsm_receive() { while(rx_data()!='+'); // wait till + symbol comes through UART as the sender number will have a + in the beginning of mobile no. while(rx_data()!='\"'); for(count=0;count<13;count++) //if + is there then wait for read 12 digit mobile number including 91 so +91xxx is read. { phone_num[count]=rx_data(); // store every digit of phone number received into array. } phone_num[count]='\0'; while(rx_data()!='\n'); //new line for(count=0;count<5;count++) // message to be received is a max of 5 characters { message[count]=rx_data(); // receive the sms and store in message array if(message[count]=='\r') break; } }
while(rx_data()!='\"');
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 void main() { unsigned char volatile ch[10], i=0; serial_init(); lcd_init(); while(1) { serial_send('A'); lcd_data(serial_read()); serial_send('T'); lcd_data(serial_read()); enter(); while(i<6) ch[i++]=serial_read(); if(ch[5]=='K') lcd_str(" AT OK "); } }
Is all your problem solved with all above posts or struck anywhere????????
unsigned char ch[10],i=0;
serial_send('A');
serial_send('T');
enter();
while ((ch[i++] = serial_read()) != 'K');
if(ch[i-1]=='K')
{
lcd_str("Modem OK",0x80);
delay_ms(500);
}
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 #include <REG51.H> #include "lcd.h" #include "uart.h" char buff[10],i; void serial_readstr() { for(i=0; i<6; i++) buff[i] = serial_read(); } void main() { char x; serial_init(); lcd_init(); serial_send('A'); serial_send('T'); enter(); while(1) { serial_readstr(); lcd_str("hi",0xc0); while(x<5) serial_send(buff[x++]); } }
I did not get what you said...
you get OK response from modem, what is the next step you want the output to be. do you want to send ok again back to hyperterminal from controller???
you can send next at command upon receiving the OK response.......
what is the purpose of sending OK again back to hyperterminal.............
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?