Home / Computers / CPCNG Prototype Design / CPCNG IDE Interface

Email


CPCNG IDE Interface

Back to main CPCNG page

Circuit and Description
CPCNG I/O Addresses for IDE Registers
IDE Project Links
IDE Register descriptions


Circuit and Description

This page describes the proposed IDE hard disk interface. The IDE specification is simpler than SCSI so has been chosen for the prototype. The IDE interface would be almost trivial but for the fact that the IDE databus is 16 bits wide, whereas the eZ80 data bus is only 8 bits wide. It is possible to connect only 8 bits of the IDE bus directly to the eZ80 data bus, but doing this sacrifices half the capacity of the disk drive.

The solution here is to buffer the high byte of the data word in an 8-bit latch, which is read/written to on an additional port number. There are a number of examples of this on the internet, with circuit diagrams and sample code (see list of links below). The information and circuit described here are derived from these project pages. Below is the draft circuit diagram.

The IDE registers are mapped to eZ80 I/O addresses in the range &0020 to &002F. The high byte is written or read on port &0028. When writing a byte, the high byte register must be written prior to writing the low byte (&0020) so that it is available for sending to the disk drive, which occurs on writing to &0020. Similarly, reading from port &0020 reads the low byte and latches the high byte from the disk drive, which can then be read from port &0028.


CPC NG I/O Addresses for IDE Registers

The following table describes the port mapping of the IDE interface:

PortRegisterFunction
&0020IDELOData Port (low byte)
&0021IDEERRRead: Error Register; Write: Precomp
&0022IDESECTCSector Count
&0023IDESECTNSector Number
&0024IDECYLLOCylinder Low
&0025IDECYLHICylinder High
&0026IDEHEADDrive/Head
&0027IDESTTSRead: Status; Write: Command
&0028IDEHIData Port (High Byte)
&0029Not Used
&002ANot Used
&002BNot Used
&002CNot Used
&002DNot Used
&002EIDECTRLRead: Alternative Status; Write; Device Control
&002FIDEADDRDrive Address (Read Only)


IDE Project Links

These are links to IDE projects with circuit diagrams, information, sample code and more.

http://www.gaby.de/gide/All about the GIDE interface
http://home.freiepresse.de/befis/hdif_e.htmZX81 Harddisc
http://members.lycos.co.uk/leeedavison/6502/ide/index.htmlIDE bus interface circuit
http://8bs.aussie.nu/subide.htmBBC IDE interface
http://home.hccnet.nl/g.baltissen/ide.htmIDE interface for the Commodore 64/128
http://www.pjrc.com/tech/8051/ide/8051 IDE Hard Drive Interface
http://www.students.tut.fi/~leinone3/ide.htmlIDE Harddisk project for the Amiga 500
http://blkbox.com/~jdbaker/SmallSys/8bitIDE.htmlIDE Devices on 8-bit machines
http://www.angelfire.com/wa2/ratgod/odcp/data.htmlIDE Project
http://home.freeuk.net/c.ward/6502/index.htmlChirs Ward's 6502 Computer system (incl IDE)
http://members.tripod.com/~piters/zx.htmSpectrum Hardware DIY: IDE interface
http://sorry.vse.cz/~xrihp01/speccy/hardware/zxide/Spectrum IDE interface (in Czeckoslovakian)
http://www.icon.co.za/~dantohi/48K ZX Spectrum expansion system
http://members.freemail.absa.co.za/dan_antohi/48K ZX Spectrum expansion system (mirror)


IDE Register descriptions

This section describes the IDE register useage.

&0021 (write): Write Precomp: A write to this port sets the "Write Precompensation Cylinder divided by 4". Not sure what this means.

&0021 (read): Error Register: The contents of the error register when in diagnostic mode are shown in this table:

ValueError
1No Error detected
2Formatter device error
3Sector buffer error
4ECC circuitry error
5Controlling microprocessor error


The contents of the error register (read &0021) when in operation mode are shown in this table:

BitValueMeaning
00DAM found
1DAM not found
10Track 000 found
1Track 000 not found
20Command completed
1Command aborted
30Reserved
40ID found
1ID not found
50Reserved
60No error
1Uncorrectable ECC error
70Block OK
1Bad Block detected


&0026: Drive/Head: Bit 4 of the drive/head register selects drive 0 or drive 1, and bits 3-0 select the head.

&0027 (read): Status: Bits in the status register are set to 1 to indicate one of the following conditions:

BitCondition
0Previous command ended in an error
1Index: set to 1 each disk revolution
2Disk data read successfully corrected
3Sector buffer requires servicing
4Seek complete
5Write fault
6Drive is ready
7Controller is executing a command


&0027 (write): Command: Writes to the command register are as follows:

CommandFunction
98 E5check power mode (IDE)
90execute drive diagnostics
50format track
ECidentify drive (IDE)
97 E3idle (IDE)
95 E1idle immediate (IDE)
91initialise drive parameters
1xrecalibrate
E4read buffer (IDE)
C8read DMA with retry (IDE)
C9read DMA without retry (IDE)
C4read multiples (IDE)
20read sectors with retry
21read sectors without retry
22read long with retry
23read long without retry
40read verify sectors with retry
41read verify sectors without retry
7xseek
EFset features (IDE)
C6set multiple mode (IDE)
99 E6set sleep mode (IDE)
96 E2standby (IDE)
94 E0standby immediate (IDE)
E8write buffer (IDE)
CAwrite DMA with retry (IDE)
CBwrite DMA with retry (IDE)
C5write multiple (IDE)
E9write same (IDE)
30write sectors with retry
31write sectors without retry
32write long with retry
33write long without retry
3Cwrite verify (IDE)
9Avendor unique (IDE)
C0-C3vendor unique (IDE)
8xvendor unique (IDE)
F0-F4EATA standard (IDE)
F5-FFvendor unique (IDE)


Back to main CPCNG page