Skip to main content
Visitor II
November 16, 2005
Question

Problem with STACKTOP in .prm file

  • November 16, 2005
  • 4 replies
  • 938 views
Posted on November 16, 2005 at 06:29

Problem with STACKTOP in .prm file

    This topic has been closed for replies.

    4 replies

    alfonso2Author
    Visitor II
    November 15, 2005
    Posted on November 15, 2005 at 07:50

    Excuse me, but i don't understand why appears this error..

    L1206: .stack overlaps with a segment which appear in the PLACEMENT block

    in linker messages help for this error is writting this ''The stack is defined trough the command STACKTOP, and the specified initial value is inside of a segment, which is used in the PLACEMENT block. This is not allowed, because the stack may overlap with some allocated objects''.

    But in CST7 help there's an example for the stacktop command that is in opposition with the linker error........:

    ''When the stack is defined trough a STACKTOP command associated with the placement of the .stack section, the stack is supposed to start at the specified address, and is defined down to the start address of the segment, where .stack has been placed.

    Example

    SEGMENTS

    MY_STK = NO_INIT 0xB00 TO 0xBFF;

    MY_RAM = READ_WRITE 0xA00 TO 0xAFF;

    MY_ROM = READ_ONLY 0x800 TO 0x9FF;

    END

    PLACEMENT

    DEFAULT_ROM INTO MY_ROM;

    DEFAULT_RAM INTO MY_RAM;

    SSTACK INTO MY_STK;

    END

    STACKTOP 0xB7E

    In the previous example, the stack pointer will be defined from address 0xB7E down to address 0xB00''.

    Now, my .prm file is this:

    /* MEMORY LOCATION SETTING ***************************************************/

    /* STACK INITIALIZATION ******************************************************/

    STACKTOP 0x1FF

    SEGMENTS

    BITS_RAM = READ_WRITE 0x0050 TO 0x00FF;

    MY_STACK = NO_INIT 0x0100 TO 0x01FF;

    BYTE_RAM = READ_WRITE 0x0200 TO 0x044F;

    USER_ROM = READ_ONLY 0x8000 TO 0xFFDF;

    END

    PLACEMENT

    STACK_SEG INTO MY_STACK;

    then the STACK overlaps the STACK_SEG....,but for the CST7 help this is an exactly instruction ,but for the linker is an error L1206.

    What's the error?what i can do for resolving this problem?

    I need of the stack and of the stack_seg....

    But is possible don't initialize the stack in .prm without error in stack assembly operations?If i comments the STACKTOP command is an error?

    Thanks for who help me... :-[

    [ This message was edited by: liotro78 on 15-11-2005 12:23 ]

    Visitor II
    November 15, 2005
    Posted on November 15, 2005 at 12:22

    Hi Liotro78,

    I think you can not change the stackpointer out of the defined range only by redefining the top of the stack. In an example which I have tested with the ST7VD (simulator) the stackpointer is unchanged when I only set the STACKTOP in the .prm-file.

    The hard wired top of the stack is usually 0x1FF. That's the address where the stackpointer will be set to with the command RSP. I'am even not shure, if the SP works out of the range of 0x100 to 0x1FF.

    By the way: This problem with the stackpointer is not new. You'll find a statement of the ''Moderator Setler'' at the end of the discussion

    Zero page - problem compile with Metrowerks

    Regards

    WoRo

    alfonso2Author
    Visitor II
    November 15, 2005
    Posted on November 15, 2005 at 13:14

    Excuse me woro,

    but if i have an ''out of allocation space in ZRAM segment'' i can increase the ZRAM memory over the 0FFh address? i can overlap a part of the stack address?

    ex.

    ZRAM = READ_WRITE 0x0050 TO 0x015F

    MY_STACK = NO_INIT 0x0160 TO 0x01FF

    i can do it???

    Visitor II
    November 16, 2005
    Posted on November 16, 2005 at 06:29

    Liotro78,

    you must not expand the ZRAM to an area above 0xFF. All the variables in the area of the ZRAM (0x00 ... 0xFF) you can address with the short addressing mode. That means you can use some commands with less programming code and less execution time (have a look at the

    http://mcu.st.com/files/mcu/4020.pdf

    To use the area up from 0x100 you should define a new SECTION in your .prm-file e.g. MY_RAM2 = READ_WRITE 0x100 TO 0x15F;.

    For further good information see the diskussion

    Zero page - problem compile with Metrowerks

    of this forum.

    In my opinion the STACKTOP feature of the compiler is dispensable and a relict from the motorola's past of Metrowerks. I really can't see any need to use it with a ST7 µC!!

    Regards

    WoRo