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
Have a look at this knowledgebase article:
http://www.keil.com/support/docs/1164.htm
It could be relevant to your problem. In particular, application note 138 discusses how to get section start address and length in C code. Not sure it will work in your case, but it's worth a try.
Regards, - mike
Hello Mike, thanks for your reply. With this method it didn't work for me. In this app note they define (extern) variables which are evaluated by the linker. (Thats the way I see it)
But I need the adress of a Data Section, which is defined in the startup-File.
Is there a explanation (I didn't find one), how to access Labels(Section), which are defined in a .a66-File, in a .c-File?
Regards, Koarl
I knew I saw it somewhere:
http://www.keil.com/appnotes/docs/apnt_142.asp
- mike
Thanks for the hint with the app.-note.
Unfortunately, it only works with sections in NCONST or NCODE! If i'd like to get access to a section in NDATA (like ?C_USERSTACK) I get an Linker-Error (ERR 127: Unresolved external symbol)
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
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')
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.