PRINTF problem in SDK 2.0

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

PRINTF problem in SDK 2.0

530 Views
regexp
Contributor I

Hello,

 

I have FRDM-K64F, KDS 3.2 and SDK 2.0 for K64F CPU family.

 

When I startet to use SDK 2.0 I found two problem with PRINTF. One less serious is definition of its first parameters "char *", which should be nowadays "const char *". It generates enormous number of warnings.

 

The second more serious problem is bug of float numbers output. Below is my main():

int main(void) {

  /* Init board hardware. */

  BOARD_InitPins();

  BOARD_BootClockRUN();

  BOARD_InitDebugConsole();

 

  float x = 0.9;

  printf( "%f %f %f\n", x, x - 1.0, -3.14 );

  PRINTF( "%f %f %f\n", x, x - 1.0, -3.14 );

 

  /* Add your code here */

  for(;;) { /* Infinite loop to avoid leaving the main function */

    __asm("NOP"); /* something to use as a breakpoint stop while looping */

  }

}

 

The output is:

0.900000 -0.100000 -3.140000

0.900000 -1.100000 -4.140000

 

The problem is in function DbgConsole_ConvertFloatRadixNumToString where some programmer badly implements condition:

if (fa <= pow(-10, precision_width))

        {

            intpart--;

        }

The sign minus must be in front of pow.

 

reg.

Labels (1)
2 Replies

365 Views
ivadorazinova
NXP Employee
NXP Employee

Hi,

I recommend what David said. There was a discussion on this topic a few days ago.

Please test it on your side and let us know, if this works you.

Have a nice day.

Iva

0 Kudos

365 Views
DavidS
NXP Employee
NXP Employee

Hi reg,

printf() is calling compiler tool chain printf.

PRINTF is calling embedded code in KSDK_v2.

PRINTF in KSDK_v2 has errata that the development team is validating currently.

A workaround for it is posted here:

https://community.nxp.com/message/754763?et=watches.email.thread#comment-754763

Regards,

David