| |||||
Technical Support Support Resources
Product Information | L166: INCORRECT ADDRESS USED FOR ARRAYInformation in this article applies to:
SYMPTOMSI am trying to copy an array from ROM to on-chip RAM. When I look at the addresses used for the memcpy in the debugger, the wrong address is used for the on-chip RAM and the code attempts to copy the array back to a location in ROM. Here are my linker directives:
DPPUSE (1=NDATA (0x200000-0x207FFF),
0=NCONST(0x003000-0x003FFF))
CLASSES (NCODE (0X0000-0X2FFF, 0x4000-0xBFFF),
SDATA (0XE000-0XE7FF, 0XFC00-0XFD7F),
SDATA0 (0XE000-0XE7FF, 0XFC00-0XFD7F),
FIXRAM (0xFD80-0xFDFF)
I am copying from an array called src to an array called dest, both three bytes in size:
const unsigned char src[3] = { 0xaa, 0x55, 0xa5};
#pragma RENAMECLASS (NDATA0=FIXRAM)
unsigned char dest[3];
After linking, src was located at 3000H and dest was located at FD80H. However, in the debugger, the address used for dest was 3D80H which is inside the NCONST class. Why isn't DPP3 being used to access the FIXRAM class? It is located in the address range accessed by DPP3. CAUSEThe Data Page Pointers may only be used to access the NCONST and NDATA classes. In your DPPUSE directive, you have specified that DPP0, 1 and 2 may be used to access NCONST and NDATA, however DPP3 is not specified. Therefore, it cannot be used to access NCONST or NDATA. RESOLUTIONInstead of using the FIXRAM class, declare your dest array as sdata. sdata is always accessed using DPP3. The correct address will then be used. unsigned char sdata dest[3]; Note that it is not possible to add the FIXRAM address range to the NDATA range specified in the DPPUSE directive, as the range of addresses used by NDATA must be contiguous. MORE INFORMATIONSEE ALSOLast Reviewed: Friday, July 15, 2005 | ||||
| |||||