Skip to main content

如何输出浮点数字uartdebug?

6 days ago

如何输出浮点数字uartdebug?

Posted bykuda40 points 2 replies
0 upvotes

Hi! Sir,
when i debug my imu data, i find that a problem about print floating digit.

when i use the angle func( ex: acos, atan....) to process the float digit, and I use printf() func to print the float digit for my application. Uart can't output any float digit, so how to enable or setup flags to output the float digit to uart for debug?

kuda

2 days ago

PM_Dialog

Hi kuda,

Thanks for posting online and sorry for the delay. Let me check this and I'll get back to you.

Thanks, PM_Dialog

accepted answer!

2 days ago

PM_Dialog

Hi kuda, In order to support float printf you should enable the "Use the float with nano printf" in the library.

Similar to scanf – you should enable the "Use float with nano scanf" in the library.

Please check the attached screenshot. Right-click on the project from the Project explorer go to the project properties.

printf("%9.6f", myFloat); //specifies a format with 9 total characters: 2 digits before the dot, the dot itself, and six digits after the dot. printf("%.6f", myFloat); // six digits after the dot

Thanks, PM_Dialog

Attachment Size
float_printf.PNG 59.15 KB