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.

tms320c5505: hwafft output

Part Number: TMS320C5505
Other Parts Discussed in Thread: TMS320VC5505, , TMS320C5515, TMS320C6748, TMS320C6747

dear ,

 i am using hwafft.asm function to perform fft.

i am providing an input array as Int32 adc_out1[8]={1,2,4,8,16,32,64,128,};; wher i should get an output as 

Real part and Imaginary part as

255.000000,0.000000
48.639610,166.066017
-51.000000,102.000000
-78.639610,46.066017
-85.000000,0.000000
-78.639610,-46.066017
-51.000000,-102.000000
48.639610,-166.066017

BUT i am getting the output as

0, 33

-20, 7

-12, 65530

-5, 65527

0, 65526

6, 65527

13, 65530

21,7

i really dont understanding my mistake plz tell me whats wrong with it

  • The sw team is notified. They will post their feedback directly here.

    Please post the SDK version that you're using.

    Best Regards,
    Yordan
  • hello sir/mam...plz solve my issue..i stuck to it
    i dont understand
  • hello..plz solve my issue..why i am getting such output.. i have followed your  errata too...

    To execute the HWAFFT routines from the ROM of the DSP, the programmer must satisfy memory allocation restrictions for the data and scratch buffers. See the device-specific errata for an explanation of the restrictions and workarounds:

    • TMS320VC5505/VC5504 Fixed-Point DSP Silicon Errata (Silicon Revision 1.4) [literature number SPRZ281]

    • TMS320C5505/C5504 Fixed-Point DSP Silicon Errata (Silicon Revision 2.0) [literature number SPRZ310]

    • TMS320C5515/C5514 Fixed-Point DSP Silicon Errata (Silicon Revision 2.0) [literature number SPRZ308

    still i am getting the same issue..please solve this.

  • plzzzz somebody reply me...

  • Hi Kanchan,

    It looks like your numbers are in a different fixed-point notation than what is expected by the HWAFFT accelerator.

    The HWAFFT inputs and outputs 2's complement 16-bit fixed-point S16Q15 fractional numbers ranging from -1 to 0.9999.

    The most significant bit is the sign bit followed immediately by the decimal point and 15 fractional bits (S.QQQ QQQQ QQQQ QQQQ)

    Examples of converting from S16Q15 hex to decimal:
    Hex               Decimal
    0x8000    = -1.000000000
    0x8001    = -0.999969482
    0xC000   = -0.500000000
    0x0000   =   0.000000000
    0x0001   =   0.000030518
    0x4000   =   0.500000000
    0x7FFF  =   0.999969482

    I dont understand the numbers that you are getting as output (like -12 and 65530). These must be signed 32-bit numbers. A signed 16-bit (without any decimal point) has a range from -32768 to 37767.

    Anyway, you should interpret the output as S16Q15 fractional numbers ranging from decimal -1 to 0.9999.

    Given that your inputs {1,2,4,8,16,32,64,128,} are actually {0.000030518, 0.000061035, 0.000152588, 0.000274658, 0.000518799, 0.001007080, 0.001983643, 0.003936768} (see below conversion table), does the FFT result now make sense? You will have to interpret the numbers again in the S16Q15 format.

    Maybe you can post the hex numbers in 16-bit format.

    You can use matlab to convert to fixed point numbers with code below:

    Nsig = 1024;
    fs = 16000;
    sig = zeros(1,Nsig);
    n = 0:(Nsig-1);    % discrete-time grid 
    %Add a pure sinusoidal tone
    fk = 1000;
    sig = .5 * sin(2*pi*n*fk/fs);        %sinusoid
    
    sig_fixed = fi(sig,1,16,15);
    sig_fixed_hex = sig_fixed.hex;

    I've attached the excel sheet that created the table below:

    /cfs-file/__key/communityserver-discussions-components-files/791/6574.S16Q15-fixed-point-numbers.xlsx

    Bit: 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0  
    Exponent: N/A -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15  
    Bit Value: Sign 2^(-1) 2^(-2) 2^(-3) 2^(-4) 2^(-5) 2^(-6) 2^(-7) 2^(-8) 2^(-9) 2^(-10) 2^(-11) 2^(-12) 2^(-13) 2^(-14) 2^(-15)  
    Value: -1 0.5 0.25 0.125 0.0625 0.03125 0.015625 0.0078125 0.00390625 0.001953125 0.000976563 0.000488281 0.000244141 0.00012207 0.000061035 0.000030518 Decimal  Value
    S16Q15: 0x8000 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1.000000000
    S16Q15: 0x8001 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 -0.999969482
    S16Q15: 0xC000 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.500000000
    S16Q15: 0x0000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.000000000
    S16Q15: 0x0001 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0.000030518
    S16Q15: 0x4000 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.500000000
    S16Q15: 0x7FFF 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999969482
    Input Hex
    1 0x0001 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0.000030518
    2 0x0002 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0.000061035
    4 0x0004 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0.000152588
    8 0x0008 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0.000274658
    16 0x0010 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0.000518799
    32 0x0020 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0.001007080
    64 0x0040 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0.001983643
    128 0x0080 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0.003936768

    Hope this helps,
    Mark

  • Hello Mark,

    Thank u so much for the most awaited response from ur side...

    thanks for the valuable information.

    i am getting the desired output i mean theorotical output (but the rounded integers)if i set the scale flag as 1 i.e. scale_flag = NOSCALE_FLAG;

    but now the problem is , HWAFFT has inbuilt function as 

    Uint16 hwafft_8pts (
    Int32 *data,
    Int32 *scratch,
    Int32 *duplicate_scratch,
    Int32 *duplicate_data,
    Uint16 fft_flag,
    Uint16 scale_flag
    );

    where  i can pass only the integer value..what if i want both input and output as float..

    if i forcefully do it i couldnt seperate imaginary and real part..if i do so using typecasting the output is completely different..

    plz suggest me what do i do?

  • Hi,

    You are welcome. Sorry for the delay.

    The HWAFFT accelerator cannot work with float. It only uses 16-bit fixed point ranging from -1 to 0.9999.

    You could convert from float to 16-bit int, convert, and then back to float. But the C55xx CPU is not optimized for floating point and it will require several more cycles to perform floating point operations (in software).

    I recommend you stick with fixed point with this processor.

    Hope this helps,
    Mark

  • Thanks Mark...!

    u mean i have to use typecasting only to convert int to float..still i will not get the exact result..then in this case i guess i need to change the processor. :(

  • Sorry.

    What are your requirements? Floating point precision? Low power?
    What is driving the requirement for floating point?

    Maybe you can use a C2000 or a C6000 DSP.

    Both TMS320F2833x and TMS320C2834x Microcontrollers offer native floating point.

    TMS320C6747 and TMS320C6748 are also possibilities - they both support fixed/floating point. C6748 has better power management, and has been used in portable mobile radios.

    Hope this helps,
    Mark
  • thank u Mark for the suggestions!

    my application is test and measurement instrument application where i need to calculate phase angle and frequency of the mixed signals..so what do i do..do i go with the same processor..i have already bought tms320c5505 evm usb stick..to develop the application. and really..i will be very difficult to change the processor but i dont get the desired output i have to do so..right? or is there any other option?

  • Hi Kanchan,

    Why don't you try the DSPLIB FFT routines instead of using the hardware accelerator.
    They will still be fixed point, but offer 32-bit FFT, which might give you enough precision
    If these FFT routines provide you with a working proof of concept, then perhaps you can optimize execution cycles by later switching to the HWAFFT accelerator, which is limited to 16-bit.

    DSPLIB: http://www.ti.com/tool/sprc100
    TMS320C55x DSP Library Programmer’s Reference: www.ti.com/.../spru422j.pdf

    CFFT: Forward Complex FFT
    CFFT32: 32-Bit Forward Complex FFT

    Do you have the DSP processing working in MATLAB or C on a PC? Maybe we can dig into why the fixed-point results from C55x do not match what you are expecting in floating point.

    Hope this helps,
    Mark
  • DSP processing in C language using CCV7.4..results get matches now but if theoretical result is 57.98 then it gives 57

    and my application is to measure tan delta where i have to measure the phase angle and its precision should be of 0.00001 

    so if fft results will be like this i will not able to achieve the desired results.

    are sure by using DSPLIB i can achieve float or exact result.

  • Hi Kanchan,

    I searched and found this helpful website about calculating phase from FFT results:

    https://www.gaussianwaves.com/2015/11/interpreting-fft-results-obtaining-magnitude-and-phase-information/

    Note that thresholding out the bins that are close to zero may be necessary.

    The DSPLIB contains optimized atan functions.

    * ushort atan16 (DATA *x, DATA *r, ushort nx) Arctan of a vector

    * ushort atan2_16 (DATA *q, DATA *i, DATA *r, ushort nx) Four quadrant inverse tangent of a vector

    Why dont you use MATLAB to simulate the FFT and arctan to find the phase, then use its fixed point toolbox to observe the effect of quantization noise (from floating point to fixed point).

    Credit to Mathuranathan:
    - Founder and Author @ gaussianwaves.com which has garnered worldwide readership. He is a masters in communication engineering and has 9 years of technical expertise in channel modeling and has worked in various technologies ranging from read channel design for hard drives, GSM/EDGE/GPRS, OFDM, MIMO, 3GPP PHY layer and DSL. He also specializes in tutoring on various subjects like signal processing, random process, digital communication etc.., LinkedIn Profile