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 ;

Or

Char * ptr;

Or

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.

 

References:

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

http://www.esacademy.com/en/library/technical-articles-and-documents/8051-programming/8051-memory-configurations-with-c-compilers.html

http://supp.iar.com/Support/?note=98587

http://stackoverflow.com/questions/2389251/pointer-to-a-specific-fixed-address

Published by

ASIM MAHAKUL

Hello, I am Asim admin of this blog. An expert in Scientific Instrumentation (Analytical Instrumentation). My works are always associated with both Physics and electronics. Currently working on ARM based embedded systems for Optical(UV and Visible) and electrochemical spectroscopy (EIS). My M.Tech. Thesis was related to all these things. I had worked for a 8 bit microcontroller based standalone EIS (electrical impedance spectroscopy) device. I have Masters in Instrumentation engineering from NIT Kurukshetra,Haryana and Masters in Electronics Science from Sambalpur University, Odisha (Formerly Orissa/Utkal) Am also work for PHP MySQL AJAX based CMS design. i love blogging and coding(am not an expert).

Leave a Reply