This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430FG6626: CTSD16 Calibration

Part Number: MSP430FG6626


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;
}

  • Hi jtm214psu,

    I'll take a look at this and try to get back to you ASAP. Btw, before I go thru your code, could you please confirm you didn't use the input also as reference voltage?

    Regards,
    Harry
  • Hi Harry,

    I'm using a fixed external reference on the VeREF+ pin and am able to read a sine wave in the A/D on the external pin (A0) and display it properly. I'm also able to output a sine wave on DAC0, I'm just not able to tie the DAC0 output to the A/D internally. I always ready ~half scale.

    Regards,

    Justin
  • Hi Justin,

    Hope you got a good weekend.

    Found the issue. Got below snapshot from the User's Guide:

    In your CTSD16 code you chose input channel 18, which means AD4+ & AD4-. However, these two channels are tied together, thus resulting your AD raw data at around 32768.

    If you want to measure the DAC output by CTSD16, you have to use an external connection.

    Hope this would help.

    Regards,

    Harry

  • Hi Harry,

    Thanks for the reply.  So from this snippet from the datasheet all you can do to calibrate the CTSD16 is read the mid point and there's really no benefit to having the internal DAC connection?

    I have to be honest this seems like a really useless feature to be documenting in the user guide and the data sheet that there's an internal dac connection when a simple short circuit with no dac or vref connection would have accomplished the same thing.

    Regards,

    Justin

  • Hi Justin,

    First of all, sorry for the inconvenient.

    The intention for these two internal connection is to calibrate the CTSD's differential offset. You are correct that even if no DAC/Vref connection, a simple short can do this.

    For the gain error/offset error, actually TI has calibrated these during the device production. You can refer to below "Device Descriptors" section in datasheet.

    And, please refer to below section in User's Guide for how to use this.

    Regards,

    Harry

**Attention** This is a public forum