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.

Accessing Stack Pointer(SP/R13) in C for TM4C123GH6PM.

Other Parts Discussed in Thread: TM4C123GH6PM

Hi,

I need help in accessing core registers in C language. I am working on a code which requires moving the content stored in uint32_t type C variable to SP/R13.

I am using TM4C123GH6PM microcontroller and Code Composer Studio 6.

Thanks,

Nachiket.

  • C uses the stack for passing parameters to and from functions (at least on machines having a stack pointer), and the core uses the stack to save the register context in case of interrupts.  So IMHO you don't actually want to mess with the stack pointer (R13).

    You can try to insert assembler code ("asm") to do this, and watch what happens...

  • Agree with poster f.m.    

    Made the time/effort to dig thru Joseph Yiu's ARM book - he cautions against "C's" usage to examine, "SP/R13!"  

    In fact - Joseph lists special "C" functions to manipulate many of the R0 - R12 Registers - and pointedly avoids any such C function targeting SP/R13.

    ASM appears your best/safest (and only) means to manipulate "SP/R13."   And - even then - proceed with great care...