sprtinf behaviour not as expected

All design tool related questions: compiler, assembler, linker. Embedded programming questions: assembler, C code.

Moderator: nferre

Volkiman
Contact:
Location: Germany
Posts: 3
Joined: Tue Apr 22, 2008 4:32 pm

sprtinf behaviour not as expected

Tue Jun 29, 2010 8:59 am

Hi together,

My system:
CPU: AT91SAM7SE32 with external flash memory and external SRAM
Compiler: RVDS 2.2 with IDE Metrowerks CodeWarrior 5.1.6.1832

I'm lookin for help after a long search:

I'd like to print float-variables into a char-Buffer (array of char's). But the behaviour is not correct what I do is the following:

char Testbuffer[20]={0};
float minizahl=123.456;
float sinizahl=0.789;

unsigned int asdfasdf= isdigit('1');setlocale(LC_ALL,"C");
//asdfasdf contains 1 (dec)
sprintf(Testbuffer, "%f",minizahl);
//Testbuffer contains "0.000000"
memset(Testbuffer, 0, sizeof(Testbuffer));
//Testbuffer contains only zero (dec)
setlocale(LC_ALL,"C");
sprintf(Testbuffer, "%f",sinizahl);
//Testbuffer contains unexpected data:-268156222443479670000000000000000000000000000000000000000000000000000000 => system crashes!

At startup I'm calling:
__rt_stackheap_init();
__rt_lib_init();

libspace (ZI-Data at the of my Data-Segment) contains zero before "__rt_stackheap_init();" and has data after "__rt_stackheap_init();" after "__rt_lib_init();" the data has changed again. Is that correct? Are there any further library or compiler switches that I have to do?

In the source tree of the project settings I already entered the name "RVCT22LIB" with the Absolute Path to installation directory\ARM\RVCT\Data\2.2\503\lib

Has anybody any ideas?

Greets Volkiman

Return to “Development Tools”

Who is online

Users browsing this forum: No registered users and 4 guests