8051 External Memory with keil

Hi friends you must have interfaced memory chips to 8085 or 8086 microprocessor. Same is the case here as both are with 8 bit processing 16 bit address space. In both cases the higher address port is shared with the data port. Means one port dedicated lower byte of address and higher byte of address is goes through a data-address multiplexed chanel.

Here in 8051 P0 is for lower address and P2 used for upper address byte and for data also. The hardware connection is also same as in case of microprocessors. You have to use a latch to latch the higher byte of address .

And the Code….

I had searched a lot both in google and the help pages, but didn’t get anything except the DATA type declaration, but how will it do all the things.

unsigned char xdata datg[32000]; //I had used a 32K byte RAM to save my data.


Do you know about pointers, have u ever tried to store a variable at some specific memory location. (I guess u never tried this), if u have done please mail me the code.

We declare pointers like

Int *ptr ;


Char * ptr;


Unsigned Char * ptr;

Where ptr is the address of the variable. Value of the variable is *ptr is an integear.

But we can’t write

ptr=0x1278; assuming 0x1278 is a memory location. Try it.


Ok u may ask what is the use of pointing to specific location(usually called static pointer). In microcontrollers we have very less memory we can use the memory randomly. It may lead to data segmentation.

After a long search I got two three lines

*datg = (char xdata *) 0x0400;

volatile unsigned int *myPointer = (volatile unsigned int *)0x1234;

#define data (*((char *) 0x0170))    

The first one is quite odd, it doesn’t look like a type declaration statement, rather seems like a assignment statement.



Keil application note http://www.keil.com/appnotes/files/apnt_129.pdf