Part Number: CC430F5137
Tool/software: Code Composer Studio
Hello All,
I am trying to start the ADC for Battery voltage monitoring in my one of the application with below sample code and having internal reference voltage of 2.0V, but the count in ADC12MEM0 register shows me constant value of '1842' even though i am changing the voltage to A0.
Please give me appropriate solution.
Sample Code:
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
P2SEL |= BIT0; // Enable A/D channel A0
/* Initialize REF module */
// Enable 2.0V shared reference, disable temperature sensor to save power
REFCTL0 |= REFMSTR+REFVSEL_1+REFON+REFTCOFF;
/* Initialize ADC12 */
ADC12CTL0 = ADC12ON+ADC12SHT02; // Turn on ADC12, set sampling time
ADC12CTL1 = ADC12SHP; // Use sampling timer
ADC12MCTL0 = ADC12SREF_1; // Vr+=Vref+ and Vr-=AVss
__delay_cycles(75); // 75 us delay @ ~1MHz
ADC12CTL0 |= ADC12ENC; // Enable conversions
while (1)
{
ADC12CTL0 |= ADC12SC; // Start conversion
while (!(ADC12IFG & BIT0));
__no_operation(); // SET BREAKPOINT HERE
}
Thanks in advance.
-Avinash T.