| [an error occurred while processing this directive] |
How to make your own AT card
PIO 8 bit data transfer modeFirst of all your card must satisfy so called PIO data transfer protocol (Programmed I/O). This means that CPU can read or write data in/from registers on your card with simple commands such as OUT xx or IN xx (in assembler language ). Your card must correctly interpret control signals such as I/O READ/WRITE, AEN, and it must decode address from address bus to determine if CPU controller are addressing a register which reside on your card. You may decode address for your I/O registers on the card anywhere in the I/O memory area from 0FF to 3FF hex (look I/O address map) until they aren't interfere with address of other devices. E. g. if you want that your I/O register have address 3E0 you must decode that address by interpreting address lines A0 through A9 (2^10=1024=400h). Then if that address appears on the address bus you must check AEN line. If AEN is low (AEN=0), then you have to check I/O READ/WRITE signals to determine if CPU wishes to read or write data in your register. In all other cases (AEN high or not proper address on bus) your card (or it's connections) must be in so called tri-state (state of high impedance) to allow other devices on the bus to communicate with each other without interference.For better understanding here is block-scheme of ISA interface of AT-card: ![]() Various analog or digital devices can be placed on your AT-card, but in order to control behavior of these devices you must have some kind of digital interface for ISA bus, as you can see on the block-scheme above, this interface can be divided in three main sections:
These digital register (one or more) can be registers of A/D converter (to read out result from last conversion), or it can be Q output of JK flip-flop or something else. If your device is for example A/D converter then you don't have to use IOW line, you can use only IOR line to read out contests of A/D digital register. If we want to place our control register at address 300h (hex) then this Address decoder have to recognize this address on the address bus, generating signal called 'ENABLE' (or you can call it Chip Select CS). When this ENABLE is active, it means that CPU tries to access our control registers (CPU tries to read or write something at address 300h). ENABLE signal must enable (or select) our target digital device for reading or writing data by CPU, also it must notify Data transceiver to enable data flow from our control register to the ISA data bus. As you can see the implementation of DIR signal is easy: it's connected to IOR line. Depending on type of Data transceiver, this logic for DIR signal can be altered: DIR=0->WRITE & DIR=1->READ. This AT-card example is trivial (or senseless) because it doesn't anything, but I think it quite well explains practical use of Address decoder and Data transceiver: ![]() Description:
MOV DX,300h ;(DX = address of our latch)
This code you can easily write in C using instructions outportb(port,value)
and inportb() or you can embed this assembler code in your C program.
main()
Address decoder is consists of digital
comparator 74688 and partly from 7428 (four NOR gate). In practical use
it's better to use 74HCT688 because of speed (ordinary 74688 has large
propagation delay time). Basically this chip (74688) compares 8 digital
inputs (B gate: B0-7) which are set to our desired address to another 8
digital inputs (A gate: A0-7) which are connected to the ISA address lines
SA2-SA9 and when they match (A=B) output Y is active (active low). This
only works when input E is active (low) or when AEN signal is low.
Data transceiver is consist of only
one chip: 74245 octal data transceiver. As you can see when ENABLE is high
it's pins are in tri-state which degates our 74373 register from ISA data
bus.
Outputs from data transceiver 74245 are in state of high impedance (E=1) and outputs from 74151 buffer are also in state of high impedance (IOR= X immaterial and ENABLE=1 always gives 1) (signal is passed from A to Y only when control gates G of buffers are in low state (see truth table for 74151). Register inputs (1D-8D) are disabled because C=0 (only when C=high inputs can change value of our register: see truth table). PIO 16 bit data transfer modeIf you want a full 16-bit data transfer you must pull down line I/O CS16 and use higher data lines D8-D15. But because there is only one I/O CS16 line on the ISA bus setting this line to 0 must take place only when our AT-card is selected for I/O operations by CPU (when ENABLE is active in previous example).![]() Use of IOCS16 isn't completely clear to me right now but I will find
more info on this.
Multiple Chip select signalIf you need to address more then one location (status or control register) on your AT card you must adapt your Address decoder to generate more then one ENABLE ( or Chip Select) signal.In our example: if we want to address four 8bit register on AT card we will use lower ISA address lines (SA0 and SA1) to accomplish that. We will put our new four registers on address:
Connecting IRQ-linesIf your card uses interrupt requests, you have to connect that IRQ from your card to the IRQ onsystem board which is not occupied (e. g. IRQ 10).IRQ inputs are positive edge-sensitive inputs which means that IRQ is generated only when IRQ lines goes from low logical level "0" to high "1". (note: this can be altered in CMOS setup of motherboard). Why IRQ: this method is an efficient way to free up the CPU to do other important things while AT-card doesn't need attention. When AT-card needs to be served by CPU it will activate IRQ line, requesting CPU attention. CPU response to the IRQ request may be very slow (resolving priority, executing specified routines and etc.) so it is best to use IRQ interrupts as asynchronous events (generated from time to time). Therefore it's not good to use IRQ for time-critical operations demanding fast respond from CPU. If your AT-card demands fast executing of some routine by CPU in specified time (depending on state of status register on card) it's best to utilize so called Polling operate mode. Polling is simple way of checking values of status register (polling status bits) which can be done at higher speed then with IRQ routines (now our status bit acts as the interrupt signal). Characteristic of IRQ line is that our AT-card have absolute control over this line (it's not shared by other devices on ISA bus). Because of that you don't have to use digital device with tri-state ability for this line. On the other hand you must provide logic which will be able to set IRQ request and to reset IRQ line (set IRQ line to 0) when IRQ request is acknowledged by CPU. The JK bistabil (or some other flip-flop bistabil) is best for generating IRQ request: it can be triggered by some impulse and afterwards it can be easily reset to start value. For example if your AT-card measures temperature using A/D converter
(converting temperature to voltage by LM36, then voltage to the digital
value by A/D) and if you want that your computer read temperature only
when it reaches specified value (you don't wont that your computer continuously
read out temperature from A/D register) then you can generate IRQ request.
![]() As you can see JK bistabil 7473 is used as flip-flop which generates
IRQ request due to triggering impulse. It holds IRQ line active until our
AT-card is accessed by CPU (IRQ interrupt has been acknowledged) which
will set ENABLE to 0 and CLR input will clear our JK bistabil
DMA data transfer modeDirect Memory Access (DMA) is a type of data transfer in which the data is directly read/write intothe system memory without the control of CPU, which results with greater speed of data transfer. In the DMA mode CPU is in the wait states and it is degated from data and address bus. The control of DMA-operation is obtain by DMA-controller which can handle 7-DMA channels. If your I/O device needs DMA-services (to increase speed of data transfer) you must control DACK n, DRQ n and T/C lines, where "n" represents a number of DMA channel that you want to use. You must choose free DMA channel for that purpose. (e.g. DMA channel number 2 is reserved for floppy drive). Also you have to choose between 8-bit or 16-bit DMA data transfer mode: DMA channel 0-3 are reserved for 8-bit and other channels are reserved for 16-bit data transfer mode. To initialize DMA data transfer you must program DMA-controller. E.g. you must "tell" him how many bytes is to read from your I/O registers and write to the system memory (or other way round). Important: if using DMA data transfer mode it is necessary to use IRQ logic (your device have to be able to generate IRQ interrupt) because once if DMA-transfer is initiated something can go wrong (some error occurred in our electronic circuit on the card:e.g overrun error) which will prevent AT-card to generate any more DRQ requests. In this case there is danger that DMA controller waits for DRQ request keeping DMA-channel active. Therefore our At-card can signalize error with IRQ interrupt making possible for DMA-controller to recover (to reset active DMA-channel). Number of bytes which will be transferred during DMA operation is determined by the value of T/C register (located in DMA-controller). With every DMA read/write cycle this value is decreased, and when it reaches zero the T/C signal is set active (T/C=1). DMA-controller registers are on the address 000-01F and 0C0-0DF, and you can access them directly or by DOS/BIOS routines (assembler language). When you initiate DMA data transfer your I/O device have to generate a DRQ n requests when it is ready to send or receive data from/in system memory. Also it have to continuously check out the condition of DACK n and T/C lines. After issuing a DRQ signal I/O device must wait for DACK signal to goes active. Only when DACK signal is active the I/O device can drive its data to data bus (or read data from data bus in DMA read cycle). After this DMA-controller takes care where to put that data in system memory (that address in system memory is defined before in initiation process ). During DMA operations AEN line is active (1) and it is used to disable selection of an I/O device when DMA address is on the address bus. The I/O device (AT-card) selection should be determined by the DMA acknowledge outputs for the that channel. (E. g. if AT-card uses DMA channel number 3, when DACK3 line is set by DMA controller AT-card should be 'aware' of that signal). When the T/C line is set active it means that DMA-data transfer operation has ended. Note: T/C signal is set active during last DACK "n" to notified the I/O device that T/C signal is Terminal Count signal for DMA channel number "n" (explanation: on ISA-bus there is a only one T/C line, and there are 7 DMA channels which can be active at same time). To make example how to implement DMA-data transfer on AT-card is too complicated for explanation ( I'm afraid that nobody will understand that) therefore I will show only time diagrams for DMA operation: ![]() This picture shows one-byte (D0-7) DMA transfer in which data is transferred
while DACK signal is active (DACK=0).During that time At-card must enable
it's data outputs (valid data is on the ISA data bus) and it must properly
recognize IOR and IOW signals.
ConclusionThese are the basic of how to make your AT-card. When you assembling your AT-card you musttake care about various things such as time-delays of your logic circuits, power dissipation, OC (open collector) and tri-state abilities of logic circuits. About time-delays: ISA bus operates at 8Mhz even on newest motherboard because of compatibility to older I/O devices (speed of PCI divided by factor 4 ). Therefore every PIO or DMA cycle (read or write) can not be faster then 8Mhz regardless on CPU speed. Every digital circuit from ordinary 74xxx family can operate up to 20Mhz but this depends on type of circuit. If digital circuit is more complex such as our digital comparator 74688 then it is better to use faster chips from HCT family (almost every digital chip from 74xxx serie has HCT equivalent). This section is made to help out everybody who needs help in getting started in designing AT-cards for PC-compatible. Later I will add some program examples on how to make IRQ handlers, how to program interrupt controller, how to program DMA cont. and etc.. |