cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7R7Z8 XSPI has timing issue in Quad mode

Leo2Ruan
Associate III

Hi, Everyone

I am trying to setup STM32H7R7Z8 XSPI2 in Quad mode for APS6404L-3SQR QSPI PSRAM.

The original code is generated from MX v6.116.1 and developed with IDE v2.0.0.

HW info:

  • The PSRAM is connected to XSPI2 with NCS, CLK, IO0~3. There is no DQS pin (PSRAM does not support it).
  • The XSPI2 is setup in 133MHz frequency PSRAM supported.
  • APS6404L-3SQR: 133MHz for 32 Bytes Wrapped Burst, 64Mb, 8M x 8bits, pagesize 1024 bytes,

SW configuration:

/* XSPI2 parameter configuration */
 hxspi2.Instance = XSPI2;
 hxspi2.Init.FifoThresholdByte = 4;
 hxspi2.Init.MemoryMode = HAL_XSPI_SINGLE_MEM;
 hxspi2.Init.MemoryType = HAL_XSPI_MEMTYPE_APMEM_16BITS;
 hxspi2.Init.MemorySize = HAL_XSPI_SIZE_64MB;
 hxspi2.Init.ChipSelectHighTimeCycle = 2;
 hxspi2.Init.FreeRunningClock = HAL_XSPI_FREERUNCLK_DISABLE;
 hxspi2.Init.ClockMode = HAL_XSPI_CLOCK_MODE_0;
 hxspi2.Init.WrapSize = HAL_XSPI_WRAP_32_BYTES;
 hxspi2.Init.ClockPrescaler = 0;
 hxspi2.Init.SampleShifting = HAL_XSPI_SAMPLE_SHIFT_HALFCYCLE;
 hxspi2.Init.ChipSelectBoundary = HAL_XSPI_BONDARYOF_NONE;
 hxspi2.Init.MaxTran = 0;
 hxspi2.Init.Refresh = 0;
 hxspi2.Init.MemorySelect = HAL_XSPI_CSSEL_NCS1;

 if (HAL_XSPI_Init(&hxspi2) != HAL_OK)
 {Error_Handler();}

 sXspiManagerCfg.nCSOverride = HAL_XSPI_CSSEL_OVR_NCS1;
 sXspiManagerCfg.IOPort = HAL_XSPIM_IOPORT_2;
 sXspiManagerCfg.Req2AckTime = 1;
 if (HAL_XSPIM_Config(&hxspi2, &sXspiManagerCfg, HAL_XSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
 {Error_Handler();}
 
 ------------------------------------------------------------------------------------------
 /* memory manager: EXTMEMORY_1 */
 extmem_list_config[0].MemType = EXTMEM_PSRAM;
 extmem_list_config[0].Handle = (void*)&hxspi2;
 extmem_list_config[0].ConfigType = EXTMEM_LINK_CONFIG_4LINES;
 extmem_list_config[0].PsramObject.psram_public.MemorySize = HAL_XSPI_SIZE_64MB;
 extmem_list_config[0].PsramObject.psram_public.FreqMax = 133 * 1000000u;
 extmem_list_config[0].PsramObject.psram_public.NumberOfConfig = 0u;

 /* Memory command configuration */
 extmem_list_config[0].PsramObject.psram_public.ReadREG          = 0u;
 extmem_list_config[0].PsramObject.psram_public.WriteREG         = 0u;
 extmem_list_config[0].PsramObject.psram_public.ReadREGSize      = 0u;
 extmem_list_config[0].PsramObject.psram_public.REG_DummyCycle   = 0u;
 extmem_list_config[0].PsramObject.psram_public.Write_command    = 0x38u;
 extmem_list_config[0].PsramObject.psram_public.Write_DummyCycle = 0u;
 extmem_list_config[0].PsramObject.psram_public.Read_command     = 0xEBu;
 extmem_list_config[0].PsramObject.psram_public.WrapRead_command = 0x00u;
 extmem_list_config[0].PsramObject.psram_public.Read_DummyCycle  = 6u;
 EXTMEM_Init(EXTMEMORY_1, HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_XSPI2));

When system startup, the SW can properly initializes the PSRAM with reset, toggle-burst-boundary(chip specific feature), readID and enabled to memory-mapped mode successfully. Below image shows the registers after init:

xspi-register.png

According to Errata: 2.4.1 Memory-mapped write error response when DQS output is disable

Description: If the DQSE control bit of the XSPI_WCCR register is cleared for memories without DQS pin, it results in an error response for every memory-mapped write request.

Workaround: When doing memory-mapped writes, set the DQSE bit of the XSPI_WCCR register, even for memories that have no DQS pin.

So I did  "commandBase.DQSMode = HAL_XSPI_DQS_ENABLE" for memory-mapped write instruction.

Problem:

In memory-mapped mode, SW try to write 0x55 to RAM from start-address 0x70000000 and then read back for verification.

  • The verification is success at beginning 24KB size - whatever the start-address is.
  • After 24KB, the verification is failed time to time. And errors happen more if read run more time.
  • The MCU hangup with free-run-read through whole PSRAM size.

It seems the XSPI has timing drift problem. Does anyone get the problem?

Question: Does XSPI support Quad mode for PSRAM without DQS pin?

 

1 ACCEPTED SOLUTION

Accepted Solutions
KDJEM.1
ST Employee

Hello @Leo2Ruan ;

 

Please look at Getting started with STM32H7Rx/7Sx MCUs hardware development - Application note and check the hardware.

Caution: The I/O HSLV configuration bit must not be set if the I/O supply (VDD) is above 2.7 V. Setting it while the voltage is higher than 2.7 V can damage the device

 

Thank you.

Kaouthar

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

6 REPLIES 6
KDJEM.1
ST Employee

Hello @Leo2Ruan ;

 

You can used a memory that have no DQS pin, you need only to set the DQSE bit of the XSPI_WCCR register when doing memory-mapped writes.

To solve the issue, I recommend you to check:

- The HSLV. Please look at Recommendations for high-speed low-voltage mode (HSLV) on the STM32H7RS.

- I/O compensation cell. I/O compensation might create skewed output rise and fall times. For that, I advise you to check the errata sheet precisely 2.215 I/O compensation could alter duty-cycle of high-frequency output signal erratum.

 

Thank you.

Kaouthar

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hi Kaouthar, Thanks for your reply!

For HSLV, I checked the high-speed-option are disabled on both XSPI 1 and 2. See:

XSPI_HSLV.png

But the HSLV are enabled from MX->SBS. Shall I disable it too?

MX_SBS.png

We will check the I/O/compensation from errata 2.2.15, and get back later.

 

Leo2Ruan
Associate III

Hi @KDJEM.1,

I did test according to errata 2.2.15. See below:

1) The error rate is significantly reduced by disabling automatic I/O compensation on XSPI pins (SW compensation is not applied), and slowdown the speed:

