Sundance SMT784 User Manual
Page 23
User Manual SMT784
Page 23 of 31
Last Edited: 19/03/2009 14:12:00
7.2 Host Control of SMT784
The provided sample program was created with Microsoft Visual C++ and the
Sundance SMT6026 software development kit. In this example, the write function
writeword
uses the function
HostWrite
to write to the registers of the FPGA while
readword
uses
HostRead
to read the registers or data back through the X-Link:
void writeword(HOST_LINK hostlink, int value)
{g_pSmt384->HostWrite(&value, sizeof(value), hostlink);}
void readword(HOST_LINK hostlink, int* ptr)
{g_pSmt384->HostRead(ptr, sizeof(int), hostlink);}
Using
readword
can return control register information or samples from the ADC’s.
Which type of data to be read from the FPGA is selected by writing to register
0x1C
-
the remaining control registers are exactly as described in the SMT384 User Manual.
By writing
0x0000
to regiser
0x1C
,
readword
will return register contents information,
0x0C00
will return raw data from channels A and B, and
0x800
will return raw data
from channels C and D. It is important to remember the FIFO’s are held at reset
while register information is being read back from the Comport. This allows a quick
empty of the FIFO for reading status and keeps data from being lost.
Word Sent
Function
0x0000
Resets all ADC sample FIFO’s. Reading words back returns
the contents in the registers address.
0x0C00
Channel A and B data is sent from the sample FIFO’s. The
14-bit sample from each channel is returned in a
concatenated, single 32-bit word as:
“00” + “14-bit B sample” + “00” + “14-bit A sample”
0x0800
Channel C and D data is sent from the sample FIFO’s. The
14-bit sample from each channel is returned in a
concatenated, single 32-bit word as:
“00” + “14-bit D sample” + “00” + “14-bit C sample”
Table 4 Register 0x1C Data Control
For example:
writeword(cp, 0x101C0000);
// registers readable (clear FIFO's)
for (k=0; k<255; k++) readword(cp, &value);
// Empty FIFO
writeword(cp, 0x101C0C00);
// Channels A&B binary out selected