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
Hard disk drive selection
-
- Posts: 13
- Joined: Mon Apr 14, 2008 2:32 am
- Location: Pune,India
- zaleschiemilgabriel
- Member
- Posts: 232
- Joined: Mon Feb 04, 2008 3:58 am
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.
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.
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.
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.