📄 ide-8255.txt
字号:
each command.
About the data rate. This IDE interface will never win any award
for its speed. It is in one word slow. I get data transfer rates
in the order of 25 KBytes per seccond. I spend most of the time
reading/writing data words from/to the disk on a word-by-word
basis under software control. On the other hand, my controller
has a total (RAM) memory of 24 KBytes. With the current interface
I can dump the complete memory to disk in less than one seccond.
That in itself makes me think that for this application the low
speed is not so much of an issue.
About the future. I think I will give interrupt modus another
try. Not because it gives me a fantastic data rate, I just can't
stand it that it does not want to work good.
I am thinking about a proper file system to put on the disk. That
will enable me to access the disk in a more normal way that the
current 'sea of sectors' approach I use now. A FAT filesystem
looks like an absolute horror when combined with a controller, so
I'll have to either find something that looks good to me or strap
something together myself.
I think I will give the ATAPI command set a try. I have just
found and printed the 'SFF committee specification of ATA Packet
Interface for CDROMs' (SFF-8020i) document. That document gives a
description of how to control an ATAPI CDROM via the IDE bus. On
the other hand: I would really not know what to begin with a
CDROM connected to a microcontroller. But what the heck, I have
no really good idea what to do with a microcontroller with a 40MB
harddisk connected..... I have seen occasional questions in this
mailing list about how to control a CDROM via its backside
connector: I think this IDE interface with an ATAPI piggy-back
software could just do the work.
Till now I've been concentrating on only one side of the
interface. The IDE interface is in fact no more than a
ready-decoded, buffered interface of a (mostly-PC) hardware
system. I could in fact connect god-knows-what at the other end.
I have an interrupt, DMA and I/O available, what else could you
ask for? A disk or CDROM is only one of the less inspired devices
you can connect to an IDE interface. Given the fact that modern
PC-motherboards have two IDE interfaces aboard I can think of
some nice things I'd like to connect to them. How about some 8
parallel input/output ports, how about a data aquisition system?
Lately I have been able to get a C-mos version of the 8255. My
controller system is quite low-power (10 mA for the entire
thing). I did not feel good about the IDE extension with a 8255
that used some 80 mA all by itself. The controller system with
the D71055C (a C-mos NEC version of the 8255) has gone down to
its normal -about 10 mA- power usage. the change from N-mos 8255
to C-mos D71055C has had no other noticable effects than a lower
power usage.
Even when I have no disk connected to this contraption it
delivers me three 8-bits I/O ports. I am thinking about what
other things I could connect to that.
conclusions:
------------
As you can see it is far from difficult to connect an IDE disk to
some computer. My implementation with a 8255 and an inverter chip
may not be the fastest thing on earth, it works, it's simple and
may be usable for many applications where a controller with a
large backup store could save the day.
I'll wrap this up with a case-study: The software I use on my
63B03 controller to control the IDE bus. I hope it can clarify
any points I have not covered in this description. I know this
software to work, I hope it can give someone inspiration to do
something similar on some controller system somewhere.
If I have been less than clear, or wrong, or you have some
questions left, remarks to make, improvements to suggest, please
drop me a line:
paper mail:
Peter Faasse
Hakfort 337
1102 LA Amsterdam
Netherlands
e-mail:
faasse@nlr.nl
Appendix:
=========
The software I use to control a single IDE harddisk using a 63B03
controller system and a 8255/74HC04 IDE interface.
Notes:
------
The interface program has been made on a 63B03 controller in
assembly code. The 63B03 code is nearly 6800 code. If in doubt,
consult some source of 6800 or 6803 or 63B03 instructions.
The source of the interface program is of course the most
complete description of how to program this interface, but
certainly not the most un-cryptic description. I try to program
without any 'dirty tricks' but who knows....
This interface program makes sporadic use of the underlying 63B03
real-time scheduler. If you see a 'jsr Sys' somewhere that is
where I called the scheduler to do something for me. As far as I
can see I only use Sys to produce a 10-ms delay. I have left the
code of the scheduler itself out. Not beacuse it is anything but
public domain, but beacuse it is another 150 KBytes of source
file. This description is long enough as it stands here. The
scheduler is not really needed, so I left it out. If you are
interested in the scheduler as such, drop me a line (the address
is a little up in the text).
The IDE interface software as such I hereby donate to the public
domain. Use it as pleases you. Change it when you think it is
wrong, suffer the consequences if you make mistakes. I do not
take responsibility if you blow up harddisks, interface hardware
or if anything goes wrong when you use it. I have found it to
work on my system and, so sorry, that is all the guarantee I can
give you about it.
>>>>>>>>>>>>>>>>>>>>>>>> 63B03 assembly listing <<<<<<<<<<<<<<<<<<<
0000 |Begin----------------------------------------------------------
0000 |
0000 | Disk interface task for the 63B03 system
0000 |
0000 | Update history:
0000 | ---------------
0000 | 02-02-1998 : Started with the thing. The hardware has been
0000 | finished today. All seems to work. Now I need
0000 | software to get some life into it.
0000 |
0000 | 05-02-1998 : Hit a bloody trick of the 8255: When you change
0000 | the modus byte ALL outputs are set to 0. I now
0000 | know why nobody wants to use this bugger. The
0000 | solution for this shit is easy: I plan to put an
0000 | inverter in all the control lines. The following
0000 | lines will be inverted:
0000 | /CS0, /CS1, /IORD, /IOW, /RES, IRQ (the latter
0000 | for the 63B03, it has a /IRQ input)..
0000 | This is the software change needed to make things
0000 | work again...
0000 |
0000 | 06-02-1998 : Hardware change done, disk reset works
0000 | Started testing the disk interface functions.
0000 | The recalibrate command works too, the stop
0000 | disk/start disk functions seem to be not
0000 | present in this 40 MB disk. I also made a LBA
0000 | routine, I can now access the disk as a set of
0000 | sequential blocks, without counting heads etc..
0000 | It seems the PC hardware starts counting sectors
0000 | starting at 1 (WHY???), all other numbers start
0000 | at 0...
0000 |
0000 | My disk (about 40 MB) tells me it has
0000 | 980 cyls, 5 heads, 17 secs/track. In fact it does
0000 | tell me different numbers, only the label
0000 | indicates that it has been translated...
0000 |
0000 | At this moment I only support disk block read
0000 | and disk block write. I want to make some file-
0000 | system too. Besides, this thing works code-bound.
0000 | I want to start using interrupts too...
0000 |
0000 | 08-02-1998 : /IRQ hardware made ok. The disk can now generate
0000 | interrupts. These will come into the system via
0000 | the CPU's /IRQ signal. I even crashed the system
0000 | by giving /IRQ's with no handler in place...
0000 | Start making the disk software /IRQ-driven.
0000 |
0000 | 10-02-1998 : Changed the interrupt generation/detection
0000 | software Found one nasty bug in the interrupt
0000 | usage as I did it: I first gave a disk reset on
0000 | the IDE bus, then started giving commends right
0000 | away. On this ONE occasion I do NOT have the
0000 | disk's interrupt facility available, the disk is
0000 | still executing its internal reset. I have to
0000 | wait for ready there, THEN start issuing
0000 | commands... Also set the bus control signals to
0000 | output BEFORE I start using the bus at all... Now
0000 | the interrupt mechanism works like the beauty it
0000 | is...
0000 |
0000 | 11-02-1998 : Cleaned up the data transfer code. The disk I/O
0000 | was very slow due to very systematic code.
0000 | ReadWord/WriteWord code substituted in the
0000 | ReadBlock/WriteBlock code. Routines ReadWord/
0000 | WriteWord removed from the code. There was an
0000 | error in the writeword routine, I've removed it.
0000 |
0000 | 15-02-1998 : I have given up about the interrupt-driven disk
0000 | control. It KEEPS on giving unexplained errors.
0000 | Does NOT want to work independently of the disk
0000 | type and is a general pain in the ass. What
0000 | exactly goes wrong I have no idea about. I now
0000 | use the scheduler's delay routines to get ready
0000 | status from the disk and that works fine. Both
0000 | the 40 MB disk and the 127 MB disk run like the
0000 | sunshine in this modus. The non-interrupt modus
0000 | does in fact not make any significant differenct
0000 | for the transfer speed. I dropped from 32 KB/s to
0000 | 25 KB/s. That is very acceptable for this
0000 | microcontroller. The controller is in this modus
0000 | a lot slower than the disk....
0000 |
0000 | I'm now going to set the thing up for the 127 MB
0000 | disk with proper track/head numbers. Works ok
0000 | too.
0000 |
0000 | Next test is with the 212 MB disk. I have to take
0000 | care that I stay below track 600 for this disk,
0000 | tracks 630 .. 660 are bad... Sunshine again..
0000 |
0000 | 16-02-1998 : Made Identify working. It now dumps a nice
0000 | display of what the disk can do. My antique 42MB
0000 | disk gives only half an answer (and a wrong one
0000 | as well, it does NOT tell about the 5 heads,17
0000 | sectors translation it does..) but the other ones
0000 | like this ident command/display a lot. Also
0000 | shifted the buffers in memory a bit. I now want
0000 | to start writing to the disk (till now I have
0000 | only been reading...).
0000 | Ok, I really messed up the data on my 42 MB disk,
0000 | but it DOES write as well as read. I get back
0000 | what I have written, so far, so good. Now I have
0000 | to make:
0000 |
0000 | 1) A proper disk I/O task. That means that I have
0000 | to implement some way of communicating with
0000 | the disk I/O task. signals? I REALLY would
0000 | like to use some sort of mailbox mechanism.
0000 | For that I will have to extend my scheduler.
0000 |
0000 | 2) some sort of file-system. I am already
0000 | contemplating a MFS (Microcontroller File
0000 | System) for some time now. It's about time to
0000 | start working on one..
0000 |
0000 | 18-02-1998 : Started making task # 0E into a disk monitor.
0000 |
0000 |End------------------------------------------------------------
0000
* START INCLUDE * incl "debug.inc" | use all debugger routines etc..
0000 |------------------------------------------------
0000 | include file for the 63B03 debugger
0000 | file : debug.inc
0000 |------------------------------------------------
0000
0000 |------------------------------------------------
0000 | defines for the 63B03 internal I/O
0000 |------------------------------------------------
0000 |
0000 = 0000 DdrP1 equ $0000 | DDR Port 1
0000 = 0001 DdrP2 equ $0001 | DDR Port 2
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -