On Sat, 2006-03-18 at 11:37 -0500, Robert Ammerman wrote: > > On Tue, 2006-03-14 at 13:31 -0800, Rob Robson wrote: > >> Not being a "C" guy, I'm still a little unclear on the sector read > >> process. > >> When a "sector read" command (20h) is issued to a drive after feeding it > >> the target sector's CHS or LBA address, does DRQ have to be polled before > >> reading each word from the drive? How does the drive "know" that you've > >> read a word from its buffer? And does it automatically place the next > >> sector word on the data lines? In short, what is the step-by-step > >> process > >> to read 512 bytes through a 16-bit port? > > > > You can poll DRQ, I found though that at the speed of my PIC in carmon > > it wasn't necessary. > > > > The drive knows you've read the data by you toggling the RDb line. Every > > time you toggle that line the drive puts the next word on the line. > > You really should poll the DRQ line. In normal circumstances the drive will > have the data ready long before the PIC can get around to reading it. > However, if the drive has to do error correction, or recalibration before > returning the data then it can be a bit before DRQ goes active. > > This is one of those things that will seem to work fine for a long time and > then turn around and bite you leaving you wondering what hit you. That may be true, when dealing with hard drives. However, the op and I were both talking about compact flash cards, bad sectors there usually mean a dead card. That said, I'm pretty sure that the drive does the read in one shot, so when you extract the data from the drives buffer all the data has already been read from the physical drive, long after any error correction has been performed. Note that I'm not talking about issuing a read command and just starting the read, I poll the status bit to confirm the read from the drive has completed, it's just that during the extraction of the sector I don't poll anything. TTYL ----------------------------- Herbert's PIC Stuff: http://repatch.dyndns.org:8383/pic_stuff/ -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist