Hello Experts,
How to create the memory dynamically in the DSP ?
Thank you,
Raju
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.
Hello Experts,
How to create the memory dynamically in the DSP ?
Thank you,
Raju
Hi ToddMullanix,
Bios version is 5_41_00_06.
Yeah i want to create a heap dynamically.
Thank you,
Raju.
Hi Raju,
The API is MEM_define(). There is a good description of this function in the DSP/BIOS API Reference Guide. Basically it is the following where the segid can be passed into MEM_alloc/MEM_free. Note, you have to provide the memory with the base parameter.
segid = MEM_define(base, length, attrs);
Parameters
Ptr base; /* base address of new segment */
Uns length; /* length (in MADUs) of new segment */
MEM_Attrs *attrs; /* segment attributes */
Return Value
Int segid; /* ID of new segment */
Todd
The heap size(s) are specified at build time and then one can allocate memory from the heap(s) at run-time. This article gives instructions on how to do so:
http://processors.wiki.ti.com/index.php/Creating_Dynamic_Objects_and_Threads_in_BIOS
Hello experts,
i am using linux os. In linux the code composer studio is not installed. how to allocate the heap memory can you explain me.
Thank you,
Raju
Raju,
The memory you give to MEM_define can either be static memory (e.g. global Char array) or memory allocated from another heap.
For example
Char bigBuffer[4096];
main()
{
int segid;
...
segid = MEM_define(bigBuffer, 4096, NULL);
or
main()
{
int segid;
Char *bigBuffer;
...
bigBuffer = MEM_alloc(0, 4096, 0); // segid 0 is the default heap
segid = MEM_define(bigBuffer , 4096, NULL);
As Brad noted, you can also create a heap statically via the configuration file.
You might want to try to build some of the BIOS examples and play with them to get a better feel for DSP/BIOS.
Todd
Hi,
I tried the global array approach as follows but could not get it work.
I use linux (no CCS) and dsp/bios bridge, the DSP source code is in a file containing 3 functions required by DSP/BIOS bridge, i.e., x_y_create(), x_y_delete(), and x_y_excute().
The file looks like:
#include ...
#define ...
Char bigBuffer[4096];
Int segid;
x_y_create()
{ segid = MEM_define(bigBuffer, 4096, NULL); ...}
...
The program can be compiled and run if I comment off the statement of segid = MEM_define(bigBuffer, 4096, NULL), but after including this statement, the program encounters run time error during dsp node creation.
Could Todd or other experts give any hints? Thanks!
Jia
Hi Jia,
What is the return from MEM_define? -1 denotes an error.
Do you have dynamic memory heaps enabled (look in the System->MEM->Properties)?
Todd