2020-03-22 11:11 PM
//My QSPI init function
u8 QSPI_Init(void)
{
QSPI_Handler.Instance = QUADSPI; //QSPI
QSPI_Handler.Init.ClockPrescaler = 4;
QSPI_Handler.Init.FifoThreshold = 4;
QSPI_Handler.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_HALFCYCLE;
QSPI_Handler.Init.FlashSize = POSITION_VAL(0x1000000) - 1;
QSPI_Handler.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_4_CYCLE;
QSPI_Handler.Init.ClockMode = QSPI_CLOCK_MODE_0;
if(HAL_QSPI_Init(&QSPI_Handler) == HAL_OK) return 0;
else return 1;
}
void QSPI_Send_CMD(u32 instruction, u32 address, u32 dummyCycles, u32 instructionMode, u32 addressMode, u32 addressSize, u32 dataMode)
{
QSPI_CommandTypeDef Cmdhandler;
Cmdhandler.Instruction = instruction;
Cmdhandler.Address = address;
Cmdhandler.DummyCycles = dummyCycles;
Cmdhandler.InstructionMode = instructionMode;
Cmdhandler.AddressMode = addressMode;
Cmdhandler.AddressSize = addressSize;
Cmdhandler.DataMode = dataMode;
Cmdhandler.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;
Cmdhandler.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE;
Cmdhandler.DdrMode = QSPI_DDR_MODE_DISABLE;
Cmdhandler.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY;
HAL_QSPI_Command(&QSPI_Handler, &Cmdhandler, 5000);
}
u8 QSPI_Receive(u8* buf, u32 datalen)
{
QSPI_Handler.Instance->DLR = datalen - 1;
if(HAL_QSPI_Receive(&QSPI_Handler, buf, 5000) == HAL_OK) return 0;
else return 1;
}
//My QSPI read the flash status regsiter program as follow:
u8 W25QXX_ReadSR(u8 regno)
{
u8 byte = 0, command = 0;
switch(regno)
{
case 1:
command = W25X_ReadStatusReg1;
break;
case 2:
command = W25X_ReadStatusReg2;
break;
case 3:
command = W25X_ReadStatusReg3;
break;
default:
command = W25X_ReadStatusReg1;
break;
}
QSPI_Send_CMD(command, 0, 0, QSPI_INSTRUCTION_1_LINE, QSPI_ADDRESS_NONE, QSPI_ADDRESS_8_BITS, QSPI_DATA_1_LINE);
QSPI_Receive(&byte, 1);
return byte;
}
2020-03-22 11:14 PM
a lot of extern flash require the clock accurate,so the last( 9 clock) is not allow.
2020-03-22 11:28 PM
I don't know the problem happen where (the QSPI hardware or the read extern flash register program is error), I wish anyone can help me, thank you very much.
2020-03-24 04:27 AM
I configure the QSPI to single Dual-Spi is also find the 9 clock.
anyone find it bugs