User`s manual
XP8500
Software Reference s 45
ADC4SMP1.C
#if (BOARD_TYPE == CPLC_BOARD) ||
(BOARD_TYPE==L_STAR)
#use cplc.lib // Program runs on PK2200
// and PK2100 controllers
// only.
#endif
main(){
struct adc4coeff adc4conv0; // Structs needed
struct adc4coeff adc4conv1; // only if you
struct adc4coeff adc4conv2; // use calibration
struct adc4coeff adc4conv3; // constants to
// convert raw A/D
// data to voltages.
int data0, data1, data2, data3;// Raw data.
unsigned int adc4_board; // Brd address.
int i;
#if (BOARD_TYPE == CPLC_BOARD) ||
(BOARD_TYPE==L_STAR)
uplc_init();
#endif
reset_pbus(); // reset the PLCBus
reset_pbus_wait();
if(sysclock() > 0x1e00)
reset_pbus_wait(); // wait double if the
// clock is faster than
// 9 MHz
// find the first available
// XP8500 board on the PLCBus
for(i=0;i<4;i++) {
if(adc4_init(0x0c0+i)) {
adc4_board = 0x0c0 + i;
break;
}
}
if( i >= 4) {
printf(“No XP8500 Board detected.\n”);
while(1) runwatch();
}
printf(“XP8500 board %x has been
detected.\n”, adc4_board);
printf(“Reading XP8500 board calibration
constants...\n”);
adc4_readcoeff(adc4_board, 0, &ADC4conv0);
// read cal for chan0
adc4_readcoeff(adc4_board, 1, &ADC4conv1);
// read cal for chan1
continued…