cancel
Showing results for 
Search instead for 
Did you mean: 

OSPI readonly in memory mapped mode

Leo_Panda
Associate III

I use the STM32L4R9I-EVAL Board and try to configure the ospi on nor-flash for readonly in memory mapped mode. there is an example projekt in Hal-Lib L4 V1.14.0.

If i skip the erase and write steps, it read out wrong values (with out hal error)!

Do any one have experiences with readonly in memory mapped mode?

it works fine if using readwrite_dma mode.

1 REPLY 1
Leo_Panda
Associate III

Now I found a solution by myself:

If only configure for read mode:

/* Initialize memory-mapped mode for read operations */

sCommand.OperationType = HAL_OSPI_OPTYPE_READ_CFG;

sCommand.FlashId = HAL_OSPI_FLASH_ID_1;

sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_8_LINES;

sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_16_BITS;

sCommand.AddressMode = HAL_OSPI_ADDRESS_8_LINES;

sCommand.AddressSize = HAL_OSPI_ADDRESS_32_BITS;

sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;

sCommand.DataMode = HAL_OSPI_DATA_8_LINES;

sCommand.DummyCycles = DUMMY_CLOCK_CYCLES_READ;

sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;

sCommand.Instruction = OCTAL_IO_READ_CMD;

sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;

sCommand.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_DISABLE;

sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE;

sCommand.DQSMode = HAL_OSPI_DQS_DISABLE;

if (HAL_OSPI_Command(&hospi1, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)

{

Error_Handler();

}

AND SKIP the write configuration:

/* Initialize memory-mapped mode for write operations */

//sCommand.OperationType = HAL_OSPI_OPTYPE_WRITE_CFG;

//sCommand.Instruction = OCTAL_PAGE_PROG_CMD;

//sCommand.DummyCycles = 0;

//if (HAL_OSPI_Command(&hospi1, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)

//{

// Error_Handler();

//}

the hospi will stay in HAL_OSPI_STATE_READY state and this caused that

HAL_OSPI_MemoryMapped()

runs into error!

Now I manually set the hospi state on HAL_OSPI_STATE_CMD_CFG and it works.

Why does HAL_OSPI_MemoryMapped only check the HAL_OSPI_STATE_CMD_CFG, is there a bug? You can get this state by sending write configuration , but for readonly operation the state remain in ready.

perhaps one should also check the ready state in HAL_OSPI_MemoryMapped:

if (hospi->State == HAL_OSPI_STATE_CMD_CFG || hospi->State == HAL_OSPI_STATE_READY)