printf float value

Discussions around product based on ARM Cortex M7 core.
This forum will be discontinued soon.

Moderator: nferre

linuxjiahuo
Posts: 11
Joined: Mon Sep 07, 2015 4:18 am

printf float value

Thu Feb 04, 2016 2:38 am

hi,guys:
I find that the printf can not show the float value normally vis a COM port. Any one have a good suggestion?
Thanks
jonavarque
Posts: 29
Joined: Fri Jul 10, 2015 6:35 pm

Re: printf float value

Thu Feb 04, 2016 9:01 pm

void printfloat(float v)
{
float dec = (v - (int)v) * 100000; // depending on the number of digits in the decimal..
printf("%d.%05d",(int)v,(int)dec)
}
linuxjiahuo
Posts: 11
Joined: Mon Sep 07, 2015 4:18 am

Re: printf float value

Mon Feb 15, 2016 2:57 am

hi,
I get it. I add -mfloat-abi=softfp -mfpu=fpv5-sp-d16 in the ARM/GNU C Compiler->Miscellanesous->other flags and it works now.
Thank you.
embeddedBee
Posts: 1
Joined: Fri May 13, 2016 6:08 am

Re: printf float value

Fri May 13, 2016 7:27 am

Hi linuxjiahuo,
I have been fighting to display floating point values in the UART Console. This is also the post I have made in stackoverflow in search of the solution.
http://stackoverflow.com/questions/3718 ... rt-console

Added those compiler flags as you have instructed, but this too is not working. Compiler generates lots of warning of same type. It says :

Code: Select all

#warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" [-Wcpp]	
I am using Atmel SAMB11 Xplained Pro board which is Cortex M0 processor and the IDE is Atmel Studio 7.
tsvoipio
Posts: 54
Joined: Wed Aug 19, 2015 9:44 pm

Re: printf float value

Fri May 13, 2016 11:20 am

embeddedBee wrote:Hi linuxjiahuo,
I have been fighting to display floating point values in the UART Console. This is also the post I have made in stackoverflow in search of the solution.
http://stackoverflow.com/questions/3718 ... rt-console

Added those compiler flags as you have instructed, but this too is not working. Compiler generates lots of warning of same type. It says :

Code: Select all

#warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" [-Wcpp]	
I am using Atmel SAMB11 Xplained Pro board which is Cortex M0 processor and the IDE is Atmel Studio 7.

Add only -mfloat-abi=soft

--

-TV
Ragnar
Posts: 7
Joined: Thu Jun 23, 2016 2:33 pm

Re: printf float value

Thu Jun 23, 2016 7:33 pm

Sorry, but printf() floating point output is not a matter of ABI, but of string formatting.
I have no experience with AtmelStudio, but with other IDEs, one chooses the proper library (clib implementation) - either with or without floating point support. Floats/doubles require the most code and stack space at runtime, which implementations on MCUs with just a few kByte cannot effort. AFAIK, nanolib does generally not support float printf.

Return to “SAM Cortex-M7 MCU”

Who is online

Users browsing this forum: No registered users and 2 guests