2021-04-07 09:10 AM
Hello!
I'm trying to use an external SDRAM (IS42S16320F) with an STM32H753 but no luck till now.
Could please anyone check if my settings are correct because I don't know if I made a bug here.
For that I have attached the FMC configuration and the schematic parts with the SDRAM and uC.
I would be very greatefull for that.
Regards,
Gregor
2021-04-07 09:24 AM
Based on very quick scan - column address bits should be 10 not 11 for IS42S16320F and start by running CAS 3 and slow timings until working
2021-04-07 09:47 AM
Thank you for the quick reply!
I have changed the number of column bits to 10 and the CAS 3 to make sure.
After check with the memory viewer I still can't see any valid address for the standard range 0xC000000:
Also if I check the alternative address mode for 0xD000 0000 I also don't get any valid address:
Here are my clock settings (in case I have also made anything wrong also here):
Regards,
Gregor
2021-04-07 10:28 AM
Have you started up the refresh?
2021-04-07 10:39 AM
Wouldn't SDRAM2 be at 0xD0000000 ?
2021-04-07 11:11 AM
@Community member : yes, that is why I have checked both addresses, the 0xC000 0000 (default for SDRAM1) and the 0xD000 0000 jsut to make sure. But as you can see from the pictures none of them are available.
@Community member : My "main" code looks like this:
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART6_UART_Init();
MX_FMC_Init();
/* USER CODE BEGIN 2 */
BSP_SDRAM_Init(); //Initialize the external SDRAM
//(FMC driver and GPIO's are initialized by the FMC function)
debugPrintln(&huart6, "some text");
I'm using the standard libraries:
#include "fmc.h"
The FMC takes care of the pins and the driver initializations.
The SDRAM initialization is done by the BSP_SDRAM_Init(), that basically contains only this function:
void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram, FMC_SDRAM_CommandTypeDef *Command)
{
__IO uint32_t tmpmrd =0;
/* Step 1: Configure a clock configuration enable command */
Command->CommandMode = FMC_SDRAM_CMD_CLK_ENABLE;
Command->CommandTarget = FMC_SDRAM_CMD_TARGET_BANK2;;
Command->AutoRefreshNumber = 1;
Command->ModeRegisterDefinition = 0;
/* Send the command */
HAL_SDRAM_SendCommand(hsdram, Command, SDRAM_TIMEOUT);
/* Step 2: Insert 100 us minimum delay */
/* Inserted delay is equal to 1 ms due to systick time base unit (ms) */
HAL_Delay(1);
/* Step 3: Configure a PALL (precharge all) command */
Command->CommandMode = FMC_SDRAM_CMD_PALL;
Command->CommandTarget = FMC_SDRAM_CMD_TARGET_BANK2;
Command->AutoRefreshNumber = 1;
Command->ModeRegisterDefinition = 0;
/* Send the command */
HAL_SDRAM_SendCommand(hsdram, Command, SDRAM_TIMEOUT);
/* Step 4 : Configure a Auto-Refresh command */
Command->CommandMode = FMC_SDRAM_CMD_AUTOREFRESH_MODE;
Command->CommandTarget = FMC_SDRAM_CMD_TARGET_BANK2;
Command->AutoRefreshNumber = 8;
Command->ModeRegisterDefinition = 0;
/* Send the command */
HAL_SDRAM_SendCommand(hsdram, Command, SDRAM_TIMEOUT);
/* Step 5: Program the external memory mode register */
tmpmrd = (uint32_t)SDRAM_MODEREG_BURST_LENGTH_1 |
SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL |
SDRAM_MODEREG_CAS_LATENCY_3 |
SDRAM_MODEREG_OPERATING_MODE_STANDARD |
SDRAM_MODEREG_WRITEBURST_MODE_SINGLE;
Command->CommandMode = FMC_SDRAM_CMD_LOAD_MODE;
Command->CommandTarget = FMC_SDRAM_CMD_TARGET_BANK2;
Command->AutoRefreshNumber = 1;
Command->ModeRegisterDefinition = tmpmrd;
/* Send the command */
HAL_SDRAM_SendCommand(hsdram, Command, SDRAM_TIMEOUT);
/* Step 6: Set the refresh rate counter */
/* Set the device refresh rate */
HAL_SDRAM_ProgramRefreshRate(hsdram, REFRESH_COUNT);
}
So at the end of it the refresh rate is set. This is why I think that the refresh shall be ok, or is there something that I miss?
Regards,
Gregor
2021-04-07 11:45 AM
Ok, so ?? ?? indicates the peripheral isn't even clocking.
You're going to want to double check where exactly you're break-pointing this, and then unpack the RCC clocks and FMC peripheral settings, and confirm they make sense.
Ideally, just do some printf/dumping after you've initialized the memory interface.
Have the Hard Fault Handler output some actionable data, and if it still faults when touching SDRAM2 (0xD0000000), then again suggests the peripheral's not setup/clocked. Getting the odd parameter wrong will yield random data, not ?? ??
On the F4 or F7 I seem to recall that SDRAM1 needed some nominal settings along with SDRAM2, for the latter to work. Perhaps look at the F429I-DISCO examples.
2021-04-07 01:22 PM
Thank you for all the usefull hints. I will check them and post the progress.
2021-04-07 05:54 PM
Hello
You didn't published the timings
Check if REFRESH_COUNT is calculated properly for this memory. This sdram chip refreshes every about 8μsec (8K/64msec) for comercial temp range.
Recalculate the counts by multiply 8.192μs *100MHz/2 =820/2 , remove some counts for safety , eg, 15 => 400.
2021-04-07 06:14 PM
The side of the barn is pretty broad here, not really presenting as a timing or geometry issue.