The monolithic integrated circuit realizes to CF the card read-write

August 8, 2008 – 11:16 am

    Abstract: The CF card was one kind has contained the control and the large capacity Flash memory’s standard component, had the capacity to be big, the volume was small, the high performance, carried merits and so on convenience, has widely applied in the data acquisition system and many news class electronic products. This article introduced in detail the CF card’s in monolithic integrated circuit system hardware interface electric circuit, as well as the monolithic integrated circuit carries on the standard file read-write to the CF card realization, and reads in the document can by the Windows operating system read-write.

    Key word: CF card monolithic integrated circuit FAT document format

Introduction

Because the CF card (Compact Flash Card) has the capacity to be big, the volume is small, the high performance, carries merits and so on convenience, moreover the read-write speed is quick, may be compatible with many kinds of computer operating system platform, therefore redeposits in data acquisition system’s data record or with the PC machine between data uses the CF card. For can carry on the data processing conveniently in PC machine, must use one kind of standard form organization data in the lower position machine end, soon the data reads in according to the Windows standard file form, through will read the card in the PC machine end to read in CF the content by the standard file form read-out. The Windows standard file form has FAT, FAT32 and NTFS. Considered the widespread use Windows 98 system’s CF card’s factors and so on capacity, usually use FAT (File Allocation Table) the filing system. The monolithic integrated circuit system to the CF card’s read-write, is carries on the direct operation from the first floor to it, including addressing, foundation document and read-write and so on.

1 CF card synopsis

In the CF card integrated the controller, Flash the Memory array and the read-write buffer, as shown in Figure 1. The built-in intelligent controller, causes the peripheral circuit design big simplification, moreover conforms to PC machine completely memory card League of nations PCMCIA (Personal Computer Memory Card International Association) and ATA (Advanced Technology Attachment) the interface specification. In fact, the controller played one kind of protocol conversion role, soon transformed to the Flash Memory read-write visit to the controller, such different CF card might use the sole organization to come the read-write, but did not use the worry compatible question. The CF card’s buffer structure, causes the external instrumentation and CF card correspondence at the same time, the CF card internal controller may carry on the read-write to Flash. This kind of design may increase the CF card data read-write the reliability, simultaneously raises the data transfer rate.

The CF card support many kinds of connection visit pattern, has conforms to PCMCIA standard Memory the Mapped pattern, I/O the Card pattern and conforms to ATA standard True the IDE pattern. When on electricity, OE (9 feet) are the low level, the CF card enter True the IDE pattern, this time pin OE also calls ATA SEL; When on electricity, OE (9 feet) are the high level, the CF card enter the PCMCIA pattern, namely Memory the Mapped pattern or I/O the Card pattern, this time may enter the corresponding pattern through the revision disposition option register.

The disposition option register form is as follows:

SRESET LevelREQ conf5 conf4 conf3 conf2 conf1 conf0

SRESET- soft reset signal;

Level REQ- interrupt pattern choice (level or border triggering).

For example, must join Memory the mapped pattern, only needs when on electricity guaranteed that OE is the high level, because the disposition option register’s conf5~conf0 position’s initialization value is “00000″; But must enter I/O the Card pattern, besides on electricity when guaranteed that OE is the high level, but must further establish conf5~conf0, like Table 1 arranges in order. But speaking of the concrete model’s CF card, the following three kind of situations are also (CF card Association) are permitted by CFA:①On when electricity enters True the IDE pattern, in the work process, so long as monitors OE to become high, withdraws from True the IDE pattern;②Permission card when replacement redeploys;③On when electricity enters the PCMCIA pattern, permits in the process, so long as monitors OE to become lowly, enters True the IDE pattern.

Table 1 pattern choice

conf5 conf4 conf3 conf2 conf1 conf0 Pattern 
0 0 0 0 0 0 Memory map
0 0 0 0 0 1 I/O Mapped, corresponds 16 systems
0 0 0 0 1 0 I/O, corresponds 1F0h-1F7h/3F6h-3F3h
0 0 0 0 1 1 I/O, corresponds 170h-177h/376h-377h

2 CF cards and 51 monolithic integrated circuit’s connection

The CF card way in PC the Memory with 51 chip’s interface circuit as shown in Figure 2. Because after using in the CF card the electricity, enters automatically Memory pattern, moreover does not exist to the characteristic register’s read-write, therefore may meet REG the high level. Selects patches or strips of land as worth saving for seed signal CE1 and the CE2 combination may the selecting data bit width, like Table 2 arrange in order. Figure 2 CE2 meets VCC, what selects is 8 (D7~D0) the data width.

