This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Problem with floating point operations



Hi,

I am presently trying to run a filter design code on C6748 processor using CCSv4. The code was fine when I was using integer values of filter coefficients. I was reading in the values as int32_t, and also writing them out in the same format. But now, I am converting the int32_t values into floats and separating them into left and right channels. 

int32_t dataIn32;

int32_t ileft;

int32_t iright;

iright=  dataIn32 >> 16;

 ileft = (dataIn32 << 16) >> 16;

I am trying to multiply ileft and iright with the floating point filter coefficients (Coefficients which look like -0.00098430158499334622, -0.00094963812473876472        , 0.00066511408673153305 etc, in fact 64 values, as I am trying to implement a 64 order filter). I am merging the left and the right channel outputs into a single int32_t value and sending out to the McASP. However, I find that, the code which was working fine with integer filter coefficients does not yield the desired output at all the moment I convert it to floating point. Do I need to do something else when I use floating point multiplication in C6748? Any help in this regard will be greatly appreciated.

Thanks,

Debarati.

  • Questions about the C6748 device are properly handled in the C67x Single Core DSP Forum.

    The C6748 has native support for both integer and floating point data types. You must use these data types in a consistent manner in your C code so that the compiler understands your intended data type, according to the standard rules of C programming.

    As with any program that you write or modify, it may operate incorrectly until you have a chance to fully debug it. In this case, you build the program in the Debug configuration and step through the code while observing the data to verify it is operating the way you require it to operate.

    Regards,
    RandyP

  • I have one additional comment: the coefficients you've listed will probably not be accurately reflected using single-precision floating point values.  You may need to use double precision variables.

  • Hi Joe,

    I find that even if I truncate half of the lowest significant digits and store them as 'floats', still, multiplying the input audio samples by the floating point coefficients is resulting in a very noisy waveform. Previously, when I was using C6713, it was fine.

    Regards,

    Debarati.

  • Debarati,

    If your audio signal starts out in integer format, then it's likely to be a very high-magnitude signal (i.e. in the range +/- MAX_INT).  This could cause a loss of precision if you multiply those numbers as-is in floating point format.  You might want to try mapping the original integer signal into the range +/- 1.0 before applying floating point processing.  Then, when you're finished, you can expand it back to the full integer range for audio output.

    Here's an example of what this might look like for a system using 16-bit integers to represent audio input/output:

    for (i = 0; i < BUF_LEN; i++)
        audio_proc_buf[i]  = (float)audio_input_buf[i] / 32768.0f;

    // audio processing...

    for (i = 0; i < BUF_LEN; i++)
        audio_output_buf[i] = (Int16)(audio_proc_buf[i] * 32768.0f);

    Hope this helps.

  • Hi,

    I tried this out, but unfortunately it didn't work for me. Now I can't even hear any audio now.

    Regards,

    Debarati.

  • Debarati Kundu,

    You had the code working on the C6713 floating point processor using integer coefficients. Then you made the good move to the newer C6748 and you changed the coefficients to float and you split the data into 2 channels. And it does not work.

    The best path (in my opinion) is to go back to the beginning and retrace your steps in smaller steps. Confirm the integer code on the C6713, then confirm the integer code on the C6748, then change the coefficients to float and confirm it, then split the data. You might have to change some of the order of things, like splitting the data earlier, but you will know the best way to do that.

    Build in the Debug Configuration and single step through some data manipulation to see if it looks right. Writing the code gets all the glory, but debug is where you have the most fun.

    Regards,
    RandyP