Skip to main content
FRAMU.1
Associate
April 13, 2022
Solved

reading the NOR flash ID and NOR SDFP of the stm32l562e_dk

I took the stm32Cube example : Projects\STM32L562E-DK\Examples\OCTOSPI\OSPI_NOR_ReadWrite_DMA and modified it to send a RDID (9Fh) instruction to the NOR. I get a "0xAC 0x28 0x53" but I ignore which codes that NOR flash is supposed to answer. It could be valid, though.

Then, I send a RDSDFP instruction (5Ah) and then I receive a sequence of "0x00" which is wrong because the NOR flash is supposed to send 0x50444653.

Could someone share the code functions using a simple OSPI_RegularCmdTypeDef to read the NOR-flash ID and the NOR-flash SDFP So that I can verify on my disco kit that the NOR-flash is alive.

Thanks

This topic has been closed for replies.
FRAMU.1
FRAMU.1Best answer
Associate
April 13, 2022

Ok for that RDID , restoring the bitorder give a coherent " C2 85 3A "

I still cannot get the a correct SDFP (but now always a sequence of 0xFF)

5 replies

FRAMU.1
FRAMU.1Author
Associate
April 13, 2022

for info:

static void OSPI_Read_NOR_ID(OSPI_HandleTypeDef *hospi)
{
 OSPI_RegularCmdTypeDef sCommand;
 
 sCommand.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
 sCommand.FlashId = HAL_OSPI_FLASH_ID_1;
 sCommand.Instruction = 0x9F;
 sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_1_LINE;
 sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_8_BITS;
 sCommand.AddressMode = HAL_OSPI_ADDRESS_NONE;
 sCommand.DataMode = HAL_OSPI_DATA_1_LINE;
 sCommand.DummyCycles = 8;
 sCommand.DQSMode = HAL_OSPI_DQS_DISABLE;
 sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;
 
 sCommand.NbData = 3;
 
 if (HAL_OSPI_Command(hospi, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
 {
 Error_Handler();
 }
 
 if (HAL_OSPI_Receive(hospi, aRxBuffer, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
 {
 Error_Handler();
 }
 
}
 
 
static void OSPI_Read_SFDP(OSPI_HandleTypeDef *hospi)
{
 OSPI_RegularCmdTypeDef sCommand;
 
 sCommand.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
 sCommand.FlashId = HAL_OSPI_FLASH_ID_1;
 sCommand.Instruction = 0x5A;
 sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_1_LINE;
 sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_8_BITS;
 sCommand.DataMode = HAL_OSPI_DATA_1_LINE;
 sCommand.DummyCycles = 8;
 sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;
 sCommand.AddressMode = HAL_OSPI_ADDRESS_1_LINE;
 sCommand.AddressSize = HAL_OSPI_ADDRESS_24_BITS;
  sCommand.Address = 0;
 
 sCommand.NbData = 0x18;
 
 if (HAL_OSPI_Command(hospi, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
 {
 Error_Handler();
 }
 
 if (HAL_OSPI_Receive(hospi, aRxBuffer, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
 {
 Error_Handler();
 }
}

What could be wrong ?

Mike_ST
ST Technical Moderator
April 13, 2022

>> I get a "0xAC 0x28 0x53" but I ignore which codes that NOR flash is supposed to answer

For the ReadID the digits you're getting are shifted... Check table 15 in the documentation.

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. 
FRAMU.1
FRAMU.1AuthorBest answer
Associate
April 13, 2022

Ok for that RDID , restoring the bitorder give a coherent " C2 85 3A "

I still cannot get the a correct SDFP (but now always a sequence of 0xFF)

FRAMU.1
FRAMU.1Author
Associate
April 14, 2022

Sending The SFDP command (0x5A) in a regular command:

sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_1_LINE;
 sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_8_BITS;
 sCommand.DataMode = HAL_OSPI_DATA_1_LINE;
 sCommand.DummyCycles = 8;
 sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;
 sCommand.AddressMode = HAL_OSPI_ADDRESS_1_LINE;
 sCommand.AddressSize = HAL_OSPI_ADDRESS_24_BITS;

and the 0x50444653 is expected from the NOR flash.