Table 2 data width choice

  8 (D7~D0) 8 (D15~D8) 16 High-resistance   
CE1 0 1 0 1
CE2 1 0 0 1

In order to realize the function which namely inserts namely uses, in the CE card provided two to use for to examine the card whether to exist the pin (CD1, CD2), earthed by the card interior. When the main engine examines with its connected CD1 and at the same time the CD2 two pins for the low level, may judge the card and the main engine is connected; Otherwise, the card has not been connected with the main engine.

Because the I/O mouth is anxious, the RDY/BSY pin hanging does not use, can judge the CF card through the inquiry condition register whether to be ready. In practical application, because one time wants a read-write sector 512 byte at least, must therefore expand together RAM. What we select is 62256, the capacity is 32KB, like this then may support in a big way (see also as follows) to the 2GB CF card, increased its extension.

3 FAT filing system

The FAT filing system is based on the DOS filing system. Often said FAT has 12 FAT12 and 16 FAT16, moreover is 32 FAT32. Considered the CF card the capacity is limited, selects FAT16 suitably. Here only does to the FAT filing system one introduced simply, more detailed content audience reference.

Floppy disk’s addressing system has two kinds: Physical addressing C/H/S (cylinder/magnetic head/sector) way and logical block LBA (Logical Block Addressing) addressing system. Between the two’s transformation relations are:

LBA address = (cylinder number * magnetic head number magnetic head number) * sector number sector number - 1

Uses the LBA addressing system, does not have the magnetic head and track’s transformation operation, when visit continual sector, the operating speed must be quicker than physics addressing system, moreover also simplified visit to the floppy disk.

Hard disk’s structural configuration divides into MBR (main boot-sector) and most 4 logical districts (including the DOS district or the non-DOS district), but is as follows in the DOS logic district’s floppy disk organization:

Boot-sector FAT1 FAT2 Root target area Data area

Boot-sector DBR (DOS Boot Record): Located at the LBA 0 sectors, contained the skipping instruction, manufacturer marking and the DOS edition number, BPB (BIOS Parameter Block, BIOS parameter block), the DOS vectoring procedure, end mark character AA55. And BPB contains each sector byte count, each bunch of sector number, each FAT sector number, sector main line, root directory number of terms and so on parameters.

FAT is for each file allocation floppy disk physical space form. The FAT16 bunch of number’s upper limit is 2 16, namely 65536, each bunch of sector number’s upper limit is 64, therefore its district space’s upper limit is 2G. FAT1 located at logical 1 sector. In a FAT bunch of mapping, 0000 express the spatial bunch, FFF0~FFF6 spare, FFF8~FFFF expressed that a bunch of chain finished, FFF7 expressed the bad bunch, its complement expressed its following bunch of bunch of number. Shown in Figure 3 a document outset bunch of number is 2, a conclusion bunch of number was 4, altogether took 2, 3, 4 three bunches.

The bunch is the storage file smallest unit, may contain many sectors. When document itself or document last bunch, even if only then 1 byte, must occupy 1 bunch. Thus, when this kind of document are many, the spatial waste is very considerable.

Document directory lists FDT (File Directory Table) is the operating system seeks for the document the entrance, its content is each document table of contents. In the FDT each table of contents item is composed of 32 bytes. The first 8 bytes are the filename, when the insufficiency fills up with the blank space. Is following close on 3 bytes are the document extensions, is 10 byte system reserved words. Is the creation of document time and the date occupies 8 bytes, the 2 bytes are the document first bunch of numbers after again, finally 4 bytes are the document sizes. The FDT outset sector may figure out by the FAT great sub-total, but the FAT size may read out in DBR.

4 softwares realize

According to the FAT16 way storage file, is an general solution. Because may obtain existing DOS and the Windows system’s support like this, but the price wastes part of spaces, i.e. the storage efficiency dropped. In order to improve this situation, has used the improvement storage method. Founds a spatial document first, and according to needs to assign a big storage space for it, the writing action is only supplements the data from the rear part. This has avoided the small document production, both may use the storage space fully, and may cause the address to be continual.

The CF card’s read-write is carries on through the card in buffer, does not support the direct read-write to save the region. The buffer is a FIFO structure, the read-write order carries on, did not support the random access, the system can only disposable read off either finish all or the many sectors according to the order.

