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.

F28335 Array of pointers to arrays makes the DSP go crazy

Dear all,

Im recently having a problem which i will explain to see if you can help me to find the reason why, and a possible solution. 

I have a number of different arrays of integers (int16) with different lengths. I want to make an array of pointers which points to each one of the previously mentioned arrays, however, this list is relatively big. I have 532 arrays, so I would need an array of 532 pointers. This is fine. The problem comes when I compile and execute the program on the DSP, since it goes ´crazy´. And with crazy I mean that I have a firmware that works, but when I include this code (only the definition of the array of pointers), the firmware just does not work as it should. 

Other information that might be useful:  Im storing the initialization values in the section FLASHB of the flash, and according to the .map file, there is still enough room in the flash sector for that array of pointers.

Here an example of my code:

int16 array1[3] = {0,0, 10000};
int16 array2[10] = {9, -1, 0, 1, 2, 3, 4, 5, 2000, 4000};
int16 array3[3] = {0,10, 30000};
int16 array4[5] = {0,10, 10000,2,5};
int16 array5[1] = {-1};

...

int16  *  list_of_arrays[532] = {

array1,
array2,
array3,
array4,
array5,

...

array532

};

Also, additional information. If I do this with, lets say, 100 vectors, everything goes fine. If I do it with 200, everything works fine, but if I do it with 400 or 500, for example, it already starts failing. It seems like there is some memory allocation error or something, bit i couldnt find out.

If someone could let me know the reason of the problem, how to debug it and/or how to fix it, I would appreciate it very much.

Thank you and best regards.

  • Jorge,

    One possibility is the watchdog timer is timing out before the variables have been initialized.  It looks like you have a lot of initialized data, all of which has to be copied from flash into RAM before the program starts.  This is done by the run-time support library functions when you power up the device, just prior calling main().  If the watchdog is active during this period it's possible it may timeout and reset the device, so you never actually reach main().

    If you're using the header files, you should have a file in your project called "DSP2833x_CodeStartBranch.asm".  If so, check in there to see if the watchdog is being disabled prior to the branch to _c_int00.  You should have:

    WD_DISABLE .set 1 ;set to 1 to disable WD, else set to 0

    I'm not certain this is the problem, but it fits with it being dependent on the size of the initialized data.

    Regards,

    Richard

  • Hell Richard,

    First of all, thank you for your time and effort.

    I followed your suggestion and checked that, however, im already disabling the watchdog with the line that you mentioned above, so it does not seem ti be that problem.

    Also, the DSP is not completely frozen. I can actually communicate with the DSP via Modbus in my main loop. Another hint: im using the flash storage API provided by TI, however, when using this big initializers and trying to write to the flash, the API returns an error.

    Thank you again and best regards,
    Jorge.

  • Jorge,

    please try these:
    1) Be sure that optimization is off, and debugging is enabled (full symbolic debug) in project options, so that you can be sure that you are debugging actual code inside the microcontroller.
    2) Try disabling all interrupts. Maybe an wrongly initialized interrupt is the cause of going crazy.
    3) Try to run the same code, but decrease the array size. For example decrease the array of 512 integer to 10 integers. If this works (if the microcontroller continues to execute code correctly in debug window) then the problem is in memory management. If you declare these arrays in a function, then increase the stack size in project options. You may also need to increase stack size in .cmd file. If these arrays are global, check the ebss size in cmd file. You can have a look at link below. It will give you more information about memory sections.

    http://processors.wiki.ti.com/index.php/C28x_Compiler_-_Understanding_Linking

    I hope these will help.
    Hakan

  • Hello Kadir,

    Thank you very much for your answer. It was very helpful, specially the link that you gave me. 

    After reading tat wiki page and checking a bit in my code i think I understand why it was not working. I will explain:

    I was defining the array of pointers as a global, so it was being stored in .ebss, however, the memory block where that section was being stored was runing out of space and I assume that was the reason why everything started to fail for bigger sizes of the array. After some changes in the .cmd file and redistributing the code sections, i managed to fit the array.

    However, there is still something that concerns me: I have some arrays of integers (int16) defined as constants (for example: const int16 array1[10];), that are saved in the .econst section, however, my array of pointer is also defined as const (const int16 * array_of_pointers), and it is still saved in the .ebss section if i look at the .map file. Why is that happening?

    Again, thank you very much for your help and best regards.

    Jorge.

  • Ok, i just realised that my array of pointers was still being saved in .ebss because i defined as an array of pointers to constant integers, but not as an array of CONSTANT pointers to CONSTANT integers.

    Everything is fixed then. Thanks a lot!!!!