We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
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
Hi Andy I surely didn't read any of those books but I've removed all intermediate ACC but still the same problem exists i.e. 1st 8 characters are missing anyway I'll continue some more debugging
Why do you use a dollar sign at the end of the strings? Anything wrong with using the zero-termination that is already available in the strings?
Not at all just used to do that way from my college days Now can't remember how to use 0 termination i guess "<string>",0 please correct me if I'm wrong
There is (almost) always a hidden zero at the end of C strings.
So you can just check if str[i] == 0 to detect when you have reached the end.
The only exception where a string does not contain the zero, is if you assign the string to an array that just has room for the characters but no termination, i.e.
char buf[] = "hello"; // 5 characters + termination char buf[6] = "hello"; // 5 characters + termination char buf[5] = "hello"; // 5 characters but no room for termination
Thanks I'll try it