QSPI仅接收数据异常
芯片信号:
STM32H743II
测试Demo如下:
void QSpiDemo(void){
uint8_t aucBuf[2];
MX_QUADSPI_Init(); /* QSPI初始化 */
aucBuf[0] = 4 << 1;
aucBuf[1] = 0;
QSPI_WriteRegEx(aucBuf, 2); /* 发送2字节数据 */
QSPI_ReadRegEx(aucBuf, 2); /* 接收2字节数据 */
}
uint8_t QSPI_WriteRegEx(uint8_t *_pBuf, uint16_t _usWriteSize)
{
QSPI_CommandTypeDef sCommand = {0};
/* 基本配置 */
sCommand.DummyCycles = 0; /* 不需要空周期 */
sCommand.Instruc
tionMode = QSPI_INSTRUCTION_NONE; /* No instruction */
sCommand.AddressMode = QSPI_ADDRESS_NONE; /* No address ;QSPI_ADDRESS_1_LINE */
sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; /* 无交替字节 */
sCommand.DataMode = QSPI_DATA_1_LINE; /* 1线数据方式 */
sCommand.NbData = _usWriteSize; /* 写数据大小 */
sCommand.DdrMode = QSPI_DDR_MODE_DISABLE; /* 不支持DDR */
sCommand.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; /* DDR模式,数据输出延迟 */
sCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; /* 仅发送一次命令 */
if(HAL_QSPI_Command( hqspi, sCommand, 5000) != HAL_OK)
{
return 0;
}
if(HAL_QSPI_Transmit( hqspi, _pBuf, 5000) != HAL_OK)
{
return 0;
}
return 1;
}
uint8_t QSPI_ReadRegEx(uint8_t *_pBuf, uint16_t _usReadSize)
{
QSPI_CommandTypeDef sCommand = {0};
sCommand.DummyCycles = 0; /* 不需要空周期 */
sCommand.InstructionMode = QSPI_INSTRUCTION_NONE; /* No instruction */
sCommand.AddressMode = QSPI_ADDRESS_NONE; /* No address ;QSPI_ADDRESS_1_LINE */
sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; /* 无交替字节 */
sCommand.DataMode = QSPI_DATA_1_LINE; /* 1线数据方式 */
sCommand.NbData = _usReadSize; /* 写数据大小 */
sCommand.DdrMode = QSPI_DDR_MODE_DISABLE; /* 不支持DDR */
sCommand.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; /* DDR模式,数据输出延迟 */
sCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; /* 仅发送一次命令 */
if(HAL_QSPI_Command( hqspi, sCommand, 5000) != HAL_OK)
{
return 0;
}
if(HAL_QSPI_Receive( hqspi, _pBuf, 5000) != HAL_OK)
{
return 0;
}
return 1;
}
读取数据时,每次执行到HAL_QSPI_Receive函数MODIFY_REG(hqspi->Instance->CCR, QUADSPI_CCR_FMODE, QSPI_FUNCTIONAL_MODE_INDIRECT_READ)时,相关寄存器就会异常
如果将接收DummyCycles配置成2时,则可以正常接收数据,但是时序会异常导致接收数据不正确。