cancel
Showing results for 
Search instead for 
Did you mean: 

[STM32H7B0][OSPI] Not able to activate Memory Mapped mode in Read and Write modes

Hello Dear Community,

I am having a real strange issue while using OSPI peripheral in STM32H7B0 custom board.

I am trying to use OSPI with PSRAM but I wanna make sure it works fine, so I am using it with a NOR Flash for test.

When I try to activate the MMM using this code, it fails:

uint8_t
SHIP_XSPI_EnableMemoryMappedMode_RW(void) {

/* -------------------------- Enable Memory-Mapped mode------------------------ */

OSPI_RegularCmdTypeDef sCommand = {0};
OSPI_MemoryMappedTypeDef sMemMappedCfg = {0};

sCommand.OperationType = HAL_OSPI_OPTYPE_Read_CFG;
sCommand.FlashId = HAL_OSPI_FLASH_ID_1;
sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_1_LINE;
sCommand.AddressSize = HAL_OSPI_ADDRESS_24_BITS;
sCommand.DataMode = HAL_OSPI_DATA_4_LINES;
sCommand.Instruction = QUAD_IN_OUT_FAST_READ_CMD;
sCommand.AddressMode = HAL_OSPI_ADDRESS_4_LINES;
sCommand.DummyCycles = DUMMY_CLOCK_CYCLES_READ_QUAD;
sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;

if (HAL_OSPI_Command(&hospi1, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE)
!= HAL_OK) {
return HAL_ERROR;
}

sCommand.OperationType = HAL_OSPI_OPTYPE_WRITE_CFG;
sCommand.DummyCycles = NO_DUMMY_CYCLES;
sCommand.Instruction = QUAD_IN_FAST_PROG_CMD;

if (HAL_OSPI_Command(&hospi1, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE)
!= HAL_OK) {
return HAL_ERROR;
}

sMemMappedCfg.TimeOutActivation = HAL_OSPI_TIMEOUT_COUNTER_DISABLE;

if (HAL_OSPI_MemoryMapped(&hospi1, &sMemMappedCfg) != HAL_OK) {
return HAL_ERROR;
}

return HAL_OK;
}

/*****************************************************************************/

Also I see a weird implementation in function HAL_OSPI_MemoryMapped.

/* Check the state */
if (hospi->State == HAL_OSPI_STATE_CMD_CFG)
Here the function checks the state of the periph which can be other than HAL_OSPI_STATE_CMD_CFG, the case when I tried to use MMM only for read. That logically, doesn't work with this implementation as hospi->State will be equal to HAL_OSPI_OPTYPE_READ_CFG and the MMM not activated.

 

Now, my real problem is that with the above code, I cannot access the NOR flash with MMM in write mode. Could you please help and give hints here?

Thanks,

Ayoub

1 ACCEPTED SOLUTION

Accepted Solutions

NOR Flash Devices aren't really designed for this type of interaction.

The data writes in pages and you need to wait for it to come ready, memory-mapped really doesn't facilitate that, or allow for concurrent direct access.

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

View solution in original post

5 REPLIES 5

NOR Flash Devices aren't really designed for this type of interaction.

The data writes in pages and you need to wait for it to come ready, memory-mapped really doesn't facilitate that, or allow for concurrent direct access.

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

Thanks @Tesla DeLorean for your comment! 

I actually tried to add some delay after writing to it but didn't work! 

So you're saying NOR flashes can't be used as RAMs even with MMM supports direct write?

 

Hello @Ayoub Cheggari,

Physically NOR Flash memories and RAMs cannot operate the same way. In AN5050, section 6.2.2 Use case description, you can see for example, when Programming Macronix OCTAL NOR FLASH, write should be in Indirect mode and reading in Memory-mapped mode.

 

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.

Hello @FBL ,

You are right! When I rethought about it, it made sense to me! 

What made me believe it's possible, is some of the examples in your Github:

https://github.com/STMicroelectronics/STM32CubeH7/blob/master/Drivers/BSP/Components/mx25lm51245g/mx25lm51245g.c#L471

The example shows that it's possible to have MMM in write also.

Thank you,

Ayoub

 

Alex - APMemory
Senior II

Hi,

OPI RAM would support you use case including Memory mapped Write & Read. It can be shared on same bus with NOR upon needs and if BW is enough. 

You can find a wide range of OPI from 64Mb up to 512Mb (APS6408L..., APS12808L, APS25608N..., APS51208N..., APS256XXN..., APS512XXN...)

Alex