AnsweredAssumed Answered

Problem with QSPI in STM32F7

Question asked by Pilous Droip on Feb 6, 2018
Latest reply on Feb 9, 2018 by Matthew Staben

Hello.

 

I have a problem with QSPI. I try everything, but program doesn't work.

 

I split my program to some parts.

qspi_gpio_ini(); /* Init GPIO pins */
qspi_dma_init(); /* Init DMA */
qspi_init(); /* Init QSPI */
qspi_config(); /* Config QSPI */
QSPI_Cmd(ENABLE); /* Enable QSPI */

QSPI_WriteEnable();   /* Enable Write*/

 

qspi_gpio_init(); //is here ----> click. This is work fine.

qspi_dma_ini(); //is here -----> click. Init DMA and I don't know, if this part working. But it has time.

 

And now. qspi_init();

/**
* Set register:
*
* CR->PRESCALER = 0x04
* CR->SSHIFT = 0x01
* DCR->FSIZE = 0x17
*/
void qspi_init(void)
{
/* Initialize QSPI ------------------------------------------------------ */
LL_AHB3_GRP1_EnableClock(LL_AHB3_GRP1_PERIPH_QSPI);
QSPI_StructInit(&QSPI_InitStructure);
QSPI_InitStructure.QSPI_SShift = QSPI_SShift_HalfCycleShift; //By default, the QUADSPI samples data 1/2 of a CLK cycle after the data is driven by the Flash memory
QSPI_InitStructure.QSPI_Prescaler = 11; //Number = (216MHz / Freq)-1 (Freq = 50MHz)
QSPI_InitStructure.QSPI_CKMode = QSPI_CKMode_Mode0; //By default, nCS is high, deselecting the external Flash memory
QSPI_InitStructure.QSPI_CSHTime = QSPI_CSHTime_1Cycle; //Chip select high time
QSPI_InitStructure.QSPI_FSize = 23; //Number = 16MB is = (2^24) where 24-1 is Number
QSPI_InitStructure.QSPI_FSelect = QSPI_FSelect_1; //Flash memory selection
QSPI_InitStructure.QSPI_DFlash = QSPI_DFlash_Disable; //Dual Flash mode disable
QSPI_Init(&QSPI_InitStructure);

QSPI_SetFIFOThreshold(0);
}

 

Next critical function is: qspi_config(). It is first setting.

/**
* Set registers:
* CCR->ADSIZE = 0x02
* CCR->DHHC = 0x01
* CCR->IMODE = 0x01
*/
void qspi_config(void)
{
/* Command default config */
QSPI_ComConfig_StructInit(&QSPI_ComConfig_InitStructure);
QSPI_ComConfig_InitStructure.QSPI_ComConfig_FMode = QSPI_ComConfig_FMode_Indirect_Write; //QUADSPI is in indirect write mode, where bytes are sent to the Flash memory during the data phase
QSPI_ComConfig_InitStructure.QSPI_ComConfig_SIOOMode = QSPI_ComConfig_SIOOMode_Disable; //Send instruction only-once
QSPI_ComConfig_InitStructure.QSPI_ComConfig_ABSize = QSPI_ComConfig_ABSize_8bit; //number of alternate bytes
QSPI_ComConfig_InitStructure.QSPI_ComConfig_ADSize = QSPI_ComConfig_ADSize_24bit; //max. addressable memory (2^24)
/* this set is from DM00224583.pdf, page 409, picture 63 */
QSPI_ComConfig_InitStructure.QSPI_ComConfig_IMode = QSPI_ComConfig_IMode_1Line; //instruction phase is skipped
QSPI_ComConfig_InitStructure.QSPI_ComConfig_ADMode = QSPI_ComConfig_ADMode_NoAddress; //address phase is skipped
QSPI_ComConfig_InitStructure.QSPI_ComConfig_ABMode = QSPI_ComConfig_ABMode_NoAlternateByte; //alternate-bytes phase is skipped
QSPI_ComConfig_InitStructure.QSPI_ComConfig_DummyCycles = 0; //Set dummy cycle
QSPI_ComConfig_StructInit(&QSPI_ComConfig_InitStructure);
QSPI_Cmd(ENABLE);

/* QSPI_ITConfig(QSPI_IT_SM , ENABLE);
NVIC_SetPriority(QUADSPI_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 0, 0));
NVIC_EnableIRQ(QUADSPI_IRQn);*/
}

