cancel
Showing results for 
Search instead for 
Did you mean: 

External SDRAM with STM32F767 Nucleo board

AMerc.4
Senior

Hello,

i bought this SDRAM and i connected it to my STM32F767 Nucleo board. My init function is

static void MX_FMC_Init(void)
{
 
  /* USER CODE BEGIN FMC_Init 0 */
 
  /* USER CODE END FMC_Init 0 */
 
  FMC_SDRAM_TimingTypeDef SdramTiming = {0};
 
  /* USER CODE BEGIN FMC_Init 1 */
 
  /* USER CODE END FMC_Init 1 */
 
  /** Perform the SDRAM1 memory initialization sequence
  */
  hsdram1.Instance = FMC_SDRAM_DEVICE;
  /* hsdram1.Init */
  hsdram1.Init.SDBank = FMC_SDRAM_BANK1;
  hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8;
  hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_13;
  hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_8;
  hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4;
  hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3;
  hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE;
  hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2;
  hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_DISABLE;
  hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_1;
  /* SdramTiming */
  SdramTiming.LoadToActiveDelay = 2;
  SdramTiming.ExitSelfRefreshDelay = 8;
  SdramTiming.SelfRefreshTime = 4;
  SdramTiming.RowCycleDelay = 7;
  SdramTiming.WriteRecoveryTime = 3;
  SdramTiming.RPDelay = 2;
  SdramTiming.RCDDelay = 2;
 
  if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK)
  {
    Error_Handler( );
  }
 
  /* USER CODE BEGIN FMC_Init 2 */
 
  /* USER CODE END FMC_Init 2 */
}

but my memory manager doesn't read it. However, if i put into this function a custom user code such as

FMC_SDRAM_CommandTypeDef Command;
 
/* Step 1: Configure a clock configuration enable command */
Command.CommandMode            = FMC_SDRAM_CMD_CLK_ENABLE;
Command.CommandTarget          = FMC_SDRAM_CMD_TARGET_BANK1;
Command.AutoRefreshNumber      = 1;
Command.ModeRegisterDefinition = 0;
 
/* Send the command */
HAL_SDRAM_SendCommand(&hsdram1, &Command, 60);

i can read my SDRAM both at 0xC0000000 and 0xD0000000. However, if i put this code in the main

uint32_t *externalRAM = 0xC000000;
const uint32_t size = 1000;
 
//write external RAM
for(int i = 0; i < size; i++)
{
    externalRAM[i] = i;
}

i can't see any difference.

18 REPLIES 18
TDK
Guru

> uint32_t *externalRAM = 0xC000000;

Probably want to write to 0xC0000000 and not 0x0C000000.

If you feel a post has answered your question, please click "Accept as Solution".

You are right. But the problem persists. If i write to 0x20000000 it works:

0x20000000  00000000 00000001 00000002 00000003 00000004 00000005 00000006  ............................
0x2000001C  00000007 00000008 00000009 0000000A 0000000B 0000000C 0000000D  ............................
0x20000038  0000000E 0000000F 00000010 00000011 00000012 00000013 00000014  ............................
0x20000054  00000015 00000016 00000017 00000018 00000019 0000001A 0000001B  ............................
0x20000070  0000001C 0000001D 0000001E 0000001F 00000020 00000021 00000022  ................ ...!..."...
0x2000008C  00000023 00000024 00000025 00000026 00000027 00000028 00000029  #...$...%...&...'...(...)...
0x200000A8  0000002A 0000002B 0000002C 0000002D 0000002E 0000002F 00000030  *...+...,...-......./...0...
0x200000C4  00000031 00000001 00000033 00000034 00000035 00000036 00000037  1.......3...4...5...6...7...
0x200000E0  00000038 00000039 0000003A 0000003B 0000003C                    8...9...:...;...<...

but if i insert it to 0xC0000000:

0xC0000000  CFCFCFCF CFCFCFCF DFCFCFCF CFCFCFCF CFCFCFCF CFCFCFCF CFCFCFCF  �?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
0xC000001C  CFCFCFCF CF8FCFCF 8F8F8FCF CFCF8F8F CF8FCF8F CFCFCFCF CFCFCFCF  �?�?�?�?�?�?.�?�?.....�?�?.�?.�?�?�?�?�?�?�?�?�?
0xC0000038  CFCFCFCF CFCFCFCF CFCFCFCF CFCFCFCF CFCFCFCF CFCFCFCF CFCFCFCF  �?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
0xC0000054  CFCFCFCF CFCFCFCF CFCFCFCF CFCFCFCF FFFFFFFF FFFFFFFF FFFFFFFF  �?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?ÿÿÿÿÿÿÿÿÿÿÿÿ
0xC0000070  7F7F7F7F 7F7F7F7F 7F7F7F7F 7F7F7F7F 7F7F7F7F 7F7F7F7F 7F7F7F7F  ............................
0xC000008C  7F7F7F7F 7F7F7F7F 7F7F7F7F 7F7F7F7F 7F7F7F7F 7F7F7F7F 7F7F7F7F  ............................
0xC00000A8  7F7F7F7F 7F7F7F7F 7F7F7F7F 7F7F7F7F 7F7F7F7F 7F7F7F7F 7F7F7F7F  ............................
0xC00000C4  7F7F7F7F 7F7F7F7F 7F7F7F7F 7F7F7F7F 7F7F7F7F 7F7F7F7F 7F7F7F7F  ............................
0xC00000E0  7F7F7F7F 7F7F7F7F 7F7F7F7F 7F7F7F7F 7F7F7F7F 7F7F7F7F 7F7F7F7F  ............................
0xC00000FC  ????????                                                        ????

Piranha
Chief II

And how is this physically connected to the Nucleo? At what frequency? Does it respect the impedance and other high frequency signal requirements?

I soldered it to a breakout board, which is connected to the Nucleo board through 15cm wires. I setted the HCLK frequency to 200 MHz, so the SDRAM frequency runs at 100 MHz frequency.

TDK
Guru

I wouldn't count on 100 MHz making it through 15cm wires without issue. 0xCF and 0x8F are one bit apart. I bet your signal is just distorted.

If you feel a post has answered your question, please click "Accept as Solution".

So, what do you suggest to me? Should i reduce the SDRAM frequency?

TDK
Guru

Yes, I would bring SDRAM frequency down to around 10 MHz or so and see if it works and go from there.

I don't know if SDRAM has a minimum frequency or not. Probably not, but I don't have a ton of experience there.

If you feel a post has answered your question, please click "Accept as Solution".

Attach as a complete/compilable project. Enumerate pin usage.

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

There is a reason why noone does it like that - it's called physics. You can try lowering the frequency as low as possible and using PATA cable or similar, but take a note that they introduced 80-wire cable (with every other line being ground) for 33 MHz connections.