OCTOSPI with STM32H573 and ISSI external flash IS25LX064. Memory mapped write causes Hardfault
Hi @Tesla DeLorean ,
I use the IS25LX064 OctoSPI Flash memory with the STM32H573 and i can write and read from memory using direct mode. In memory mapped mode i can read the flash correctly for 0x90000000 but writing at 0x90000000 using memory mapped mode causes a hard fault with precise error at 0x90000000.
Does that mean it's not possible to write to the flash in memory mapped mode? RM0481 says:

Line 44 fails. Line 34 and 35 are working fine. And if i write using line 34 and then enable the memory mapped mode the read sequence from line 54 works fine, which means the memory mapped mode configuration is ok.
int main(void) {
/* USER CODE BEGIN 1 */
__IO uint8_t *mem_addr;
uint32_t address = 0;
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_ICACHE_Init();
MX_OCTOSPI1_Init();
/* USER CODE BEGIN 2 */
ResetMemory(&hospi1);
OSPI_DummyCycles(&hospi1);
OSPI_EraseSector(&hospi1, address);
/*---- direct read and write works fine--------*/
//OSPI_Write(&hospi1, aTxBuffer, address, BUFFERSIZE);
//OSPI_Read(&hospi1, aRxBuffer, address, BUFFERSIZE);
OSPI_EnableMemoryMapped(&hospi1);
/*It is not recommended to program the flash memory using the memory-mapped writes:
the indirect-write mode fulfills this operation. See RM0481 Rev 2 section 23.4.15*/
/* Writing Sequence ----------------------------------------------- */
mem_addr = (uint8_t*) (OCTOSPI1_BASE + address);
for (uint16_t index = 0; index < BUFFERSIZE; index++) {
*mem_addr = aTxBuffer[index]; /*-------- bus fault here -----*/
mem_addr++;
}
/* In memory-mapped mode, not possible to check if the memory is ready
after the programming. So a delay corresponding to max page programming
time is added */
HAL_Delay(2);
/* Reading Sequence ----------------------------------------------- */
mem_addr = (uint8_t*) (OCTOSPI1_BASE);
for (uint16_t index = 0; index < BUFFERSIZE; index++) {
if (*mem_addr != aTxBuffer[index]) {
Error_Handler();
}
mem_addr++;
}
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1) {
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
Thank you