XSPI-2 Clock (MHz)Total BytesError BytesError Rate
1338MiB525740 ~ 6856298.57%
66.58MiB800 ~ 1000120 PPM
33.258MiB172 PPM

2) Then apply SW I/O compensation on XSPI (Follow workaround from Errata 2.2.15)

The value of flash memory at address 0x08FFF840 @3.3 V is 0xFFFFFFFF. So we go with case-1: The calibration value from register SBS_CCVALR is 8. The result shows the SW compensation does not help in high speed, and a little bad with low speed:

XSPI-2 Clock (MHz)Total BytesError BytesError Rate
1338MiB527700 ~ 6856948.57%
66.58MiB800 ~ 1191200 PPM
33.258MiB13 ~ 304 PPM

Double check the SBS registers:

SBS_CCCSR.png

Summary:

  • The DQSE bit of the XSPI_WCCR register is set for doing memory-mapped writes.
  • Both XSPI1_HSLV and XSPI2_HSLV are disabled.
  • Automatic I/O compensation is disabled in XSPI1 and XSPI2, with or without SW compensation applied.

All these can't fix the unstable problem. Any suggest?

By testing with lower speed, we find there may be EMC issue on board.

Thanks!

Leo Ruan

 

 

 

KDJEM.1
ST Employee

Hello @Leo2Ruan ;

 

Please look at Getting started with STM32H7Rx/7Sx MCUs hardware development - Application note and check the hardware.

Caution: The I/O HSLV configuration bit must not be set if the I/O supply (VDD) is above 2.7 V. Setting it while the voltage is higher than 2.7 V can damage the device

 

Thank you.

Kaouthar

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hi @KDJEM.1

The VDD for MCU and PSRAM is 3.3v. It is confirmed that I/O HSLV is not set on my board.

To avoid the damage case, I checked the HSLV and do all tests on 3 boards. Get same result.

I did not check the pin-mux settings since this is generated by MX.

2026-03-13_17h27_10.png

Thanks!

Leo Ruan

 

Hi @KDJEM.1 Thank you!

We did not find root cause after review the hardware and layout design. Will keep working on EMC side.

I have one last question about burst setting: hxspi2.Init.WrapSize = HAL_XSPI_WRAP_32_BYTES

When XSPI works in memory-mapped mode, how do the AXI and XSPI know a new instruction is required cross the 32 bytes boundary?

Leo Ruan