2022-03-30 08:06 AM
I am struggeling with a HyperRAM on STM32H7A3 with OctoSPI2 in Memory Mapped Mode Write.
In order to check, if the access to the HyperRAM is ok, I am running through a loop which writes all 0 / 0x55555555 / 0xAAAAAAAA (with 32 Bit access) to the RAM and then tests if it is ok. In the debugger memory dump I see that most words are written ok, But almost regularly on the last 4 bytes of a 256 byte block the data is not always written.
Signals are looking good. I tried to reduce clock rate, change the timing parameters, etc. but no success.
Has anybody an idea of what might be wrong?
void MX_OCTOSPI2_Init(void)
{
/* USER CODE BEGIN OCTOSPI2_Init 0 */
/* USER CODE END OCTOSPI2_Init 0 */
OSPIM_CfgTypeDef sOspiManagerCfg = {0};
OSPI_HyperbusCfgTypeDef sHyperBusCfg = {0};
/* USER CODE BEGIN OCTOSPI2_Init 1 */
// 24 = Device 16 MByte Size
//
// Prescaler:
// 3 = 93 MHz
// 4 = 70 MHz!
// 5 = 56 MHz
// 8 = 35 MHz
// 16 = 17.5 MHz
//
//
/* USER CODE END OCTOSPI2_Init 1 */
hospi2.Instance = OCTOSPI2;
hospi2.Init.FifoThreshold = 4;
hospi2.Init.DualQuad = HAL_OSPI_DUALQUAD_DISABLE;
hospi2.Init.MemoryType = HAL_OSPI_MEMTYPE_HYPERBUS;
hospi2.Init.DeviceSize = 24;
hospi2.Init.ChipSelectHighTime = 1;
hospi2.Init.FreeRunningClock = HAL_OSPI_FREERUNCLK_DISABLE;
hospi2.Init.ClockMode = HAL_OSPI_CLOCK_MODE_0;
hospi2.Init.WrapSize = HAL_OSPI_WRAP_NOT_SUPPORTED;
hospi2.Init.ClockPrescaler = 5;
hospi2.Init.SampleShifting = HAL_OSPI_SAMPLE_SHIFTING_NONE;
hospi2.Init.DelayHoldQuarterCycle = HAL_OSPI_DHQC_ENABLE;
hospi2.Init.ChipSelectBoundary = 23; /* memory die boundary 2^23=8MBs*/
hospi2.Init.DelayBlockBypass = HAL_OSPI_DELAY_BLOCK_USED;
hospi2.Init.MaxTran = 0;
hospi2.Init.Refresh = 200;
if (HAL_OSPI_Init(&hospi2) != HAL_OK)
{
Error_Handler();
}
sOspiManagerCfg.ClkPort = 2;
sOspiManagerCfg.DQSPort = 2;
sOspiManagerCfg.NCSPort = 2;
sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_2_LOW;
sOspiManagerCfg.IOHighPort = HAL_OSPIM_IOPORT_2_HIGH;
sOspiManagerCfg.Req2AckTime = 1;
if (HAL_OSPIM_Config(&hospi2, &sOspiManagerCfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
{
Error_Handler();
}
sHyperBusCfg.RWRecoveryTime = 3;
sHyperBusCfg.AccessTime = 6;
sHyperBusCfg.WriteZeroLatency = HAL_OSPI_LATENCY_ON_WRITE;
sHyperBusCfg.LatencyMode = HAL_OSPI_FIXED_LATENCY;
if (HAL_OSPI_HyperbusCfg(&hospi2, &sHyperBusCfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
{
Error_Handler();
}
S70KL1281_EnableMemoryMappedMode(&hospi2);
}
int32_t S70KL1281_EnableMemoryMappedMode(OSPI_HandleTypeDef *Ctx)
{
OSPI_HyperbusCmdTypeDef sCommand;
OSPI_MemoryMappedTypeDef sMemMappedCfg;
/* OctoSPI Hyperbus command configuration */
sCommand.AddressSpace = HAL_OSPI_MEMORY_ADDRESS_SPACE;
sCommand.AddressSize = HAL_OSPI_ADDRESS_32_BITS;
sCommand.Address = 0;
sCommand.DQSMode = HAL_OSPI_DQS_ENABLE;
sCommand.NbData = 1;
if (HAL_OSPI_HyperbusCmd(Ctx, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
{
return S70KL1281_ERROR;
}
/* OctoSPI activation of memory-mapped mode */
sMemMappedCfg.TimeOutActivation = HAL_OSPI_TIMEOUT_COUNTER_DISABLE;
if (HAL_OSPI_MemoryMapped(Ctx, &sMemMappedCfg) != HAL_OK)
{
return S70KL1281_ERROR;
}
return S70KL1281_OK;
}
Thank you for any replies.
Best regards
GS
Solved! Go to Solution.
2022-03-31 08:42 AM
Solution for anyone interested:
Set sHyperBusCfg.AccessTime = 7; (instead of 6)
HyperRam now does the job correctly.
2022-03-31 08:42 AM
Solution for anyone interested:
Set sHyperBusCfg.AccessTime = 7; (instead of 6)
HyperRam now does the job correctly.
2023-11-09 07:53 AM
Thanks a lot!
This solved my problem of using HyperRAM.