초보의 아웅다웅 설계하기/STM32

IAR 에서 고정 영역 SRAM과 ROM 사용

로망와니 2018. 7. 6. 10:55


/*------------------------------------------------------------------------------*/

.icf

/*-Specials-*/

define symbol __ICFEDIT_intvec_start__ = 0x08000000;

/*-Memory Regions-*/

define symbol __ICFEDIT_region_ROM_start__    = 0x08000000;

define symbol __ICFEDIT_region_ROM_end__      = 0x0800FFFF;

define symbol __ICFEDIT_region_RAM_start__    = 0x20000240;

define symbol __ICFEDIT_region_RAM_end__      = 0x20016FFF;


/*-Sizes-*/

define symbol __ICFEDIT_size_cstack__ = 0x400;

define symbol __ICFEDIT_size_heap__   = 0x200;

/**** End of ICF editor section. ###ICF###*/


/* Rom에서 원하는 함수나 고정값을 넣을 영역 */

define symbol __ICFEDIT_Fixed_region_ROM_start__    = 0x08010000;

define symbol __ICFEDIT_Fixed_region_ROM_end__      = 0x0801FFFF;


/* Ram에서 원하는 변수를 넣을 영역 */

define symbol __ICFEDIT_Fixed_region_SRAM_start__    = 0x20000000;

define symbol __ICFEDIT_Fixed_region_SRAM_end__      = 0x200001FF;




define memory mem with size = 4G;

define region ROM_region      = mem:[from __ICFEDIT_region_ROM_start__   to __ICFEDIT_region_ROM_end__];

define region Fixed_ROM_region      = mem:[from __ICFEDIT_Fixed_region_ROM_start__   to __ICFEDIT_Fixed_region_ROM_end__];

define region Fixed_SRAM_region    = mem:[from __ICFEDIT_Fixed_region_SRAM_start__   to __ICFEDIT_Fixed_region_SRAM_end__];

define region RAM_region      = mem:[from __ICFEDIT_region_RAM_start__   to __ICFEDIT_region_RAM_end__];



place in Fixed_ROM_region {readonly object Fixed_ROM.o};


place in Fixed_SRAM_region   {readwrite section .Fixed_Sram };


initialize by copy { readwrite };

do not initialize  { section .noinit };

initialize by copy { section .Fixed_Sram };


/*------------------------------------------------------------------------------*/


Fixed_ROM.c

/*------------------------------------------------------------------------------*/

int FixedData(int a, int b)

{

return (a+b);

}

/*------------------------------------------------------------------------------*/


Fixed_SRAM.c

/*------------------------------------------------------------------------------*/

#pragma section =".Fixed_Sram"


#pragma default_variable_attributes = @ ".Fixed_Sram"

uint32_t FixedSRAMData[10];


/* Stop placing data in section Fixed_SRAM_region */

#pragma default_variable_attributes =

/*------------------------------------------------------------------------------*/