cancel
Showing results for 
Search instead for 
Did you mean: 

printf fail to print float type

STM32L09
Associate II

Software tool: IAR Workbench 9.60

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <intrinsics.h>

int putchar( int ch ){  
  while(!(USART2->ISR&0X0080));   
USART2->TDR  = (unsigned char)ch;
return ch;
}
 
test code:
printf("%d\n",ADC_array[0]);
printf("%f\n",1.234567);
 
Output on computer:
62615       ----correct
%f             ----incorrect(should output 1.234567)
1 ACCEPTED SOLUTION

Accepted Solutions
AScha.3
Super User

check : project->properties->settings : use float with printf...

AScha3_0-1747501069208.png

 

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

3 REPLIES 3

Perhaps need to check box full scanf/printf libraries supporting floating point.

Likely quite large so not enabled by default.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
AScha.3
Super User

check : project->properties->settings : use float with printf...

AScha3_0-1747501069208.png

 

If you feel a post has answered your question, please click "Accept as Solution".
STM32L09
Associate II

thank you, I found it in this window:

STM32L09_0-1747530336194.png

the default is Small, I change it to Full, now it works, I have float printed.

63445
1.234567

 

by the way, will this configuration increase the hex fill? should I change it back to Small after debugging? so I can save the flash size.