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

Placing Stack and Heap in different memory

Is there a way to place Stack in internal processor RAM and to place Heap on external RAM chip.

I am using the STMicroelectronic STM32F103ZxH6. When I define additional 'Read/Write Memory Areas' in the Target tab of the project options, it looks as though this toolchain automatically uses this information and configures the stack and heap in the external RAM memory area. However, RTX cannot talk to this memory because initialization has not happened. I want to be able to first initialize the FSMC bus for this memory by calling a C function from the startup__stm32f10x_hd.s file to initialize it and return. After this the __main function can be called. To do this requires function calling which means using the stack to pass parameters.

I want to place the stack in internal processor memory and heap in external processor memory.

How could I go about modifying this code to do this:

;*******************************************************************************
; User Stack and Heap initialization
;*******************************************************************************
                 IF      :DEF:__MICROLIB

                 EXPORT  __initial_sp
                 EXPORT  __heap_base
                 EXPORT  __heap_limit

                 ELSE

                 IMPORT  __use_two_region_memory
                 EXPORT  __user_initial_stackheap

__user_initial_stackheap

                 LDR     R0, =  Heap_Mem
                 LDR     R1, =(Stack_Mem + Stack_Size)
                 LDR     R2, = (Heap_Mem +  Heap_Size)
                 LDR     R3, = Stack_Mem
                 BX      LR

                 ALIGN

                 ENDIF

                 END

The code is part of my startup file.

0