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.

Missing Detail in C5515 HWAFFT Documentation

I've found that the built-in routines for the HWAFFT module on the C5505/C5515 do not return the correct results if the input/output and scratch buffers provided by the caller do not lie in the same data page. Looking at the corresponding assembly code, it becomes apparent why. Between each stage of FFT computation, there are steps like:

; Start 1st double stage
                AR0 = AR4
                AR1 = AR5

; Start second double stage
                AR2 = AR5
                AR3 = AR4

And so on. The two pointers bounce back and forth between the input/output and scratch buffers. However, since the move instruction only references the auxiliary registers and not the extended auxiliary registers (XARn), only the bottom 16 bits are copied. As long as the two buffers are in the same page (so their most-significant 8 bits are the same), then everything works. However, if they are on different pages, data ends up getting fetched from the wrong address and the results are garbage.

Obviously this can't be changed in ROM, but it would probably be a good idea if the HWAFFT documentation specified this requirement.

Jason

  • Sure. We will update the doc.

    Thanks,

    Steve

  •  This hasnot yet been done!!!

  • The FFT assembly routines burned in C5515 ROM seems to support only small memory model!

    In order to use HWAFFT for large/huge memory models and allow allocating HWAFFT buffers in different data pages, I created the following wrapper:

    In a C header file:

    typedef Uint16 (*hwafft_func_t)(Int32 *data,
                                    Int32 *scratch,
                                    Uint16 fft_flag,
                                    Uint16 scale_flag);
    Uint16 hwafft_wrapper(  Int32 *data,
                            Int32 *scratch,
                            Uint16 fft_flag,
                            Uint16 scale_flag,
                            hwafft_func_t fft_func);

    In an ASM source file:

        .sect ".onchip_code"
        .def _hwafft_wrapper

    ; HWAFFT code burned in C5515 ROM seems to support small memory model only.
    ; The following wrapper helps to use HWAFFT for large/huge memory models.
    ; CVN 20110920
    _hwafft_wrapper:
        XAR2 = XAR1
        XAR3 = XAR0
        call AC0
        return

  • Another possible workaround is to disassembly all FFT routines from ROM, replace all occurrences of

    AR2 = AR5

    AR3 = AR4

    by

    XAR2 = XAR5

    XAR3 = XAR4

    and then allocate these modified routines in RAM instead. This workaround would consume 4KB of RAM.

  • Is any change required for the following lines if using huge memory model?

    AR0 = AR4

    AR1 = AR5

     

  • Just a quick note to thank all of you who contributed to this thread, otherwise I wouldn't have found how to get this working because I was working on documentation downloaded a few months ago.

    TI have finally (!!!!) updated the documentation on the HWAFFT to point to a new update to the silicon errata for C5515 and C5505.

    See http://www.ti.com/dsp/docs/litabsmultiplefilelist.tsp?sectionId=3&tabId=409&literatureNumber=sprabb6b&docCategoryId=1&familyId=325

    I can confirm that placing both the data and scratch buffers in the first 64kByte of memory appears to work correctly.

    Antony

  • Some1 please help me out !!

    But, when i am running the code, I am not able to get the FFT computed. As soon as the code reaches the FFT computation part, it just stands still.
    So , I stopped the running to see what is getting executed. The code gets stuck here

    8e49bdeb1110             COPR #16,AC0,dbl(*AR2-),AC1 :: MOV AC1,dbl(*(AR3+T0))
    8e49bdeb1110             COPR #16,AC0,dbl(*AR2-),AC1 :: MOV AC1,dbl(*(AR3+T0))
    8e49bdeb1110             COPR #16,AC0,dbl(*AR2-),AC1 :: MOV AC1,dbl(*(AR3+T0))
    8e49bdeb1110             COPR #16,AC0,dbl(*AR2-),AC1 :: MOV AC1,dbl(*(AR3+T0))

    I am not sure , what exactly these statements does. But all the lines are same !!

    If i step debug this, it loops arround these lines.

    But, If i give a run and stop , it get stuck @

    040009                   BCC #0x3d12c3,AC0 == #0

    and if I give a run again : I get an error message saying I cant do tht !!!!!!

    I am struggling with this issue for the past 2-3 days. It will be a great help, If you can tell me how to solve this.
    I have a breif code structure, which shows how I am computing FFT. Please have a look.

    This is my code
    ==================================================================================================================================
    #include "stdio.h"
    #include "usbstk5515.h"
    #include "usbstk5515_led.h"
    #include "usbstk5515_gpio.h"
    #include "usbstk5515_i2c.h"
    #include "sar.h"
    #include "lcd.h"
    #include "hwafft.h"
    #include "math.h"

    Int32 Input_Signal1024];
    extern Uint16 hwafft_wrapper(  Int32 *data,Int32 *scratch,Uint16 fft_flag,Uint16 scale_flag,hwafft_func_t fft_func);
    Int32* fft(Int32 *data);

    void main( void )
    {
        Int16 result = 0;Int32 *fft_data = 0;
        USBSTK5515_init( );
        Input_Signal =  Aquire_signal_from_ADC_for_10s();
        fft_data = fft( Input_Signal);
        while(1);
    }

    Int32* fft(Int32 *data)
    {
        Int32 *result = 0;
        Int32 *data_br = 0;
        Uint16 out_sel = 0;
        Int32 *scratch=  0;
        hwafft_br(data,data_br,DATA_LEN_1024); // bit reversal
        data = data_br;
        out_sel = hwafft_wrapper(data,scratch,FFT_FLAG,SCALE_FLAG,hwafft_1024pts); // I am using this because, I am using large memory model
        if (out_sel == OUT_SEL_DATA)
        {
            result = data;
        }
        else
        {
            result = scratch;
        }        
        return(result);
    }   
    ===================================================================================================================================
    ===================================================================================================================================

    I have defined the below code in an assembly file. I got this code snippet from TI forum. I was asked to use this since I am using large memory model. It seems
    FFT accelerator supports only small memory model

             .sect ".onchip_code"
             .def _hwafft_wrapper
            ; HWAFFT code burned in C5515 ROM seems to support small memory model only.
            ; The following wrapper helps to use HWAFFT for large/huge memory models.
            ; CVN 20110920
    _hwafft_wrapper:
        XAR2 = XAR1
        XAR3 = XAR0
        call AC0
        return

    I have defined the below code in a C header file.(USBSTK5515.h)

    typedef Uint16 (*hwafft_func_t)(Int32 *data,
                                    Int32 *scratch,
                                    Uint16 fft_flag,
                                    Uint16 scale_flag);
    Uint16 hwafft_wrapper(  Int32 *data,
                            Int32 *scratch,
                            Uint16 fft_flag,
                            Uint16 scale_flag,
                            hwafft_func_t fft_func);


    ===================================================================================================================================
    ===================================================================================================================================

    The following is my .cmd file

    -stack    0x400                /* PRIMARY STACK SIZE    */
    -sysstack 0x400                /* SECONDARY STACK SIZE  */
    -heap     0x400               /* HEAP AREA SIZE        */  
    MEMORY
    {
        MMR     (RW) : origin = 0000000h length = 0000c0h     /* MMRs */
        DARAM_0 (RW)  : origin = 00000c0h length = 001f40h    /* on-chip DARAM 0 */
        DARAM_1 (RW)  : origin = 0002000h length = 002000h    /* on-chip DARAM 1 */
        DARAM_2 (RW)  : origin = 0004000h length = 002000h    /* on-chip DARAM 2 */
        DARAM_3 (RW)  : origin = 0006000h length = 002000h    /* on-chip DARAM 3 */
        DARAM_4 (RW)  : origin = 0008000h length = 002000h    /* on-chip DARAM 4 */
        DARAM_5 (RW)  : origin = 000a000h length = 002000h    /* on-chip DARAM 5 */
        DARAM_6 (RW)  : origin = 000c000h length = 002000h    /* on-chip DARAM 6 */
        DARAM_7 (RW)  : origin = 000e000h length = 002000h    /* on-chip DARAM 7 */
        SARAM   (RW) : origin = 0010000h length = 040000h    /* on-chip SARAM */
        SAROM_0 (RX)  : origin = 0fe0000h length = 008000h     /* on-chip ROM 0 */
        SAROM_1 (RX)  : origin = 0fe8000h length = 008000h     /* on-chip ROM 1 */
        SAROM_2 (RX)  : origin = 0ff0000h length = 008000h     /* on-chip ROM 2 */
        SAROM_3 (RX)  : origin = 0ff8000h length = 007f00h     /* on-chip ROM 3 */
        VECS    (RX)  : origin = 0ffff00h length = 000100h    /* on-chip ROM vectors */
        EMIF_CS0 (RW) : origin = 0050000h  length = 07B0000h    /* mSDR */
        EMIF_CS2 (RW) : origin = 0800000h  length = 0400000h    /* ASYNC1 : NAND */
        EMIF_CS3 (RW) : origin = 0C00000h  length = 0200000h    /* ASYNC2 : NAND  */
        EMIF_CS4 (RW) : origin = 0E00000h  length = 0100000h    /* ASYNC3 : NOR */
        EMIF_CS5 (RW) : origin = 0F00000h  length = 00E0000h    /* ASYNC4 : SRAM */
    }
    SECTIONS
    {
        vectors (NOLOAD)
        .intvec                         : > DARAM_0        ALIGN = 256
        .bss                             : > SARAM         /*, fill = 0 */
        .stack                           : > DARAM_1     ALIGN = 1024
        .sysstack                    : > DARAM_1     ALIGN = 1024
        .heap                          : > DARAM_1        ALIGN = 1024
        .text                              : > SARAM          ALIGN = 1024
        .onchip_code            : > SARAM
         .cinit                            : > DARAM_2
        .cio                                : > DARAM_2
        .const                            : > DARAM_2
        
    // The Bit-Reverse destination buffer data_br_buf requires an address with
    // at least 4+log2(FFT_LENGTH) least significant binary zeros

        data_br_buf          : > DARAM_1        ALIGN = 1024
        scratch_buf           : > DARAM_1        ALIGN = 1024
        convolved_buf       : > DARAM_2
        coeffs_fft_buf         : >    DARAM_2

        RcvL1            : > DARAM_3    
        RcvL2            : > DARAM_3    
        RcvR1            : > DARAM_4    
        RcvR2            : > DARAM_4    

        FilterOut    : > DARAM_5    
        OverlapL    : > DARAM_5    
        OverlapR    : > DARAM_5    

        XmitL1        : > DARAM_6    
        XmitL2        : > DARAM_6    
        XmitR1        : > DARAM_7    
        XmitR2        : > DARAM_7    

        RcvL1_copy    : > SARAM    
        RcvL2_copy    : > SARAM    
        RcvR1_copy    : > SARAM    
        RcvR2_copy    : > SARAM    

        .emif_cs0   : > EMIF_CS0
        .emif_cs2   : > EMIF_CS2
        .emif_cs3   : > EMIF_CS3
        .emif_cs4   : > EMIF_CS4
        .emif_cs5   : > EMIF_CS5
    }

    ===================================================================================================================================
    ===================================================================================================================================

    Following is my console output:


    **** Build of configuration Debug for project first_Project ****

    E:\TI\ccsv4\utils\gmake\gmake -k all
    'Building file: ../csl_irqplug.asm'
    'Invoking: Compiler'
    "E:/TI/ccsv4/tools/compiler/c5500/bin/cl55" -vcpu:3.3 -g --include_path="E:/TI/xdais_6_25_01_08/packages/ti/xdais" --include_path="E:/C5505/CD/C5505/Chapter 1/Application 1 Getting Started" --include_path="E:/TI/ccsv4/emulation/boards/usbstk5515_v1/include" --include_path="E:/TI/ccsv4/tools/compiler/c5500/include" --include_path="E:/TI/bios_5_41_02_14" --include_path="E:/TI/bios_6_21_00_13" --include_path="E:/C5505/CSL/build" --include_path="E:/C5505/CSL/inc" --include_path="E:/C5505/CSL/src" --diag_warning=225 --ptrdiff_size=32 --algebraic --memory_model=large --asm_source=algebraic --preproc_with_compile --preproc_dependency="csl_irqplug.pp"  "../csl_irqplug.asm"
    'Finished building: ../csl_irqplug.asm'
    ' '
    'Building file: ../main.c'
    'Invoking: Compiler'
    "E:/TI/ccsv4/tools/compiler/c5500/bin/cl55" -vcpu:3.3 -g --include_path="E:/TI/xdais_6_25_01_08/packages/ti/xdais" --include_path="E:/C5505/CD/C5505/Chapter 1/Application 1 Getting Started" --include_path="E:/TI/ccsv4/emulation/boards/usbstk5515_v1/include" --include_path="E:/TI/ccsv4/tools/compiler/c5500/include" --include_path="E:/TI/bios_5_41_02_14" --include_path="E:/TI/bios_6_21_00_13" --include_path="E:/C5505/CSL/build" --include_path="E:/C5505/CSL/inc" --include_path="E:/C5505/CSL/src" --diag_warning=225 --ptrdiff_size=32 --algebraic --memory_model=large --asm_source=algebraic --preproc_with_compile --preproc_dependency="main.pp"  "../main.c"
    "E:\TI\ccsv4\emulation\boards\usbstk5515_v1\include\usbstk5515.h", line 144: warning: typedef name has already been declared (with same type)
    "E:\TI\ccsv4\emulation\boards\usbstk5515_v1\include\usbstk5515.h", line 144: warning: typedef name has already been declared (with same type)
    "E:\TI\ccsv4\emulation\boards\usbstk5515_v1\include\usbstk5515.h", line 144: warning: typedef name has already been declared (with same type)
    "E:/TI/ccsv4/emulation/boards/usbstk5515_v1/include/usbstk5515.h", line 144: warning: typedef name has already been declared (with same type)
    "../main.c", line 33: warning: integer conversion resulted in a change of sign
    "../main.c", line 34: warning: integer conversion resulted in a change of sign
    "../main.c", line 341: warning: last line of file ends without a newline
    'Finished building: ../main.c'
    ' '
    'Building file: ../sample_code.c'
    'Invoking: Compiler'
    "E:/TI/ccsv4/tools/compiler/c5500/bin/cl55" -vcpu:3.3 -g --include_path="E:/TI/xdais_6_25_01_08/packages/ti/xdais" --include_path="E:/C5505/CD/C5505/Chapter 1/Application 1 Getting Started" --include_path="E:/TI/ccsv4/emulation/boards/usbstk5515_v1/include" --include_path="E:/TI/ccsv4/tools/compiler/c5500/include" --include_path="E:/TI/bios_5_41_02_14" --include_path="E:/TI/bios_6_21_00_13" --include_path="E:/C5505/CSL/build" --include_path="E:/C5505/CSL/inc" --include_path="E:/C5505/CSL/src" --diag_warning=225 --ptrdiff_size=32 --algebraic --memory_model=large --asm_source=algebraic --preproc_with_compile --preproc_dependency="sample_code.pp"  "../sample_code.c"
    At end of source: warning: a translation unit must contain at least one declaration
    'Finished building: ../sample_code.c'
    ' '
    'Building file: ../vectors.asm'
    'Invoking: Compiler'
    "E:/TI/ccsv4/tools/compiler/c5500/bin/cl55" -vcpu:3.3 -g --include_path="E:/TI/xdais_6_25_01_08/packages/ti/xdais" --include_path="E:/C5505/CD/C5505/Chapter 1/Application 1 Getting Started" --include_path="E:/TI/ccsv4/emulation/boards/usbstk5515_v1/include" --include_path="E:/TI/ccsv4/tools/compiler/c5500/include" --include_path="E:/TI/bios_5_41_02_14" --include_path="E:/TI/bios_6_21_00_13" --include_path="E:/C5505/CSL/build" --include_path="E:/C5505/CSL/inc" --include_path="E:/C5505/CSL/src" --diag_warning=225 --ptrdiff_size=32 --algebraic --memory_model=large --asm_source=algebraic --preproc_with_compile --preproc_dependency="vectors.pp"  "../vectors.asm"
    'Finished building: ../vectors.asm'
    ' '
    'Building target: first_Project.out'
    'Invoking: Linker'
    "E:/TI/ccsv4/tools/compiler/c5500/bin/cl55" -vcpu:3.3 -g --diag_warning=225 --ptrdiff_size=32 --algebraic --memory_model=large --asm_source=algebraic -z -m"first_Project.map" --warn_sections -i"E:/TI/ccsv4/tools/compiler/c5500/lib" -i"E:/C5505/CSL/first_Project/../../lib" -i"E:/TI/ccsv4/tools/compiler/c5500/include" --reread_libs --rom_model -o "first_Project.out"  "./vectors.obj" "./sample_code.obj" "./main.obj" "./csl_irqplug.obj" -l"E:\TI\ccsv4\tools\compiler\c5500\lib\rts55x.lib" -l"E:\C5505\CD\C5505\Chapter 1\Application 1 Getting Started\55xdsph.lib" -l"E:\C5505\CSL\build\cslVC5505.lib" -l"E:\TI\ccsv4\tools\compiler\c5500\lib\lib\usbstk5515bsl.lib" "../C5515.cmd"
    <Linking>
    'Finished building target: first_Project.out'
    ' '
    Build complete for project first_Project

  • Anand,

    Sounds like you are probably not initialising the device clocks correctly - I suggest you search on this site or take a look at the processor's wiki page for further details of the small number of instructions you need to drop into the start of main() to set it up.

    Antony