I am trying to print values of C language variables through the Serial Communications Interface (SCI). These values are IQ15 (IQMath) values, but the values that are being printed are incorrect. I suspect it maybe a formatting issue. I convert the IQ15 values into floating point values by using the _IQtoF function and then print them. Below is a code snippet of how I am doing it,
float f1 = 0, f2 = 0;
f1 = _IQtoF(ledOpenVoltage);
f2 = _IQtoF(ledVoltage);
memset(serialTxBytes, 0x00, sizeof(serialTxBytes));
sprintf((char *)serialTxBytes, "ledOpenVoltage: %.2f, ledOVoltage: %.2f, ledVoltage: %i \r\n", f1, f2, ledVoltage);
Both ledOpenVoltage and ledVoltage are declared as long. But they get assigned _IQ15 values. The above code prints the f1 value correctly, but not the f2 value.