Other Parts Discussed in Thread: CONTROLSUITE
Is there an assembly code snippet I can add to CodeStartBranch.asm to fill my stack space with a pattern?
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.
Other Parts Discussed in Thread: CONTROLSUITE
Is there an assembly code snippet I can add to CodeStartBranch.asm to fill my stack space with a pattern?
Hi Jim,
Right now we do not have an assembly code snipet to do this in controlSUITE. However, there is a few ways to fill the stack space with a specific pattern. First, you can write a for loop in assembly to fill the stack with a specific value.
Or you can use the linker command file to do this for you. Check out the C28x Assembly Language Tools and User Guide. http://www.ti.com/lit/ug/spru513h/spru513h.pdf
Best Regards,
sal
The following C-code should do what you want:
#define STACK_PATTERN (0xAAAAu)
static uint16_t *globalIterator;
/**
* @brief Stack intialization
*/
void stackInit(void)
{
uint16_t topOfStack;
globalIterator = &topOfStack;
while(globalIterator < &vStackEnd)
{
*globalIterator = STACK_PATTERN;
globalIterator++;
}
}
The trick is, that globalIterator is initialized by the address of topOfStack variable, thus this variable cannot be assigned to a register (register has no address) and must be allocated on the top of the stack. Then simply fill the rest of the stack by predefined pattern. The vStackEnd is a symbol defined by linker - the address of this symbol is equal to the last address of the stack (see the RUN_END operator in SPRU513h, paragraph 8.5.10.6).