A kind of single-chip microcomputer super large data external memory extension system and control method thereof
Technical field
The invention belongs to single-chip microcomputer technical field of memory, particularly to a kind of single-chip microcomputer super large data external memory extension system and control method thereof.
Background technology
Along with becoming increasingly popular of computer network communication, the structure of computer data memory capacity is more and more important.And the address pins number of MCU limits the access capability of memorizer.Therefore, how can more extend the memorizer of MCU to deal with the storage demand of vast capacity, become the problem that the people of this technical field earnestly needs to solve.
Current existing MCU storage extended method is roughly divided into two kinds:
One, extending access capability by P1, P3 pin of single-chip microcomputer, but this method is by P1, P3 mouth number quantitative limitation, the capacity of extension is extremely limited, the most common MCS51 single-chip microcomputer, at most can only extend 256*256 memorizer (fully decoded);And occupy I/O mouth P1, P3 pin;
Two, serial ports expansion is passed through, such as use string to turn and chip 74LS164 is converted into parallel port data serial data, connect the CS(sheet choosing of each memorizer) pin, thus realize extension, but the drawback of this method is the most of extension, and the time that serial ports sends is the longest, and real-time is bad, and take the serial ports of MCU, add difficulty and cost..
Summary of the invention
In order to solve the technical problem that above-mentioned background technology proposes, it is desirable to provide a kind of single-chip microcomputer super large data external memory extension system and control method thereof, break through the capacity limit of conventional Extension method, meet the real time access demand of vast capacity.
In order to realize above-mentioned technical purpose, the technical scheme is that
A kind of single-chip microcomputer super large data external memory extension system, including 1 single-chip microcomputer, multiple first decoders, multiple expansion I/O mouth chips, multiple second decoders and multiple memorizer, each memorizer all with the address of single-chip microcomputer, DCB is connected, the input of each first decoder connects the address bus of single-chip microcomputer, the outfan of the first decoder connects the Enable Pin of each expansion I/O mouth chip, the input of each expansion I/O mouth chip is connected with the data/address bus of single-chip microcomputer, each expansion I/O mouth chip and each second decoder one_to_one corresponding, the input of each second decoder is connected with the outfan of corresponding expansion I/O mouth chip, the outfan of each second decoder sheet with each memorizer respectively selects port to be connected.
Wherein, described expansion I/O mouth chip uses 74LS373 chip.
Wherein, described first decoder, the second decoder all use 74LS138 chip.
Wherein, described memorizer can be ROM, it is also possible to for RAM.
Present invention additionally comprises control method based on above-mentioned single-chip microcomputer super large data external memory extension system, comprise the following steps:
(1) single-chip microcomputer enables each expansion I/O mouth chip by the first decoder;
(2) single-chip microcomputer is to the expansion I/O mouth chip write data enabled;
(3) using the output data of expansion I/O mouth chip as high address, after the second decoder carries out fully decoded, the output data of expansion I/O mouth chip are converted into the chip selection signal of each memorizer, thus gate respective memory;
(4) single-chip microcomputer carries out data access by the instruction of standard access external memory storage to the memorizer of gating;
(5) at next storage cycle, if the memorizer carrying out accessing is constant, the most directly perform step (4), when changing memorizer, then return step (1) and again enable expansion I/O mouth chip.
The beneficial effect that employing technique scheme is brought:
(1) present invention carrys out extension storage capacity by increasing I/O mouth extended chip, determines the memory capacity of extension according to the I/O mouth quantity of extension, breaches the capacity limit (256) utilizing the P1 mouth of common 51 single-chip microcomputers to be extended;
(2) present invention is compared with serial ports expansion, need not take the serial ports of single-chip microcomputer, the real-time of serial ports expansion can reduce along with the increase of extension, and the present invention switches selected memorizer by write instruction, when memorizer is constant, need not again write instruction to select memorizer, be directly accessed, improve the efficiency of access;
(3) using the external memory extended method of the present invention, I/O address and each memorizer of extension are overlapping, when choosing the I/O of each extension, choose the appropriate address of each memorizer the most simultaneously.If memorizer is RAM, overlapping space cannot be used for depositing data, wastes point space, and whole storage space is discontinuous;If memorizer is ROM, being read-only, and the I/O extended only writes, be independent of each other mutually, this space that partly overlaps is to use, can't wasting space, but whole storage space remains discontinuous.The theory of the present invention is exactly to sacrifice few overlapping space, and exchanges huge memory space for, is particularly suited for need not Coutinuous store space but to the highest field of storage capacity requirement and occasion.
Accompanying drawing explanation
Fig. 1 is the block diagram of system of the present invention.
Detailed description of the invention
Below with reference to accompanying drawing, technical scheme is described in detail.
The block diagram of system of the present invention as shown in Figure 1, a kind of single-chip microcomputer super large data external memory extension system, including 1 single-chip microcomputer, multiple first decoders, multiple expansion I/O mouth chips, multiple second decoders and multiple memorizer, each memorizer all with the address of single-chip microcomputer, DCB is connected, the input of each first decoder connects the address bus of single-chip microcomputer, the outfan of the first decoder connects the Enable Pin of each expansion I/O mouth chip, the input of each expansion I/O mouth chip is connected with the data/address bus of single-chip microcomputer, each expansion I/O mouth chip and each second decoder one_to_one corresponding, the input of each second decoder is connected with the outfan of corresponding expansion I/O mouth chip, the outfan of each second decoder sheet with each memorizer respectively selects port to be connected.
In the present embodiment, described expansion I/O mouth chip uses 74LS373 chip.
In the present embodiment, described first decoder, the second decoder all use 74LS138 chip.Wherein the first decoder is used for extending multiple I/O mouth, determines the address of the I/O of extension, and the second decoder is for carrying out fully decoded by the data that the I/O mouth of extension exports, it is achieved the sheet choosing of memorizer.
In the present embodiment, described memorizer can be ROM, it is also possible to for RAM.
Present invention additionally comprises control method based on above-mentioned single-chip microcomputer super large data external memory extension system, comprise the following steps:
(1) single-chip microcomputer enables each expansion I/O mouth chip by the first decoder;
(2) single-chip microcomputer is to the expansion I/O mouth chip write data enabled;
(3) using the output data of expansion I/O mouth chip as high address, after the second decoder carries out fully decoded, the output data of expansion I/O mouth chip are converted into the chip selection signal of each memorizer, thus gate respective memory;
(4) single-chip microcomputer carries out data access by the instruction of standard access external memory storage to the memorizer of gating;
(5) at next storage cycle, if the memorizer carrying out accessing is constant, the most directly perform step (4), when changing memorizer, then return step (1) and again enable expansion I/O mouth chip.
Above example is only the technological thought that the present invention is described, it is impossible to limiting protection scope of the present invention with this, every technological thought proposed according to the present invention, any change done on the basis of technical scheme, within each falling within scope.