/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / calling stdlib atoff resets processor

Username:     
Password:     
             

Forum

# 1   2009-05-13 09:09:20 calling stdlib atoff resets processor

The_Todd
Member
Registered: 2008-12-07
Posts: 15

calling stdlib atoff resets processor

I have a string I would like to convert to a float. As an examle:

Code:

#include <stdlib.h>

void main(void)
{
numStr[] = "123.5";
float number;

number=atoff(numStr);

}

When compiling I get error:

Running: LD
\"C:\Program Files\Raisonance\Ride\arm-gcc\bin\arm-none-eabi-gcc.exe" -mcpu=cortex-m3 -mthumb -Wl,-T -Xlinker "output\Pose_Sensor.elf.ld" -u _start -Wl,-static -Wl,--gc-sections -nostartfiles -Wl,-Map -Xlinker "output\Pose_Sensor.map"   
c:/program files/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-sbrkr.o): In function `_sbrk_r': 
sbrkr.csad.text+0x12): undefined reference to `_sbrk' 
collect2: ld returned 1 exit status 
 
Build failed

So I include <ride>/lib/ARM/io_putchar/syscalls.c in the project and it compiles, but when I step to and try to step over atoff func, processor goes to reset vector.

I am using the latest version or RIDE7 & Rkit-ARM

Any help greatly appreciated!!

-Todd

Offline

 

# 2   2009-05-13 13:44:38 calling stdlib atoff resets processor

VincentC
Administrator
Registered: 2007-11-08
Posts: 149

Re: calling stdlib atoff resets processor

Hi,

At first glance, I would say it's simply an optimization problem:
Your variable "number" is not volatile, and it is only affected once.
Therefore, the compiler may completely remove it and its affectation, leaving your main function almost reduced to a simple "return"... And the main function is not supposed to end.

Always put a "while(1);" at the end of "main".

Always declare your 'debug variables' ("number" in your case) as global volatile, and reduce the optimization level of the compiler to zero when you want to watch very simple code like this.


Here is the test I've made:

1. open this example: (that contains a while(1) in main)
<Ride>\Examples\ARM\REva\STM32F103_Toggle\STM32F103_toggle.rprj

2. reduce opti level to zero in the compiler options. (to prevent opti)

3. add UART0_putchar library in the linker options. (to have _sbrk)

4. add this code before the main function:

#include <stdlib.h>

volatile float number=5.5;
volatile float number2=3.5;

volatile char numStr[] = "123.5";

5. Add this code at the start of the main function:

number2=number*3;

number=atoff(numStr);

number2=number*3;

6. compile, start debug, add "number" and "number2" to the list of watches.

7. step three times and observe the variables "number" and "number2" being modified.


I hope it helps. If not, please send us a complete project that shows the problem. (support@raisonance.com)

Best Regards,

Vincent

Offline

 

# 3   2009-05-17 23:16:37 calling stdlib atoff resets processor

The_Todd
Member
Registered: 2008-12-07
Posts: 15

Re: calling stdlib atoff resets processor

Thank you again Vincent!
The example you posted worked fine, which made me realize it was not may call to atoff screwing up, but in the instruction before I was trying to memcpy a string over a constant defined string in Flash, causing the reset!

Now I have the issue that including <stdlib.h> and calling atoff increases my hex file size by  40kb, but I'll start a new topic for that.

Thanks,
Todd

Offline

 

# 4   2009-05-18 06:37:48 calling stdlib atoff resets processor

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: calling stdlib atoff resets processor

For the size issue, you have to edit the LD files that defines the FLASH size...

Offline

 

Board footer