Stack Overflow Failure Recovery of S32K3XX

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Stack Overflow Failure Recovery of S32K3XX

Jump to solution
523 Views
raj12
Contributor III

Hello,

I am injecting the stack overflow error of S32K3XX MCU, and after successfully injection of error DebugMon_Handler exception triggering.

I have a query Related to recovering methods. during testing observed only After power on reset MCU is able to recover from Stack Overflow exception.

Please let me know is there any other methods of recovery.
Thanks

Tags (2)
0 Kudos
Reply
1 Solution
497 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @raj12,

Any reset can recover it.

The SP is set during the startup process.

Use the Power_Ip RTD driver to trigger a SW reset from the exception handler.

 

Regards,

Daniel

View solution in original post

0 Kudos
Reply
3 Replies
498 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @raj12,

Any reset can recover it.

The SP is set during the startup process.

Use the Power_Ip RTD driver to trigger a SW reset from the exception handler.

 

Regards,

Daniel

0 Kudos
Reply
456 Views
raj12
Contributor III
Hello @danielmartynek,

Thanks for your reply.

Now, I am now able to recover from stack overflow error after doing the functional reset.

Below is the pseudo code which currently, I am using for injection of stack overflow.

*DEMCR_reg = (1 << 24) | (1 << 16);
/* Get implemented values for num of comparators in DWT registers*/
numcomp = (DWT->CTRL & (0xF << 28)) >> 28;

DWT->NUMCOMP[0].COMP = (uint32_t)stackPointer - (1016 * sizeof(uint32_t));
DWT->NUMCOMP[0].MASK = 0;
DWT->NUMCOMP[0].FUNCTION = 0x7;
DWT->NUMCOMP[0].FUNCTION &= ~((1 << | /* Perform address comparison */
(1 << 7));
for (counter = 0, reg0 = 0; counter < 1016; counter++, reg0++)
{
__asm("PUSH {r0}");
}

Can you please let me know the other method to inject the stack over flow error.

because, I not want to use below variable there is some limitation on GHS compiler not allowing me to save the stack pointer (__asm("SP")) in register type variable.

register uint32_t* stackPointer __asm("sp");

Please let me know the other method for injecting the stack overflow/underflow error error it will be helpful for my development.

Thanks
0 Kudos
Reply
449 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @raj12,

Call a recursive function (that calls itself) or create a large local variable.

 

Regards,

Daniel

0 Kudos
Reply