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.

28335 How to make Fast Array Operations and "memset" Problem

#include "string.h"

We have some arrays in our code like

float arr[200] = {};   //an array declaration

void PI (){    //a function here 

//some codes here

if (a==0){

// I want to fill arr[200] with zeros here. 

}

}

I used this:

memset(arr, 0, 200*sizeof(float));

but debug freezes. Anyone can help??

  • What runtime support library are you using?
  • The map file is created by the linker with the option --map_file=filename (or -m for short).  In a Code Composer Studio project, it is usually found in the Debug directory of the project (or whatever the current build configuration is named).  Inspect the map file and search for the symbol arr.  You will see the memory location for it.  Verify that it is located where you expect it, and this memory supports read and write access.

    Thanks and regards,

    -George

  • Thank you for your response. I am using rts2800_fpu32.lib.

    In the map file here is my array:

    GLOBAL DATA SYMBOLS: SORTED BY DATA PAGE

    address data page name
    -------- ---------------- ----

    0000c680 31a (0000c680) _arr


    The code was not working because it didn't fit into the RAM. I opened a new project and I managed to run the code but it is way too slow.

    I measured 32us with memset, 28us with a for cycle and...

    I tried to zero out manually: arr[0]=0;, arr[1]=0; ...... arr[199] = 0; ->It is 5us!

    If I use Fast RTS library, do memset and memcopy work faster?

    Is there any other option?
  • Hello Emre,

    Did you initialize the CPU Clock, ie. SysCtrlRegs.PLLSTS.bit.DIVSEL and and other clock registers? I am assuming you did, but it doesn't hurt to ask.

    Stephen
  • Emre Bahtiyar said:
    If I use Fast RTS library, do memset and memcopy work faster?

    I'm not familiar with the rts2800_fpu32_fast_supplement.lib library.  But I'm pretty sure it does not implement the functions memset or memcpy.  If that is correct, then it won't make any difference.

    I suspect you are experiencing issues because of how you have configured the system, or how you have allocated code and data to memory, or something like that.  System issues like that are not something we compiler experts know much about.  I recommend you start a new thread in the C2000 device forum.  Or, if you prefer, I can move this thread to that forum.

    Thanks and regards,

    -George