参考论坛一个帖子的配置方法,如下Init QSPI,以及读取时先发送 QSPI_QUAD_INOUT_FAST_READ_4_BYTE_ADDR_CMD,在接手500个字节的数据,可是时钟信号出来如图并不是连续的,然后读取速度就很慢。 QSPI_StaticTypeDef QSPI_UserInit(void) { uint32_t i; uint8_t QspiID[3]; __IO QSPI_StaticTypeDef __QspiStatus = QSPI_OUT_TIME; if(g_isQSPIInit) { return QSPI_OK; } g_isQSPIInit = 1; QUADSPI_Init(); __QspiStatus = QSPI_ResetMemory(&hqspi); if ( __QspiStatus != QSPI_OK) { printf("QSPI reset memory Error ... ... \r\n"); return QSPI_ERROR; } i = 0x100000; while(i --) { } QSPI_Read_ID(QSPI_READ_ID_CMD, (uint8_t *) & QspiID[0], 3); QSPI_AutoPollingMemReady(&hqspi); QSPI_DummyCyclesCfg(&hqspi); _QspiFlashInf.Id = (QspiID[0] << 16) | (QspiID[1] << 8) | QspiID[2]; #ifdef DEBUG printf("QSPI_READ_ID = 0x%X\r\n", _QspiFlashInf.Id ); #endif __QspiStatus = QSPI_Quad_Enter(); #ifdef DEBUG printf("QSPI_UserInit OK ... DD \r\n\r\n"); #endif return QSPI_OK; } void QUADSPI_Init(void) { hqspi.Instance = QUADSPI; HAL_QSPI_DeInit(&hqspi); hqspi.Init.FifoThreshold = 10; hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_HALFCYCLE; hqspi.Init.FlashSize = QSPI_FLASH_SIZE_LINE; hqspi.Init.ClockPrescaler = 1; hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_4_CYCLE; hqspi.Init.ClockMode = QSPI_CLOCK_MODE_3; hqspi.Init.FlashID = QSPI_FLASH_ID_1; hqspi.Init.DualFlash = QSPI_DUALFLASH_DISABLE; if (HAL_QSPI_Init(&hqspi) != HAL_OK) { } } /* int QSPI_Read(uint8_t* data, uint32_t address, uint32_t size) --Read data from QSPI flash A function to read data from QSPI flash Return an integer value (default QSPI_OK), a parameter for data buffer, a parameter for QSPI memory address, a parameter for data size. */ QSPI_StaticTypeDef QSPI_ReadBuff(uint8_t* data, uint32_t address, uint32_t size) { uint32_t __InstructionMode, __AddressMode, __DataMode; uint8_t readBuffer_RegVal = 0; if(QSPI_WorkMode) // Work In QUAD Model { __InstructionMode = QSPI_INSTRUCTION_4_LINES; __AddressMode = QSPI_ADDRESS_4_LINES; __DataMode = QSPI_DATA_4_LINES; } else { __InstructionMode = QSPI_INSTRUCTION_1_LINE; __AddressMode = QSPI_ADDRESS_1_LINE; __DataMode = QSPI_DATA_1_LINE; } if(QSPI_SendCmdData( QSPI_QUAD_INOUT_FAST_READ_4_BYTE_ADDR_CMD, __InstructionMode, __AddressMode, QSPI_ADDRESS_32_BITS, __DataMode, size, 4 , address, &readBuffer_RegVal, QSPI_SEND_CMD ) != QSPI_OK ) { return QSPI_ERROR; } if(QSPI_Receive( data, size) != QSPI_OK) return QSPI_ERROR; return QSPI_OK; } |
评分
查看全部评分
评分
查看全部评分