Do anybody know how can I define some variables in a range of external ram, and start at a fixed address ? When I use IAR, I can do it in the following way : ---------------------------------- (In the ....h file) #pragma memory=dataseg(E_XDATA) EXTERN UINT16 Tot_Rx_Cnt; EXTERN UINT16 Tot_Misc_Err; EXTERN UINT16 Tot_Tout_Err; #pragma memory=default ---------------------------------- (In the ....xcl file) -Z(XDATA)E_XDATA=0000-00FF ---------------------------------- How can I do in order to achieve the same thing using Keil ?
I see no reason to do so, except for debugging reasons. It is so much easier to display a buffer when you know where it is every time instead of having to hunt it because C and the linker (legally) may have relocated it. I define all XDATA in an assembler module and then have a .h that makes tham defined as externs. Erik
Defining addresses is a job for the Linker - so look in the Linker Manual
Actually, I have 2 external memory chips connected to the 8051mcu. I allocate the address 8000 & A000 to them respectively. I'm going to define some variables on them respectively. How can I implement the definition of those 2 groups of variables ?
Put the definitions of the variables into their own .c file, so that you get a single segment containing just those variables. Use the linker directives to assign the address you want to that segment. (See "SEGMENTS" for Lx51, or "XDATA", "DATA", etc for BL51.) The linker manual is part of the "Assembler/Utilities" manual.
"The linker manual is part of the 'Assembler/Utilities' manual." True for the printed manual, which is the same as the PDF. The Linker Manuals are available separately online: http://www.keil.com/support/man_c51.htm http://www.keil.com/support/man/docs/bl51/ http://www.keil.com/support/man/docs/lx51/