I have to read a flash written by another program and am provided a file looking like this
// data locations #define data1 0 #define data2 data1+0x100 ...
Without knowing what errors or wrong code you were getting, I can only guess that the typecasting failures are due data2's expression definition lacking parentheses to avoid side effects. To use the include file unchanged, I would suggest you provide the parentheses explicitly or by xdata access macros as in:
#define XDATA_BYTE_ACCESS(addr) (*(unsigned char xdata *)(addr)) #define XDATA_WORD_ACCESS(addr) (*(unsigned int xdata *)(addr)) unsigned char b; unsigned int w; void main(void) { b = XDATA_BYTE_ACCESS(data2); w = XDATA_WORD_ACCESS(data2); }
Have you checked out the C51 predefined macros for this - XBYTE, XWORD, etc? They're in the manual under "Absolute Memory Access Macros"
Thanks Andy, Things are so simple to use when you know what they are called. Erik
View all questions in Keil forum