Hello, I'm working on a project to read files from a PC-formatted
>compactflash card using an 8051. CF card is in 8 bit memory mode. I can
>read & write its control registers OK, and I've used "WinHex" to display
>the FAT16 structure of the card so I know what's going on in there.
>
>Here is my problem: reading sectors 0x01-0x20 all return the boot sector
>which WinHex shows at 0x00. Sector 0x00 returns some data I don't
>recognise. From sectors 0x21 onwards, the 8051 reads the sectors which
>WinHex shows at 0x01 onwards, i.e, all sector numbers seem to be 0x20
>higher than they should be. Apart from that, I can read the sector data
>correctly so it seems like the hardware interface is fine. I'm using LBA
>addressing, I can't get my head round Sector/Cylinder/Head mode. Can
>anyone tell me what's going on here?
Tim,
The way it sounds you stumbled over a common misinterpretation.
Removeable media can be formatted in two flavours. With one you have a partition table, and then at the offset specified by the partition table you have the FAT MBR and remaining parts of what forms the FAT filesystem(s) etc. The other flavour does not have a partition table and the medium directly starts with the FAT MBR. This latter case is what happens if Windows formats a removeable media. Windows recognizes both cases. WinHex by default showes you the start of the MBR. If memory serves you can put it into some sort of "physical" mode where you should be able to look at sector 0 on the PC end also and where you will see the IMHO present partition table of your specific CF also from within WinHex.
HTH
Markus