National Instruments GPIB-COM Switch User Manual


 
Programming the GPIB-COM Section Five
GPIB-COM User Manual 5-16 © National Instruments Corporation
Programming the Serial Adapter
The operation of the serial adapter is controlled by software, either IBM BIOS or an application.
To transfer data to and from the serial port, the communications parameters must first be set up in
the following manner:
1. Load the baud rate divisor into the divisor latch.
2. Store the RS-232 parameters in the Line Control Register.
3. Send the modem control signals by writing to the Modem Control Register.
4. Enable interrupts, if used, by writing to the appropriate bits in the Interrupt Enable Register.
Once the control registers have been programmed correctly, the software can transmit and receive
serial data by polling, interrupts, or both.
Polling Method
In the polled method of operation, the Line Status Register is continuously read to check if the Data
Ready Bit is set. When this bit becomes set, the Receive Buffer Register is read to get the
character that just came from the serial port, and the process continues. To transmit data, the Line
Status Register is polled until the Transmitter Holding Register Empty Bit is set. A byte can then
be written to the Transmitter Holding Register, and polling continues.
Interrupt-Driven Method
In the interrupt-driven mode of operation, the desired interrupts are enabled through the OUT2 bit
and the Interrupt Enable Register. An interrupt handler is installed to respond when an interrupt
occurs. Software processes can perform other tasks until an interrupt is received. When an
interrupt occurs, the handler reads the Interrupt Identification Register to determine the type of
interrupt and takes appropriate action, such as reading the Receive Buffer Register in the case of a
received data available interrupt, writing to the Transmitter Holding Register if it was a THRE
interrupt, or printing an error message in the case of a line status interrupt.