When design uses the LBA way to visit the CF card to be quite convenient, when read-write only needs to read in the LBA address first in the corresponding register then. Must establish the LBA way, must visit the driver/magnetic head register. Under the memory pattern partial register decoding like table 3 arrange in order.

Table under 3 memory patterns partial register decoding

REG A10 A9~A4 A3~A0 offset OE=0 WE=0
1 0 X 0000 0 Occasionally the byte reads Leans the byte to write
1 0 X 0001 1 Wrong register Characteristic register
1 0 X 0010 2 Sector number Sector number
1 0 X 0011 3 Sector number (LBA7~0) Sector number (LBA7~0)
1 0 X 0100 4 Low cylinder number (LBA15~8) Low cylinder number (LBA15~8)
1 0 X 0101 5 High cylinder number (LBA23~16 High cylinder number (LBA23~16)
1 0 X 0110 6 Driver/magnetic head (LBA27~24) Driver/magnetic head (LBA27~24)
1 0 X 0111 7 Condition register Orders the register

The driver/magnetic head register structure is as follows:

1 LBA 1 DRV HS3 HS2 HS1 HS0

LBA-1 is the LBA way, 0 are C/H/S (cylinder/magnetic head/sector) the way; DRV- choice driver 0 or driver 1; HS3~HS0-LBA27~24, or is the C/H/S way magnetic head number.

The document foundation process is also aims at FAT and the FDT read-write process. First in FDT the request form item, the foundation document name, the attribute, an outset bunch of number, the document size and so on, then revises FAT, assigns the data space, backup FAT. The file memory is must first obtains the document from FDT and FAT an outset bunch of number and the bunch of number chain, namely LBA address. Then, gives the register this address 3, 4, 5, 6 (Table 3 offset3, 4, 5, 6), occupies the sector integer to the sector number register filling in read-write data, to the CF card’s order register write operation’s order character, writes again operates 30H, reads operates 20H. After reading in the order or the write data, must inquire the condition register’s condition, determines the CF card whether to be ready or read in successfully. The condition register structure is as follows:

BUSY RDY DWF DSC DRQ CORR 0 ERR

Everybody’s value is 1 when the meaning is as follows:

The BUSY-CF card records, this time cannot accept other orders;

The RDY- card may accept the order;

DWF- writes the mistake;

The DSC- card is ready;

DRQ-CF card request data transfer;

But the CORR- data error is revised, will not terminate the multi-sectors to read the operation;

ERR- in the previous order by some kind of wrong conclusion, might examine the wrong type in the wrong register.

Below take writes a sector data to the CF card as an example, gives shown in Figure 4 the flow and the C procedure code.

bit flag_1, flag_2;

void cfwr()

{

unsigned char status;

cfwr_comm(0xe0,0×00,0×00,0×6c);

// writes the parametric command, the directional logic 6c sector

do{status=PBYTE[0x07]; // reads the condition register

if ((status & 0×01) ==0×01)

flag_1=1; if // ERR=1, sets makes a mistake the symbol, makes corresponding processing

while (status! =0×58);

cfwr_dat(); // write data

do{status=PBYTE[0x07]; // reads the condition register

if ((status & 0×20) ==0×20)

flag_2=1; if // time DWF=1, sets makes a mistake the symbol, makes corresponding processing

while (status! =0×50);

}

void cfwr_comm (unsigned char lba27, lba23, la15, lba7) // writes the parametric command function

{PBYTE[0x02] the sector number is 1

PBYTE[0x03]=lba7;

PBYTE[0x04]=la15;

PBYTE[0x05]=lba23;

PBYTE[0x06]=lba27; // establishes the LBA way

PBYTE[0x07]=0×30; // delivers reads in orders 30H

}

void the cfwr_dat() // writes the data function

{unsigned int i, temp;

unsigned char xdata dat[512]; //dat [] deposits a sector the data

for (i=0; i<512; i ) // writes 512 bytes continuously

{P1=P1 & 0xf8; // selects exterior RAM

temp=dat[i];

P1 ; // acts according to the actual electric circuit choice the CF card

PBYTE[0x00]=temp;}

}

5 conclusions

The author in the humidity instrumentation, the method which introduced according to this article, redeposits the data with the CF card to the computer, may carry on the maintenance very conveniently to the data.

Share/Save/Bookmark

Post a Comment