{"id":161,"date":"2018-07-26T11:37:16","date_gmt":"2018-07-26T11:37:16","guid":{"rendered":"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/?post_type=chapter&#038;p=161"},"modified":"2018-08-13T05:32:08","modified_gmt":"2018-08-13T05:32:08","slug":"memory-system","status":"publish","type":"chapter","link":"https:\/\/ebooks.inflibnet.ac.in\/csp13\/chapter\/memory-system\/","title":{"rendered":"Memory System"},"content":{"raw":"&nbsp;\r\n<p style=\"text-align: justify\">In this lecture, the semiconductor memory will be discussed in detail. Memory address decoding and the interfacing of 8051 will also be discussed.<\/p>\r\n&nbsp;\r\n\r\n<strong>1.<\/strong><strong>Semiconductor Memory<\/strong>\r\n\r\n&nbsp;\r\n\r\n<strong>1.1 Memory Capacity:<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The number of bits that a semiconductor memory chip can store is called chip capacity. It can be in units of Kbits (kilobits), Mbits (megabits), and so on.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">This must be distinguished from the storage capacity of computer systems.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">While the memory capacity of a memory IC chip is always given in bits, the memory capacity of a computer system is given in bytes. If a 16M memory chip is present, then 16 megabits is stored in the semiconductor memory. If a computer comes with 16M memory, 16 megabytes can be stored which means that 16 words are stored, each with the capacity of 8 bits.<\/p>\r\n&nbsp;\r\n\r\n<strong>1.2 Memory Organization<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Memory chips are organized into a number of locations within the IC. Each location can hold 1 bit, 4 bits, 8 bits, or even 16 bits, depending on how it is designed internally. The number of locations within a memory IC depends on the address pins. The number of bits that each location can hold is always equal to the number of data pins. In general, if x is the number of address lines in a memory chip, it contains 2x locations. Dynamic RAMs (DRAMs) are exceptions to this as indicated in a later section (1.9.2). Each location contains y bits, where y is the number of data pins on the chip. The entire chip will contain 2x \u00d7 y bits.<\/p>\r\n&nbsp;\r\n\r\n<img class=\"size-full wp-image-164 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-87.png\" alt=\"\" width=\"195\" height=\"300\" \/>\r\n<div>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Figure 1.1 shows the memory capacity where x is the number of address pins and 2x the corresponding memory capacity.<\/p>\r\n&nbsp;\r\n\r\n<strong><em>1.2.1 Example for memory organization<\/em><\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">A 512K memory chip has 8 pins for data. Find: (a) The organization, and (b) the number of address pins for this memory chip.<\/p>\r\n&nbsp;\r\n\r\n<strong>Solution:<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">(a)\u00a0 A memory chip with 8 data pins means that each location within the chip can hold 8 bits of data. To find the number of locations within this memory chip, divide the capacity by the number of data pins. 512K\/8 = 64K; therefore, the organization for this memory chip is 64K \u00d7 8.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">(b) The chip has 16 address lines since 2<strong>16<\/strong>= 64K.<\/p>\r\n&nbsp;\r\n\r\n<strong>1.3 Speed<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The speed of the memory chip is commonly referred to as its <em>access time.<\/em> The access time of a memory chip varies from a few nanoseconds to hundreds of nanoseconds, depending on the IC technology used in the design and fabrication process.<\/p>\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<strong>1.4 ROM (read-only memory):<\/strong>\r\n\r\n&nbsp;\r\n\r\nROM is a type of memory that does not lose its contents when the power is turned off. For this reason,\r\n\r\n&nbsp;\r\n\r\nROM is also called <strong>nonvolatile<\/strong> memory. There are different types of read-only memory. They are:\r\n\r\n&nbsp;\r\n\r\n\u2713\u00a0\u00a0\u00a0\u00a0 PROM\r\n\r\n&nbsp;\r\n\r\n\u2713\u00a0\u00a0\u00a0\u00a0 EPROM\r\n\r\n&nbsp;\r\n\r\n\u2713\u00a0\u00a0\u00a0\u00a0 EEPROM\r\n\r\n&nbsp;\r\n\r\n\u2713\u00a0\u00a0\u00a0\u00a0 Flash EPROM\r\n\r\n&nbsp;\r\n\r\n\u2713\u00a0\u00a0\u00a0\u00a0 Mask ROM\r\n\r\n&nbsp;\r\n\r\n<strong>1.5 PROM (programmable ROM) and OTP:<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">For every bit of the PROM, there exists a fuse. PROM is programmed by blowing the fuses. If the information burned into PROM is wrong, that PROM must be discarded since its internal fuses are blown permanently.<\/p>\r\n&nbsp;\r\n\r\n\u2713\u00a0\u00a0\u00a0\u00a0 PROM is also referred to as an OTP (one-time programmable) device.\r\n\r\n&nbsp;\r\n\r\n\u2713\u00a0\u00a0\u00a0\u00a0 Programming ROM, also called burning ROM, requires special equipment called a ROM burner or ROM programmer.\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<strong>1.6 EPROM(Erasable Programmable ROM) and UV-EPROM:<\/strong>\r\n\r\n&nbsp;\r\n\r\nEPROM was invented to allow making changes in the contents of PROM after it is burnt.\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">\u2713 In EPROM, one can program the memory chip and erase it thousands of times. A widely used EPROM is called UVEPROM.<\/p>\r\n&nbsp;\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">\u2713 UV stands for ultra-violet.<\/span>\r\n\r\n<\/div>\r\n&nbsp;\r\n<p style=\"text-align: justify\">The only problem with UV-EPROM is that erasing its contents can take up to 20 minutes. All UV-EPROM chips have a window that is used to shine ultraviolet (UV) radiation to erase its contents. The major disadvantage of UV-EPROM, is that it cannot be programmed while in the system board.<\/p>\r\n&nbsp;\r\n\r\n<strong>1.7 EEPROM(Electrically Erasable Programmable ROM) :<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">EEPROM has several advantages over EPROM. Its method of erasure is electrical and therefore instant, as opposed to the 20-minute erasure time required for UVEPROM. One can select which byte is to be erased, in contrast to UV-EPROM, in which the entire contents of the ROM are erased. One can program and erase its contents while it is still in the system board. EEPROM does not require an external erasure and programming device. The designer incorporates into the system board the circuitry to program the EEPROM.<\/p>\r\n&nbsp;\r\n\r\n<strong>1.8 RAM(Random Access Memory) :<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">RAM memory is called volatile memory since cutting off the power to the IC will result in the loss of data. Sometimes RAM is also referred to as RAWM (read and write memory), in contrast to ROM, which cannot be written to.<\/p>\r\n&nbsp;\r\n\r\nThere are three types of RAM:\r\n\r\n&nbsp;\r\n\r\n\u2713 Static RAM (SRAM),\r\n\r\n\u2713 NV-RAM (nonvolatile RAM), and\r\n\r\n\u2713 Dynamic RAM (DRAM).\r\n\r\n&nbsp;\r\n\r\n<strong><em>1.9.1 SRAM (static RAM) :<\/em><\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Storage cells in static RAM memory are made of flip-flops. Therefore, they do not require refreshing in order to keep their data. This is in contrast to DRAM.<\/p>\r\n&nbsp;\r\n\r\n<img class=\"size-full wp-image-166 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-88.png\" alt=\"\" width=\"408\" height=\"300\" \/>\r\n\r\n<strong><em style=\"text-align: initial;text-indent: 1em;font-size: 1em\">1.9.2 DRAM (Dynamic RAM):<\/em><\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\"><span style=\"text-align: justify;font-size: 1em\">DRAM (dynamic RAM) uses a capacitor to store each bit. It requires constant refreshing due to leakage of charge from the capacitor.<\/span><\/p>\r\n&nbsp;\r\n\r\n<strong>Packaging issue in DRAM:<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">In DRAM there is a problem of packing a large number of cells into a single chip with the normal number of pins assigned to addresses. To solve this problem, multiplexing is used. Column address and row address are multiplexed onto the same pins here. Row Address Strobe (RAS) and Column Address Strobe (CAS) are used to indicate whether the row address or the column address are carried on the address lines. This requires only half the number of address pins. As shown in Fig 1.3, in the 256Kx1 DRAM, the address lines A0 to A8 are used along with RAS and CAS to carry row address and column address respectively. Thus with 9 pins we can address 256K locations<\/p>\r\n&nbsp;\r\n\r\n<img class=\"size-full wp-image-167 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-89.png\" alt=\"\" width=\"303\" height=\"303\" \/>\r\n\r\n&nbsp;\r\n\r\n<strong><em>1.9.3 Non-volatile random-access memory (NVRAM)<\/em><\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">NVRAM is <a href=\"https:\/\/en.wikipedia.org\/wiki\/Random-access_memory\">random-access memory <\/a>that retains its information when power is turned off <a href=\"https:\/\/en.wikipedia.org\/wiki\/Non-volatile_memory\">(non-volatile)<\/a>. This is in contrast to dynamic, random-access memory(DRAM) and <a href=\"https:\/\/en.wikipedia.org\/wiki\/Static_random-access_memory\">static random-access memory<\/a> (SRAM), which both maintain data only for as long as power is applied. The best-known form of NVRAM memory today is <a href=\"https:\/\/en.wikipedia.org\/wiki\/Flash_memory\">flash memory.<\/a><\/p>\r\n&nbsp;\r\n\r\n<strong> Memory Address Decoding<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Large capacity memories are constructed using smaller blocks of memories. Hence the required block has to be selected based on the memory address. This is done by decoding the memory addresses. There are three ways to generate a memory block selector a) using simple logic gates, b) using a decoder, such as, 74LS138, and c) using the programmable logic. We discuss the first two methods here.<\/p>\r\n&nbsp;\r\n\r\n<strong>2.1 Decoder using NAND and other gates<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Figure 2.1 shows 4K*8 memory chip Decoder with NAND and other gates. There are twelve address lines from A0-A11 for accessing the location and data lines from D0-D7.CS, RD and WR are the control signals. CS is the Chip select pin which is enabled by the address lines A15 to A12. If RD is set to 0, then we can read the Content, and if WR is set to 0, we can write into the chip. The chip select can be enabled by giving the address lines A15-A12=0011. This will correspond to an address range of 3000 to 3FFFH.<\/p>\r\n&nbsp;\r\n\r\n<img class=\"size-full wp-image-168 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-90.png\" alt=\"\" width=\"618\" height=\"352\" \/>\r\n\r\n<strong>2.2 74LS138, 3-8 Decoder<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The 3 inputs A, B, and C generate 8 active low outputs Y0 \u2013 Y7. O\/P Y is connected to CS of a memory chip as shown in figure 2.2. It selects 8 memory blocks. A,B and C select which o\/p is to be activated. Additional i\/p\u2019s G2A and G2B are both active low, and G1 is active high. If any one of the inputs G1, G2A, or G2B is not connected to an address signal, they must be activated permanently either by Vcc or ground, depending on the activation level.<\/p>\r\n&nbsp;\r\n\r\n<img class=\"size-full wp-image-169 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-91.png\" alt=\"\" width=\"324\" height=\"490\" \/>\r\n<div>\r\n\r\n&nbsp;\r\n\r\n<strong>2.3. Accessing On-chip and off-chip code ROM<\/strong>\r\n\r\n<\/div>\r\n<p style=\"text-align: justify\">In this section we are going to discuss the interfacing of 8031 microcontroller with external ROM. EA pin of 8031 microcontroller is connected to Vcc to indicate that the program code is stored in the C's on-chip ROM. Figure 2.3 shows the on-chip and off-chip program code access.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">To indicate that the program code is stored in external ROM, this pin must be connected to GND.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">If we have EA= Gnd, then it refers to the on-chip Program. If EA=VCC, it refers to the off-chip program. However, , upon reset the 8051 executes the on-chip program first. Then, when it reaches the end of the on-chip ROM, it switches to external ROM for the rest of the program code.<\/p>\r\n&nbsp;\r\n\r\n<img class=\"size-full wp-image-170 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-92.png\" alt=\"\" width=\"570\" height=\"259\" \/>\r\n<div>\r\n\r\n&nbsp;\r\n\r\n<strong>2.3.1 8051 Interfacing with External ROM<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">CPU gives the address of the data required. Decoding circuit has to locate the selected memory block. Memory chips have CS (chip select) pin, which must be activated for the memory\u2019s contents to be accessed.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">The pins 29, 30 and 31 of the 8051 microcontroller (shown in Fig. 2.4) are used to provide the memory interface related signals.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong>Pin 29<\/strong>: PSEN-If we use an external ROM then this pin should have a logic 0 which indicates that the Microcontroller should read data from memory.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong>Pin 30<\/strong>: ALE\/PROG- This pin is used for ALE that is Address Latch Enable. This pin is used to demultiplex address and data lines. This pin also gives program pulse input during programming of EPROM.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong>Pin 31<\/strong>: EA\/VPP- If we have to use multiple memories then applying logic 1 to this pin instructs 8051 to read data from both memories - first internal and then external.<\/p>\r\n\r\n<\/div>\r\n<img class=\"size-full wp-image-171 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-93.png\" alt=\"\" width=\"408\" height=\"508\" \/>\r\n<div>\r\n\r\n<strong><em>2.3.2 Steps to be followed when connecting external memory<\/em><\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">CPU data bus is connected directly to the data pins of the memory chip. Control signals RD (read) and WR (memory write) from the CPU are connected to the OE (output enable) and WE (write enable) pins of the memory chip. The lower bits of the address from the CPU are connected directly to the memory chip address pins. The upper ones are used to activate the CS pin of the memory chip.<\/p>\r\n&nbsp;\r\n\r\n<strong>P0 and P2 role in providing addresses:<\/strong>\r\n\r\n&nbsp;\r\n\r\n\u2022 The PC (program counter) of the 8031\/51 is 16-bit, it is capable of accessing up to 64K bytes of program code.\r\n\r\n&nbsp;\r\n\r\n\u2022 16 bit address is provided by port 0 and port 2 to access external memory.\r\n\r\n&nbsp;\r\n\r\n\u2022 P0 provides the lower 8 bit address A0 \u2013 A7.\r\n\r\n&nbsp;\r\n\r\n\u2022 P2 provides the upper 8 bit address A8 \u2013 A15.\r\n\r\n&nbsp;\r\n\r\n\u2022 P0 is also used to provide the 8-bit data D0\u2013D7.\r\n\r\n&nbsp;\r\n\r\n\u2022 P0.0 \u2013 P0.7 are used for both the address\u00a0 and data paths (address\/data multiplexing).\r\n\r\n&nbsp;\r\n\r\nThe ALE signal is used to determine whether P0 carries address or data signals.\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<strong><em>2.3.2.1 ALE (Address Latch Enable):<\/em><\/strong>\r\n\r\n&nbsp;\r\n\r\n\u2022 ALE (address latch enable) pin is an output pin for 8031\/51.\r\n\r\n&nbsp;\r\n\r\n\u2022 When ALE = 0, then 8031 uses P0 for the data path.\r\n\r\n<\/div>\r\n<span style=\"text-align: initial;font-size: 1em\">\u00a0 \u00a0 \u2022 W hen ALE = 1, then 8031 uses P0 for the address path.<\/span>\r\n<div>\r\n\r\n\u00a0 \u00a0 \u2022 To extract the addresses from the P0 pins, it is connected to 74LS373 D Latch. The pins and structure of 74LS373 are shown in figure 2.5.\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">\u2022 Separation of address and data can be obtained by using 74LS373. Figure 2.6 shows the address\/data de-multiplexing. In the figure it is noted that when ALE=0 and P0 is used as a data bus, sending data out or bringing data in. Whenever the 8031\/8051 wants to use P0 as an address bus, it puts the addresses A0-A7 on the P0 pins and activates ALE=1 to indicate that P0 has the addresses.<\/p>\r\n&nbsp;\r\n\r\n<img class=\"size-full wp-image-172 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-94.png\" alt=\"\" width=\"372\" height=\"437\" \/>\r\n\r\n<\/div>\r\n<img class=\"size-full wp-image-173 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-95.png\" alt=\"\" width=\"642\" height=\"208\" \/>\r\n<div>\r\n<p style=\"text-align: justify\">\u2022PSEN is the Program store enable and it is an o\/p signal. It is used to handle the Program memory and Data memory. PSEN is connected to OE pin of Program ROM. PSEN and EA of 8031\/8051 are used to access external ROM. If the Memory is the Program memory then PSEN is connected to External Memory which reads the Program from the external Memory. If EA is connected to Ground then external ROM is accessed. If EA is connected to VCC, then the internal ROM is accessed. Figure 2.7 shows the Data, Address and Control buses for the 8031\/8051.<\/p>\r\n\r\n<\/div>\r\n<div>\r\n\r\n<img class=\"size-full wp-image-174 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-96.png\" alt=\"\" width=\"817\" height=\"493\" \/>\r\n\r\n<img class=\"size-full wp-image-175 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-97.png\" alt=\"\" width=\"690\" height=\"414\" \/>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">While accessing the address, ALE should be equal to one, and for accessing the data ALE should be equal to zero. When accessing the external program memory, PSEN pin of 8051\/8031 should be connected to the chip enable (CE and OE) pins of external memory, as shown in Figure 2.8.<\/p>\r\n&nbsp;\r\n\r\n<strong>2.44 8051 Data Memory Space<\/strong>\r\n\r\n<\/div>\r\n<span style=\"text-align: initial;font-size: 1em\">The 8051 has 128 bytes of address space.<\/span>\r\n<ul>\r\n \t<li><span style=\"text-align: initial;font-size: 1em\">\u00a064 bytes are set aside for program code.<\/span><\/li>\r\n \t<li>Program space is accessed using the program counter (PC) to locate and fetch instructions.<\/li>\r\n<\/ul>\r\n<div>\r\n\r\n&nbsp;\r\n\r\n<strong>2.44.1 External ROM for data:<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">For the ROM containing the program code, PSEN is used to fetch the code.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">For the ROM containing data, the RD signal is used to fetch the data. Figure 2.9 shows the connection to the external data ROM. Figure 2.10 shows the external memory for data.<\/p>\r\n&nbsp;\r\n\r\n<img class=\"size-full wp-image-176 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-98.png\" alt=\"\" width=\"713\" height=\"370\" \/>\r\n\r\n<strong><em>2.44.1.1 MOVX instruction<\/em><\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">We will now look at how the MOVX instruction is used to connect 8051 with the external data as shown in figure 2.11 .MOVX is a widely used instruction allowing access to the external data memory space. To bring externally stored data into the CPU, we use the instruction MOVX A,@DPTR.<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\"><strong>Example: <\/strong>The word \u201cSAM\u201d has been burned in external data ROM locations starting from 4100H. Write a program to read this data into RAM locations of an 8031 starting from 60H.<\/p>\r\n\r\n<\/div>\r\n<div>\r\n\r\n<strong>Solution: <\/strong>\r\n\r\n&nbsp;\r\n\r\nMOV DPTR, #4100H ;DPTR=4100H(points to first source location )\r\n\r\n<\/div>\r\n<span style=\"text-align: initial;font-size: 1em\">\u00a0 \u00a0MOV A, @DPTR\u00a0<\/span><span style=\"text-align: initial;font-size: 1em\">;get \u2018s\u2019 from location 1000H<\/span>\r\n\r\n&nbsp;\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">MOV 60H, A\u00a0<\/span><span style=\"text-align: initial;font-size: 1em\">;move it to data RAM location 60H<\/span>\r\n\r\n&nbsp;\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">INC\u00a0<\/span><span style=\"text-align: initial;font-size: 1em\">DPTR\u00a0<\/span><span style=\"text-align: initial;font-size: 1em\">; DPTR=4100H(points to next location)<\/span>\r\n\r\n&nbsp;\r\n\r\n<span style=\"text-align: initial;font-size: 1em\">MOVX A, @DPTR<\/span>\r\n<div>\r\n\r\n\u00a0 \u00a0 MOV 61H, A\r\n\r\n&nbsp;\r\n\r\nINC DPTR\r\n\r\n<\/div>\r\n<span style=\"text-align: initial;font-size: 1em\">\u00a0 \u00a0 MOVX A, @DPTR<\/span>\r\n<div>\r\n\r\n\u00a0 \u00a0 MOV 62H, A\r\n\r\n&nbsp;\r\n\r\nEND\r\n\r\n<img class=\"size-full wp-image-177 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-99.png\" alt=\"\" width=\"752\" height=\"499\" \/>\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<strong>2.44.2 A single ROM for both program and data:<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">To access same external memory for data and program, PSEN and RD are connected to an AND gate to signal the OE pin of the ROM chip. Figure 3.1 and 3.2 shows the 8031 connection to external Program ROM, Data RAM and Data ROM.<\/p>\r\n\r\n<\/div>\r\n<div>\r\n\r\n<img class=\"size-full wp-image-178 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-100.png\" alt=\"\" width=\"759\" height=\"290\" \/>\r\n\r\n<img class=\"size-full wp-image-179 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-101.png\" alt=\"\" width=\"761\" height=\"488\" \/>\r\n\r\n&nbsp;\r\n\r\n<strong>Exercises: ( Refer figure 3.2)<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">1. Find the address space of the data RAM, data ROM and program ROM<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">2. Write a program to access bytes of data which is in data ROM, divide it by 2, and save the quotient in the data RAM<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">3. Re-write the program for the case that the data byte is in the program ROM<\/p>\r\n&nbsp;\r\n\r\n<strong>Solution for Exercise 1:<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">The address line A15 and A14 of data RAM =10 for the chip to be selected. Thus address space is 1000 0000 0000 0000 to 1011 1111 1111 1111(8000H to BFFFH).<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">For the data ROM, A15 and A14 of data RAM =00 for the chip to be selected. Thus address space is 0000 0000 0000 0000 to 0011 1111 1111 1111(0000H to 3FFFH).<\/p>\r\n&nbsp;\r\n<p style=\"text-align: justify\">For the program ROM, address lines A15 and A14 are not used in address decoding. However , if A15 and A14 are 0, then the address space is from 0000H to 3FFFH. But , it does not create a clash with the address space of the data ROM or RAM, because different instructions are used to access the code space and the data space.<\/p>\r\n&nbsp;\r\n\r\n<strong>Solution for Exercise 2:<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Let the required data be in first location in data ROM and let us transfer the quotient to the first location in the data RAM. Note that MOVX instruction is used to access the data ROM.<\/p>\r\n&nbsp;\r\n\r\nORG 0000H ; load the program in 0000H of program memory\r\n\r\n&nbsp;\r\n\r\nMOV DPTR,#0000H ; let DPTR point to data location\r\n\r\n&nbsp;\r\n\r\nMOVX A, @DPTR\r\n\r\n<\/div>\r\n<span style=\"text-align: initial;font-size: 1em\">\u00a0 \u00a0MOV B, #02<\/span>\r\n<div>\r\n\r\n\u00a0 \u00a0DIV AB\r\n\r\n&nbsp;\r\n\r\nMOV DPTR,#8000H\r\n\r\n&nbsp;\r\n\r\nMOVX @DPTR, A\r\n\r\n&nbsp;\r\n\r\nEND\r\n\r\n&nbsp;\r\n\r\n<strong>Solution for Exercise 3:<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">Assume that the required data has already been burnt into location 0100H of program ROM . Here MOVC instruction is to be used to access data from program ROM.<\/p>\r\n&nbsp;\r\n\r\nORG 0000H\r\n\r\n&nbsp;\r\n\r\nMOV DPTR,#0100H\u00a0 ; let DPTR point to data location\r\n\r\n&nbsp;\r\n\r\nCLR A\r\n\r\n&nbsp;\r\n\r\nMOVC A.A+@DPTR\r\n\r\n&nbsp;\r\n\r\nMOV B, #02\r\n\r\n&nbsp;\r\n\r\nDIV AB\r\n\r\n&nbsp;\r\n\r\nMOV DPTR,#8000H\r\n\r\n&nbsp;\r\n\r\nMOVX @DPTR, A\r\n\r\n&nbsp;\r\n\r\nEND\r\n\r\n&nbsp;\r\n\r\n<strong>2.5 Interfacing to large External Memory<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">In some applications we need a large amount of memory to store data. Figure 3.3 shows 8051 Accessing the 256Kx8 External NV-RAM. For accessing the larger memory, some extra pins are used for accessing as address lines. P0 is address multiplexed. P2 is used for the address on the higher side. The 8051 can support only 64K bytes of external data memory since DPTR is 16-bit wide. To solve this problem, we connect P0 port and P2 port(A0 \u2013A15) of the 8051 directly to the external memory\u2019s A0 \u2013 A15 pins, and the additional A16 and A17 address pins are connected from P1.1 and P1.2 of 8051. Usually P0 and P2 ports are used as address ports, if needed P1 port pins can be used for additional address lines.<\/p>\r\n\r\n<\/div>\r\n<img class=\"size-full wp-image-180 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-102.png\" alt=\"\" width=\"770\" height=\"418\" \/>\r\n\r\n&nbsp;\r\n\r\n<strong>3.Summary<\/strong>\r\n\r\n&nbsp;\r\n<p style=\"text-align: justify\">In this module, we have discussed different semiconductor memories in terms of capacity, organization and access time. We have also discussed interfacing of ROM with 8051, and demonstrated accessing code and data from external memory through assembly program.<\/p>\r\n&nbsp;\r\n\r\n<strong>4. References<\/strong>\r\n<ol>\r\n \t<li style=\"text-align: justify\">Muhammad Ali Mazidi, Janice Gillispie Mazidi, Rolin D. McKinlay, \u201cThe 8051 Microcontroller and Embedded Systems Using Assembly and C -Second Edition\u201d, New Delhi(2000).<\/li>\r\n<\/ol>\r\n&nbsp;","rendered":"<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">In this lecture, the semiconductor memory will be discussed in detail. Memory address decoding and the interfacing of 8051 will also be discussed.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>1.<\/strong><strong>Semiconductor Memory<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><strong>1.1 Memory Capacity:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The number of bits that a semiconductor memory chip can store is called chip capacity. It can be in units of Kbits (kilobits), Mbits (megabits), and so on.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">This must be distinguished from the storage capacity of computer systems.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">While the memory capacity of a memory IC chip is always given in bits, the memory capacity of a computer system is given in bytes. If a 16M memory chip is present, then 16 megabits is stored in the semiconductor memory. If a computer comes with 16M memory, 16 megabytes can be stored which means that 16 words are stored, each with the capacity of 8 bits.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>1.2 Memory Organization<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Memory chips are organized into a number of locations within the IC. Each location can hold 1 bit, 4 bits, 8 bits, or even 16 bits, depending on how it is designed internally. The number of locations within a memory IC depends on the address pins. The number of bits that each location can hold is always equal to the number of data pins. In general, if x is the number of address lines in a memory chip, it contains 2x locations. Dynamic RAMs (DRAMs) are exceptions to this as indicated in a later section (1.9.2). Each location contains y bits, where y is the number of data pins on the chip. The entire chip will contain 2x \u00d7 y bits.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-164 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-87.png\" alt=\"\" width=\"195\" height=\"300\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-87.png 195w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-87-65x100.png 65w\" sizes=\"auto, (max-width: 195px) 100vw, 195px\" \/><\/p>\n<div>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Figure 1.1 shows the memory capacity where x is the number of address pins and 2x the corresponding memory capacity.<\/p>\n<p>&nbsp;<\/p>\n<p><strong><em>1.2.1 Example for memory organization<\/em><\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">A 512K memory chip has 8 pins for data. Find: (a) The organization, and (b) the number of address pins for this memory chip.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Solution:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">(a)\u00a0 A memory chip with 8 data pins means that each location within the chip can hold 8 bits of data. To find the number of locations within this memory chip, divide the capacity by the number of data pins. 512K\/8 = 64K; therefore, the organization for this memory chip is 64K \u00d7 8.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">(b) The chip has 16 address lines since 2<strong>16<\/strong>= 64K.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>1.3 Speed<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The speed of the memory chip is commonly referred to as its <em>access time.<\/em> The access time of a memory chip varies from a few nanoseconds to hundreds of nanoseconds, depending on the IC technology used in the design and fabrication process.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>1.4 ROM (read-only memory):<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>ROM is a type of memory that does not lose its contents when the power is turned off. For this reason,<\/p>\n<p>&nbsp;<\/p>\n<p>ROM is also called <strong>nonvolatile<\/strong> memory. There are different types of read-only memory. They are:<\/p>\n<p>&nbsp;<\/p>\n<p>\u2713\u00a0\u00a0\u00a0\u00a0 PROM<\/p>\n<p>&nbsp;<\/p>\n<p>\u2713\u00a0\u00a0\u00a0\u00a0 EPROM<\/p>\n<p>&nbsp;<\/p>\n<p>\u2713\u00a0\u00a0\u00a0\u00a0 EEPROM<\/p>\n<p>&nbsp;<\/p>\n<p>\u2713\u00a0\u00a0\u00a0\u00a0 Flash EPROM<\/p>\n<p>&nbsp;<\/p>\n<p>\u2713\u00a0\u00a0\u00a0\u00a0 Mask ROM<\/p>\n<p>&nbsp;<\/p>\n<p><strong>1.5 PROM (programmable ROM) and OTP:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">For every bit of the PROM, there exists a fuse. PROM is programmed by blowing the fuses. If the information burned into PROM is wrong, that PROM must be discarded since its internal fuses are blown permanently.<\/p>\n<p>&nbsp;<\/p>\n<p>\u2713\u00a0\u00a0\u00a0\u00a0 PROM is also referred to as an OTP (one-time programmable) device.<\/p>\n<p>&nbsp;<\/p>\n<p>\u2713\u00a0\u00a0\u00a0\u00a0 Programming ROM, also called burning ROM, requires special equipment called a ROM burner or ROM programmer.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>1.6 EPROM(Erasable Programmable ROM) and UV-EPROM:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>EPROM was invented to allow making changes in the contents of PROM after it is burnt.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">\u2713 In EPROM, one can program the memory chip and erase it thousands of times. A widely used EPROM is called UVEPROM.<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">\u2713 UV stands for ultra-violet.<\/span><\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The only problem with UV-EPROM is that erasing its contents can take up to 20 minutes. All UV-EPROM chips have a window that is used to shine ultraviolet (UV) radiation to erase its contents. The major disadvantage of UV-EPROM, is that it cannot be programmed while in the system board.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>1.7 EEPROM(Electrically Erasable Programmable ROM) :<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">EEPROM has several advantages over EPROM. Its method of erasure is electrical and therefore instant, as opposed to the 20-minute erasure time required for UVEPROM. One can select which byte is to be erased, in contrast to UV-EPROM, in which the entire contents of the ROM are erased. One can program and erase its contents while it is still in the system board. EEPROM does not require an external erasure and programming device. The designer incorporates into the system board the circuitry to program the EEPROM.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>1.8 RAM(Random Access Memory) :<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">RAM memory is called volatile memory since cutting off the power to the IC will result in the loss of data. Sometimes RAM is also referred to as RAWM (read and write memory), in contrast to ROM, which cannot be written to.<\/p>\n<p>&nbsp;<\/p>\n<p>There are three types of RAM:<\/p>\n<p>&nbsp;<\/p>\n<p>\u2713 Static RAM (SRAM),<\/p>\n<p>\u2713 NV-RAM (nonvolatile RAM), and<\/p>\n<p>\u2713 Dynamic RAM (DRAM).<\/p>\n<p>&nbsp;<\/p>\n<p><strong><em>1.9.1 SRAM (static RAM) :<\/em><\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Storage cells in static RAM memory are made of flip-flops. Therefore, they do not require refreshing in order to keep their data. This is in contrast to DRAM.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-166 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-88.png\" alt=\"\" width=\"408\" height=\"300\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-88.png 408w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-88-300x221.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-88-65x48.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-88-225x165.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-88-350x257.png 350w\" sizes=\"auto, (max-width: 408px) 100vw, 408px\" \/><\/p>\n<p><strong><em style=\"text-align: initial;text-indent: 1em;font-size: 1em\">1.9.2 DRAM (Dynamic RAM):<\/em><\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><span style=\"text-align: justify;font-size: 1em\">DRAM (dynamic RAM) uses a capacitor to store each bit. It requires constant refreshing due to leakage of charge from the capacitor.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Packaging issue in DRAM:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">In DRAM there is a problem of packing a large number of cells into a single chip with the normal number of pins assigned to addresses. To solve this problem, multiplexing is used. Column address and row address are multiplexed onto the same pins here. Row Address Strobe (RAS) and Column Address Strobe (CAS) are used to indicate whether the row address or the column address are carried on the address lines. This requires only half the number of address pins. As shown in Fig 1.3, in the 256Kx1 DRAM, the address lines A0 to A8 are used along with RAS and CAS to carry row address and column address respectively. Thus with 9 pins we can address 256K locations<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-167 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-89.png\" alt=\"\" width=\"303\" height=\"303\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-89.png 303w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-89-150x150.png 150w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-89-300x300.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-89-65x65.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-89-225x225.png 225w\" sizes=\"auto, (max-width: 303px) 100vw, 303px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong><em>1.9.3 Non-volatile random-access memory (NVRAM)<\/em><\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">NVRAM is <a href=\"https:\/\/en.wikipedia.org\/wiki\/Random-access_memory\">random-access memory <\/a>that retains its information when power is turned off <a href=\"https:\/\/en.wikipedia.org\/wiki\/Non-volatile_memory\">(non-volatile)<\/a>. This is in contrast to dynamic, random-access memory(DRAM) and <a href=\"https:\/\/en.wikipedia.org\/wiki\/Static_random-access_memory\">static random-access memory<\/a> (SRAM), which both maintain data only for as long as power is applied. The best-known form of NVRAM memory today is <a href=\"https:\/\/en.wikipedia.org\/wiki\/Flash_memory\">flash memory.<\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong> Memory Address Decoding<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Large capacity memories are constructed using smaller blocks of memories. Hence the required block has to be selected based on the memory address. This is done by decoding the memory addresses. There are three ways to generate a memory block selector a) using simple logic gates, b) using a decoder, such as, 74LS138, and c) using the programmable logic. We discuss the first two methods here.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>2.1 Decoder using NAND and other gates<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Figure 2.1 shows 4K*8 memory chip Decoder with NAND and other gates. There are twelve address lines from A0-A11 for accessing the location and data lines from D0-D7.CS, RD and WR are the control signals. CS is the Chip select pin which is enabled by the address lines A15 to A12. If RD is set to 0, then we can read the Content, and if WR is set to 0, we can write into the chip. The chip select can be enabled by giving the address lines A15-A12=0011. This will correspond to an address range of 3000 to 3FFFH.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-168 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-90.png\" alt=\"\" width=\"618\" height=\"352\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-90.png 618w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-90-300x171.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-90-65x37.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-90-225x128.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-90-350x199.png 350w\" sizes=\"auto, (max-width: 618px) 100vw, 618px\" \/><\/p>\n<p><strong>2.2 74LS138, 3-8 Decoder<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The 3 inputs A, B, and C generate 8 active low outputs Y0 \u2013 Y7. O\/P Y is connected to CS of a memory chip as shown in figure 2.2. It selects 8 memory blocks. A,B and C select which o\/p is to be activated. Additional i\/p\u2019s G2A and G2B are both active low, and G1 is active high. If any one of the inputs G1, G2A, or G2B is not connected to an address signal, they must be activated permanently either by Vcc or ground, depending on the activation level.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-169 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-91.png\" alt=\"\" width=\"324\" height=\"490\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-91.png 324w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-91-198x300.png 198w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-91-65x98.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-91-225x340.png 225w\" sizes=\"auto, (max-width: 324px) 100vw, 324px\" \/><\/p>\n<div>\n<p>&nbsp;<\/p>\n<p><strong>2.3. Accessing On-chip and off-chip code ROM<\/strong><\/p>\n<\/div>\n<p style=\"text-align: justify\">In this section we are going to discuss the interfacing of 8031 microcontroller with external ROM. EA pin of 8031 microcontroller is connected to Vcc to indicate that the program code is stored in the C&#8217;s on-chip ROM. Figure 2.3 shows the on-chip and off-chip program code access.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">To indicate that the program code is stored in external ROM, this pin must be connected to GND.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">If we have EA= Gnd, then it refers to the on-chip Program. If EA=VCC, it refers to the off-chip program. However, , upon reset the 8051 executes the on-chip program first. Then, when it reaches the end of the on-chip ROM, it switches to external ROM for the rest of the program code.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-170 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-92.png\" alt=\"\" width=\"570\" height=\"259\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-92.png 570w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-92-300x136.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-92-65x30.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-92-225x102.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-92-350x159.png 350w\" sizes=\"auto, (max-width: 570px) 100vw, 570px\" \/><\/p>\n<div>\n<p>&nbsp;<\/p>\n<p><strong>2.3.1 8051 Interfacing with External ROM<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">CPU gives the address of the data required. Decoding circuit has to locate the selected memory block. Memory chips have CS (chip select) pin, which must be activated for the memory\u2019s contents to be accessed.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The pins 29, 30 and 31 of the 8051 microcontroller (shown in Fig. 2.4) are used to provide the memory interface related signals.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong>Pin 29<\/strong>: PSEN-If we use an external ROM then this pin should have a logic 0 which indicates that the Microcontroller should read data from memory.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong>Pin 30<\/strong>: ALE\/PROG- This pin is used for ALE that is Address Latch Enable. This pin is used to demultiplex address and data lines. This pin also gives program pulse input during programming of EPROM.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong>Pin 31<\/strong>: EA\/VPP- If we have to use multiple memories then applying logic 1 to this pin instructs 8051 to read data from both memories &#8211; first internal and then external.<\/p>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-171 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-93.png\" alt=\"\" width=\"408\" height=\"508\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-93.png 408w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-93-241x300.png 241w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-93-65x81.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-93-225x280.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-93-350x436.png 350w\" sizes=\"auto, (max-width: 408px) 100vw, 408px\" \/><\/p>\n<div>\n<p><strong><em>2.3.2 Steps to be followed when connecting external memory<\/em><\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">CPU data bus is connected directly to the data pins of the memory chip. Control signals RD (read) and WR (memory write) from the CPU are connected to the OE (output enable) and WE (write enable) pins of the memory chip. The lower bits of the address from the CPU are connected directly to the memory chip address pins. The upper ones are used to activate the CS pin of the memory chip.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>P0 and P2 role in providing addresses:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>\u2022 The PC (program counter) of the 8031\/51 is 16-bit, it is capable of accessing up to 64K bytes of program code.<\/p>\n<p>&nbsp;<\/p>\n<p>\u2022 16 bit address is provided by port 0 and port 2 to access external memory.<\/p>\n<p>&nbsp;<\/p>\n<p>\u2022 P0 provides the lower 8 bit address A0 \u2013 A7.<\/p>\n<p>&nbsp;<\/p>\n<p>\u2022 P2 provides the upper 8 bit address A8 \u2013 A15.<\/p>\n<p>&nbsp;<\/p>\n<p>\u2022 P0 is also used to provide the 8-bit data D0\u2013D7.<\/p>\n<p>&nbsp;<\/p>\n<p>\u2022 P0.0 \u2013 P0.7 are used for both the address\u00a0 and data paths (address\/data multiplexing).<\/p>\n<p>&nbsp;<\/p>\n<p>The ALE signal is used to determine whether P0 carries address or data signals.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong><em>2.3.2.1 ALE (Address Latch Enable):<\/em><\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>\u2022 ALE (address latch enable) pin is an output pin for 8031\/51.<\/p>\n<p>&nbsp;<\/p>\n<p>\u2022 When ALE = 0, then 8031 uses P0 for the data path.<\/p>\n<\/div>\n<p><span style=\"text-align: initial;font-size: 1em\">\u00a0 \u00a0 \u2022 W hen ALE = 1, then 8031 uses P0 for the address path.<\/span><\/p>\n<div>\n<p>\u00a0 \u00a0 \u2022 To extract the addresses from the P0 pins, it is connected to 74LS373 D Latch. The pins and structure of 74LS373 are shown in figure 2.5.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">\u2022 Separation of address and data can be obtained by using 74LS373. Figure 2.6 shows the address\/data de-multiplexing. In the figure it is noted that when ALE=0 and P0 is used as a data bus, sending data out or bringing data in. Whenever the 8031\/8051 wants to use P0 as an address bus, it puts the addresses A0-A7 on the P0 pins and activates ALE=1 to indicate that P0 has the addresses.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-172 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-94.png\" alt=\"\" width=\"372\" height=\"437\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-94.png 372w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-94-255x300.png 255w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-94-65x76.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-94-225x264.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-94-350x411.png 350w\" sizes=\"auto, (max-width: 372px) 100vw, 372px\" \/><\/p>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-173 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-95.png\" alt=\"\" width=\"642\" height=\"208\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-95.png 642w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-95-300x97.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-95-65x21.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-95-225x73.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-95-350x113.png 350w\" sizes=\"auto, (max-width: 642px) 100vw, 642px\" \/><\/p>\n<div>\n<p style=\"text-align: justify\">\u2022PSEN is the Program store enable and it is an o\/p signal. It is used to handle the Program memory and Data memory. PSEN is connected to OE pin of Program ROM. PSEN and EA of 8031\/8051 are used to access external ROM. If the Memory is the Program memory then PSEN is connected to External Memory which reads the Program from the external Memory. If EA is connected to Ground then external ROM is accessed. If EA is connected to VCC, then the internal ROM is accessed. Figure 2.7 shows the Data, Address and Control buses for the 8031\/8051.<\/p>\n<\/div>\n<div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-174 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-96.png\" alt=\"\" width=\"817\" height=\"493\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-96.png 817w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-96-300x181.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-96-768x463.png 768w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-96-65x39.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-96-225x136.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-96-350x211.png 350w\" sizes=\"auto, (max-width: 817px) 100vw, 817px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-175 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-97.png\" alt=\"\" width=\"690\" height=\"414\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-97.png 690w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-97-300x180.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-97-65x39.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-97-225x135.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-97-350x210.png 350w\" sizes=\"auto, (max-width: 690px) 100vw, 690px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">While accessing the address, ALE should be equal to one, and for accessing the data ALE should be equal to zero. When accessing the external program memory, PSEN pin of 8051\/8031 should be connected to the chip enable (CE and OE) pins of external memory, as shown in Figure 2.8.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>2.44 8051 Data Memory Space<\/strong><\/p>\n<\/div>\n<p><span style=\"text-align: initial;font-size: 1em\">The 8051 has 128 bytes of address space.<\/span><\/p>\n<ul>\n<li><span style=\"text-align: initial;font-size: 1em\">\u00a064 bytes are set aside for program code.<\/span><\/li>\n<li>Program space is accessed using the program counter (PC) to locate and fetch instructions.<\/li>\n<\/ul>\n<div>\n<p>&nbsp;<\/p>\n<p><strong>2.44.1 External ROM for data:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">For the ROM containing the program code, PSEN is used to fetch the code.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">For the ROM containing data, the RD signal is used to fetch the data. Figure 2.9 shows the connection to the external data ROM. Figure 2.10 shows the external memory for data.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-176 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-98.png\" alt=\"\" width=\"713\" height=\"370\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-98.png 713w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-98-300x156.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-98-65x34.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-98-225x117.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-98-350x182.png 350w\" sizes=\"auto, (max-width: 713px) 100vw, 713px\" \/><\/p>\n<p><strong><em>2.44.1.1 MOVX instruction<\/em><\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">We will now look at how the MOVX instruction is used to connect 8051 with the external data as shown in figure 2.11 .MOVX is a widely used instruction allowing access to the external data memory space. To bring externally stored data into the CPU, we use the instruction MOVX A,@DPTR.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\"><strong>Example: <\/strong>The word \u201cSAM\u201d has been burned in external data ROM locations starting from 4100H. Write a program to read this data into RAM locations of an 8031 starting from 60H.<\/p>\n<\/div>\n<div>\n<p><strong>Solution: <\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>MOV DPTR, #4100H ;DPTR=4100H(points to first source location )<\/p>\n<\/div>\n<p><span style=\"text-align: initial;font-size: 1em\">\u00a0 \u00a0MOV A, @DPTR\u00a0<\/span><span style=\"text-align: initial;font-size: 1em\">;get \u2018s\u2019 from location 1000H<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">MOV 60H, A\u00a0<\/span><span style=\"text-align: initial;font-size: 1em\">;move it to data RAM location 60H<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">INC\u00a0<\/span><span style=\"text-align: initial;font-size: 1em\">DPTR\u00a0<\/span><span style=\"text-align: initial;font-size: 1em\">; DPTR=4100H(points to next location)<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"text-align: initial;font-size: 1em\">MOVX A, @DPTR<\/span><\/p>\n<div>\n<p>\u00a0 \u00a0 MOV 61H, A<\/p>\n<p>&nbsp;<\/p>\n<p>INC DPTR<\/p>\n<\/div>\n<p><span style=\"text-align: initial;font-size: 1em\">\u00a0 \u00a0 MOVX A, @DPTR<\/span><\/p>\n<div>\n<p>\u00a0 \u00a0 MOV 62H, A<\/p>\n<p>&nbsp;<\/p>\n<p>END<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-177 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-99.png\" alt=\"\" width=\"752\" height=\"499\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-99.png 752w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-99-300x199.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-99-65x43.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-99-225x149.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-99-350x232.png 350w\" sizes=\"auto, (max-width: 752px) 100vw, 752px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>2.44.2 A single ROM for both program and data:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">To access same external memory for data and program, PSEN and RD are connected to an AND gate to signal the OE pin of the ROM chip. Figure 3.1 and 3.2 shows the 8031 connection to external Program ROM, Data RAM and Data ROM.<\/p>\n<\/div>\n<div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-178 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-100.png\" alt=\"\" width=\"759\" height=\"290\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-100.png 759w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-100-300x115.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-100-65x25.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-100-225x86.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-100-350x134.png 350w\" sizes=\"auto, (max-width: 759px) 100vw, 759px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-179 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-101.png\" alt=\"\" width=\"761\" height=\"488\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-101.png 761w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-101-300x192.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-101-65x42.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-101-225x144.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-101-350x224.png 350w\" sizes=\"auto, (max-width: 761px) 100vw, 761px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Exercises: ( Refer figure 3.2)<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">1. Find the address space of the data RAM, data ROM and program ROM<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">2. Write a program to access bytes of data which is in data ROM, divide it by 2, and save the quotient in the data RAM<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">3. Re-write the program for the case that the data byte is in the program ROM<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Solution for Exercise 1:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">The address line A15 and A14 of data RAM =10 for the chip to be selected. Thus address space is 1000 0000 0000 0000 to 1011 1111 1111 1111(8000H to BFFFH).<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">For the data ROM, A15 and A14 of data RAM =00 for the chip to be selected. Thus address space is 0000 0000 0000 0000 to 0011 1111 1111 1111(0000H to 3FFFH).<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">For the program ROM, address lines A15 and A14 are not used in address decoding. However , if A15 and A14 are 0, then the address space is from 0000H to 3FFFH. But , it does not create a clash with the address space of the data ROM or RAM, because different instructions are used to access the code space and the data space.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Solution for Exercise 2:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Let the required data be in first location in data ROM and let us transfer the quotient to the first location in the data RAM. Note that MOVX instruction is used to access the data ROM.<\/p>\n<p>&nbsp;<\/p>\n<p>ORG 0000H ; load the program in 0000H of program memory<\/p>\n<p>&nbsp;<\/p>\n<p>MOV DPTR,#0000H ; let DPTR point to data location<\/p>\n<p>&nbsp;<\/p>\n<p>MOVX A, @DPTR<\/p>\n<\/div>\n<p><span style=\"text-align: initial;font-size: 1em\">\u00a0 \u00a0MOV B, #02<\/span><\/p>\n<div>\n<p>\u00a0 \u00a0DIV AB<\/p>\n<p>&nbsp;<\/p>\n<p>MOV DPTR,#8000H<\/p>\n<p>&nbsp;<\/p>\n<p>MOVX @DPTR, A<\/p>\n<p>&nbsp;<\/p>\n<p>END<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Solution for Exercise 3:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Assume that the required data has already been burnt into location 0100H of program ROM . Here MOVC instruction is to be used to access data from program ROM.<\/p>\n<p>&nbsp;<\/p>\n<p>ORG 0000H<\/p>\n<p>&nbsp;<\/p>\n<p>MOV DPTR,#0100H\u00a0 ; let DPTR point to data location<\/p>\n<p>&nbsp;<\/p>\n<p>CLR A<\/p>\n<p>&nbsp;<\/p>\n<p>MOVC A.A+@DPTR<\/p>\n<p>&nbsp;<\/p>\n<p>MOV B, #02<\/p>\n<p>&nbsp;<\/p>\n<p>DIV AB<\/p>\n<p>&nbsp;<\/p>\n<p>MOV DPTR,#8000H<\/p>\n<p>&nbsp;<\/p>\n<p>MOVX @DPTR, A<\/p>\n<p>&nbsp;<\/p>\n<p>END<\/p>\n<p>&nbsp;<\/p>\n<p><strong>2.5 Interfacing to large External Memory<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">In some applications we need a large amount of memory to store data. Figure 3.3 shows 8051 Accessing the 256Kx8 External NV-RAM. For accessing the larger memory, some extra pins are used for accessing as address lines. P0 is address multiplexed. P2 is used for the address on the higher side. The 8051 can support only 64K bytes of external data memory since DPTR is 16-bit wide. To solve this problem, we connect P0 port and P2 port(A0 \u2013A15) of the 8051 directly to the external memory\u2019s A0 \u2013 A15 pins, and the additional A16 and A17 address pins are connected from P1.1 and P1.2 of 8051. Usually P0 and P2 ports are used as address ports, if needed P1 port pins can be used for additional address lines.<\/p>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-180 aligncenter\" src=\"http:\/\/csp13.epgpbooks.inflibnet.ac.in\/wp-content\/uploads\/sites\/62\/2018\/07\/2-102.png\" alt=\"\" width=\"770\" height=\"418\" srcset=\"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-102.png 770w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-102-300x163.png 300w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-102-768x417.png 768w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-102-65x35.png 65w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-102-225x122.png 225w, https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-content\/uploads\/sites\/62\/2018\/07\/2-102-350x190.png 350w\" sizes=\"auto, (max-width: 770px) 100vw, 770px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>3.Summary<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">In this module, we have discussed different semiconductor memories in terms of capacity, organization and access time. We have also discussed interfacing of ROM with 8051, and demonstrated accessing code and data from external memory through assembly program.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>4. References<\/strong><\/p>\n<ol>\n<li style=\"text-align: justify\">Muhammad Ali Mazidi, Janice Gillispie Mazidi, Rolin D. McKinlay, \u201cThe 8051 Microcontroller and Embedded Systems Using Assembly and C -Second Edition\u201d, New Delhi(2000).<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"author":2,"menu_order":14,"template":"","meta":{"pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":["dr-k-vani"],"pb_section_license":""},"chapter-type":[],"contributor":[58],"license":[],"class_list":["post-161","chapter","type-chapter","status-publish","hentry","contributor-dr-k-vani"],"part":3,"_links":{"self":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-json\/pressbooks\/v2\/chapters\/161","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-json\/wp\/v2\/users\/2"}],"version-history":[{"count":5,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-json\/pressbooks\/v2\/chapters\/161\/revisions"}],"predecessor-version":[{"id":452,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-json\/pressbooks\/v2\/chapters\/161\/revisions\/452"}],"part":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-json\/pressbooks\/v2\/parts\/3"}],"metadata":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-json\/pressbooks\/v2\/chapters\/161\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-json\/wp\/v2\/media?parent=161"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-json\/pressbooks\/v2\/chapter-type?post=161"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-json\/wp\/v2\/contributor?post=161"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/ebooks.inflibnet.ac.in\/csp13\/wp-json\/wp\/v2\/license?post=161"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}