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

6 REPLIES 6
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.
KDJEM.1
ST Employee

Hello @NajeebUllahKhan;

 

What is the OCTOSPI frequency value?

Could you please try to decrease the OCTOSPI clock frequency.

Is the memory configured in memory mapped mode?

 

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.

@KDJEM.1 

System is running at 110 MHz and Prescaler is 2, so OSPI Freq is 55 MHz.

Yes, tried but still no response from W25Q256.

I am just configuring Quad Mode, then write and read that's it.

You can see my above main.c file I shared, my code goes into error handler when in write enable function.

Do you have any example for OSPI configured in Quad Mode for any flash? Or any working example code or function for it, you can share may be that can help me???

Looking to your response as I need to get it done very soon due to time limitation in project

Clear the sCommand structure. Probably sConfig too and whatever configuration parameters it needs.

Part would need to be in quad mode already for 4-bit command operation.

 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
NajeebUllahKhan
Associate II

@Tesla DeLorean 

Already doing it for sCommand and sConfig using {0} but still not working.

I have a question, does OSPI in Quad Mode really works with W25Q Quad based Flash? If yes, then there should be some example or test code for it to check if its really works?

I can't find any STM example or test code to confirm if its really works because I am doing QSPI with W25Q in Quad Mode and its working fine but when use OSPI in Quad Mode then no response???

Isn't the code generator supposed to do that? Or the Engineer responsible for the board, and board bring up? Not everything is a cut-n-paste exercise. ST generally provides code showing that THEIR boards work, ie EVAL, DISCO, not what others chose to build.

I'd previously built a Micron MT25Q256 implementation for a STM32L562

For the W25Q256, try this one

https://github.com/cturvey/stm32extldr/blob/main/l5_w25q256/README.md

PA3:AF10 CLK 

PA2:AF10 NCS 

PB1:AF10 IO0

PB0:AF10 IO1

PA7:AF10 IO2

PA6:AF10 IO3

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..