Skip to main content
Visitor II
October 6, 2025
Question

OSPI_NOR_MemoryMapped example on STM32U5x9J-DK returns garbage on read

  • October 6, 2025
  • 1 reply
  • 187 views

Board: STM32U5x9J-DK (Discovery)

MCU: STM32U5xx (U5G9J series)

STM32Cube package: STM32Cube_FW_U5_V1.8.0

Example path:

STM32Cube\Repository\STM32Cube_FW_U5_V1.8.0\Projects\STM32U5x9J-DK\Examples\OSPI\OSPI_NOR_MemoryMapped

File: main.c (write/read operations performed in switch(step), case 1)

IDE / toolchain: (please mention your IDE, e.g., STM32CubeIDE v1.19.0)

 

Running the example on the Discovery board: the write appears to run, memory-mapped mode is entered, but reading back returns garbage — the mismatch counter res always becomes 256 (I interpret that as every byte failed the compare). The write/read block is in case 1 of the main loop.

case 1:
 if (CmdCplt != 0)
 {
 CmdCplt = 0;
 /* ... set up mem-mapped write/read ... */

 /* Writing Sequence ----------------------------------------------- */
 mem_addr = (uint8_t *)(OCTOSPI1_BASE + address);
 for (index = 0; index < BUFFERSIZE; index++)
 {
 *mem_addr = aTxBuffer[index];
 mem_addr++;
 }

 HAL_Delay(MEMORY_PAGE_PROG_DELAY);

 /* Reading Sequence ----------------------------------------------- */
 mem_addr = (uint8_t *)(OCTOSPI1_BASE + address);
 for (index = 0; index < BUFFERSIZE ; index++)
 {
 if (*mem_addr != aTxBuffer[index])
 {
 res++;
 }
 mem_addr++;
 }

 if (res != 0)
 { BSP_LED_On(LED_RED); }
 else
 { BSP_LED_Toggle(LED_GREEN); HAL_Delay(50); }
 /* ... */
 }
 break;
 

 

    This topic has been closed for replies.

    1 reply

    ST Employee
    October 10, 2025

    Hello @RC123,

    The example works correctly. I recommend downloading the STM32Cube_FW_U5_V1.8.0 package again and following the instructions in the ReadMe file.

    I hope my answer has helped you. When your question is answered, please select this topic as the solution that answered you, as it will help others find that answer faster.

    Thanks for your contribution.

    Dor_RH