We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I have an existing design with external RAM mapped from 0000 and a lot of units manufactured. To rectify some intermittent errors in the original code, I need to gain a bit more RAM without modifying the hardware, so I want to use a chip with some internal XDATA memory in it. 1) How do I define which variables are in internal XDATA and which are in external XDATA since the addresses are the same, and MOVX is used in either case. 2) How do I specify the switch mechanism between internal and external XDATA since they are chip dependent (I know that e.g. Winbond and Philips use different mechanisms). Erik
Question 2 first - If you can decide which is the target at compile time use a compiler flag to allow either set of code to be compiled. If you need to decide at run time, you have to discover a way to differentiate between the two chips and then use an if statement to steer accordingly. Question 1 - This is more difficult. You can assign two variables to the same location using the _at_ directive, but you will get warnings at link time. If you can live with this, at least it allows you multiple variable names accessing the same location. If not, you'd have to define a single variable, and then just access it by that name. You will get no warnings, but some of your functions may use variable names that sound peculiar. You could get around this by creating a macro that gives an equivalent name :
extern void dataselect1(void); extern void dataselect2(void); extern char xdata abc; // data space 1 #define xyz abc // data space two void main (void) { char xdata aaa; dataselect1(); //select the first data space aaa = abc; dataselect2(); aaa = xyz; }
Tom, I appreciate your response; however I'm not looking for workarounds, they are aplenty and I have already 3. I am looking for a method that GUARANTEES that when accessing internal XDATA the uC is switched to that mode and vice versa. A human will never get it right, automatics are required. Thanx, Erik
The only other alternative I can think of are Dallas Semi 5000 series micro's. These are battery backed 8051 cores. They come with up to 128K of memory which can be allocated for either code or data space. The architecture of the parts with internal XDATA is always set up with the internal ram at the low end. Since your external overlaps this, I don't think you can access it without extra code.
Is the bankswitching code replaceable? Could I specify that e.g. my external RAM is 0-ffff and the internal RAM is 10000 to 103ff and then replace the bankswitching code. Thanx, Erik