Frequently, a device will have a word serial response to a word serial command. To read an instrument’s response, you must first check the Response register (offset 0xA) to determine if Write Ready (bit9) and DOR (bit 13) are set. If these bits are not set, then poll the Response Register until either a time out occurs or the bits become set. If the bits do not become set, then either the instrument is not ready to give a response or the query command was sent incorrectly.
Once the Write Ready (bit9) and DOR (bit 13) are set, then a character should be requested from the instrument. To request a byte, write 0xDEFF to Data Low (offset 0xE).
Now wait until the device makes the byte available. The byte can be read from Data Low (offset 0xE), but only after the Read Ready (bit 10) is set in the Response register (offset 0xA). Therefore, you must poll the Response register until you see this bit set. An attempt to read from Data Low before the Read Ready bit is set, may cause an error in the firmware of the instrument.
Once the character is read from Data Low, notice the upper byte of the register. This is the handshake byte. The format of this handshake byte is:
FE - another character is to come
FF - this is the last character (EOI)
Use an ASCII lookup table to decode the hex value of the ASCII character in the lower byte.
|Below is a summary of the word serial read protocol.
1. Read the Response Register (offset 0xA) until Write Ready (bit 9) and DOR (bit 13) are set. If these are not set, keep reading this register until they get set or a time out occurs.
2. Write 0xDEFF to Data Low (offset 0xE) to request a byte to be transferred from the instrument.
3. Read the Response Register (offset 0xA) until Read Ready (bit 10) is set. Keep reading until either this bit gets set or a time out occurs.
4. Read from the Data Low Register (offset 0xE). The format of this register will be 0xFEyy, where yy is the ACSII hex character. If this is the last character being transferred, the data will be of the format 0xFFyy.
5. Repeat step one to four until all characters are read.
Low Level Word Serial Implementation Example in C