3 - 13
3.5.5 Reading the VXI-5534's Status Byte
There are several ways the user can test the VXI-5534 to see if there is data in the receive buffer. The
simplest way is to use the Word Serial ReadSTB command to read the channel's Status Byte. This
can be done while the channel is in the Data Mode and does not interfere with receiving data. Bit
0 is set when there is are one or more serial messages (EOM characters) in the receive buffer or the
number of bytes in the receive buffer exceeds the preset character count. Bit 1 is set when there is
data in the receive buffer. Refer to paragraph 3.6 and Figure 3-3 for a complete description of the
VXI-5534's Status Reporting structure and Status Byte Register. If the test for data is positive, branch
to a routine to input the data.
CAUTION - Do not read the Status Byte by a tight program loop.
This ties up the VXI-5534 processors, wastes controller time and
could result in lost data. Instead sample the Status Byte no more
often than 1/10 the time estimated to receive the serial message.
3.5.6 Using VXIbus Interrupts to Input Data
A more sophisticated approach to inputting data is to have the VXI-5534's serial channel generate
an interrupt when it has a message or the desired character count in the receive buffer. Interrupts are
enabled by setting the Status Byte enable bits so that bit 0 can generate an service request. If the
corresponding enable bits are set, a logic 1 in an enabled bit will set the RQS/MSS bit 6) and generate
an interrupt if an interrupt level has been assigned to the serial channel and it is enabled. If your
Resource Manager does not automatically assign an interrupt line, refer to its instruction manual for
directions on manually assigning an interrupt line. The following example shows how to enable a
serial channel to generate interrupts.
e.g. vxiWScmd (17, 0x0100) ; //sets channel #2 to Command Mode
vxiWSOutput (17, "SET EOM FF" ); //disables EOM character checking
vxiWSOutput (17, "SET BUFINT 128" ); //sets character count to 128
vxiWSOutput (17, "*SRE 01" ); //enables Status Byte bit 0 to generate an
interrupt
vxiWScmd (17, 0x0000) ; //sets channel #2 to Data Mode
When binary data is being inputted, the interrupt service routine should read the number of bytes that
caused the interrupt. Depending upon the data flow rates, it may improve the overall performance
to retest the Status Byte Register to see if there is more data in the receive buffer before exiting the
service routine. When character counts >10 are being used, bit 0 in the Status Byte will be reset by
the time that the message has been read.
When ASCII data is being inputted and EOM checking is enabled, the interrupt service routine
should read a message and exit the service routine. Allow 250 microseconds after reading a message
from the VXI-5534's receive buffer before retesting Bit 0 to avoid false EOM indications. This delay
time may have to be increased if the slave processor is busy receiving data or servicing the other serial
channel. Note that VXI interrupts are only generated when Bit 0 sets. If multiple messages are
expected, either the interrupt routine will have to test for presence of another message before exiting
the routine and/or Bit 0 will have to be tested in the program's main line. Adding a periodic test of
Bit 0 in the program is good insurance against any data loss and system hang-ups.
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com
Comentarios a estos manuales