Hi,
I'm trying to calibrate the CTSD16 A/D by using the internal DAC connection but I'm not able to get a reading that corresponds to the DAC output. I'm able to use both the A/D and DAC independently and can monitor the Veref+, internal temperature sensor, and AVcc through the A/D but every time I try to read the DAC I get a reading of approximately 32768 regardless of what the DAC output is set to. Are there any special considerations for reading the DAC other than setting the channel to CTSD16_INPUT_CH18?
Thanks,
Justin
void initialize_dac()
{
//Set the reference to external, setup the amplifier to medium speed and current
DAC12_0CTL0 = DAC12SREF_3 | DAC12AMP_5 | DAC12OPS;
//Set Gain to 2x reference (If DAC12OG is on and DAC12IR is off gain is 2x)
DAC12_0CTL1 = DAC12OG;
__delay_cycles(1000);
//Clear the data register
DAC12_0DAT = 0;
//Run the internal calibration routine on the DAC
DAC12_0CALCTL = DAC12PW; //Set the password and disable the cal register lock bits
DAC12_0CTL0 |= DAC12CALON; //Start the calibration
while( DAC12_0CTL0 & DAC12CALON ); //Wait for calibration to finish
DAC12_0CALCTL = ( DAC12PW | DAC12LOCK ); //Enable the cal register lock bits
DAC12_0CTL0 |= DAC12ENC;
}
#define CALSAMPLES 10
void adcOffsetCal()
{
// enable the external reference block for CTDS16
CTSD16CTL &= ~CTSD16OFFG;
//External Reference IO Pin must be set to alternative function
P5SEL |= BIT0;
// enable P6SEL.0 to gate reference for conversions on A0-A3
// P4SEL.6 and P4SEL.1 for A4 and A5
P6SEL |= BIT3 + BIT2 + BIT1 + BIT0;
P4SEL |= BIT6 + BIT1;
DAC12_0DAT = 1000;
// Initialize CTSD16 using external reference and internal resistor for clock
CTSD16_init(CTSD16_BASE, CTSD16_RTR_INPUT_CHARGEPUMP_BURST_REQUEST_ENABLE, CTSD16_REF_EXTERNAL);
CTSD16_initConverterAdvancedParam convAdvParam = {0};
convAdvParam.converter = CTSD16_CONVERTER_0;
convAdvParam.conversionMode = CTSD16_SINGLE_MODE;
convAdvParam.groupEnable = CTSD16_NOT_GROUPED;
convAdvParam.inputChannel = CTSD16_INPUT_CH18;
convAdvParam.dataFormat = CTSD16_DATA_FORMAT_BINARY;
convAdvParam.railToRailInput = CTSD16_RTR_INPUT_ENABLE;
convAdvParam.interruptDelay = CTSD16_FOURTH_SAMPLE_INTERRUPT;
convAdvParam.oversampleRatio = CTSD16_OVERSAMPLE_256; // Required for 16 bit samples
convAdvParam.gain = CTSD16_GAIN_1;
CTSD16_initConverterAdvanced(CTSD16_BASE, &convAdvParam);
uint16_t dummy[CALSAMPLES];
uint32_t dummyAvg = 0;
int16_t i = 0;
for( i = 0; i < CALSAMPLES; i++ ) {
// Clear converter 0 interrupt flags
CTSD16_clearInterrupt(CTSD16_BASE, CTSD16_CONVERTER_0, CTSD16_CONVERTER_INTERRUPT | CTSD16_CONVERTER_OVERFLOW_INTERRUPT);
CTSD16_startConverterConversion(CTSD16_BASE, CTSD16_CONVERTER_0);
while(!CTSD16_getInterruptStatus(CTSD16_BASE, CTSD16_CONVERTER_0, CTSD16_CONVERTER_INTERRUPT));
dummy[i] = CTSD16_getResults(CTSD16_BASE, CTSD16_CONVERTER_0) >> 8;
dummyAvg += dummy[i];
}
dummyAvg /= CALSAMPLES;
}


