cancel
Showing results for 
Search instead for 
Did you mean: 

External RAM on STM32H743IIT6

GGowi.1
Associate II

I am trying to set up FMC to work with external RAM. The code compiles and works with KEIL, but I am trying to make it work with STM32CubeIDE. The code compiles and runs, but the RAM is not initialized. I copied all of the code, including the .ioc file, and used it but it won't enable the RAM.

I have a temporary license for KEIL and I have confirmed that the memory and the code work by compiling and debugging in KEIL and accessing the RAM in the code and in the debugger.

Any thoughts or ideas? I need this external ram so I can continue to port TouchGFX to my board for a research project.

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
PMath.4
Senior III

Setup FMC and SDRAM

void RAMSETUP(void){
	  /*##-1- Configure the SDRAM device #########################################*/
	  /* SDRAM device configuration */
	  hsdram.Instance = FMC_SDRAM_DEVICE;
 
	    /* Timing configuration for 100Mhz as SDRAM clock frequency (System clock is up to 200Mhz) */
	  SDRAM_Timing.LoadToActiveDelay    = 2;
	  SDRAM_Timing.ExitSelfRefreshDelay = 7;
	  SDRAM_Timing.SelfRefreshTime      = 4;
	  SDRAM_Timing.RowCycleDelay        = 7;
	  SDRAM_Timing.WriteRecoveryTime    = 2;
	  SDRAM_Timing.RPDelay              = 2;
	  SDRAM_Timing.RCDDelay             = 2;
 
	  hsdram.Init.SDBank             = FMC_SDRAM_BANK2;
	  hsdram.Init.ColumnBitsNumber   = FMC_SDRAM_COLUMN_BITS_NUM_8;
	  hsdram.Init.RowBitsNumber      = FMC_SDRAM_ROW_BITS_NUM_12;
	  hsdram.Init.MemoryDataWidth    = FMC_SDRAM_MEM_BUS_WIDTH_16;
	  hsdram.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4;
	  hsdram.Init.CASLatency         = FMC_SDRAM_CAS_LATENCY_3;
	  hsdram.Init.WriteProtection    = FMC_SDRAM_WRITE_PROTECTION_DISABLE;
	  hsdram.Init.SDClockPeriod      = FMC_SDRAM_CLOCK_PERIOD_2;
	  hsdram.Init.ReadBurst          = FMC_SDRAM_RBURST_ENABLE;
	  hsdram.Init.ReadPipeDelay      = FMC_SDRAM_RPIPE_DELAY_1;
 
	  /* Initialize the SDRAM controller */
	  if(HAL_SDRAM_Init(&hsdram, &SDRAM_Timing) != HAL_OK)
	  {
	    /* Initialization Error */
	    SystemError=1;Error_Handler();
	  }
 
	  /* Program the SDRAM external device */
	  SDRAM_Initialization_Sequence(&hsdram, &command);
 
}

View solution in original post

18 REPLIES 18

"the RAM is not initialized."

Hard Faults, because the hardware/pins don't come up, or some static initialization is not copied over there?

The latter means you have to add code in startup.s to copy over the statics, which Keil would have done if the memory was properly setup in SystemInit()

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Thanks. I'll look into it. I'm new to STM bare-metal programming. I'll see what differences I can find.

I tried copying the original code from the KEIL project but it wouldn't work, so something is obviously missing. Thanks.

Probably the Keil library code that unpacks the Load Region properly.

Didn't really answer the question as to whether the memory was accessible..​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Thanks.

The RAM is not accessible when I compile the code in STM32CubeIDE - that's what causes the hard fault - attempting to access the address that does not exist as far as the chip is concerned.

I added the region of memory to the linker scripts and that seems to be working correctly, but the chip itself is not accessing the memory. I've stepped through the initialization process in the debugger and no errors are being returned. The additional code that the board manufacturer included to initialize the RAM runs without generating any faults.

Need to check you enable clocks before the peripherals and pins. Sequence/order is important here. SDRAM also has timing dependencies when starting up.

Anything happening in the Keil startup.s ?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

There is no startup.s file in the directory I have.

There are four different files named startup_stm32h743xx.s. Three of them are functionally identical with only declarations of variables and filling out "structures". The fourth has a couple of bits of actual code which simply zero out various areas of memory.

The clocks are being enabled before the peripherals and pins - I literally copied the code from the Keil version and compiled it using STM32CubeIDE, so it didn't copy the Keil startup files but instead generated its own which were functionally identical though they used a slightly different syntax. I copied the .ioc file as well and used it to generate the other code before I copied the files with user code in them.

I'm going to keep beating on this thing because I need this to work. The board is the CoreH743I https://www.waveshare.com/coreh743i.htm

The example code (18.FMC SDRAM_FMC) is linked in this wiki page https://www.waveshare.com/wiki/CoreH743I if you're familiar with the board.

Like I said before, I'm new to STM bare metal programming, so I'm sure I'm missing something fairly simple here.

Thanks

Not a board I own.

Had a couple of other WaveShare boards in the past. Pretty sure I could port something working, Have H743 EVAL and some H747, H745 DISCOs

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

That would be amazing if you could put something together that works in STM32CubeIDE using CubeMX. Then I could look at it and figure out what I need, because I thought I pulled out all of the code for my memory (the BSP_SDRAM.c and .h files from the demo) but there's something else I'm missing.

Thanks

>>.. works in STM32CubeIDE using CubeMX.

I typically work with Keil, and GNU/GCC via make

If you have code working in Keil, the same thing should be viable in GNU/GCC.

You'll want to unpack the registers to see why the SDRAM doesn't come up.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..