cancel
Showing results for 
Search instead for 
Did you mean: 

how to write the QSPI flash memory

Yugenthar
Senior

Hello everyone!!!

I'm yugenthar

Still I am working in QSPI concept in stm32f746 disco board

I tried to write the data for QSPI flash memory but I can't able to write and read the QSPI flash memory

I have attached my code and snap pls find and give any solution


_legacyfs_online_stmicro_images_0693W00000bjmI1QAI.png

/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "quadspi.h"
#include "gpio.h"
 
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
 
/* USER CODE END Includes */
 
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
uint8_t *writebuf = "Hello world from QSPI !";
 
uint8_t readbuf[100];
 
uint16_t number = 1234;
uint8_t buf[5];
/* USER CODE END PTD */
 
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
 
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
typedef  void (*pFunction)(void);
pFunction JumpToApplication;
 
#define APPLICATION_ADDRESS 0x90000000
/* USER CODE END PM */
 
/* Private variables ---------------------------------------------------------*/
 
/* USER CODE BEGIN PV */
 
/* USER CODE END PV */
 
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
/* USER CODE BEGIN PFP */
 
/* USER CODE END PFP */
 
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
 
/* USER CODE END 0 */
 
/**
  * @brief  The application entry point.
  * @retval int
  */
int main(void)
{
  /* USER CODE BEGIN 1 */
 
  /* USER CODE END 1 */
 
  /* Enable I-Cache---------------------------------------------------------*/
  SCB_EnableICache();
 
  /* Enable D-Cache---------------------------------------------------------*/
  SCB_EnableDCache();
 
  /* MCU Configuration--------------------------------------------------------*/
 
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();
 
  /* USER CODE BEGIN Init */
 
  /* USER CODE END Init */
 
  /* Configure the system clock */
  SystemClock_Config();
 
  /* USER CODE BEGIN SysInit */
 
  /* USER CODE END SysInit */
 
  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_QUADSPI_Init();
  /* USER CODE BEGIN 2 */
 
   if (CSP_QUADSPI_Init() != HAL_OK)
   {
 	  Error_Handler();
   }
 
 
 /****************** FOR SIMPLE WRITE READ ********************/
 	// Comment out these if you are using the EXT MEM BOOT
 
   if (CSP_QSPI_Erase_Chip() != HAL_OK)
   {
 	  Error_Handler();
   }
 
 
   sprintf (buf, "%u", number);
   if (CSP_QSPI_Write(buf, 0, strlen (buf)) != HAL_OK)
   {
 	  Error_Handler();
   }
 
 
   if (CSP_QSPI_Read(readbuf, 0, 100) != HAL_OK)
   {
 	  Error_Handler();
   }
 
 /*************************************************/
 
 
 /***********************  FOR EXT MEM BOOT *************************/
 	// Comment out these if you are using the simple Read Write
 
   if (CSP_QSPI_EnableMemoryMappedMode() != HAL_OK)
    {
 	  Error_Handler();
    }
 
 
   // Disable the cache
   SCB_DisableDCache();
   SCB_DisableICache();
 
 
   // Disable the systick interrupt
   SysTick->CTRL = 0;
 
 
   /* Initialize user application's Stack Pointer & Jump to user application */
   JumpToApplication = (pFunction) (*(__IO uint32_t*) (APPLICATION_ADDRESS + 4));  // Reset Handler
   __set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);   // stack pointer
   JumpToApplication();	  // make the jump

ution are example code

5 REPLIES 5

Erasing the entire memory is probably overkill.

You don't really describe what the issue is. ie your expectation vs what you're seeing.

The code here is very superficial, top level stuff.

Not sure there's a lot of interest in describing and debugging functionality like this.

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

Hai sir ,

I am using stm32f746 disco board its in build QSPI memory... first i try to write one data to qspi memory but is note store in qspi flash region but is store normal flash region.thats problem i ahve tried all code and tutorial and google but not give better sollution .that my problem

my expectation only store the data in qspi memory

Hello sir!!

I have one doubt for QSPI MT25QL series External flash ..

my doubt is any external flash loader is available for Mt25Ql driver c file in github .

Pls give the link or tutorial link sir

KDJEM.1
ST Employee

Hello @Yugenthar​ ,

I recommend you to start from an available example. 

For that I recommend you to take a look to this QSPI_ReadWrite_IT example running on STM32746G-Discovery board.

This example describes how to erase a part of a QSPI memory, write data in Interrupt mode, read data

in interrupt mode and compare the result in an infinite loop.

So, try to get inspired from the instructions in the readme file.

I hope this help you!

Kaouthar

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.