printf function works but not float variables.

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

printf function works but not float variables.

1,263 次查看
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?

标签 (1)
0 项奖励
回复
1 回复

798 次查看
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 项奖励
回复