TouchGFX memory mapped flash memory

For most projects, it is recommended to use external flash memory as this allows the application to use multiple large images. Even the most common applications can quickly fill up the internal flash memory.

1. Configure QSPI ( embedded basic knowledge, not analyzed here)

2. Write W25Q256 configuration code (copy punctual atomic routine)

w25q256.c

#include "w25q256.h"
#include "quadspi.h"

#define QUAD_INOUT_FAST_READ_4_BYTE_ADDR_CMD 0xEC
void QSPI_MemoryMapped(void)
{
	QSPI_CommandTypeDef s_command = {0};
	QSPI_MemoryMappedTypeDef s_mem_mapped_cfg = {0};

	s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE;
	s_command.AddressSize = QSPI_ADDRESS_32_BITS;
	s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE;
	s_command.DdrMode = QSPI_DDR_MODE_DISABLE;
	s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY;
	s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;

	s_command.Instruction = QUAD_INOUT_FAST_READ_4_BYTE_ADDR_CMD;
	s_command.AddressMode = QSPI_ADDRESS_4_LINES;
	s_command.DataMode = QSPI_DATA_4_LINES;
	s_command.DummyCycles = 6;

	s_mem_mapped_cfg.TimeOutActivation = QSPI_TIMEOUT_COUNTER_DISABLE;
	s_mem_mapped_cfg.TimeOutPeriod = 0;

	if(HAL_QSPI_MemoryMapped(&hqspi, &s_command, &s_mem_mapped_cfg) != HAL_OK)
	{
		Error_Handler();
	}
}
quadspi.c
 
  /* USER CODE BEGIN QUADSPI_Init 2 */
	QSPI_MemoryMapped();
  /* USER CODE END QUADSPI_Init 2 */

3. Modify the scatter loading file

; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************

LR_IROM1 0x08000000 0x00200000  {    ; load region size_region
  ER_IROM1 0x08000000 0x00200000  {  ; load address = execution address
   *.o (RESET, +First)
   *(InRoot$$Sections)
   .ANY (+RO)
   .ANY (+XO)
  }
  RW_IRAM1 0x20000000 0x00020000  {  ; RW data
   .ANY (+RW +ZI)
  }
  RW_IRAM2 0x24000000 0x00080000  {
   *(.RAM_D1)
  }
  RW_IRAM3 0x30000000 0x00048000  {
   *(.RAM_D2)
  }
  RW_IRAM4 0x38000000 0x00010000  {
   *(.RAM_D3)
  }
;  RW_IRAM5 0xC0000000 UNINIT 0x02000000  {
;   *(.RAM_SDRAM)
;  }
}

LR_ROM1 0x90000000 0x02000000  {
  ER_ROM1 0x90000000 0x02000000  {  ; load address = execution address
	*.o (ExtFlashSection)
	*.o (TextFlashSection)
	*.o (FontFlashSection)
  }
}

4. Add download algorithm (embedded basic knowledge, no analysis here)

5. Create variables and run the simulation

/* USER CODE BEGIN PV */
//uint16_t framebuffer[1024 * 200];  //16 bpp framebuffer
uint16_t *framebuffer = (uint16_t *)0xC0000000;  //16 bpp framebuffer

__attribute__((section ("ExtFlashSection"))) const unsigned char qspi_flash[100];
/* USER CODE END PV */

Guess you like

Origin blog.csdn.net/lushoumin/article/details/132447627