Hi,
here's what I wrote. It's been able to read a sector from the CF card.
Note it's :
1/ directly ported from a very useful SanDisk AN that can be downloaded here :
http://www.sandisk.com/tech/oem_desi...%20MemMode.ZIP
2/ ugly code
romuald
void wait_ready(void) {
while((cf[STATUS_REG] & 0xF0) != 0x50);
}
void wait_drq(void) {
while((cf[STATUS_REG] & 0xF8) != 0x58);
}
void read_sect(const unsigned long num) {
wait_ready();
cf[SEC_COUNT_REG] = 0x01;
cf[LBA_LOW] = num; // No need for a cast...
cf[LBA_MID] = (num >> 8) & 0x000000FF;
cf[LBA_HI] = num >> 16;
cf[DRV_HD_REG] = 0xE0;
cf[COMMAND_REG] = 0x20;
wait_drq();
get_data();
}
void get_data(void) {
uint i;
xdata char * data b;
b = IDE_BUF;
for(i=0;i<512;i++) {
*(b + i) = cf[DATA_REG];
}
}
tim@apl.washington.edu (Timothy Wen) wrote in message news:<fcda06f1.0307141204.2e480039@posting.google. com>...