Hi guys I read the topics about interfacing 8051 with gsm modem those are really helpful However when I implemented my program to receive a msg and give an acknowledgment(through sms) for same There went something wrong : While sending my sms modem doesn't send 1st 8 characters of my msg i.e. Consider example:
unsigned char *msg = "abcdefghijklmnop"
then my msg sending routine tend to send ijklmnop thats all can anybody help Thank you
How do you suppose that anybody will be able to diagnose the fault in your message sending routine without seeing it?
What have you done to find the fault yourself?
Random guesses:
- The driver eats the first 8 characters of any message.
- The modem has a delay after you tell it to "send" while it's ignoring incoming data, but the driver is blasting away anyway; this delay happens to be 8 character times.
- The caller is bugged, and is actually passing in a pointer deeper into the message string than you think.
With no information on the code, the hardware, or what you've already tried to diagnose, it's hard to suggest anything.
Actually, a common mistake when attempting to send SMS messages programatically is not to wait for the prompt after issuing the AT command.
So that "random guess" could well be right!
Sorry for incomplete information here is a part of code its only part of not whole so let me know if thats insufficient:
unsigned char *Ack_ON1="Device iDevice is turned ON$"; //1st 8 chars. are not xmitted unsigned char *at_cmgs = "at+cmgs=\"+9199xxxxxxxx\"$"; //to send ack to this no. Cmd(at_cmgs); CR(); XMIT(Ack_ON1); Cnt_Z(); void XMIT(unsigned char *msg) { unsigned char i; i = 0; do { ACC = msg[i]; SBUF = ACC; while(TI == 0){} TI = 0; i++; } while(msg[i] != '$'); return; } void Cmd(unsigned char *at_command) { unsigned char i; i = 0; do { ACC = at_command[i]; SBUF = ACC; while(TI == 0){} TI = 0; i++; } while(at_command[i] != '$'); return; } void CR(void) { SBUF = 0x0D; //0x0D CR while(TI == 0){} TI = 0; return; } void Cnt_Z(void) { SBUF = 0x1A; while(TI == 0){} TI = 0; return; }
I hope this much would be sufficient what else i've done in code is i. receiving the msg ii. verifying it iii. taking action iv. sending acknowledgment msg
ACC = msg[i]; SBUF = ACC;
You simply cannot use ACC in 'C' like that!
You have absolutely no guarantee whatsoever that the compiler won't have used the Accumulator for its own purposes between those two lines!!
In fact, as you're indexing arrays, it is quite likely that the compiler will have used the Accumulator for its own purposes!
In fact, it is entirely pointless - you can just write
SBUF = msg[i];
You're not in assembler now!
I suggest you spend some time reviewing the example programs: http://www.keil.com/download/list/c51.htm
And possibly some books: http://www.keil.com/books/8051books.asp
Thanks Andy I will look to it and will let you know
About these books do I need to go through all of them or can you suggest me which are best and absolutely necessary mainly for C and embedded (right from 8051 to more complex architecture)
one more thing can I see assembly code in uVision just because I'm curious and if required how to add assembly code in my C program. I can work on C or assembly but not assembly and C at a same time
View all questions in Keil forum