cancel
Showing results for 
Search instead for 
Did you mean: 

Using ST FSMC_SRAM_DataMemory example on keil

rishi2
Associate III
Posted on June 14, 2013 at 12:41

I cannot find the startup file and scatter file for Keil for FSMC_SRAM_DataMemory example in STM32F4xx_DSP_StdPeriph_Lib_V1.1.0.

Basically i want to use external memory on STM3240G eval  board as my stack and heap space.  I would appreciate if somebody can share these startup and scatter file for keil environment. Thanks

#st-fsmc_sram_datamemory-example #fsmc_sram_datamemory-example
4 REPLIES 4
Posted on June 14, 2013 at 14:11

Why would you use the slowest memory available for a stack?

From a prior version

STM32F4xx_DSP_StdPeriph_Lib_V1.0.0\Project\STM32F4xx_StdPeriph_Examples\FSMC\FSMC_SRAM_DataMemory\readme.txt

 <li> MDK-ARM

    - in Project->Options for Target window, select 'RAM1'and enter 0x64000000

      as start address with size of 0x100000 (IRAM1 must be un-checked)

    - uncomment ''#define DATA_IN_ExtSRAM '' in the ''system_stm32f4xx.c'' file

STM32F4xx_DSP_StdPeriph_Lib_V1.0.0\Project\STM32F4xx_StdPeriph_Examples\FSMC\SRAM_DataMemory\startup\MDK-ARM\startup_stm32f4xx.s

In the newer version what's wrong with the regular startup file? It has the external memory setup with DATA_IN_ExtSRAM defined.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
rishi2
Associate III
Posted on June 14, 2013 at 17:28

Thanks clive. Our main application uses internal RAM for stack and heap. But we have one calibration application for our sensor which only has to run once in factory so we can afford to compromise speed in this application. And calibration library uses lots of stack space which i can not accommodate in 192KB.

It worked for me but i have to check the IRAM1 checkbox although readme says IRAM1 must be un-checked. If i leave it unchecked then SP remains at 2000xxxx in my main function. If i am checking it then its changing to 6400xxxx.

In the newer startup file i don't see the following lines :

LDR     R0, =__initial_sp          ; restore original stack pointer

MSR     MSP, R0  

Thanks again for your support.

Posted on June 14, 2013 at 18:23

There are many ways to deal with this, I'd create a simple scatter file and modify the startup to suit.

The purpose of changing the stack setting to after SystemInit() is so that the external memory can be initialized BEFORE you cause the processor to use it. If SystemInit() has local variables these may need a stack, and at start up that's going to need to be in Internal SRAM, setting the initial SP in the Vector Table to 0x20002000 or something like that will achieve that goal. After it returns from SystemInit() you can move the SP to the External RAM as it should now be functional. You should also make your monster stack allocation in startup_stm32f4xx.s

; *************************************************************
; *** Scatter-Loading Description File for STM32F4 ***
; *************************************************************
LR_IROM1 0x08000000 0x00100000 { ; load region size_region
ER_IROM1 0x08000000 0x00100000 { ; load address = execution address
*.o (RESET, +First)
*(InRoot$$Sections)
.ANY (+RO)
}
RW_IRAM1 0x20000000 0x00020000 { ; RW data
.ANY (+RW +ZI)
}
RW_IRAM2 0x64000000 0x00100000 { ; Ext
startup_stm32f4xx.o (STACK)
}
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
rishi2
Associate III
Posted on June 15, 2013 at 05:55

Thanks Clive for the sample scatter file.

Thank you so much for your prompt replies always 🙂