Hi PRJOY,
The example baremetal code has its own printf() function that does only simple stuff to keep the printf() code size manageable for a small MCU.
You can use the development tools libraries for complex printf/scanf stuff.
I used CW10.2 and creted a new baremetal project.
Opened the project properties dialog box and made change to the Librarian settings (Print and Scan Formats now set to "int_FP").
The code I ran is:
/*
* main implementation: use this 'C' sample to create your own application
*
*/
#include <math.h> //DES added
#include <stdio.h>
#include "derivative.h" /* include peripheral declarations */
void mypow(double x, double y); //prototype
int main(void)
{
int counter = 0;
float x=3.14678234;
printf("Hello (Kinetis) World in 'C' from MK70FN1M0 derivative! \n\r");
for(;;) {
counter++;
mypow((double)2,(double)counter);
printf("x=%f\n", x*(counter+3.1244232));
}
return 0;
}
void mypow(double x, double y)
{
double p;
y+=0.257;
x+=1.25;
p = pow(x, y);
switch (fpclassify(p))
{
case FP_ZERO:
case FP_NORMAL:
case FP_SUBNORMAL:
printf("%f ", p);
break;
default:
printf("error in pow()");
break;
}
}
The terminal output is:
Hello (Kinetis) World in 'C' from MK70FN1M0 derivative!
4.399845 x=12.978662
14.299496 x=16.125445
46.473364 x=19.272227
Regards,
David