\section{Am9513}

The Am9513 was a versatile counter chip originally sold by AMD and later
by Celeritous.  It has now been discontinued by both, but still widely
in use in existing equipment.

\ \newline
MX provides four drivers for this chip:
%
\newline
\begin{tabular}{lp{8cm}}
    \textit{am9513} & Interface driver for controlling the chip.\\
    \textit{am9513\_scaler} & MX scaler driver.\\
    \textit{am9513\_timer} & MX timer driver.\\
    \textit{am9513\_motor} & MX motor driver.\\
\end{tabular}

\ \newline
The \textit{am9513} MX driver communicates with the chip via 
an MX port I/O driver.
\newline
\MxAmJFBDDriverFields

\ \newline\newline
The \textit{am9513\_scaler} driver can cascade together multiple 16-bit
Am9513 counters to make counter channels with a larger number of bits.
Typically, two counters will be cascaded together to form a single
32-bit counter.
\newline
\MxAmJFBDZscalerDriverFields

\ \newline\newline
The \textit{am9513\_timer} driver can only use a single 16-bit counter
at present, so \textit{num\_counters} should always be 1.
\newline
\MxAmJFBDZtimerDriverFields

\ \newline\newline
The \textit{am9513\_motor} driver can be used to implement a primitive
stepper motor controller.  The primary limitation of this motor controller
is that it has no ability to ramp up the step rate from a base speed
to a slew speed.  It is probably simplest to think of it as a 
stepper motor controller that always runs at the base speed.
\newline
\MxAmJFBDZmotorDriverFields

\ \newline
\begin{figure}
\MxPicture{am9513_bcps}
\caption{Wiring diagram used by the IIT BCPS department}
\end{figure}

The following is an example database for the IIT BCPS setup for Am9513 boards:

\begin{verbatim}
ports   interface portio linux_portio "" "" /dev/portio
am9513  interface controller am9513 "" "" ports 0x284 0x1b0
i8255   interface controller i8255 "" "" ports 0x280
#
# Motor 1 uses Am9513 counters 1 & 2 to generate the motor step pulses while
# 8255 output bit 2 of port C is used to generate the direction signal.
#
motor1  device motor am9513_motor "" "" 0 0 -1000000 1000000 0 -1 -1 0.005 0 um 2 am9513:1 am9513:2 portc 2 5000000 1000 0
portc   device digital_output i8255_out "" ""  0 i8255 C
#
# Scaler 1 is a 32 bit scaler created using Am9513 counters 4 & 5.  The
# counter is gated by the gate input for its low order counter (GATE4),
# while external pulses to be counted are fed to the source input for
# its low order counter (SRC4).
#
scaler1 device scaler am9513_scaler "" "" 0 0 0 2 am9513:4 am9513:5 0x4 0x4
#
# Timer 1 is a 16 bit timer created using Am9513 counter 3.  It is using
# a 5 MHz clock signal.
#
timer1  device timer am9513_timer "" "" 1  am9513:3 5000000
\end{verbatim}

\textbf{Warning:}  The \textit{am9513} interface driver has only been
fully implemented and tested for Am9513-based systems using 8-bit bus access.

At present, MX Am9513 timers can only use one 16-bit counter.  Also note
that the timer driver relies on the output for the timer's counter being
connected to its own gate input.  That is, OUT(n) must be connected to GATE(n)
for the timer to work.  Of course, OUT(n) is also connected to the GATE
inputs of the scalers that this timer is gating.
