Tech Support > Computers & Technology > Programming > Query regarding Compact Flash cards
Query regarding Compact Flash cards
Posted by Ravi kumar.N on August 25th, 2004


Respected Experts,

I am Ravi kumar.N, currently working on CF cards

I have written a FORMATTING program for an embedded environment where
OS is not used.I have used intel 386ex embedded processor.

Flash card is configured into memory mapped mode.

Also we have used the command 0xEC(CF - ATA Command set) to identify
the drive . Here sectors are accessed in LBA mode.



Here Iam explaining FORMAT code in brief. My formatting code does the
following.





1) writes boot sector content.i.e. jump code, no: of sectors per FAT,
total no: of sectors, type of file system etc.. at Sector 0.

2) writes FAT1 copy to sector 1. First 3 bytes contain 0xF8, 0xFF,
0xFF and remaining bytes are 0's

3) writes FTA2 copy to sector 7. FAT1 and FAT2 copy are identical.

4)Root sector is written at sector 0x0d ( decimal 13). Root sector
contain filename, file ext, size of file etc..

The code is like this...



main()

{

do

{

flag = reset _card(); /*this function is explained in brief below*/

} while( ! ((check_fatentry()) && (detect_card() && flag)));

}



if check_fatentry(), detect_card() and flag returns TRUE, control will
come out of the loop else keeps on repeating in the do ---- while
loop.





reset_card()

{

writes boot sector to sector 0.

writes FAT1 to sector 1 and FAT2 to sector 7.

writes root directory to sector 13(decimal value).

}



After writing all the above things to the particular sectors
check_fatentry is called at while loop as shown above.

Here I have used two pointers *buffer1, *buffer2.

Whatever the content I write to FAT1 is also placed in buffer1.



check_fatentry()

{

Iam retrieving the FAT copy from sector 1 to buffer2 and comparing the
same with buffer1.

Also Iam retrieving FAT copy from sector 7 to buffer2 and comparing
the same with buffer1.

if both buffers (i.e. buffer1 and buffer2) are equal check_fatentry
returns TRUE(1) else FALSE(0).

}

check_fatentry() is returning FLASE after comparing buffers 1 and 2
for CF cards like sagatek, simpletech, viking etc...

But the same code is working fine for Sandisk CF card.What ever the
content I write to Sandisk I am getting the samething when I read it
back. But it's not happening like that for other CF cards.



What might be the problem, please let me know.

Thanks in advance.

With Regards

Ravikumar.N


Similar Posts