> -----Original Message----- > From: pic microcontroller discussion list > [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Peter L. Peres > Sent: Wednesday, March 20, 2002 13:01 > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: [PIC]: IDE interfacing > >I have had more success, being completely confounded by it always > >returning 4F4F when I tried a sector read (but working fine when I do an > >identify drive command) I changed from using LBA (11100000 in the > >device/head register) to CHS (10100000 in the device/head register) and > >that appears to work. I am royally confused, this drive DOES support LBA > >(I checked in another computer and I checked the bit field in the > >identify drive command response) so I'm not sure why it didn't work > >properly in LBA mode. Do I have to SET it for LBA (aside from the > >device/head register?). I really don't want to use CHS if I don't have > >to, the conversions get annoying, especially on something as small as a > >PIC. Thanks for any info. TTYL > > 4F4F may be what you read from a drive that was wiped in the factory or > hard formatted. You should put the drive in another computer (preferrably > running linux) and write the first sector with a known hex file (or use > seq and dd in linux). Then you will know what you expect to read. There is > NO need to format the drive, just write a sector or a few using a disk > editing tool. Actually before I started I fdisked, formatted (with FAT16) and added one file to both drives so that I know what to expect. > The LBA issue is moot until you are sure that the IO routines you wrote > work right. Try several commands besides init and status (like spindown > etc). You can also exercise the drive interface via the buffer write/read > commands. This will not write to disk. Sector 0 is the same in LBA and > all other modes. If you concentrate to read it right, knowing what to > expect, then it should work right eventually. I believe my routines are at least very close, since accessing the drive with CHS DOES return the correct data (the partition table), and those same routines work with the identify command. FWIW is it necessary to issue the "spin up" and "recalibrate" commands? I thought those were supposed to be done during power up? > You do read the status (destructively), at the end of each command, don't > you ? I was once tempted to use incomplete addressing and only read > non-destructively. Guess what happened. I'm not sure what you mean by "(destructivly)". I send the command 0x20 and then wait for the DRQ in the status register before reading, is that what you meant? Should I check the status register after writing the device/head register? I check it before writing that register but not after (I send the 0x20 command right after writing the device/head register). > Most new disks support some high UDMA or PIO mode and PIO0. Trying to make > them work with something else may give unpredictable results. You do it > with PIO0, right ? Actually I tried to stay away from new drives specifically for that reason, maybe I went to old? (and LBA doesn't work correctly or in a standard way on that drive). I guess if I don't get this solved soon I'll just work with CHS, it's less flexible and harder to implement but it seems to work. For now though I'll keep trying, thanks for the tips. TTYL -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.