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

Stack initialization with constant

Doe Keil IDE support initializing stack space with a constant? For example with a #define. If not, please does someone have ARM Cortex M3/M4 assembler code to do that and where should it be located? For example in startup*.s prior to the branch to main?

Parents
  • Hi John,

    Why modify the scatter file?
    It's not easy to put the code in the stack initalisation?
    The ram is initialized before.

    __user_initial_stackheap
    
                     LDR     R0, =Stack_Mem            ; Test stack
                     LDR     R1, =Stack_Size           ;
                     LDR     R2, =0xCCCCCCCC           ;
    Fill             STR     R2, [R0], #4              ;
                     SUBS    R1,#4                     ;
                     BNE     Fill                      ;
    
    
                    LDR     R0, =  Heap_Mem
                    LDR     R1, =(Stack_Mem + Stack_Size)
                    LDR     R2, = (Heap_Mem +  Heap_Size)
                    LDR     R3, = Stack_Mem
                    BX      LR
    
                    ALIGN
    

    thank you for your thread, it helped me a lot.

Reply
  • Hi John,

    Why modify the scatter file?
    It's not easy to put the code in the stack initalisation?
    The ram is initialized before.

    __user_initial_stackheap
    
                     LDR     R0, =Stack_Mem            ; Test stack
                     LDR     R1, =Stack_Size           ;
                     LDR     R2, =0xCCCCCCCC           ;
    Fill             STR     R2, [R0], #4              ;
                     SUBS    R1,#4                     ;
                     BNE     Fill                      ;
    
    
                    LDR     R0, =  Heap_Mem
                    LDR     R1, =(Stack_Mem + Stack_Size)
                    LDR     R2, = (Heap_Mem +  Heap_Size)
                    LDR     R3, = Stack_Mem
                    BX      LR
    
                    ALIGN
    

    thank you for your thread, it helped me a lot.

Children
No data