cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L475 QSPI read extern flash status register(0x05) 9 clock.

lwen.1
Associate II

//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;

}

3 REPLIES 3
lwen.1
Associate II

a lot of extern flash require the clock accurate,so the last( 9 clock) is not allow.

lwen.1
Associate II

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.

lwen.1
Associate II

I configure the QSPI to single Dual-Spi is also find the 9 clock.

anyone find it bugs