User`s manual

XP8500
Software Reference s 41
int adc4
_
sample( unsigned int board
_
adr,
int chan, int count, int *buf,
unsigned int divider )
Samples data from an A/D chan at uniform intervals of time.
PARAMETERS: board
_
adr is the physical address of the XP8500
board, defined as 0000 1100 ppxy.
chan ranges from 0 to 10, corresponding to the boards 11 A/D
channels. In addition, passing channel numbers above 10 will access
the A/D chips internal nodes: passing chan = 11 will return (VREF+
 VREF)/2, passing chan = 12 will return VREF, and passing chan
= 13 will return VREF+.
count specifies the number of samples to collect.
buf points to a buffer where the samples will be stored.
divider specifies the sample rate based on the formula
sample rate = sysclock/(20 * divider) , or
divider = sysclock * (sample period/20) .
All data default to 12 bits unipolar mode with MSB first. The mini-
mum value for divider depends on the clock speed, the number of
I/O wait states, and the number of memory wait states. The number of
states is approximately
12 * ( 131 + 4 * IOWait + 38 * Mwait) .
For example, a 9 MHz clock with 4 I/O wait states and 0 memory wait
states has a sample period of approximately 192 µs; for 1 memory
wait state, the sample period is approximately 240 µs. For a 6 MHz
clock with 4 I/O wait states and 0 memory wait states, the sample
period is approximately 290 µs; with 1 memory wait state the sample
period becomes approximately 357 µs.
RETURN VALUE: 0 if the data collection is successful, 1 if the
XP8500 board cannot be found, 2 if the sampling rate is too fast.
The function will not collect data if the sampling rate is set too fast.
This function turns off the interrupts for the duration of each
sampling period.
!