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 using calloc in V4

I'm having Issues with calloc in CCSv4


Im running an FFT program that used to work ok in V3.1

 

it uses three dynamic arrays that are delcared as pointers


float *input;
float *intermediate;
float *output;


these are then intialized using calloc:

    input        = (float *) calloc(BUFLEN, sizeof(float)); /* Input array */
    output       = (float *) calloc(BUFLEN, sizeof(float)); /* Output array */
    intermediate = (float *) calloc(BUFLEN, sizeof(float)); /* Array for processing*

an FFT is performed on intermediate the result is then IFFT and placed back in intermediate.
input and output are for the input and output time domain signals respectivley.

The data is swapped around the arrays using  pointer swapping thus:


 /* rotate data arrays */
 p = input;
 input = output;
 output = intermediate;
 intermediate = p;

this no longer works in V4. The project compiles but I get no sound.

 

Can anyone help me?

regards
Danny

  • Danny,

    What target device is this running on? Since the compiler versions have changed from CCS 3.1 to CCS4, the code generated could be quite different between the 2 versions, so you may need to debug further to isolate why the program is not working as expected. As a first step, you may want to try increasing your heap size in the project build properties.

    As an intermediate step, you could try loading the program built in CCS 3.1 (if you still have access to it), on to CCS v4. Just connect to the target with CCS4, and then load the old .out file. That should confirm if the old .out file loads and runs properly on CCS v4. Then check the versions of compiler used for both builds and try to isolate the issue and debug the differences from there.

  • Thanks for  the quick reply!

    Its a DSK6713 from spectrum digital. (I run an undergraduate lab using over 200 of them!) 

    I have tried various heap sizes for example 0x400 was one such value. I have tried the project using statically declared arrays and it works.

    I have to get this working before term starts as the students will be using the DSK6713's.

    regards

    Danny

     

     

     

     

  • Did you try increasing the heap to over 0x400? Depending on the application and amount of dynamic memory allocation (calls to things like printf also use heap) you may need a larger heap.

    To help debug this further, you could use a different (earlier) version of the compiler with CCS4. Please take a look at http://processors.wiki.ti.com/index.php/Compiler_Installation_and_Selection for how to install and select a different version of compiler tools for use with CCS4.

  • I think I have solved the problem, and your advice definitely pointed me in the right direction


    I had tried various heap sizes (by using project/properties/tool settings, c6000 linker basic options) up to
    0x3000 and nothing worked.

    Then I decided to have a look at the DSPBIOS config tool.

    I opened the TCF file, navigated to  system/MEM right clicked and hit properties

    unchecked the No dynamic Memory Heaps check.
    right clicked IRAM properties and checked create a heap in this memory left it at the default 0x00008000
    did the same in SDRAM.

    Back in Mem properties...

    set the segment for DSP/BIOS objects as IRAM
    and segment for Malloc/free() IRAM


    the code now works.


    My questions now are:

    Have I set it up ok?
    Does the setting in project/properties have to match the settings in the DSPBIOS config tool?
    Why is it set in two places?
    Are their any other things I should be aware of? (for example whats the max heap I can create?)

    regards
    Danny


     

     

  • Danny,

    The way you have set up the heap is correct for DSP/BIOS projects. The linker heap setting is for projects that do not use DSP/BIOS. I should've checked that with you to begin with, but you are now on the right track. As a reference this wiki article explains how to set up heap for BIOS, which is the same as what you have already done: http://processors.wiki.ti.com/index.php/Tips_for_using_printf#Heap_Size

    As far as the max heap, it is limited only by the amount of memory available, however you may not want to use up memory by allocating too much heap if it is not required. Take a look at this thread for tips on finding out how much heap is being used by your application: http://e2e.ti.com/support/embedded/f/355/p/49607/204679.aspx#204679.
    Based on that you can customize your heap size to an optimal value.