How to trace stack for program flow in MPC5746R

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

How to trace stack for program flow in MPC5746R

625 Views
renjithr
Contributor I

Hi,

I want to trace stack for program flow to store some information as follows

-current program counter value

-last few function calling addresses (eg:. fun3,fun2,fun1 address )

void fun1()

{

fun2();

 

}

void fun2()

{

fun3(); // fault checking inside fun3()

}

void fun3()

{

store_NVM(); // store PC,last few function calling addresses to NVM

reset(); // call reset if fault occured

}

whenever fault happens, I need to store those information in NVM and reset.

 

Please suggest ,is there any SPR available to read such information or any other methods..?

Thanks & Regards,

RR

Labels (1)
0 Kudos
1 Reply

477 Views
martin_kovar
NXP Employee
NXP Employee

Hello,

stack pointer is stored in GPR register R1. So there is no problem to read stack pointer and the whole stack.

If the function causes some issue which triggers exception, you can create exception interrupt handler and according the exception type, there are Save and Restore registers which contains address of the instruction which caused the exception.

Please look at the core reference manual for e200z4 core and read chapter 6 Interrupts and Exceptions. There you will find many usable information.

http://cache.nxp.com/assets/documents/data/en/reference-manuals/e200z4RM.pdf?fsrch=1&sr=1&pageNum=1 

You can also check EABI document which could be very helpful for you.

http://cache.nxp.com/assets/documents/data/en/application-notes/PPCEABI.pdf?fsrch=1&sr=2&pageNum=1 

If you have any other questions, please feel free to write me back.

Best Regards,

Martin

0 Kudos