Skip to main content
Carter Lee
Associate III
February 23, 2018
Question

How to get initial MSP and PC values?

  • February 23, 2018
  • 3 replies
  • 2127 views
Posted on February 23, 2018 at 14:29

Hi.

I'm trying to get the MSP and PC values in the example of STM32F4 firmware.

How can I do to get the Main stack pointer and Program counter value?

I came across the below snippet code from 

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.kui0097a/armcc_cihccdja.htm

 

int f(int x)

{

int r0;

__asm

{

ADD r0, x, 1

EOR x, r0, x

}

return x;

}

but I can't see the that function whether work as well or not, because break point doesn't work in uVision.

Would you please let me know how to do to get the  MSP and PC value ?

Also how do set the breakpoint into the f function? in my case when I set the breakpoint by using F9 function key, that break point doesn't work.

    This topic has been closed for replies.

    3 replies

    Tesla DeLorean
    Guru
    February 23, 2018
    Posted on February 23, 2018 at 14:53

    extern int32_t __Vectors[];

    printf('MSP:%08X PC:%08X\n',__Vectors[0],

    __Vectors[1]);

    You could try to break-point the call to f() and step-into it

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Carter Lee
    Associate III
    February 23, 2018
    Posted on February 23, 2018 at 15:36

    In my case,  I can't step into f(). Break point disabled in that moment. 

    Have you tried this?  Not sure, I don't know the reason if why that break point is disabled when I debug mode.

    Tesla DeLorean
    Guru
    February 23, 2018
    Posted on February 23, 2018 at 16:03

    Look at a disassembly of the code actually generated by the compiler. In the C source view there may be granularity issues, or where it in-lines at the calling address rather than emit a function.

    Break-point or step in the 'Disassembly View', or use run to cursor type execution.

    >>

    Have you tried this?

    I've done this stuff for a long time, and I'm situationally adaptive. Perhaps you work with someone who is similarly adept?

    I really don't understand the purpose/goal of what you're attempting to do. Design Validation?

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..