STM32L562 hard fault in SPI_WaitFifoStateUntilTimeout
I am using MX25 NOR flash memory 256Mbit (https://www.mxic.com.tw/en-us/products/NOR-Flash/Serial-NOR-Flash/Pages/spec.aspx?p=MX25L25645G&m=Serial%20NOR%20Flash&n=PM2075#Technical-Documents) and I am mounting a littleFS file system on it. The memory communicates through SPI with an STM32L562 microcontroller. After writting and reading files multiple times (more than 100) I get a hard fault. MX25_CMD.c is provided by the memory manufacturer and calls HAL_SPI_Receive(). It seems that the hard fault occurs in SPI_WaitFifoStateUntilTimeout().
I am really blocked by this issue and I don't know towards which direction to look for solutions. Does anybody have any suggestions?
The function calls (from recent to older) before the hard fault:
SPI_WaitFifoStateUntilTimeout() at stm32l5xx_hal_spi.c:3’989 0x80338f6
SPI_EndRxTxTransaction() at stm32l5xx_hal_spi.c:4’101 0x8033ae2
HAL_SPI_TransmitReceive() at stm32l5xx_hal_spi.c:1’535 0x8033566
HAL_SPI_Receive() at stm32l5xx_hal_spi.c:1’020 0x8032f52
GetByte() at MX25_CMD.c:685 0x801980e
