i.MX8MP: Cannot print float values from SDK M7 examples

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

i.MX8MP: Cannot print float values from SDK M7 examples

Jump to solution
751 Views
vin_imd
Contributor II

Hello all,

I am using custom board based on i.MX8MP EVK. I am using the SDK created from NXP MCUXpresso SDK builder for i.MX8MPEVK. I am not using the MCUXpresso  IDE as it is not supported for i.MX8MP platform so building the examples on Ubuntu 20.04 using gcc-arm toolchain. Looking at the examples for M7 co-processor (ecspi polling), I'm unable to print floating point values. The floating point values are stored correctly and in the flags.cmake I see that the below flags are defined.

-mfloat-abi=hard 
-mfpu=fpv5-sp-d16 

The statement - PRINTF("Execution timer: %s\n\rTime: %u ticks %2.5f milliseconds\n\rDONE\n\r", "1 day", 86400, 86.4); doesn't print 86.4, just a blank space. If I check the hex value at the address of a float variable, the value is correct which means only PRINTF has issue printing the float value.

float test = 86.6;
uint32_t *ptr = (int32_t *)&test;
PRINTF("float in hex - %x\r\n", *ptr);
outputs - 0x42ad3333 which is correct for 86.6
 

Does any one know how to get the custom PRINTF function of the SDK to print floating point values? Is it the problem with the C library being used for M7 co-processor examples build?

 

Thanks.

0 Kudos
1 Solution
743 Views
b36401
NXP Employee
NXP Employee

Here is attachment.

View solution in original post

2 Replies
744 Views
b36401
NXP Employee
NXP Employee

Please note that %x option in printf means integer in hex. So in this case the code gets the bytes of the variable and looks at them as an integer variable.
You need to write a routine that parses a float and divides in into integer and fractional parts of a number.
You can refer to example I attached.

0 Kudos
744 Views
b36401
NXP Employee
NXP Employee

Here is attachment.