printf function works but not float variables.

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

printf function works but not float variables.

1,069件の閲覧回数
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 返信

604件の閲覧回数
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 件の賞賛
返信