# strannge sprintf in 4 wires measurement example

Question asked by gugi on Mar 6, 2016
Latest reply on Mar 7, 2016 by emoloney

Hi,

I made a frequency sweep in 4-wries example. I added to print the frequency, but something strange appears.

This is my code:

sprintf(msg, "%d Hz    CURRENT     = (%6X, %6X)\t",new_frequency,  (uint16_t)dft_results[0], (uint16_t)dft_results[1]);

PRINT(msg);

sprintf(msg, "   CURRENT     = (%6X, %6X)\t", (uint16_t)dft_results[0], (uint16_t)dft_results[1]);

PRINT(msg);

sprintf(msg, "    VOLTAGE     = (%6X, %6X)\t\r\n", (uint16_t)dft_results[2], (uint16_t)dft_results[3]);

PRINT(msg);

This is what I have in terminal:

170 Hz    CURRENT     = (     0,     B0).   CURRENT     = (    B0,   EFE3).    VOLTAGE     = (  FE90,   24CE).

.       9.1250.     179.8125

340 Hz    CURRENT     = (     0,    120).  CURRENT     = (   120,   EFE3).   VOLTAGE     = (  FD69,   24B1).

.       9.1250.     180.0625

680 Hz    CURRENT     = (     0,    23B).   CURRENT     = (   23B,   EFFD).    VOLTAGE     = (  FADE,   246A).

In the first CURRENT sprintf, where I added to print and the frequency , instead of real part I have 0 and instead of imaginary part I have the real (I think). If I do not add to print the frequency (the second sprintf) it looks everything to be ok ?!?!

Any ideas?

Thank you

Petar