微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > IAR STM32 函数和变量的绝对地址定位

IAR STM32 函数和变量的绝对地址定位

时间:11-10 来源:互联网 点击:

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

这是.icf文件

/*###ICF### Section handled by ICF editor, dont touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x08004000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x08004000;
define symbol __ICFEDIT_region_ROM_end__ = 0x08020000;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x2000BFFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0x400;
define symbol __ICFEDIT_size_heap__ = 0x200;
/**** 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 block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with 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 at address mem:0x08017000 { readonly section .sendstr};
place at address mem:0x08018500 { readonly section .MYSEG};

place at address mem:0x08018000 { section .text object test.o };

place in ROM_region { readonly };
place in RAM_region { readwrite,
block CSTACK, block HEAP };

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

main.c

/* Includes ------------------------------------------------------------------*/
//#include "stm32f10x.h"
#include "string.h"
#include "stdio.h"

void sendstr(unsigned *buf,unsigned shortlen) @".sendstr"
{
}

extern void test(void);
extern void main1(void);
int main(void)
{
test();
}

#ifdefUSE_FULL_ASSERT
/**
* @briefReports the name of the source file and the source line number
* where the assert_param error has occurred.
* @paramfile: pointer to the source file name
* @paramline: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

/* Infinite loop */
while (1)
{
}
}
#endif

/**
* @}
*/

/**
* @}
*/

/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

test.c

//__no_init char array1[100]@0x2000B000;

//char array1[100];

const char str1[8]@".MYSEG"="test11!!";
const char str2[8]@".MYSEG"="test66!!";

int f1(int a,int b);
void test(void)// @".test" //MYSEGMENT段可在XCL中开辟
{
char arrayx[150];
char array1[150];
int i,a,b,c;
for (i=0;i<8;i++){
array1[i]=str1[i];
arrayx[i]=str2[i];
}
a=1;
b=2;
c=f1(a,b);
for (i=0;isendstr(array1,8);
sendstr(arrayx,8);
}
}

int f1(int a,int b){
if(a>0){
return (a+b)*1;
}
else return 0;
}

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

对于你的第三点,cortex和其他arm处理器都提供了一种特殊的中断

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top