这是通过定义一个自己定义段来实现的,下面程序中我定义的段名叫".xdata",程序如下:
//mian.c
#include
unsigned char g_xx[10] __attribute__((section(".xdata")));
int main(void)
{
int i;
/*
这里要做一些初始化工作用于访问外部RAM.........
*/
for(i=0;i<10;i++)
g_xx[i]=i;
while(1);
}
在MAKEFILE中找到以下内容:
#---------------- External Memory Options ----------------
# 64 KB of external RAM, starting after internal RAM (ATmega128!),
# used for variables (.data/.bss) and heap (malloc()).
#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
# 64 KB of external RAM, starting after internal RAM (ATmega128!),
# only used for heap (malloc()).
#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff
EXTMEMOPTS =
并将最后一行改为:
EXTMEMOPTS = -Wl,--section-start,.xdata=0x801100
这里0x801000为此段的开始地址,
对于ATMEGA128来说0x1100为外部RAM开始地址。
|
|