Dear colleagues, we are using the TINI DS80C400 platform and the KEIL PK51 development tools. We would like to perform a fast memcpy of some physical CAN registers located in far memory to a buffer also located in far memory. We use the following code lines: #pragma moddp2 #include "absacc.h" unsigned char far *SrcPtr; unsigned char far *DestPtr; SrcPtr = &FVAR(unsigned char, 0xFFDBF7); /* physical register COM15D0 */ /* or alternatively: SrcPtr = (void far*)0xFFDBF7; */ DestPtr = ...; memcpy(DestPtr, SrcPtr, 8); /* should copy 8 bytes */ But it does not work! What's wrong here? Thanks for any hint. Raoul
I think you have a problem with your chosen memory map. From L51_BANK.A51:
; Each function gets as a parameter the memory address with 3 BYTE POINTER * ; representation in the CPU registers R1/R2/R3. The register R3 holds the * ; memory type. The C51 compiler uses the following memory types: * ; * ; R3 Value | Memory Type | Memory Class | Address Range * ; -----------------------+--------------+-------------------------- * ; 00 | data/idata | DATA/IDATA | I:0x00 .. I:0xFF * ; 01 | xdata | XDATA | X:0x0000 .. X:0xFFFF * ; 02..7F | far | HDATA | X:0x010000 .. X:0x7E0000 * ; 80..FD | far const | HCONST | C:0x800000 .. C:0xFD0000 (see note) * ; FE | pdata | XDATA | one 256-byte page in XDATA memory * ; FF | code | CODE | C:0x0000 .. C:0xFFFF * ; *
#define FVAR(object, addr) (*((object volatile far *) ((addr)+0x10000L)))