STM32F10x Device,ICF运用外部SRAM,Heap放入SRAM中。
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x08000200;
define symbol __ICFEDIT_region_ROM_end__= 0x0807FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__= 0x2000FFFF;
define symbol __ICFEDIT_region_EXT_SRAM_start__ = 0x64000000;
define symbol __ICFEDIT_region_EXT_SRAM_end__= 0x6407FFFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ =0x200;
define symbol __ICFEDIT_size_heap__= 0x80000;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region= mem:[from __ICFEDIT_region_ROM_start__to __ICFEDIT_region_ROM_end__];
define region RAM_region= mem:[from __ICFEDIT_region_RAM_start__to __ICFEDIT_region_RAM_end__];
define region EXT_SRAM_region= mem:[from __ICFEDIT_region_EXT_SRAM_start__to __ICFEDIT_region_EXT_SRAM_end__];
define block CSTACKwith alignment = 8, size = __ICFEDIT_size_cstack__{ };
define block HEAPwith alignment = 8, size = __ICFEDIT_size_heap__{ };
initialize by copy { readwrite };
do not initialize{ section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region{ readonly };
place in RAM_region{ readwrite, block CSTACK };
place in EXT_SRAM_region{ block HEAP };
编译 /GUI出产Library,然后在工程中引证。
在linker中运用自定义icf,以及/GUI的<.a>格局lib。
IAR->Option->Linker->Library->Additional libraries:$PROJ_DIR$\Debug\Exe\ GUI_Lib.a
/GUI编译生成library。
根本的设置就不说了,比方说LCDConf.h,GUITo hConf.h,GUIConf.h。需求留意的是,当运用GUI_SUPPORT_MEMDEV时,运用的内存量添加,故需求适度的将#define GUI_ALLOC_SIZE 64*1024扩大到够用停止,以避免stack溢出。
#define HEAPBASE((unsignedchar*)0x64000000)外部SRAM在FSMC的blankX,因地制宜。
因为运用外部SRAM作为heap,GUI_ALLOC的时分,修正
将原文件中的:
GUI_MEM_ALLOC GUI_HEAP GUI_Heap;
GUI_MEM_ALLOC tBlock aBlock[GUI_MAXBLOCKS];
修正为:
GUI_MEM_ALLOC GUI_HEAP *GUI_Heap;
GUI_MEM_ALLOC tBlock *aBlock;
在函数初始化时修正如下:
void GUI_ALLOC_Init(void) {
GUI_Heap = malloc(GUI_ALLOC_SIZE);
aBlock = malloc(GUI_MAXBLOCKS * sizeof(tBlock));
memset(HEAPBASE,0,GUI_ALLOC_SIZE+GUI_MAXBLOCKS * sizeof(tBlock));
将malloc申请到的内存初始化一下,假如工程函数中没有初始化外部RAM的数据,GUI分配不到内存,LCD无法显现。