2017-01-26 07:00 AM
Hi,
The QSPI peripheral in the STM32F7 is wonderful. Nice job ST!
One question: Is there any way to exit memory mapped mode and go back to indirect RX/TX through the HAL driver?
Thanks!
Bobby2017-01-26 07:20 AM
I tried just re-initializing the peripheral, which worked with the additional step of clearing out FMODE before the re-init. The code below seems to work:
/* Stop memory mapped mode */ QUADSPI->CCR &= (~(QUADSPI_CCR_FMODE)); /* ReInitialize QuadSPI ------------------------------------------------------ */ HAL_QSPI_DeInit(&hqspi);/* ClockPrescaler set to 2, so QSPI clock = 216MHz / (2+1) = 72MHz */
hqspi.Init.ClockPrescaler = 2; hqspi.Init.FifoThreshold = 4; hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_HALFCYCLE; hqspi.Init.FlashSize = POSITION_VAL(0x1000000) - 1; hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_2_CYCLE; hqspi.Init.ClockMode = QSPI_CLOCK_MODE_0; hqspi.Init.FlashID = QSPI_FLASH_ID_1; hqspi.Init.DualFlash = QSPI_DUALFLASH_DISABLE;if (HAL_QSPI_Init(&hqspi) != HAL_OK)
2017-01-26 08:57 AM
Hi,
Refer also to this application note
, it may help you.-Nesrine-
2017-06-08 09:47 AM
Hi Bobby,
There is no need to completely re-initilize the QSPI preipheral. The memory-mapped mode can be deactivated by changing the FMODE bits in the QUADSPI_CCR register when BUSY is cleared. In Memory-mapped mode, BUSY goes high as soon as the first memory-mapped access occurs. Because of the prefetch operations, BUSY does not fall until there is a timeout, there is an abort, or the peripheral is disabled.
Using the an abort and the HAL library, you can exit out of QSPI memory-mapped mode using the following code:
if
(HAL_QSPI_MemoryMapped(&QSPIHandle, &sCommand, &sMemMappedCfg) != HAL_OK){ Error_Handler(); }/* ... QSPI in memory-mapped mode ... */
/* Clear busy bit */
HAL_QSPI_Abort(&QSPIHandle);/* WARNING: Do not make any other memory-mapped access (even using debugger) *//* Go back to indirect mode */if (HAL_QSPI_Command(&QSPIHandle, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK){ Error_Handler(); }if
(HAL_QSPI_Receive(&QSPIHandle, aRxBuffer, 1000) != HAL_OK) { Error_Handler();}Guillaume2018-06-05 11:20 AM
Hi Guillaume,
I have some problem with the Abort command: I'm able to use HAL Abort function only when the 'OSPI Timeout Activation' is disable and at least one read request is done on the mapped memory.
If I try to use the Abort function without the above conditions, the function hangs waiting for the Transmission Complete flag to be set:
/* Wait until the transfer complete flag is set to go back in idle state */
status = OSPI_WaitFlagStateUntilTimeout(hospi, HAL_OSPI_FLAG_TC, SET, tickstart, hospi->Timeout);
and after the Timeout (5 seconds default timeout) the function returns
HAL_ERROR
.Many Thanks!
Matteo