I need a program code for ADSP21489 that fills stack memory with appropriate value before main() execution
Stack and Heap are Run-time storage sections: The compiler uses the run-time stack as the storage area for local variables and returns addresses. During a function call, the calling function pushes the return address onto the stack. During a function call, the calling function pushes the return address onto the stack.
If you define the memory values before the main() execution, it will act as the global variable and it will be stored on a fixed location decided by the compiler.
incase you need to store the values in the stack, you need to define the memory value as a local variable within the programming blocks or subroutines.
Since, we could not understand, why you are trying to declare the stack memory value before the main() execution, could you please share with us more details on this.
For run-time memory usage, the Expert Linker does offer a means to analyze your stack/heap usage. Open your LDF in the Expert Linker, then right-click in the Expert Linker and select "Global Properties". Enable the option "Show stack/heap usage". After running your application, you can zoom in on the Stack/Heap sections in the Expert Linker and view the used/unused space (as illustrated in the help under 'Help: Contents: Graphical Environment: Expert Linker: Overview: Stack/Heap Usage'.
Please refer "Run-Time Stack Storage" and "Run-Time Heap Storage" in below linked compiler manual:
Thanks for the suggested solution. But in my application, the hardware doesn't connect to the VDSP environment via JTAG at runtime, so this solution can't help.
I need my operational program be able to check at runtime that the stack fill level is not reaching some predetermined maximum.
We added support for stack overflow detection capabilities detecting when an application's stack increases beyond its allocated size. This greatly enhances the debugging experience, as it means a pernicious issue can be detected immediately, before data corruption leads to hard-to-resolve second-order effects.
Please refer in VisualDSP++ help for more information about Stack Overflows:
C/C++ Compiler and Library Manual for SHARC® Processors > 2 Achieving Optimal Performance From C/C++ Source Code > Analyzing Your Application > Stack Overflow Detection
For more information about Stack Overflow Detection please refer the following FAQ:
Also, you can find the example project for the "Stack_Overflow_Detection" from the VisualDSP++ installation path:
Installation path:\Analog Devices\VisualDSP 5.1.2\214xx\Examples\No Hardware Required\VDK