Re: compact flash

Jul 15, 2003 1 Replies

In article , Timothy Wen writes



Dear list,
>I am trying to use a compact flash in true IDE mode in an embedded environment.
>Has anyone done something similar before and is willing to share an
>example code?
>thanks.

I'm using it in memory mode, but while searching the web I found an audio player project which did use CF in IDE mode. If you google for "Compact Flash" IDE you should find it.

Tim Mitchell

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 :

formatting link

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 Dear list,

code?

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required