At24C512 data document systematization management
August 8, 2008 – 1:59 pmAbstract: In order to facilitate in monolithic integrated circuit’s to carry on the systematized management to AT24C512 data, in introduced that at24C512 basic structure and in principle of work’s foundation, realizes at24C512 filing system according to the PC machine document management’s thought that enhances the data management the efficiency.
Key word: AT24C512 monolithic integrated circuit filing system data management
In constitutes by the monolithic integrated circuit in the middle of the data acquisition system and the smart instrument measuring appliance, often has the mass data to preserve. Along with observation system digitization development, the people set a higher request to the data storage, thus uses in the stored datum the storage capacity being also getting bigger and bigger. But, while increases the data reserves, the people also hoped that can operate data highly effective conveniently (including browsing, increase and deletion and so on), namely looks like on the PC machine managerial data to be equally easy and feasible. However, the monolithic integrated circuit as well as uses in preserving the data the chip itself not to provide this kind of function, for this reason, needs to develop one kind to use in managing the monolithic integrated circuit data the efficacious device. This article in absorbs the PC machine document management thought in the foundation, take AT24C512 as the example, constructed one kind to be similar in the filing system uses in the management monolithic integrated circuit data the method, raised the data manipulation efficiency greatly.
1 AT24C512 introduction
The programmable memory which AT24C512 is Atmel Corporation produces the 64KB serial electricity which may scratch, the interior has 512 pages, each page is 128 bytes, any one unit’s address is 16, the address range is 0000~0FFFFH. It uses 8 pin seals, has the structure to be compact, storage capacity big and so on characteristics, may connect in parallel fashion 4 piece of chips on 2 main lines, is suitable specially in has the large capacity data storage request data acquisition system, therefore is used massively in the observation system.
AT24C512 seal as shown in Figure 1, various pins’ function is as follows:
①A0, A1– address selection input end. In the serial bus structure, like must connect 4 AT24C512 chips, then available A0, A1 differentiate various chips. A0, A1 are hanging when is 0.
②SDA– bidirectional serial data input outlet. Uses between the memory and monolithic integrated circuit’s data exchange.
③SCL– serial clock input. Usually in its rise along the SDA on data write store, but along and escorts to the drop from the memory readout SDA.
④WP– writes the protection input. When this pin and the place are connected, the permission writes the operation; Is connected when with VCC, all writes the memory operation to forbid. If the company, this foot will not pull under the chip interior.
⑤VCC– power source.
GND earth. NC is hanging.
(1) and monolithic integrated circuit connection
Because AT24C512 has followed at24C series connection characteristic, therefore may also follow the conventional routes with monolithic integrated circuit’s connection. Generally A0, A1, WP meet VCC or GND, SCL, SDA the earth monolithic integrated circuit’s P1 mouth, then realizes the monolithic integrated circuit to at24C512 operation.
(2) equipment selected location
In starts the operation before24C512, needs to send a 8 address character to choose the chip first to carry on the read-write. Device address character form as shown in Figure 2. And “10100″ are the fixed 5 binary systems; A0, A1 use to many AT24C512 differentiate; R/W is the read-write operation position, is when 1 indicates reads the operation, is when 0 indicated that writes the operation.
(3) writes the operation
AT24C512 writes the operation to have writes the byte and writes the page two ways. Writes when the byte usually in connects in parallel fashion to at24C512 transmitter installation address character after the answering signal, but also needs to transmit 2 8 bit addresses to choose must write the data the address. After AT24C512 receives this address, will reply a zero signal, will then receive 8 bit data to come, and will return to a zero answering signal again.
When writes the page way, AT24C512 may disposable read in page of 128 bytes. Its initialization process with writes the byte basically the method same. What is different: After reading in a data byte, the monolithic integrated circuit does not send the stopped state, but after answering signal then inputs 127 bytes; After each byte receive finished, AT24C512 in the same old way output a zero answering signal.
(4) reads the operation
Reads the operation to have the current address to read, to read, reads the string three ways stochastically. Its initialization process with writes the operation to be the same basically, is only must alter to the unit select character most low position reads. When the current address reads the operating mode, internal data’s address will maintain, in the final read-write operation address adds on 1, after reading the final byte returns to the position which most starts. But reads the operation, before stochastically must read in a byte address first to AT24C512, then can read. Reads the string operation already to be possible to be the current address reads, may also be the random address reads. When the monolithic integrated circuit receives after a data character, will respond an answering signal. AT24C512 after receiving the answering signal will add the address 1, then output next byte. When the monolithic integrated circuit receives the data but does not deliver the answering signal, reads the process to end.
2 filing system constitution
To manage at24C512 effectively the data, the author imitates PC machine the document management mechanism, was AT24C512 has constructed a simple filing system. Considered the observation system’s timely request and hardware source’s finiteness, has used the second-level shape of tree table of contents organization.
For the managerial data is convenient, at24C512 physical space division is 1024 logical pages, each page of 64 bytes. According to filing system’s need, at24C512 complete spatial division is three parts: The data area, takes the final 960 pages; The page distribution area, takes the middle 30 pages; Front the table of contents area, takes 24 pages.
(1) data area
At24C512 most behind 960 page of achievement data area, its serial number from 0 starts the serial number. This area takes the file data the memory region, when file documents data, assigns certain pages from this area, each time saves a page.
(2) page distribution area
The page distribution area has recorded the data area each page of assignment situation. In this area every 2 bytes compose one record item, altogether has 960 record items (30×64/2). The record item from 0 starts the serial number, each record item is corresponding the data area corresponding page service condition.
In the practical application, a document’s data often is bigger than 64 bytes, in this kind of document’s data area must take many pages. But along with the document additions and deletions, the data area’s idle space has not the continual condition, thus the data area’s assignment cannot guarantee continual, but according to the current data area’s service condition decided that on which page some part of document content should place. For organically connects these dispersion’s data, organizes the record item according to the chain table form, each document is corresponding a chain table, in the chain table each point is a record item, a record content for a next record serial number, last a record content is 0FFFFH, indicated that the chain table finished. Connected these record correspondence’s page constituted a document complete data.
Moreover, if records a content is 0EEEEH, indicated that its correspondence’s data page has not assigned.
(3) table of contents area
The table of contents area uses for the storage file the main information. May know the filename, the file generation date as well as the document data according to these information in the data area memory first address. A file directory structure is as follows:
①Filename. The filename by 4 byte double BCD code constitution, when produced this document by the keyboard entry digit (on hardware keyboard only provides numeric keyboard) to take the filename, and transformed automatically by the procedure them forms a pair the BCD code. When needs to demonstrate, decomposes them 8 byte list BCD code to supply again the demonstration.
②File generation date. Takes 4 bytes, according to the double BCD code’s form memory, like 20H, 04H,03H, 20H expressed on March 20, 2004. The date may by the keyboard entry or through the clock chip gain.
③Document first address. The instruction is giving this file allocation space to enter, assigns for its first data page serial number, namely it corresponds chain table first record serial number.
The table of contents area altogether takes 24 pages. Because each document information only takes 10 bytes, in this filing system, most may save 153 (24×64/10) a document. The table of contents area, the page distribution area and data area’s logical relation as shown in Figure 3.
Take Figure 3 as an example, explained how this filing system does gain the file data:
①Found in the table of contents area according to the filename contains this filename the table of contents item, thus gained this document attribute and the first address. If document “00000103″ the date was on November 24, 2003, its first address was 0005H.
②According to the document first address, found this record item of 0005H in the page distribution area. The value which saves in this record item is 0007H, may know this document the next record item is 0007H.
③Likewise, may obtain the document following record item is 0008H, 0009H, 000BH, until reads 0FFFFH from the 000BH record item. This time expressed that this is the last item, could not continue to look for the successor item again.
④Hence, may know the document “00000103″ the data divides into 5 parts to save in the data area, saves separately in 0005H, 0007H, 0008H, 0009H, in the 000BH page. So long as arrives in the data to read in these’s data according to sequence, and connects, has formed this document complete data.
⑤Likewise, the document “00000001″ have used 0002H and the 0003H two pages in the data area, the document “00015671″ has only used the data area 000AH page.
3 system programming
According to the above filing system structure, the system may through the table of contents area and the page distribution area to at24C512 complete data real-time document management. In the management process, the most main operation is the append file and the delete files.
(1) append file
Append file’s prime task is seeks for the storage space for the new document, it seeks for the step to be as follows:
①Seeks for the spatial position in the table of contents area. If the table of contents area already saved fully (most saves 153 documents), reports and stops the procedure to the user; Otherwise, records this position (to record is MyFile).
②The computation file data must take the page number, records is My Page.
③Seeks for and counts the symbol in the page distribution area for the spatial record item, its content is 0EEEEH. If its number is smaller than MyPage, reported to the user, and stops the procedure.
④In the MyFileA position filling in filename and the date, and a first spatial record serial number which finds fill, take this document the first address.
⑤In found in turn in the spatial record item fills in a next spatial record serial number, last spatial record item fills in 0FFFFH.
⑥Starts from the document first address, according to document chain table in turn data write data area corresponding page.
(2) delete files
Delete files’ prime task recycles the space which this document takes, so that the future will be able to assign for other documents.
①Seeks in the table of contents area to this document, withdraws its first address, records First. Afterward, the table of contents area first byte which takes this document clear is 0FFH, indicates this table of contents free time.
②Found the First record item in the page distribution area, scooped up its content, recorded is Next. Afterward, First record content rewriting is 0EEEEH.
③First=Next, redundant②, until Next=0FFFFH.
Figure 3
May see by the append file, when search space, only to table of contents area and page distribution area operation, therefore, time delete files, only needs to release the table of contents and the page distribution area then, but does not need to revise the data area. This raised the deletion efficiency greatly.
(3) system formatting
The system formatting’s goal is carries on AT24C512 according to the form which front states the initialization, by correct reflection present behavior in service. The formatted prime task includes:
①Writes the table of contents area is 0FFH completely, by clear spatial table of contents area in all data;
②Writes the page distribution area’s all record item is 0EEEEH, symbolized that they have not used completely.
Note: The filing system procedure source code sees the website: www.dpj.com.cn.
4 performance comparisons
In the majority systems, in at24C512 data storage is needs to use the order to save the law: Each time when stored datum defers to successively the order in turn write data space. This article states the method and the smooth memory law compares, has the following merit:
①When memory simplicity of operator. In the smooth memory, seeks for the data which the idle space needed to read out gradually already saved, until found the idle space, the data level of operation was big. This article states the method only to need to read the table of contents area and the page distribution area then, the search idle space’s efficiency is high.
②The deleted data is simple. In smooth memory, to locate to the data which needs to delete, must read out the data which gradually saves, until found needs the deletion data, rewrote again this free time for has not used the condition. This article states the method only to need to revise the table of contents area and the page distribution area then, not only the locator data is quick, moreover revises the work load is very small.
③Has realized the data space recycling. In smooth memory law, after deletion some data, this data takes the space is possibly unable to recycle the use. Because recycles the space will form the fragment: Around this space saves has the data, but this space’s length is unable to satisfy a greater length the data. This article states the method use chain table assignment storage space, allows a document the data must continuously to present, the recycling space may use freely.
④Through read table of contents area, what the user may know in this document to save approximately is any data, but the smooth memory law is actually unable to supply these information.
5 conclusions
In order to realize the real-time observation system data highly effective management, according to the PC machine filing system’s thought that to observed and controlled in system’s AT24C512 to design a simple filing system, including functions and so on system formatting, append file, delete files, obtained the success application in the great data quantity’s observation system. This filing system revises slightly may apply in the different capacity memory chip, has the widespread application value.