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?
Do you have enough stack? If you get a stack overflow, you can't really tell what will happen - an irrelevant change to a function parameter may make a huge difference.
I am using the default startup code for stack configurations. These are the the stack configurations
UND_Stack_Size EQU 0x00000000 SVC_Stack_Size EQU 0x00000008 ABT_Stack_Size EQU 0x00000000 FIQ_Stack_Size EQU 0x00000000 IRQ_Stack_Size EQU 0x00000080 USR_Stack_Size EQU 0x00000400
ISR_Stack_Size EQU (UND_Stack_Size + SVC_Stack_Size + ABT_Stack_Size + \ FIQ_Stack_Size + IRQ_Stack_Size)
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE USR_Stack_Size __initial_sp SPACE ISR_Stack_Size
Stack_Top
This subject also covered in duplicate thread: http://www.keil.com/forum/19330/