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.
Hi,
in the SYS/BIOS file "C:\ti\bios_6_76_02_02\packages\ti\sysbios\family\c28\TaskSupport.c (line 113) the task stack configuration is validated like this:
/*
* The SP register is only 16 bits on 28x. Ensure that the last address
* in the new stack is less than 0xffff
*/
if (((ULong)tsk->stack) + (tsk->stackSize) >= MAX_SP_ADDR) {
Error_raise(eb, TaskSupport_E_invalidStack, tsk->stack, 0);
return (NULL);
In my case this check failed because the stack started at address 0xFF00 with a size of 256. But from my point of view this should be valid because the stack goes from address 0xFF00 to 0xFFFF which is still 16bit and in the internal RAM of the controller.
So from my point of view the correct code should look like:
/*
* The SP register is only 16 bits on 28x. Ensure that the last address
* in the new stack is not bigger than 0xffff
*/
if (((ULong)tsk->stack) + (tsk->stackSize) > (MAX_SP_ADDR + 1U) {
Error_raise(eb, TaskSupport_E_invalidStack, tsk->stack, 0);
return (NULL);
Kind regards,
Matthias
H,
Thanks for reaching out to C2000 e2e Forum. your post has been assigned to a TI employee and you can expect a response in the next 24hours.
Regards
Pramod
Matthias,
I see what you are saying. I want to confirm with the engineers that there isn't some other reason why it is the way it is.
Judah
Matthias,
After we looked further into the question, we believe that the logic is correct as is.
The C28x requires even address stack alignment. So the largest address possible for the stack is actually 0xFFFE.
This is why the logic is checking to make sure we are less than 0xFFFF.
Judah
Hi Judah,
Thank you for your answer. I understand your explanation! But to avoid a situation like I had, I would like to give an other extended suggestion for an improved condition:
/* The SP register is only 16 bits on 28x. Ensure that the last address * in the new stack is less than 0xffff and the stack starts at an even address. */ if ( (0U != (tsk->stack & 0x0001U) || (((ULong)tsk->stack) + (ULong)tsk->stackSize)) > ((ULong)MAX_SP_ADDR + 1UL)) { Error_raise(eb, TaskSupport_E_invalidStack, tsk->stack, 0); return (NULL);
If you don't agree please at least update the description with the explanation you provided me.
Thanks and regards,
Matthias
Matthias,
Sorry for the delayed response. We plan to update the comment to make this clear.
Judah