Page 1 of 1

Hard disk drive selection

Posted: Fri Apr 25, 2008 6:22 am
by ravi_chobey
Hello All,
Currently I am working on hard disc drive and sending commands to it. Only Execute Device Diagnostic command is working in that case. If I give any other commands to drive such as check power mode, identify device etc. then it is not giving command aborted but not giving desired output also. Suppose I give, check power mode command then I should get 00h in sector count register if device is in standby mode. FFh , if device is in active mode, 80h if it is in the idle mode. But instead of expecting these values, i am getting 01h in sector count register, which is default value of this register. Also drive is not setting bit ERR of status register. That means command is not aborted. But not getting desired outputs. What could be the reason? How would I know whether drive has accepted my command? Whether my drive got selected properly? What are the methods for selecting drive? i.e. what value of DEV bit in the device/head register should be?
Yours suggestions will be helpful for my project.

Regards,
Sneha

Posted: Fri Apr 25, 2008 8:29 am
by zaleschiemilgabriel
The only important register you need to read and check is the command/status register. After you send a command by writing the command register, you need to repeatedly read it and (usually) check the ERR, DRQ and BSY bits. If those are ok (ERR and BSY are not set, DRQ is set) then it's ok to read the other registers and check them accordingly.
Since your question is not specific to one command, I say you should RTFM. Start with the wiki article on ATA, then move on to the specs.

Posted: Sat Apr 26, 2008 1:21 pm
by bewing
There are only 3 possible settings for the drive/head register, for a master drive (in situations where you don't need to set the 4 head bits).
0xA0 for CHS compatibility. 0xE0 for LBA with legacy compatibility. Or 0. For the slave drive, add 0x10 to each of those values.

As said above, it sounds more like you still aren't waiting enough time for the status register/disk drive to set DRQ, on all the other commands.