sprintf problem in MCF51QE128 and Codewarrior.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

sprintf problem in MCF51QE128 and Codewarrior.

4,167 Views
erooll
Contributor II
Hi all.

I'm trying to use sprintf function to convert a float value to a string, but it doesn't work, this function with integer values works fine.
an example of use is this:

int   valueInteger;
float valueFloat;
char str[32];

valueInteger = 420;
valueFloat = 4.20;

sprintf(str,"%d",valueInteger);   //works fine
sprintf(str,"%f",valueFloat);     //Doesn't work

I read help of CodeWarrior about sprintf function and this note at the end of page could be the way to fix my problem

NOTE

Floating point support increases the sprintf size considerably, and therefore the define LIBDEF_PRINTF_FLOATING exists. Set LIBDEF_PRINTF_FLOATING if no floating point support is used. Some targets contain special libraries without floating point support.
The IEEE64 floating point implementation only supports printing numbers with up to nine decimal digits. This limitation occurs because the implementation is using unsigned long internally, which cannot hold more digits. Supporting more digits increases the printf size still more and also causes the application to run considerably slower.




How I set LIBDEF_PRINTF_FLOATING in order to sprintf works?
Labels (1)
8 Replies

1,513 Views
alfredogualdron
Contributor III

I found a place in codewarrior where we can configure which variable types are allowed for printf

here is the pic

sprintf_build_confg.PNG.png

after select the int_FP in the print formats option, the printf function started to work fine..

hope it helps

1,513 Views
orlandozapata
Contributor II

Alfredo´s solution works perfect !! thanks man.

0 Kudos

1,513 Views
PO220
Contributor IV

HI

Can you run your application without BDM with ewl_hosted option ?

With my Kinetis KL run without multilink is not possible in "ewl_hosted", only possible with "ewl". But in "ewl" sprintf, printf, scanf don't work.

(I do not understand the "ewl_hosted" mode interest if you can not operate without programmer connexion. The fate of a microcontroller is to live without debug connexion, is not it ?)

thanks

0 Kudos

1,513 Views
TomE
Specialist II

This is a Kinetis and/or Codewarrior question. You should be searching those forums for answers, and then posting in them if you don't find anything.

Tom

0 Kudos

1,513 Views
PO220
Contributor IV

Hi

I do that... searching and don't finding..

0 Kudos

1,513 Views
kef
Specialist I
0 Kudos

1,513 Views
alfredogualdron
Contributor III

Same problem,

But the link is broken

0 Kudos

1,513 Views
TomE
Specialist II

The link is broken because the forum is now running different software to what it was in 2008.

Cut/paste "LIBDEF_PRINTF_FLOATING" into the Search Bar at upper right, read the 9 or so matches, and then update this thread with the best answer to your problem.

Tom

0 Kudos