cancel
Showing results for 
Search instead for 
Did you mean: 

Why is printf not working with floating point on the STM32F407VG, IAR 8.30.1

km shim
Associate II

ex) When compiled with IAR 8.30.1, HardFault exception was occured.

float gfSetDataRate = 100.0f;
printf("Data Rate = %f \r\n", gfSetDataRate);

HardFault is occured at VCVT.F64.F32 instruction.

I also tested following case

  1. In case Compiled with GCC, is working well.
    1. Other device STM32F411, Working well with IAR, GCC.

What is wrong? IAR, my source, STM32F407 FPU?

Ggive me any other hints, please.

12 REPLIES 12
AvaTar
Lead

Stack too small ?

Chose a lib without float support (supposedly not causing hardfaults) ?

Check the FPU is being enabled, usually in the SystemInit() code, and being called from startup.s

Make sure the right libraries and target processor are being selected.

Compare and contrast source files and metadata in project between the ones crashing, and ones functioning.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
km shim
Associate II

Thanks,

I have already checked stack size up to 32kbytes and also fpu enabled function.

thank you very much.

AvaTar
Lead

Does it work, then ?

32kB is not necessary, but the 128 or 256 byte default stack of some toolchains is destined to fail quickly.

Printing floating point numbers does not strictly require the FPU.

km shim
Associate II

No, still not working.

Yes, I think that 4 Kbytes is enough for stack in my application.

And, as attached picture, exception is occurred at execution of FPU instruction, vcvt.f64.f32,

I thought that this may be related with lazy stack. so, now reviews the lazy stacking.

Thank you very much.

AvaTar
Lead

Seems you are using floating point numbers anyway. Have you enabled the FPU ?

If I remember correctly, IAR does enable the FPU automatically in the startup, if it is set in the project options (General Options-> Target, FPU).

And check the device is set correctly (STM32F407xx, Cortex-M4F).

Mike_ST
ST Employee

Please check that the printf formatter is set to "Full" in the project's "General Option"=>"Library Options 1".

km shim
Associate II

Yes,

Target, and library configuration. and also, debug info picture as following.

0690X000006CE4CQAW.png

0690X000006CE4HQAW.png

0690X000006CE4MQAW.png

FPU enabled routine. at that time FPU coprocessor info.

0690X000006CE4RQAW.png

0690X000006CE4WQAW.png

0690X000006CE4bQAG.png

km shim
Associate II

I found the hints on Keil site(http://www.keil.com/support/man/docs/armasm/armasm_dom1361289950613.htm).

They says that VCVT instruction can produce invalid operation, ....

and also I found that vcvt.f64.f32 never used in the gcc asm code. so, suspected that there is problem in IAR tool chain. I reported this phenomenon to IAR.

Thank all, very very much.