8051 memory access
While the 8051 has 4 kilobytes of built-in ROM (other variants may have 8 kilobytes or none at all), it is also capable of addressing 64 kilobytes of external code memory and 64 kilobytes of external data memory.
In the Harvard architecture, the code memory and data memory are separate, whereas they are combined into one block of memory in the von Neumann architecture.
Reading external code memory
- To configure the 8051 to access the external code memory for instructions, the EA# pin must be pulled down to ground.
- The upper byte of the address is output to Port 2.
- Port 0 is used as both as an output (lower byte of the address) and as an input (to read the data from the ROM)
- The PSEN# (program store enable) pin connects to the OE# (output enable) pin of the ROM.
- The ALE pin enables a latch connected to port 0 in order to hold its value while port 0 is used for input.