ADLINK CM1-86DX2 User Manual
Page 68

62
Using the Module
}
adc_channel =
(
unsigned char
)
strtol
(
argv[1], NULL, 16
)
;
if(
adc_channel
<
0
||
adc_channel > 7
)
{
usage
();
return 3
;
}
adcChannel = 0x00
|
(1
<<
adc_channel
);
// set the selected ADC channel
int
i=0;
for(
i=17 ; i>0 ; --i
)
{
// Get the 16'th value as a valid one
// This is necessary to flush the FIFO
/
*##################################################################
##########
# 2. power down temperature sensor on SB function 0 --> ON_CHIP_CTRL_REG[31] = 1
#
2a. activate (power on) the ADC on SB function 0 --> ON_CHIP_CTRL_REG[28] = 0
#
2b. disable I2C1, which is needed at another place ON_CHIP_CTRL_REG[17] = 1
########################################################################
####*/
// Read an modify the On-Chip Device Control Register @ SouthBridge function 0
retVal = PCICS_Read_Long
(
SB_PCICS0, ON_CHIP_CTRL_REG, &onChipDeviceControl_value
);
onChipDeviceControl_value =
( (
onChipDeviceControl_value
&
ADC_DISABLE_TEMPERATURE_SENSOR
) |
I2C1_DISABLE
)
;
if (
retVal != 0
) {
return 2; }
retVal = PCICS_Write_Long
(
SB_PCICS0, ON_CHIP_CTRL_REG, onChipDeviceControl_value
);
if (
retVal
!= 0 ) { return 2; }
//
###################################################################
#############
/
*##################################################################
##############
# 3. set ADC Base Address, enable ADC IO Address Decode,configure ADC channel 7
# as normal ADC input --> SB1_ADC_CONTROL_REG
# 3a. disable the 8051A access to the ADC
########################################################################
#########*/
adc_control_register_value =
(
1
<<
20
) +
ADC_BASE_ADDR
;
retVal = PCICS_Write_Long
(
SB_PCICS1, SB1_ADC_CONTROL_REG, adc_control_register_value
);
if (
retVal
!=
0
) { return
2
; }
retVal = PCICS_Write_Byte
(
SB_PCICS1, ANALOG_SHARE_REG, ANALOG_SHARE_DISABLE
);
if (
retVal
!=
0
) { return 2; }
//
###################################################################
#############
/
*##################################################################
##############
# 4. select (activate) a channel (0 .. 7 as binary coded value) --> ADC_AUX_CHS
########################################################################
########*/