cancel
Showing results for 
Search instead for 
Did you mean: 

OSPI in Quad SPI Mode Configuration

NajeebUllahKhan
Associate II

Hi Everyone,

I have W25Q256JV and STM32L562CEU6 with 38 Pin Package and have OSPI (Single SPI, Dual SPI and Quad SPI option only). Below is my Clock Settings, OSPI (Quad SPI) with Quad Lines Settings and Error Status during Write Enable and main.c file.

Kindly check and let me what is wrong so it's going into Error Handler every time on Write Enable.

If any basic drivers are available for OSPI in Quad Mode for Read/Write/Erase.

Looking forward to your kind help...

static void WriteEnable(OSPI_HandleTypeDef *hospi) {

OSPI_RegularCmdTypeDef sCommand;

OSPI_AutoPollingTypeDef sConfig;

HAL_StatusTypeDef ret;



/* Enable write operations ------------------------------------------ */

sCommand.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;

sCommand.FlashId = HAL_OSPI_FLASH_ID_1;

sCommand.Instruction = 0x06; // Use standard Write Enable command for Quad mode

sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_4_LINES; // Use 4-line instruction mode

sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_8_BITS; // 8-bit instruction size

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;



ret = HAL_OSPI_Command(hospi, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE);

if (ret != HAL_OK) {

// Log the error here

Error_Handler();

}



/* Configure automatic polling mode to wait for write enabling ---- */

sCommand.Instruction = 0x05; // Read the status register command for Quad mode

sCommand.Address = 0x0;

sCommand.AddressMode = HAL_OSPI_ADDRESS_4_LINES; // Use 4-line address mode

sCommand.AddressSize = HAL_OSPI_ADDRESS_24_BITS; // Standard 3-byte address size

sCommand.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_DISABLE;

sCommand.DataMode = HAL_OSPI_DATA_4_LINES; // Use 4-line data mode

sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE;

sCommand.NbData = 1; // 1 byte to read from status register

sCommand.DummyCycles = 8;



ret = HAL_OSPI_Command(hospi, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE);

if (ret != HAL_OK) {

// Log the error here

Error_Handler();

}



ret = HAL_OSPI_AutoPolling(hospi, &sConfig, HAL_OSPI_TIMEOUT_DEFAULT_VALUE);

if (ret != HAL_OK) {

// Log the error here

Error_Handler(); /* every time goes into error handler here */

}



/* Polling finished successfully */

}

 

1.PNG

 

2.PNG3.PNG

1 REPLY 1
mƎALLEm
ST Employee

Hello @NajeebUllahKhan ,

Please kindly use </> button to share your code. refer to this post. I'm editing your post.

Thank you for your understanding.

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.