Tool/software: Code Composer Studio
Hi,
my question is on the CTSD16 of MSP430FG6626.
For testing purposes I used the given example code of msp430fg662x_ctsd16_04.c (Single Conversion on a Single Channel, Poll IFG) from the TI product page.
According to the data sheet the differential input voltage range for the internal voltage reference 1.16mV and a gain factor of 1 is 928mV.
When I apply a constant voltage of e.g. 500mV between pins P6.4 and P6.5 I'd expect a repetitive constant value of 500mV / 928mV x 32767 = 17654 for the results variable when I debug the program several times in a row.
Instead I get alternating values of e.g. 42677, 9307, 5959, 5087, 42669, 13748, ...
#include <msp430.h> unsigned int results; // CTSD16 Conversion Results void main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop WDT P6SEL |= BIT4 | BIT5; // Select AD0+/- analog input pins CTSD16CTL = CTSD16REFS; // Internal ref CTSD16CCTL0 |= CTSD16SNGL | CTSD16DF; // Single sample, 2's complement CTSD16INCTL0 |= CTSD16INCH_9; // Select AD0+ / AD0- for CH1 __delay_cycles(2000); // Delay ~120us for 1.2V ref to settle while(1) { CTSD16CCTL0 |= CTSD16SC; // Set bit to start conversion while(!(CTSD16IFG & CTSD16IFG)); // Poll IFG until conversion completes results = CTSD16MEM0; // Save CTSD16 conversion results __no_operation(); // SET BREAKPOINT HERE } }
Am I getting something wrong here? Please help! Thanks!