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.
I am using keil IDE for arm7 (LPC2138 by NXP) programming. Here is my code. >> #include <LPC213X.H> #include "Stdlib.h" #include "Serial.h" void initialize(void); int main () { float number; int i;
initialize(); UART0_sendstring("Here 1\r\n");
number = atof("643.783");
UART0_sendstring("Here 2\r\n");
while(1){} }
Program compiles successfully.Only 2 warnings: main_testProj2.c(51): warning: #550-D: variable "number" was set but never used main_testProj2.c(52): warning: #177-D: variable "i" was declared but never referenced
Now when i simulate the code on Hardware. Only "Here 1\r\n" string is displayed on HyperTerm. "Here2\r\n" is not Displayed at All. If i replace the argument string of atof() with something like this >> number = atof("6.3e+2"); then the program works fine. Both the strings are displayed in respective order.
What i concluded: In first case, The program enters into the atof function but it never comes back, looks like it hangs somewhere inside the atof() function. Why? Also i have found that similar problem occurs when i use sprintf function to convert float to string.
And exactly why, did you 4 hours 15 minutes after the creation of the following thread feel a need to create yet another thread with the same question?
It doesn't sound like you have tried to increase the stack size to figure out if that made a difference. Your only tiny little addendum is that yo unotice the same problem with sprintf() - why not just add that note in the original thread?
http://www.keil.com/forum/19328/
Very Well, With all due respect,
I will keep in mind not to start a new thread but all u have answered is "Is your stack enough.?". I did increase the stack size of user/system mode in startup configuration, but the problem remains the same.
I expect some explanatory answer plz.
What else did you try?
I happened to have a couple of minutes to spare so I created a new project, pasted in your code, compiled it, started debug with the simulator and ... presto ... it worked.
Since you've got very little code there, it would be worth you trying the same.
With all due respect: Where in your thread did you write that?
With all due respect 2: You "expect"? Do you feel that this a support forum where you pay for professional help? Did you read the 'Terms of Use' etc? Official Keil support is not through this forum.
Well thanx for ur couple of minutes. I too tried it on debugger and monitored the values of variables in watch window and ..yes ..it does reaches the end and the values are also correct.
But then why is it not working in real world.. I am simulating it in Proteus and there too it stucks at the same point.
any ideas??
If you don't have answer to the problem . Plz do not reply.
Plz do not reply.
Aha. When exactly were you elected Pope of this forum, again?
"any ideas??"
So, your summary of "atof() function problem" appear to be incorrect. It looks like the compiler, libraries and tools are good.
You need to check for (and take account of) whatever could be different between reasonably accurate simulation of uVision and your 'real world' hardware platform.
Have you made sure that your stack is properly aligned?
When exactly were you elected Pope of this forum, again?
Last Week :-)