AnsweredAssumed Answered

About the stack configuration in MPC574xP

Question asked by Jerry Lee on Jan 24, 2018
Latest reply on Jan 31, 2018 by Jerry Lee

I have read the example in S32DS including  57xx_flash.ld & startup.S.


At the beginning of  '57xx_flash.ld":

/* define heap and stack size */
__HEAP_SIZE = 0 ;
__STACK_SIZE = 4096 ;



At the end of "startup.S" is the "Configure Stack":

;#****************************** Configure Stack ******************************/
e_lis r1, __SP_INIT@h ;# Initialize stack pointer r1 to
e_or2i r1, __SP_INIT@l ;# value in linker command file.

e_lis r13, _SDA_BASE_@h ;# Initialize r13 to sdata base
e_or2i r13, _SDA_BASE_@l ;# (provided by linker).

e_lis r2, _SDA2_BASE_@h ;# Initialize r2 to sdata2 base
e_or2i r2, _SDA2_BASE_@l ;# (provided by linker).

e_stwu r0,-64(r1) ;# Terminate stack.


And my questions are:


1)  what is the stack use for? what is the heap use for?  And why the HEAP SIZE is defined to zero?

2) I have seen __SP_INIT defined in the link file, but I have not seen any _SDA_BASE_ or _SDA2_BASE_ definition, other than the extern define in "startup.S", and I search the project , there is no definition for _SDA_BASE_ or _SDA2_BASE_.

 So why the compiler or linker  tell any error when I build the project? And the program works well.

3) what is the meaning of the "Configure Stack" in "startup.S"?  Is r1 used for stack pointer when the program running?

    And what r2 & r13 use for ?  and what about r0?



Thanks a lot