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.

TM4C1233E6PZ: Stack usage increases by around 1200 bytes on using sprintf function

Part Number: TM4C1233E6PZ

Hello,

I have been facing issue of stack overflow, in the stack usage tab it shows that the stack is used 100% even if my stack size is 4096 bytes. I have also observed that sprintf function is using a lot more stack which eventually hangs my controller or fill garbage value in global variables. I am attaching screenshot link for your reference. Please help me to solve this issue. 

stack usage with sprintf

stack usage without sprintf

  • Hello Shubham,

    sprintf uses a lot of stack, 1200 bytes is within expected range for it. Usually we see programs need to expand stack up to 1500 bytes to use it. To get around that issue, use the usprintf() function which is provided in TivaWare via the ustdlib.c/h files from the utils folder.

    Best Regards,

    Ralph Jacobi