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

MCBSTM32F400 external ram

I'm using the Keil MCBSTM32F400 development board and I'd like to start using the external SRAM.

From the user's guide the SRAM uses the following pins and is at the following location:
SRAM FSMC_NE3 / PG10 0x68000000 - 0x681FFFFF

I'm having trouble accessing the memory. When trying to write, nothing happens and when reading back I always get 0xFF.

Does anyone have an example of setting up the FSMC for the Keil development board to use its external SRAM?

Is there a Keil example application that shows how to use the memory?

What I've tried so far:

In the standard system_stm32f4xx.c file, I enabled the external memory by defining DATA_IN_ExtSRAM (uncommenting).

In the SystemInit_ExtMemCtl() function I commented out three lines where they were directly configuring the FSMC_Bank1 timing and control registers; uncommented the FSMC_NORSRAMInitStructure; changed FSMC_Bank1_NORSRAM2 to FSMC_Bank1_NORSRAM3; called teh FSMC_NORSRAMInit() function with the structure; and finally added a call to FSMC_NORSRAMCmd() to enable.

I did not change any of the GPIO alternate function setup from what is in the standard system file.

I have not looked into the timing settings for the SRAM on the Keil board vs. the timing for the G_EVAL board external SRAM to see if they're different enough to change.

Any help would be greatly appreciated.

Parents
  • Hi Toff,

    Can you specify a little bit more?

    For example in my case;

    in the startup_stm32f4xx.s file there is;

    42 Stack_Size EQU 0x00002000
    43
    44 AREA STACK, NOINIT, READWRITE, ALIGN=3
    45 Stack_Mem SPACE Stack_Size
    46 __initial_sp

    should i replace line 46 with

    __initial_sp    EQU 0x20000000+Stack_Size
    

    ?

    which didnot work for me.

    ------------------------

    Before this i also did;

    * modifications in stm324xg_eval_fsmc_sram.c file as Anderson Machado says and called the SRAM_Init() from SystemInit() instead of SystemInit_ExtMemCtl();

    * and added start address 0x68000000 and size 0x200000 in the "options for target"

    After all these, code compiles ok, but when i try to debug i saw that after SystemInit() before the call of main() it jumps to HardFault_Handler().

    --------------------------

    if i try to call SRAM_Init() from main() as a first line. Then, in the debug after the SystemInit() pointer jumps to 0x00000000 addresss and stop there.

    --------------------------

    I try to join all hints from the top to bottom but it seems i miss something,

    Can u summarize the steps using external memory from RTX as like other internal ram areas?

    TY.

Reply
  • Hi Toff,

    Can you specify a little bit more?

    For example in my case;

    in the startup_stm32f4xx.s file there is;

    42 Stack_Size EQU 0x00002000
    43
    44 AREA STACK, NOINIT, READWRITE, ALIGN=3
    45 Stack_Mem SPACE Stack_Size
    46 __initial_sp

    should i replace line 46 with

    __initial_sp    EQU 0x20000000+Stack_Size
    

    ?

    which didnot work for me.

    ------------------------

    Before this i also did;

    * modifications in stm324xg_eval_fsmc_sram.c file as Anderson Machado says and called the SRAM_Init() from SystemInit() instead of SystemInit_ExtMemCtl();

    * and added start address 0x68000000 and size 0x200000 in the "options for target"

    After all these, code compiles ok, but when i try to debug i saw that after SystemInit() before the call of main() it jumps to HardFault_Handler().

    --------------------------

    if i try to call SRAM_Init() from main() as a first line. Then, in the debug after the SystemInit() pointer jumps to 0x00000000 addresss and stop there.

    --------------------------

    I try to join all hints from the top to bottom but it seems i miss something,

    Can u summarize the steps using external memory from RTX as like other internal ram areas?

    TY.

Children
No data