Hello Sandip Ardalkar,
I'm not aware of the macro that you are trying to use. However, I made an example to read the stack pointer on run time with a different approach. The following function returns the value of the stack pointer.
void *GetSP(void)
{
#ifdef __GNUC__
void *sp;
__asm__ __volatile__ ("mov %0, sp" : "=r"(sp));
return sp;
#else
#warning "only for GCC"
return NULL;
#endif
}
To call the function I did the following:
void* (*vfunc)(void);
vfunc = GetSP;
void* StackPointer = vfunc();
uint32_t sp = (uint32_t)StackPointer;
At the end the variable sp will have the value of the stack pointer.
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------