- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hello,
i am trying to read and write data to S25FL128 NOR Flash(defaults mode is QUAD) with STM32L4R5ZI controller.
i am able to read device id, but when i trying to send write enable command and after that reading command for the status register 1 ,and then waiting for the WEL bit to be set in status register 1, code returns "HAL_Error" status.
basically i am not able to run two commands back to back like ( HAL_OSPI_Command followed by HAL_OSPI_Receive ), it gives me wrong status which result in HAL_Error return status.
can any-body help me with the exact sequencing of NOR Flash for read/write operation with QSPI along with STM32 Controller.
please find below code,
static void MX_OCTOSPI1_Init(void)
{
OSPIM_CfgTypeDef OSPIM_Cfg_Struct;
OSPI_MemoryMappedTypeDef sMemMappedCfg;
/* OCTOSPI1 parameter configuration*/
hospi1.Instance = OCTOSPI1;
hospi1.Init.FifoThreshold = 4;
hospi1.Init.DualQuad = HAL_OSPI_DUALQUAD_DISABLE;
hospi1.Init.MemoryType = HAL_OSPI_MEMTYPE_MICRON;
hospi1.Init.DeviceSize = 23;
hospi1.Init.ChipSelectHighTime = 1;
hospi1.Init.FreeRunningClock = HAL_OSPI_FREERUNCLK_DISABLE;
hospi1.Init.ClockMode = HAL_OSPI_CLOCK_MODE_0;
hospi1.Init.WrapSize = HAL_OSPI_WRAP_NOT_SUPPORTED;
hospi1.Init.ClockPrescaler = 1;
hospi1.Init.SampleShifting = HAL_OSPI_SAMPLE_SHIFTING_NONE;
hospi1.Init.DelayHoldQuarterCycle = HAL_OSPI_DHQC_DISABLE;
hospi1.Init.ChipSelectBoundary = 1;
if (HAL_OSPI_Init(&hospi1) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
}
void WriteEnable (void)
{
OSPI_RegularCmdTypeDef sCommand;
OSPI_AutoPollingTypeDef sConfig;
sCommand.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
sCommand.FlashId = HAL_OSPI_FLASH_ID_1;
sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_1_LINE;
sCommand.Instruction = WRITE_CMD; //0x06
sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_8_BITS;
// sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE;
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;
sCommand.AddressMode = HAL_OSPI_ADDRESS_NONE;
sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
sCommand.DataMode = HAL_OSPI_DATA_NONE;
sCommand.DummyCycles = 0;
sCommand.DQSMode = HAL_OSPI_DQS_DISABLE;
sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;
if (HAL_OSPI_Command ( &hospi1 , &sCommand , 1000 ) != HAL_OK )
{
_Error_Handler(__FILE__, __LINE__);
}
sCommand.Instruction = READ_STATUS_REG_CMD;
sCommand.DataMode = HAL_OSPI_DATA_1_LINE;
sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE;
sCommand.NbData = 1;
if ( HAL_OSPI_Receive ( &hospi1 , Id_Reg , 1000 ) != HAL_OK ) //it is not returning the HAL_OK
{
_Error_Handler(__FILE__, __LINE__);
}
sConfig.Match = WRITE_ENABLE_MATCH_VALUE;
sConfig.Mask = WRITE_ENABLE_MASK_VALUE;
sConfig.MatchMode = HAL_OSPI_MATCH_MODE_AND;
sConfig.Interval = AUTO_POLLING_INTERVAL;
sConfig.AutomaticStop = HAL_OSPI_AUTOMATIC_STOP_ENABLE;
if ( HAL_OSPI_AutoPolling(&hospi1, &sConfig,HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
asm("NOP");
}
kindly reply as soon as possible.
thanks in advance!!!
Solved! Go to Solution.
- Labels:
-
Serial NOR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
We recommend to attach a logic analyzer and see what is going on at the SPI bus level. Also please contact STM since you are using STM controller and driver.
Thank you
Regards,
Bushra