printf function works but not float variables.

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

printf function works but not float variables.

696 Views
ernesto_arc
Contributor II

Hello,

 

In my program I have the Following definitions:

 

 

extern void TERMIO_Init(void){cdc_init();}        extern void TERMIO_PutChar(UINT8 ch){cdc_write(ch);}

 

The printf function works well for variables char, int, long. Using% u,% x.

But float variables does not work. to write% f, prints numbers not close to being thenumber that is stored in RAM.

What should be done so that you can print data float?

Labels (1)
0 Kudos
1 Reply

231 Views
CrasyCat
Specialist III

Hello

 

Which processor are you targeting (HC08, HC12, Coldfire v1, Coldfire v2, ...)?

 

For some processor the delivered library do not provide full support for printf function in order to minimize footprint.

 

If you are using HC08 or HC12 MCU, you can add support for floating point number in printf setting

LIBDEF_PRINTF_FLOATING to 1 in libdefs.h. This file is located in the library include folder.

After you changed that you will need to re-build the ANSI library.

 


CrasyCat

0 Kudos