You havn't mentioned what error you are getting?
The following sequence is working fine for me
The modem will respond with ">"
Then you have to send the content of the message and send escape character ie. 0x21
Thanks Mr. nandhu015. I receive only 'Error' message and not any specific error message like +CME ERROR or +CMS ERROR. The same command works fine on PIC16F877A (using Hi-Tech C Compiler). But here(MPLAB C18) not works. I don't know why? The modem not displaying '>' char. Just throw Error after the AT+CMGS command.
I checked whether AT+CMGF=1 executed correctly before sending AT+CMGS. Its correct. After disconnecting serial port and reconnect with Hyperterminal and try to send SMS using AT+CMGS, it also works fine.
---------- Post added at 14:35 ---------- Previous post was at 14:24 ----------
Dear Mr. Nandhu,
I checked with SMS command AT+CMGR=1 at the place of AT+CMGS.
putrsUSART((const far rom char*) "AT+CMGR=");
putrsUSART((const far rom char*) "1");
putcUSART(0x0D);
(OR)
putrsUSART((const far rom char*) "AT+CMGR=1");
putcUSART(0x0D);
Both commands work fine.
---------- Post added at 14:38 ---------- Previous post was at 14:35 ----------
For your information, I used inside the interrupt handler.
---------- Post added at 15:29 ---------- Previous post was at 14:38 ----------
Thanks Dear Mr. Sivaram and Nandhu. I have added some delay before issuing AT+CMGS command and inbetween the 0x0D. Now everything works perfect.
The working code is:
Code C - [expand] |
1
2
3
4
5
6
7
8
9
10
11
12
13
| [B]for(i=0;i<20000;i++){
}
[/B]
putrsUSART((const far rom char*)"AT+CMGS=");
putcUSART(0x22);
putsUSART(strBuff_IncomingPhNum);
putcUSART(0x22);
[B]for(i=0;i<10000;i++){
}
[/B]
putcUSART(0x0A);
putcUSART(0x0D); |
Once again thanks to both of you and all.