大侠们,读写片外RAM的时候,我的问题到底出在哪里?
- UID
- 109919
- 性别
- 男
|
大侠们,读写片外RAM的时候,我的问题到底出在哪里?
我的工程文件如下:
NAMES
END
SEGMENTS
//USE FOR EXTERNAL RAM IF USED
EXT_RAM = READ_WRITE 0x0400 TO 0x1FFF; /* External ram */
/* banked external RAM */
RAMPAGE_0 = READ_WRITE 0x008000 TO 0x00BFFF;
RAMPAGE_1 = READ_WRITE 0x018000 TO 0x01BFFF;
RAMPAGE_2 = READ_WRITE 0x028000 TO 0x02BFFF;
RAMPAGE_3 = READ_WRITE 0x038000 TO 0x03BFFF;
RAMPAGE_4 = READ_WRITE 0x048000 TO 0x04BFFF;
RAMPAGE_5 = READ_WRITE 0x058000 TO 0x05BFFF;
RAMPAGE_6 = READ_WRITE 0x068000 TO 0x06BFFF;
RAMPAGE_7 = READ_WRITE 0x078000 TO 0x07BFFF;
RAMPAGE_8 = READ_WRITE 0x088000 TO 0x08BFFF;
RAMPAGE_9 = READ_WRITE 0x098000 TO 0x09BFFF;
RAMPAGE_A = READ_WRITE 0x0A8000 TO 0x0ABFFF;
RAMPAGE_B = READ_WRITE 0x0B8000 TO 0x0BBFFF;
RAMPAGE_C = READ_WRITE 0x0C8000 TO 0x0CBFFF;
RAMPAGE_D = READ_WRITE 0x0D8000 TO 0x0DBFFF;
RAMPAGE_E = READ_WRITE 0x0E8000 TO 0x0EBFFF;
RAMPAGE_F = READ_WRITE 0x0F8000 TO 0x0FBFFF;
// Uncomment RAM segment based on BUFMAP setting
//
// RAM = READ_WRITE 0x2180 TO 0x3FFE; /* BUFMAP = 0 (128 byte) */
// RAM = READ_WRITE 0x2300 TO 0x3FFE; /* BUFMAP = 1 (256 byte) */
// RAM = READ_WRITE 0x2600 TO 0x3FFE; /* BUFMAP = 2 (512 byte) */
// RAM = READ_WRITE 0x2C00 TO 0x3FFE; /* BUFMAP = 3 (1K) */
RAM = READ_WRITE 0x3200 TO 0x3FFE; /* BUFMAP = 4 (1.5K) */
/*Add 'FILL 0x18 0xA7' command following FLASH memory space allocation to implement a TRAP interrupt service routine
opcode in the unprogrammed memory locations. Example -> PAGE_XX = READ_ONLY 0x3X8000 TO 0x3XBFFF FILL 0x18 0xA7;*/
/* unbanked FLASH ROM */
ROM_4000 = READ_ONLY 0x4000 TO 0x7FFF; /* 16K */
ROM_C000 = READ_ONLY 0xC000 TO 0xF3FF; /* ~13K */
SECURITY = READ_ONLY 0xFF00 TO 0xFF0F;
ROM_FF10 = READ_ONLY 0xFF10 TO 0xFF7F;
PAGE_3C = READ_ONLY 0x3C8000 TO 0x3CBFFF;
PAGE_3D = READ_ONLY 0x3D8000 TO 0x3DBFFF;
END
PLACEMENT
_PRESTART, STARTUP,
ROM_VAR, STRINGS,
NON_BANKED,
COPY INTO ROM_4000, ROM_C000;
DEFAULT_ROM INTO PAGE_3C, PAGE_3D, ROM_FF10;
DEFAULT_RAM INTO RAM;
EXT_RAM INTO RAMPAGE_1;
END
INIT _EntryPoint
//STACKSIZE 0x200
STACKTOP 0x3FFF
片外RAM的变量定义如下:
#pragma DATA_SEG __PPAGE_SEG EXT_RAM
tU16 a[100];
#pragma DATA_SEG DEFAULT
片外总线设置程序如下:
void main(void)
{
INT16 len;
tU08 i;
//Change bus clock to external bus 16 Mhz maximum
CLKSEL=0;
CLKSEL_PLLSEL = 0; /* Select clock source from XTAL */
PLLCTL_PLLON = 0; /* Disable the PLL */
SYNR = 8; /* Set the multiplier register */
REFDV = 13; /* Set the divider register */
PLLCTL = 192;
PLLCTL_PLLON = 1; /* Enable the PLL */
while(!CRGFLG_LOCK); /* Wait */
CLKSEL_PLLSEL = 1; /* Select clock source from PLL */
//Configure to External Bus Mode
//The following must not use BSET instructions.
RDRIV = 0x00;
PEAR = 0x0C; // ((LSTRE|RDWE)&~NECLK)
EBICTL = 0x01; // Enable clock stretching (ESTR)
MISC = 0x05; // (~EXSTR1+EXSTR0+~ROMHM+ROMON)
MODE = 0xE2; // (MODC+MODB+MODA+EMK+~EME)
赋值给外部RAM中 的变量:
for(i=0;i<100;i++)
{
a=i;
}
然后通过UDP协议将a[0]---a[100]发送到主机,但是收到的都是一些错误数据,只要把A定义到内部RAM,数据都是对的,片外RAM的问题到底处在什么地方阿?请大侠们指点迷津!
|
|
|
|
|
|
- UID
- 104380
- 性别
- 男
|
|
|
|
|
|
- UID
- 109919
- 性别
- 男
|
|
|
|
|
|
- UID
- 104380
- 性别
- 男
|
你可以做一个最简单的project,对片外RAM进行一个字节的读写操作。看看其地址和数据波形是否正确。 |
|
|
|
|
|
- UID
- 109919
- 性别
- 男
|
好的,我再去好好试试,我的工程文件和读写片外RAM的方法有错误吗?在CW编译的时候选择的是BANKED MEMORY,版主,读写片外RAM与CW的设置有关系吗? |
|
|
|
|
|
- UID
- 104380
- 性别
- 男
|
应该没太大关系。不过你可以参考一下这个帖子中提到的对编译器的设置:
http://bbs.eccn.com/dispbbs.asp?boardID=3&RootID=118421&ID=118421 |
|
|
|
|
|