2019-09-02 02:49 AM
Dear all,
I am trying to communicate to a flash memory using the STM32H750 micro and its QUADSPI interface. For this I use the STM32H750B-DK Discovery board which provides a dual external flash
memory (MT25QL512). In my first example I am just trying to read some memory locations which I previously pogrammed suing the ST-Link Utility.
The program is straightforward, I read 16 bytes at the time and I print them using the UART interface. The problem I am experiencing is the following: it seems that one byte every two is skipped. Please look at the pictures above showing the content of the memory (ST-LINK Utility) and the output of the virtual port. (Attached view of terminal and memory content)
What am I doing fundamentally wrong?
Here is the part of the code I am using.
Initialization QUADSPI:
static void MX_QUADSPI_Init(void)
{
/* QUADSPI parameter configuration*/
hqspi.Instance = QUADSPI;
hqspi.Init.ClockPrescaler = 2;
hqspi.Init.FifoThreshold = 16;
hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_NONE;
hqspi.Init.FlashSize = 26;
hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_6_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)
{
Error_Handler();
}
/* USER CODE BEGIN QUADSPI_Init 2 */
/* USER CODE END QUADSPI_Init 2 */
}
QSPI_read function:
uint8_t QSPI_Read(uint8_t* pData, uint32_t ReadAddr, uint32_t Size)
{
QSPI_CommandTypeDef s_command;
/* Initialize the read command */
s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE;
s_command.Instruction = READ_CMD;
s_command.AddressMode = QSPI_ADDRESS_1_LINE;
s_command.AddressSize = QSPI_ADDRESS_32_BITS;
s_command.Address = ReadAddr;
s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_1_LINE;
s_command.AlternateBytesSize = QSPI_ALTERNATE_BYTES_8_BITS;
s_command.DataMode = QSPI_DATA_1_LINE;
s_command.DummyCycles = 0;
s_command.NbData = Size;
s_command.DdrMode = QSPI_DDR_MODE_DISABLE;
s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY;
s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;
/* Configure the command */
if (HAL_QSPI_Command(&hqspi, &s_command, 1000) != HAL_OK)
{
return HAL_ERROR;
}
/* Reception of the data */
if (HAL_QSPI_Receive(&hqspi, pData, 1000) != HAL_OK)
{
return HAL_ERROR;
}
return HAL_OK;
}
The While(1) :
while (1)
{
QSPI_Read(qspi_aRxBuffer, flash_address, BUFFER_SIZE);
HAL_Delay(10);
flash_address = flash_address + 16;
HAL_UART_Transmit(&huart3,qspi_aRxBuffer,BUFFER_SIZE,1000);
HAL_GPIO_TogglePin(GPIOI, GPIO_PIN_13);
HAL_GPIO_TogglePin(GPIOJ, GPIO_PIN_2);
HAL_Delay(500);
}
2019-09-02 03:35 AM
This looks strange:
hqspi.Init.DualFlash = QSPI_DUALFLASH_DISABLE;
You use only one flash chip, and hence you get only every other byte.
2019-09-02 03:40 AM
It is look likes ST-Link Utility flash data in QSPI_DUAL_FLASH mode. So you also need read data with QSPI_DUALFLASH_ENABLE option.
2019-09-02 06:07 AM
Dear @oleksandr.karbivsky , thank you for your answer. I modified the project adding the dual memory interface and it works fine. Therefore it seems that as you said STLink flashes the data in dual mode. I am wondering if there is a way to select SINGLE mode. I will do another test writing to the memory from the uC and reading back. Thank you very much, Matteo