|
Command |
typ |
Command |
Parameters used |
|
|
|
code |
FR |
SC |
SN |
CY |
DH |
|
SPIN UP |
O |
E1h |
|
y |
|
|
D |
|
SPIN DOWN |
O |
E0h |
|
|
|
|
D |
|
INITIALIZE DEVICE PARAMETERS |
M |
91h |
|
y |
|
|
y |
|
NOP |
O |
00h |
|
|
|
|
D |
|
READ BUFFER |
O |
E4h |
|
|
|
|
D |
|
READ DMA (w/ retry) |
M |
C8h |
|
y |
y |
Y |
y |
|
READ DMA (w/o retry) |
M |
C9h |
|
y |
y |
Y |
y |
|
READ LONG (w/ retry) |
O |
22h |
|
y |
y |
Y |
y |
|
READ LONG (w/o retry) |
O |
23h |
|
y |
y |
Y |
y |
|
READ SECTOR(S) (w/ retry) |
M |
20h |
|
y |
y |
Y |
y |
|
READ SECTOR(S) (w/o retry) |
M |
21h |
|
y |
y |
Y |
y |
|
READ VERIFY SECTOR(S) (w/ retry) |
M |
40h |
|
y |
y |
Y |
y |
|
READ VERIFY SECTOR(S) (w/o retry) |
M |
41h |
|
y |
y |
Y |
y |
|
RECALIBRATE |
O |
10h |
|
|
|
|
D |
|
SET FEATURES |
M |
EFh |
y |
|
|
|
D |
|
SLEEP |
O |
99h E6h |
|
|
|
|
D |
|
SMART SAVE VALUES |
O |
0B0h |
y |
|
|
y |
D |
|
WRITE BUFFER |
O |
E8h |
|
|
|
|
D |
|
WRITE DMA (w/ retry) |
M |
CAh |
|
y |
y |
y |
y |
|
WRITE DMA (w/o retry) |
M |
CBh |
|
y |
y |
y |
y |
|
WRITE LONG (w/ retry) |
O |
32h |
* |
y |
y |
y |
y |
|
WRITE LONG (w/o retry) |
O |
33h |
* |
y |
y |
y |
y |
|
This list shows you the
most frequently used IDE commands. You can use those commands with
the selected register. Remember there are other registers as well
and they are used to send parameters with the associated commands
written to the commands register.
Now I will discuss how we can write data to the hard disk.
As I mentioned, we have
to write data blocks to the hard disk and not byte by byte. We can
write a one byte to a block and its size is 512 bytes, so 511 bytes
will have no use. So how we can write a data block to a register
?.
Before writing a value to the command register first we should
read the status register in the hard disk, because sometimes the IDE
interface can accept commands is it is busy with the previous
command. Remember, LED does not show the status in detail.
How to read the satus register ?. See the status register addresses.
It is same as the value we set for command register, but this time
we use nIOR to read the status register. This means the same
register value can be used to indicate two registers with nIOW and
nIOR.
Procedure
1. Select the
Status register address using AD0, AD1 , ..... etc.
2. Strobe nIOR and read the register values through PORT A.
3. Put nIOR back to logic1.
This status register
has bitwise meanings. We will look at it now.
|
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
|
BSY |
DRDY |
DF |
DSC |
DRQ |
CORR |
IDX |
ERR |
Bit 7 (BSY)
tell whether the hard disk is busy or not. If that bit is
set, the device is busy and will not accept
any command. So wait until the bit is cleared. When the device is busy
there are no means to the other bits
in this register.
(If the device does not become stable ( I mean not busy ) you can
use nRESET pin to reset the device at anytime whether the device is
at busy or not busy status.) |