And here is my problem. When I call QSPI_WriteEnable(), program stop and wait on QSPI_FLAG_SM. But I don know, why.

 

Here is function: QSPI_Write_Enable()

void QSPI_WriteEnable(void)
{
/* Command Config for Write Enable */
QSPI_ComConfig_InitStructure.QSPI_ComConfig_DHHC = QSPI_ComConfig_DHHC_Disable;
QSPI_ComConfig_InitStructure.QSPI_ComConfig_DDRMode = QSPI_ComConfig_DDRMode_Disable;
QSPI_ComConfig_InitStructure.QSPI_ComConfig_FMode = QSPI_ComConfig_FMode_Indirect_Write;
QSPI_ComConfig_InitStructure.QSPI_ComConfig_SIOOMode = QSPI_ComConfig_SIOOMode_Disable;
QSPI_ComConfig_InitStructure.QSPI_ComConfig_ABSize = QSPI_ComConfig_ABSize_8bit;
QSPI_ComConfig_InitStructure.QSPI_ComConfig_ADSize = QSPI_ComConfig_ADSize_24bit;
QSPI_ComConfig_InitStructure.QSPI_ComConfig_DMode = QSPI_ComConfig_DMode_NoData;
QSPI_ComConfig_InitStructure.QSPI_ComConfig_ADMode = QSPI_ComConfig_ADMode_NoAddress;
QSPI_ComConfig_InitStructure.QSPI_ComConfig_ABMode = QSPI_ComConfig_ABMode_NoAlternateByte;
QSPI_ComConfig_InitStructure.QSPI_ComConfig_IMode = QSPI_ComConfig_IMode_1Line;
QSPI_ComConfig_InitStructure.QSPI_ComConfig_Ins = WRITE_ENABLE_CMD ;
QSPI_ComConfig_InitStructure.QSPI_ComConfig_DummyCycles = 0;
QSPI_ComConfig_Init(&QSPI_ComConfig_InitStructure);

QSPI_ITConfig(QSPI_IT_SM, ENABLE);
/* Switch to Autopolling mode for the end of the Command */
while(QSPI_GetFlagStatus(QSPI_FLAG_BUSY) != RESET){};
QSPI_AutoPollingMode_Config(0x02, 0x02, QSPI_PMM_AND);
QSPI_SetDataLength(0x01);
QSPI_AutoPollingMode_SetInterval(0x10);
QSPI_AutoPollingModeStopCmd(ENABLE);
QSPI_SetDataLength(0x00);

QSPI_ComConfig_InitStructure.QSPI_ComConfig_FMode = QSPI_ComConfig_FMode_Auto_Polling;
QSPI_ComConfig_InitStructure.QSPI_ComConfig_ADMode = QSPI_ComConfig_ADMode_NoAddress;
QSPI_ComConfig_InitStructure.QSPI_ComConfig_DMode = QSPI_ComConfig_DMode_1Line;
QSPI_ComConfig_InitStructure.QSPI_ComConfig_Ins = READ_STATUS_REG_CMD;
QSPI_ComConfig_Init(&QSPI_ComConfig_InitStructure);

//QSPI_ClearFlag(QSPI_FLAG_SM | QSPI_FLAG_TE | QSPI_FLAG_FT | QSPI_FLAG_TO | QSPI_FLAG_TC);

while(QSPI_GetFlagStatus(QSPI_FLAG_SM) == RESET){};
QSPI_ClearFlag(QSPI_FLAG_SM);
QSPI_ClearFlag(QSPI_FLAG_TC);
while(QSPI_GetFlagStatus(QSPI_FLAG_BUSY) != RESET){};
asm("NOP");
}

In attach files are my use library for QSPI and scope views on signals.

 

Setting:

  1. STM32F767ZI
  2. Clock: 216MHz
  3. Clock QSPI: 18MHz
  4. Mode: single-SPI mode
  5. Memory connect:
  • PB10 - CS flash
  • PF8 - IO0 (SI)
  • PF9 - IO1 (SO)
  • PF10 - SCK

6. Connect memory: is25lp064

 

Any idea what's wrong? I tried to set up registers but the result was the same.

Attachments

Outcomes