This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Checking User Stack during runtime

Hello,

i'd like to know how much space I need in the Userstack Area.
I'd cleard the UserStack-Section in start_v2.a66.
In my 'main.c' I'd like to have a function which shows me the Userstack. Therefore I have to know where the UserStack is located.

So how could I get access to ?C_USRSTKBOT & ?C_USRSTKTOP in 'main.c'? (I could look in the Memory Map & type in the numbers by hand, okay. But automaticaly it would be nice)

/Koarl

Parents
  • Why don't you simply make stack top an bottom public in START_V2.a66:

    PUBLIC  stack_top
    PUBLIC  stack_bottom
    
    ?C_USERSTACK    SECTION DATA PUBLIC 'SDATA'
    ?C_USRSTKBOT:
    stack_bottom:
                    DS      USTSZ    ; Size of User Stack
    ?C_USERSTKTOP:
    stack_top:
    ?C_USERSTACK    ENDS
    

    And declare extern where you use them:

    extern unsigned int stack_top;
    extern unsigned int stack_bottom;
    

    Sauli

Reply
  • Why don't you simply make stack top an bottom public in START_V2.a66:

    PUBLIC  stack_top
    PUBLIC  stack_bottom
    
    ?C_USERSTACK    SECTION DATA PUBLIC 'SDATA'
    ?C_USRSTKBOT:
    stack_bottom:
                    DS      USTSZ    ; Size of User Stack
    ?C_USERSTKTOP:
    stack_top:
    ?C_USERSTACK    ENDS
    

    And declare extern where you use them:

    extern unsigned int stack_top;
    extern unsigned int stack_bottom;
    

    Sauli

Children
  • Hello Sauli,
    thank you for the tip it works!

    I'm not so familar with the assembler.

    Only for better understanding the hole thing, do you know why I cant get acces to the '?C_USRSTKBOT' Label? (which is in the original start_V2.a66 'public')

    /Koarl

  • I guess it has something to do with the question mark in the label. You cannot have a question mark in any names in C code. There is a hint somewhere in the Keil application notes that you could use underscore in C code to reference a name containing a question mark, but trying to use _C_USRSTKBOT to access ?C_USRSTKBOT does not work. I am sure that Keil people could explain this if they wanted.

    Sauli