cancel
Showing results for 
Search instead for 
Did you mean: 

QSPI with stm32cubeIDE on custom stm32f746IGT board

istepne
Associate III

Is there any one to help me on get QSPI work?

I am using n25q128 and the SPI pins;

 /**QUADSPI GPIO Configuration   

   PE2    ------> QUADSPI_BK1_IO2

   PF9    ------> QUADSPI_BK1_IO1

   PB2    ------> QUADSPI_CLK

   PD11    ------> QUADSPI_BK1_IO0

   PD13    ------> QUADSPI_BK1_IO3

   PB6    ------> QUADSPI_BK1_NCS

   */

I am trying to find out a sample code to get it work. I tried to test my hardware is OK or not via ST-Link External memory read&write but my hardware olsa used different pins. So, how can I change *.stldr file according to my hardware easily?

Regards,

Murat

void HAL_QSPI_MspInit(QSPI_HandleTypeDef* hqspi)

{

 GPIO_InitTypeDef GPIO_InitStruct = {0};

 if(hqspi->Instance==QUADSPI)

 {

 /* USER CODE BEGIN QUADSPI_MspInit 0 */

 /* USER CODE END QUADSPI_MspInit 0 */

   /* Peripheral clock enable */

   __HAL_RCC_QSPI_CLK_ENABLE();

   __HAL_RCC_GPIOE_CLK_ENABLE();

   __HAL_RCC_GPIOF_CLK_ENABLE();

   __HAL_RCC_GPIOB_CLK_ENABLE();

   __HAL_RCC_GPIOD_CLK_ENABLE();

   /**QUADSPI GPIO Configuration   

   PE2    ------> QUADSPI_BK1_IO2

   PF9    ------> QUADSPI_BK1_IO1

   PB2    ------> QUADSPI_CLK

   PD11    ------> QUADSPI_BK1_IO0

   PD13    ------> QUADSPI_BK1_IO3

   PB6    ------> QUADSPI_BK1_NCS

   */

   GPIO_InitStruct.Pin = GPIO_PIN_2;

   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

   GPIO_InitStruct.Pull = GPIO_NOPULL;

   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

   GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;

   HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);

   GPIO_InitStruct.Pin = GPIO_PIN_9;

   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

   GPIO_InitStruct.Pull = GPIO_NOPULL;

   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

   GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI;

   HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);

   GPIO_InitStruct.Pin = GPIO_PIN_2;

   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

   GPIO_InitStruct.Pull = GPIO_NOPULL;

   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

   GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;

   HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

   GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_13;

   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

   GPIO_InitStruct.Pull = GPIO_NOPULL;

   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

   GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;

   HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);

   GPIO_InitStruct.Pin = GPIO_PIN_6;

   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

   GPIO_InitStruct.Pull = GPIO_NOPULL;

   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

   GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI;

   HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

   /* QUADSPI interrupt Init */

   HAL_NVIC_SetPriority(QUADSPI_IRQn, 0, 0);

   HAL_NVIC_EnableIRQ(QUADSPI_IRQn);

 /* USER CODE BEGIN QUADSPI_MspInit 1 */

 /* USER CODE END QUADSPI_MspInit 1 */

 }

}

19 REPLIES 19
AVI-crak
Senior

The algorithm for working with memory n25q128 is located in the documentation for this chip.

The algorithm for working with the qspi interface is in the stm32f746IGT documentation.

The program code for working n25q128 together with stm32f746IGT is already a driver, it will be unique in any case.

I can provide my example for the S25FL256S chip https://bitbucket.org/AVI-crak/system_f746/src/default/qspi_driver_S25FL256S/qspi_rw.c

You need to prove out your HW from your own application.

The STLDR are not particularly easy nor reliable.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I accept PayPal

STM32F746IG

N25Q128A

CS PB6 AF10

CLK PB2 AF9

D0 PD11 AF9

D1 PF9 AF10

D2 PE2 AF9

D3 PD13 AF9

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Slightly different configuration

STM32F750N8

N25Q128A

CS PB6 AF10

CLK PB2 AF9

D0 PD11 AF9

D1 PD12 AF9

D2 PF7 AF9

D3 PD13 AF9

#STLDR

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Thank you for the file upload.

But there is still something wrong.

Using software ST-LINK Utility v4.2.0.0 and the STM32F072B-DISCO kits SWD port (tried with the fw v2.j29.S0 and also tried with fw v2.j31.S0) reads as 0x99999999 all registers starting from the address 0x90000000 (external memory). And when I try to change the values then the ST-LINK gives an error (message is "Error occured during memory writing!" )

Now I wonder that, is there a software bug on ST-LINK or hardware bug on my side?

Regards,

Murat

Current version should be v4.5

https://www.st.com/en/development-tools/stsw-link004.html

I've been using STM32 Cube Programmer predominantly

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Forgot to enable GPIOF, updated .stldr images

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
istepne
Associate III

Found the problem!

I have a look up the datasheet and the instructions that I send.

And the instruction 81h was not on the datasheet of the QSPI IC (winbond). I changed the W25Q128JVSIM (winbond) to MT25QL128ABA1ESE (Micron).

After that I can read and write via External Memory on CubeProgrammer (Sometimes can not RW).

And also I realized that the write operations to QSPI IC, can only change bits 1 to 0. So, I have to manage the write operations as; firstly reading 4096bytes from QSPI to RAM and Sector_Erase command and finally writing from RAM to QSPI with 4096bytes operation.

Regards,

Murat

Dams
Associate III

Hello,

I'm also using a SMT32F746IG with a MT25QL128ABA1E but my Hardware configuration seems to be slightly different:

  /**QUADSPI GPIO Configuration   

  PE2   ------> QUADSPI_BK1_IO2

  PF6   ------> QUADSPI_BK1_IO3

  PF8   ------> QUADSPI_BK1_IO0

  PF9   ------> QUADSPI_BK1_IO1

  PB2   ------> QUADSPI_CLK

  PB6   ------> QUADSPI_BK1_NCS 

  */

When I'm using .stldr file I'm not able to write on the external memory and when I read I get 0x99999999. Is the problem come from the stldr file ?

Any help shall be appreciated !

Regards,

Dams