S16A SBus 16-bit Dual Analog Interface for the Sun SPARCstation USER’S GUIDE 008-00630-01 EDT
S16A User’s Guide The information in this document is subject to change without notice and does not represent a commitment on the part of Engineering Design Team, Inc. The software described in this document is furnished under a license agreement or nondisclosure agreement. The software may be used or copied only in accordance with the terms of the agreement.
S16A User’s Guide Contents Overview .......................................................................................................................................................................1 Installation.....................................................................................................................................................................2 Installing the Hardware........................................................................................................
S16A User’s Guide Tables General DMA Library Routines .....................................................................................................................................7 S16A-specific Library Routines......................................................................................................................................8 Error Codes and Conditions .................................................................................................................................
S16A User’s Guide Overview Overview The S16A SBus 16-bit Dual Analog Interface is a single-slot board for SBus-based computer systems. The S16A has two analog I/O channels, each incorporating one 16-bit Analog-to-Digital (ADC) converter and one 20-bit Digital-to-Analog (DAC) converter. The S16A is designed for continuous input and output on both channels simultaneously and is typically used for scientific and medical research and development.
Installation S16A User’s Guide Installation Installing the S16A SBus 16-bit Dual Analog Interface is a two-step process. First you must physically install the board inside the host computer. Then you must install the software driver so that applications can access the S16A. Hardware installation is described in the following section. Software installation is described in the section after. Installing the Hardware The S16A board is a single-slot SBus board.
S16A User’s Guide Installation 4. Place the diskette that came with the S16A into the diskette drive. 5. The S16A driver and related files are included on a diskette in tar format. To copy them to your hard disk, enter: tar xvf /dev/rfd0 6. The tar program extracts a number of files. (The list of files distributed is provided in the section entitled Included Files.) The S16A diskette contains versions of the S16A driver for a variety of Sun platforms and versions of the Sun operating system.
Installation 3. S16A User’s Guide Enter: make unload Using System V Release 4 (Solaris 2.4 or Later) If you are using Sun System V Release 4 (Solaris 2.4 or later), use the following procedure to install the S16A driver: 1. Become root or superuser. 2. Place the diskette that came with the S16A into the diskette drive. 3. Enter: volcheck pkgadd -d /floppy/floppy0 EDTs16a The pkgadd program asks several confirmation questions, which you can answer with a y for affirmative.
S16A User’s Guide Installation Included Files The S16A driver release diskette contains the following files (see the readme file for a complete, up-to-date listing): s16a.o.sun4c The executable S16A driver for SunOS 4.1.3 on a Sun 4C architecture such as a SPARCStation 1, 1+, 2, or IPC. s16a.o.sun4m The executable S16A driver for SunOS 4.1.3 on a Sun 4M architecture such as a SPARCStation 5, 10, 20, LX, Classic, or an Ultra 1 or 2. s16a The executable S16A driver for Solaris Version 2.4 or later.
Input and Output S16A User’s Guide Input and Output The driver can perform two kinds of DMA transfers: continuous and noncontinuous. For noncontinuous transfers, the driver uses DMA system calls for read() and write(). Each read() and write() system call allocates kernel resources, during which time DMA transfers are interrupted. To perform continuous transfers, use the ring buffers. The ring buffers area set of buffers that applications can access continuously, reading and writing as required.
S16A User’s Guide 7. Input and Output The -ls16a option to the compiler, to link the library file libs16a.a with your program See the makefile and example programs provided for examples of compiling code using the library routines. DMA Library Routines The DMA library provides a set of consistent routines across many of the EDT products, with simple yet powerful ring-buffered DMA capabilities. Table 1, DMA Library Routines lists the general DMA library routines.
Input and Output S16A User’s Guide The following driver-specific routines are also available: Routine Description s16a_get_dac_control_reg Get the current state of the output DAC control register. s16a_get_dio_data_reg Get the current state of the DIO Data register. s16a_get_dio_direction_reg Get the current state of the DIO Direction register. s16a_get_output_bits Get the output resolution of the S16A. s16a_serial_read Read a response string from the Analog Input module.
S16A User’s Guide Input and Output s16a_cancel Description Stops any transfers currently in progress, resets the ring buffer pointers to restart on the current buffer. Syntax int s16a_cancel(S16aDev *s16a_p); Arguments s16a_p S16A device handle returned from s16a_open. Return 0 on success, –1 on failure. Sets errno on failure. s16a_cancel_current Description Stops the current transfers, resets the ring buffer pointers to the next buffer.
Input and Output S16A User’s Guide s16a_close Description Closes the device associated with the device handle and frees the handle. Syntax int s16a_close(S16aDev *s16a_p); Arguments s16a_p S16A device handle returned from s16a_open. Return 0 on success, –1 on failure. Sets errno on failure. 10 EDT, Inc.
S16A User’s Guide Input and Output s16a_configure_ring_buffers Description Configures the SBus 16-bit Dual Analog Interface ring buffers. Any previous configuration is replaced, and previously allocated buffers are released. Buffers can be allocated and maintained within the SBus 16-bit Dual Analog Interface library or within the user application itself.
Input and Output S16A User’s Guide s16a_done Description Returns the cumulative count of completed buffer transfers. Syntax int s16a_done_count(S16aDev *s16a_p); Arguments s16a_p S16A device handle returned from s16a_open. Return The number of completed buffer transfers. Completed buffers are numbered consecutively starting with 0 when the S16A is opened. (Thus, the allocated buffer number is the transferred buffer number modulo the number of allocated buffers.
S16A User’s Guide Input and Output s16a_get_dio_data_reg Description Get current state of the DIO Data register. The low 12 bits reflect the current state of the DIO pins. Bits that are configured as outputs are read as zero. To check for an error, clear the errno global variable before calling this function, then check it for nonzero after the function returns.
Input and Output S16A User’s Guide s16a_get_output_bits Description Get the output resolution of the S16A. Returns 16 or 20, reflecting the current driver setting for the output channel. Syntax int s16a_get_output_bits(S16aDev *s16a_p); Arguments s16a_p S16A device handle returned from s16a_open Return Returns 16 or 20 on success; returns –1 if the ioctl driver call fails, and sets errno to indicate the problem. s16a_open Description Opens the specified S16A and sets up the device handle.
S16A User’s Guide Input and Output s16a_read Description Performs a read on the S16A. The UNIX 2 GB file offset bug is avoided during large amounts of input or output, that is, reading past 231 does not fail. This call is not multibuffering, and no transfer is active when it completes.
Input and Output S16A User’s Guide s16a_serial_str Description Send a command string to the Analog Input Module. Read the response from the AIM and return it only if it differs from the command string sent. Otherwise return NULL. This routine is especially useful for command strings, which echo the command string, unless an error occurs.
S16A User’s Guide Input and Output s16a_set_dac_control_reg Description Write a specified value to the output DAC Control register. Syntax int s16a_set_dac_control_reg(S16aDev *s16a_p, int value); Arguments s16a_p S16A device handle returned from s16a_open value Value to write to the DAC Control register. Return Returns 0 on success or –1 on failure. Fails if s16a_p does not refer to an output channel. Sets errno on failure.
Input and Output S16A User’s Guide s16a_set_dio_data_reg Description Write a specified value to the DIO Data register. Only the low 12 bits are significant; of these, bits that are configured as inputs are ignored when written. Syntax int s16a_set_dio_data_reg(S16aDev *s16a_p, int value); Arguments s16a_p S16A device handle returned from s16a_open value Value to write to the DIO Data register. Return Returns 0 on success or –1 on failure. Fails if s16a_p does not refer to an output channel.
S16A User’s Guide Input and Output s16a_set_output_bits Description Set the output resolution of the S16A to 16 or 20 bits. Syntax int s16a_set_output_bits(S16aDev *s16a_p, int value); Arguments s16a_p S16A device handle returned from s16a_open value Either 16 or 20, indicating the operational mode of the output DAC. Return Returns 0 on success or –1 on failure. Fails if s16a_p does not refer to an output channel, or if value is anything but 16 or 20. Sets errno on failure.
Input and Output S16A User’s Guide s16a_stop_buffers Description Stops DMA transfer after the current buffer has completed, whether DMA is occurring continuously or noncontinuously. If DMA is continuous, also dismantles ring buffer mode and frees the resources it consumed. Syntax int s16a_stop_buffers(S16aDev *s16a_p); Arguments s16a_p S16A device handle returned from s16a_open Return 0 on success; –1 on error. If an error occurs, check the errno global variable for the error number.
S16A User’s Guide Input and Output s16a_wait_for_next_buffer Description Blocks until the next buffer is returned from the driver. Returns immediately if a buffer is already complete. The completed buffers are numbered consecutively, so the first call to s16a_wait_for_next_buffer returns the address of buffer 0, the next will be 1, and so on.
Input and Output S16A User’s Guide foi_parity_error Description Checks to determine if a parity error has occurred since the last time this routine was called and returns 0 if not, 1 if so, and –1 if the routine is not supported for a particular device or an illegal argument was provided.
S16A User’s Guide Hardware Interface Hardware Interface This section describes how to connect your device to an S16A interface, including the electrical characteristics of the signal, the signal descriptions, the timing specifications, and the connector pinout.
Hardware Interface S16A User’s Guide Interface Signals The following table describes the signals in the external connector. Signal S16A I/O Description DIO00-11 I/O Configurable I/O pins. CH0OUT O Output of channel 0. CH1OUT O Output of channel 1. CH0INP I Channel 0 “plus” input. Configurable as one of a pair of differential signals, the only single-ended signal, or disabled. CH0INM I Channel 0 “minus” input.
S16A User’s Guide Hardware Interface Connector Pinout The S16A uses a 37-pin D connector, such as an AMP 748878-1. The following pinout diagram describes the connection from the S16A board to the cable. NOTE: Do not connect your own circuits to the unused pins, as they may be internally connected to the S16A.
Registers S16A User’s Guide Registers The S16A SBus 16-bit Dual Analog Interface is configured and controlled with 8-bit and 32-bit SBus registers. Eleven additional internal registers in the Analog Input Module are accessed indirectly through the SBus registers using a simple protocol. Applications access S16A registers through library calls or ioctl calls with S16A-specific parameters, as described in the s16a.h header file. NOTE: All registers initialized and manipulated by the S16A driver.
S16A User’s Guide Registers SBus Addresses The addresses listed in the figure below are offsets from the SBus slot base address. Obtain the SBus base address from the SBus host documentation. The following sections describe the S16A registers in detail. 0x0006.0000 reserved ... not used 0x0004.00C4 uart_data 0x0004.00C0 uart_csr ... not used 0x0004.0080 dac_ctrl ... not used 0x0004.0044 dio_data 0x0004.0040 dio_dir 0x0004.003C nxt_cnt_ctl_3 0x0004.0038 cur_cnt_3 0x0004.
Registers S16A User’s Guide DMA Registers The S16A provides four independent DMA channels: one each for input and output for each of the two analog I/O channels. Each DMA channel can be accessed to set up a new DMA transfer while it is currently performing a DMA transfer. When the current transfer completes the new one begins automatically without pause, allowing non-stop I/O on both I/O channels in both directions. The following table shows the assignment of DMA channels to I/O channels.
S16A User’s Guide Registers These registers hold the address of the next DMA transfer to be performed for each channel. When the current DMA transfer on a channel completes, if there is a “next” one set up, the contents of the Next DMA Address register for the channel are copied to the Current DMA Address register, the next count is copied to the Current DMA Count register, and the new transfer is started automatically. Bit Description 31–20 Show or store the 1 MB page addressed by the next DMA.
Registers S16A User’s Guide Bit S16A_ Description 24 BURST_EN A value of 1 enables burst transfer. For channels 0 & 1 must be 0; for channels 2 & 3 must be 1. 23–20 Unused. 0 when read. 19–2 SIZ_MSK Number of words to transfer in the next DMA transfer. When the next DMA starts, this value is copied into the corresponding bits of the current count register. 1–0 CNT_MSK Always 0. S16A DMA transfers consist of whole 32-bit words. Table 10.
S16A User’s Guide Registers Bit S16A_ Description 0 OUT0_ENABLE Enables I/O channel 0 output 1 OUT0_20BIT When set, configures I/O channel 0 as 20-bit digital-to-analog; when clear, the channel is in 16-bit mode. 4 OUT1_ENABLE Enables I/O channel 1 output 5 OUT1_20BIT When set, configures I/O channel 1 as 20-bit digital-to-analog; when clear, the channel is in 16-bit mode. Table 11.
Registers S16A User’s Guide Input Clock Prescale Registers The Analog Input Module contains two 1-byte Input Clock Prescale registers (one for each input channel) that provide 1-biased divisors for the input clock, which has a base rate of 192 KHz. The low 3 bits of these registers are significant. Thus, the input sample rate for each channel is 192 KHz/(value + 1) where value is the channel’s Input Clock Prescale register value, which can range from 0 to 7.
S16A User’s Guide Registers Value (hex) AIN_ Description 08xx X1 Unit gain. 09xx X2 Gain factor 2. 0Axx X5 Gain factor 5. 0Cxx X10_1 First gain factor 10. Uses the first-stage gain at maximum. 10xx X10_2 Second gain factor 10. Uses the second-stage 10 x gain. Recommended for higher bandwidth. 11xx X20 Gain factor 20. 12xx X50 Gain factor 50. 14xx X100 Gain factor 100. Uses both stages at maximum. Table 14.
Registers S16A User’s Guide Trim Input Gain Registers These two trim registers control the fine-tuning of the analog I/O input gain. Trim register 4 controls the gain trim for analog I/O channel 0 input; trim register 6 controls the gain trim for channel 1 input. The input offset should be set using a zero-level input signal before setting the input gain. Trim Input Offset Registers These two trim registers control the fine-tuning of the input gain.
S16A User’s Guide Registers Write to a Clock Prescale Register The clock prescale registers are written by sending a four-byte sequence beginning with W or w. Wnmm Write an 8-bit value to a Clock Prescale register. n Number of the Clock Prescale register to be written. 0 is input channel 0; 1 is input channel 1. mm Hexadecimal value to write to the register. The UART responds with the four-character sequence return linefeed > space.
Registers S16A User’s Guide Write to a Trim Register The trim registers are written by sending a four-byte sequence beginning with D or w. Dnmm Write an 8-bit value to a trim register. n Number of the trim register to be written: 2 Output 0 offset 3 Output 1 offset 4 Input 0 gain trim 5 Input 0 offset 6 Input 1 gain trim 7 Input 1 offset mm Hexadecimal value to write to the register. The UART responds with the four-character sequence return linefeed > space.
S16A User’s Guide Registers UART Data Register The UART Data register is and 8-bit register at address 0400C4x. This register provides the byte stream for communicating with the analog input module. Write to this register (when the UART CSR indicates that it is ready for a write) to send a byte to the Analog Input Module. Read this register to receive status bytes from the Analog Input Module when the UART CSR indicates that a received byte is available.
Specifications S16A User’s Guide Specifications The SBus 16-bit Dual Analog Interface conforms to the following specifications. SBus Compliance Number of slots: 1 Transfer size Input: 1 word per transfer Output: 4 words per transfer DVMA master SBus memory space approx. 320 KBytes Clock rate 25 MHz Software Drivers for Sun OS Version 4.1.3 or later and System V Version 4 (Solaris 2.
S16A User’s Guide References References The following additional documentation may prove helpful. Burr-Brown PCM1702 product specification, in Burr-Brown Integrated Circuits Data Book, Data Conversion Products1995, pp. 8.2.108 to 8.2.115. Available from Burr-Brown Corporation, (800) 548-6132. National Semiconductor ADC16071 product specification, in National Data Acquisition Databook 1995 Edition, pp. 2-672 to 2-689. Available from National Semiconductor Corporation, (800) 272-9959.
Contacting EDT S16A User’s Guide Contacting EDT Contact EDT directly at the following address or phone numbers: Engineering Design Team, Inc. 1100 NW Compton Drive, Suite 306 Beaverton, Oregon 97006 Phone (503) 690-1234 FAX (503) 690-1243 In addition, a variety of services, from sales information to updated manuals to technical support, is available through EDT’s World Wide Web site, at http://www.edt.
S16A User’s Guide Index Index A ADC16071. See National Semiconductor ADC16071 Analog Input Module ........................................1 configuration & control ........................15–16 internal registers ........................................31 Installation hardware ....................................................2 software ......................................................2 INT register bit ................................................29 M make file ...............................
Index S16A User’s Guide Register bits BURST_EN ...............................................30 DIFFERENTIAL ........................................32 DMA_DIR_READ .....................................29 DMA_START ............................................29 EN_EODMA .............................................29 INT...........................................................29 MINUS_ONLY ..........................................32 OUT0_20BIT .............................................