Other Parts Discussed in Thread: MSP-EXP430G2ET
Hello,
I am trying to use the SD16 on the F2013 to measure Vcc internally on channel A5, but I keep getting measurements around 2.7 V to 2.8 V when I am powering with 3.3 V. I am using a MSP-EXP430G2ET with a F2013 and the IDE I am using is IAR workbench for MSP430 ( 7.12.4). I have also tried powering the board externally but it gave me similar results. Can anybody inform me of what I am doing wrong with my code? My code is below. I calculate Vcc by Vcc = ( ( SD16MEM0 * ( 0.5 * Vref ) ) / ( 2^16 ) ) * 11
#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR |= 0x01; // Set P1.0 to output direction
SD16CTL = SD16REFON + SD16SSEL_1; // 1.2V ref, SMCLK
SD16INCTL0 = SD16INTDLY_0 + SD16GAIN_1 + SD16INCH_5; // A5
SD16CCTL0 = SD16UNI + SD16IE; // 256OSR, unipolar, interrupt enable
SD16AE = 0;
SD16CCTL0 |= SD16SC; // Set bit to start conversion
__bis_SR_register(LPM0_bits + GIE);
}
#pragma vector = SD16_VECTOR
__interrupt void SD16ISR(void)
{
if (SD16MEM0 < 0x7FFF) // SD16MEM0 > 3.3V?, clears IFG
P1OUT &= ~0x01;
else
P1OUT |= 0x01;
}