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.

CCS/MSP430F2619: Too much current draw while in LPM3

Part Number: MSP430F2619

Tool/software: Code Composer Studio

I am currently programming the MSP430F2619 chip with the 64 pin DEV board. When I run a the simple ta1 example code and enter LPM3 I see 1 uA current draw in low power mode which is exactly what I expect. However now I am trying to use the ADC12 with a timer interrupt.I am measuring the on board temp sensor and measuring P6.0 as well. It seems no matter what I turn off after getting the ADC12 measurements I am still drawing 1.3 mA when I enter LPM3. I have set break points everywhere and it appears the code is working correctly but I can't seem to get ~1uA in LPM3 while using the ADC12.

/* --COPYRIGHT--,BSD_EX
 * Copyright (c) 2012, Texas Instruments Incorporated
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * *  Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * *  Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * *  Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *******************************************************************************
 *
 *                       MSP430 CODE EXAMPLE DISCLAIMER
 *
 * MSP430 code examples are self-contained low-level programs that typically
 * demonstrate a single peripheral function or device feature in a highly
 * concise manner. For this the code may rely on the device's power-on default
 * register values and settings such as the clock configuration and care must
 * be taken when combining code from several examples to avoid potential side
 * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
 * for an API functional library-approach to peripheral configuration.
 *
 * --/COPYRIGHT--*/
//*****************************************************************************
//  MSP430x26x Demo - ADC12, Sample A10 Temp, Set P1.0 if Temp ++ ~2C
//
//  Description: Use ADC12 and the integrated temperature sensor to detect
//  temperature gradients. The temperature sensor output voltage is sampled
//  ~ every 60ms and compared with the defined delta values using an ISR.
//  (ADC12OSC/256)/ determines sample time which needs to be greater than
//  30us for temperature sensor.
//  ADC12 is operated in repeat-single channel mode with the sample and
//  convert trigger sourced from Timer_A CCR1. The ADC12MEM0_IFG at the end
//  of each converstion will trigger an ISR.
//  ACLK = n/a, MCLK = SMCLK = default DCO ~ 1.045M, ADC12CLK = ADC12OSC
//
//           MSP430F261x/241x
//            -----------------
//        /|\|              XIN|-
//         | |                 |
//         --|RST          XOUT|-
//           |                 |
//           |A10          P1.0|-->LED
//
//  B. Nisarga
//  Texas Instruments Inc.
//  September 2007
//  Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.42A
//******************************************************************************

#include <msp430.h>

#define ADCDeltaOn   12                     // ~2 Deg C delta

//static unsigned int FirstADCVal;            // holds 1st ADC result
int in_value1=0, in_value2=0;
int main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog

  /////////TIMER//////////////////////////////////
    TACCTL1 = OUTMOD_4;                       // Toggle on EQU1 (TAR = 0)
    TACTL = TASSEL_1 + MC_1 + ID_0; // ACLK, divider of 1, up mode
    TACCR0 = 65000;                  // 8192 ACLK periods = 0.25 seconds
    TACCTL0 = CCIE; // Enable interrupt on Timer A2
///////////TURN ON CRYSTAL/////////////////////////
      BCSCTL1 &=  ~XTS;
      BCSCTL3 |= XT2S_0 + LFXT1S_0 + XCAP_3;


          do

          {
              IFG1 &= ~OFIFG;
              __delay_cycles(100);
          }
          while(IFG1 & OFIFG);

          BCSCTL2 |= SELM_3;
          BCSCTL2 |= DIVM_0;


  ///////ADC/////////////////////////////////
  ADC12CTL1 = SHS_0 + SHP + CONSEQ_3;       // TA trig., rpt conv.
  ADC12MCTL0 = SREF_1 + INCH_0;
  ADC12MCTL1 = SREF_1 + INCH_10 + EOS;// Channel A10, Vref+
  ADC12IE = 0x01;                           // Enable ADC12IFG.0

  ADC12CTL0 = SHT0_8 + REF2_5V + REFON + ADC12ON + ENC + MSC; // Config ADC12

  //HANDLE PINS/////////////////////////

    P1DIR = 0xFF;//Initialize ports
    P1OUT = 0x00;
    P2DIR = 0xFF;//Initialize ports
    P2OUT = 0x00;
    P3DIR = 0xFF;//Initialize ports
    P3OUT = 0x00;
    P4DIR = 0xFF;//Initialize ports
    P4OUT = 0x00;
    P5DIR = 0xFF;//Initialize ports
    P5OUT = 0x00;
    P6DIR = 0xFF;//Initialize ports
    P6OUT = 0x00;
    P7DIR = 0xFF;//Initialize ports
    P7OUT = 0x00;
    P8DIR = 0xFF;//Initialize ports
    P8OUT = 0x00;
    PAOUT = 0;
    PADIR = 0xFFFF;




    while (1)
    {
        ADC12CTL0 &= ~ADC12ON; //ADC OFF
        P6DIR = 0xFF;//Initialize ports
        P6OUT = 0x00;
        ADC12IE = 0x00;
        ADC12CTL0 &= ~REF2_5V; //Reference voltage off
        __bis_SR_register(LPM3_bits + GIE);       // Enter LPM3 w/ interrupt

    }
}


// Timer A0 interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(TIMERA0_VECTOR))) Timer_A (void)
#else
#error Compiler not supported!
#endif
{

    P6SEL |= 0x01;                            // P6.0-ADC option select
    P6SEL |= BIT0;                            //Connect pin to A0 input
    ADC12CTL0 |= ADC12ON; //ADC ON
    ADC12IE = 0x01; //ADC12 interrupt enabled
    ADC12CTL0 |= REF2_5V; //Reference votlage on
    ADC12CTL0 |= ADC12SC; //Software controlled start sample and hold
    __bic_SR_register(LPM3_bits + GIE ); ///Exit LPM3, go back to main

}





//////////////////////ADC Interrupt///////////////////////
///////Interrupt happens when sample and hold conversion is done/////////////////
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=ADC12_VECTOR
__interrupt void ADC12ISR (void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(ADC12_VECTOR))) ADC12ISR (void)
#else
#error Compiler not supported!
#endif
{

    in_value1= ADC12MEM0; //P6.0
    in_value2= ADC12MEM1; //On board temperature sensor

    __bic_SR_register_on_exit(LPM3_bits + GIE); // Exit active CPU ///Exit LPM3, go back to main


}

  • > ADC12CTL0 &= ~ADC12ON; //ADC OFF
    This won't actually turn the ADC off, since ENC is still set. [Ref User Guide (SLAU144J) section 23.3.1 -- note blue shading] Thus the ADC is running constantly. Clear ENC then ON.

    Also, with CONSEQ=3 the ADC doesn't stop immediately. [Ref UG Sec. 23.2.6.6]

    As I read this code, you don't really want CONSEQ=3, since you want a timer(-ish) trigger. For that you want CONSEQ=1.
  • Hello Bruce, 

    Sorry for the delayed response. I took your advice and I am now using CONSEQ_1, and also clearing the ENC bit before turning everything off. I am now seeing 0.5 mA of current draw in LPM3, which is better than the 1 mA I was seeing. However I still need to be around the ~1uA range that the datasheet specifies in LPM3. It seems something is still staying on after I get my first measurement from the ADC. Here is my updated code.  

    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2012, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *******************************************************************************
     *
     *                       MSP430 CODE EXAMPLE DISCLAIMER
     *
     * MSP430 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
     * for an API functional library-approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    //*****************************************************************************
    //  MSP430x26x Demo - ADC12, Sample A10 Temp, Set P1.0 if Temp ++ ~2C
    //
    //  Description: Use ADC12 and the integrated temperature sensor to detect
    //  temperature gradients. The temperature sensor output voltage is sampled
    //  ~ every 60ms and compared with the defined delta values using an ISR.
    //  (ADC12OSC/256)/ determines sample time which needs to be greater than
    //  30us for temperature sensor.
    //  ADC12 is operated in repeat-single channel mode with the sample and
    //  convert trigger sourced from Timer_A CCR1. The ADC12MEM0_IFG at the end
    //  of each converstion will trigger an ISR.
    //  ACLK = n/a, MCLK = SMCLK = default DCO ~ 1.045M, ADC12CLK = ADC12OSC
    //
    //           MSP430F261x/241x
    //            -----------------
    //        /|\|              XIN|-
    //         | |                 |
    //         --|RST          XOUT|-
    //           |                 |
    //           |A10          P1.0|-->LED
    //
    //  B. Nisarga
    //  Texas Instruments Inc.
    //  September 2007
    //  Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.42A
    //******************************************************************************
    
    #include <msp430.h>
    
    #define ADCDeltaOn   12                     // ~2 Deg C delta
    
    //int in_value1=0, in_value2=0;
    int main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog
    
      /////////TIMER//////////////////////////////////
        TACCTL1 = OUTMOD_4;  // Toggle on EQU1 (TAR = 0)
        TACTL = TASSEL_1 + MC_1 + ID_0; // ACLK, divider of 1, up mode
        TACCR0 = 65000;
        TACCTL0 = CCIE; // Enable interrupt on Timer A2
    ///////////TURN ON CRYSTAL/////////////////////////
          BCSCTL1 &=  ~XTS;
          BCSCTL3 |= XT2S_0 + LFXT1S_0 + XCAP_3;
    
    
              do
    
              {
                  IFG1 &= ~OFIFG;
                  __delay_cycles(100);
              }
              while(IFG1 & OFIFG);
    
              BCSCTL2 |= SELM_3;
              BCSCTL2 |= DIVM_0;
    
    
      ///////ADC/////////////////////////////////
      ADC12CTL1 = SHS_0 + SHP + CONSEQ_1;       // TA trig., rpt conv.
      ADC12MCTL0 = SREF_1 + INCH_0;
      ADC12MCTL1 = SREF_1 + INCH_10 + EOS;// Channel A10, Vref+
      ADC12IE = 0x01;                           // Enable ADC12IFG.0
    
      ADC12CTL0 = SHT0_8 + REF2_5V + REFON + ADC12ON + ENC + MSC; // Config ADC12
    
      //HANDLE PINS/////////////////////////
    
        P1DIR = 0xFF;//Initialize ports
        P1OUT = 0x00;
        P2DIR = 0xFF;//Initialize ports
        P2OUT = 0x00;
        P3DIR = 0xFF;//Initialize ports
        P3OUT = 0x00;
        P4DIR = 0xFF;//Initialize ports
        P4OUT = 0x00;
        P5DIR = 0xFF;//Initialize ports
        P5OUT = 0x00;
        P6DIR = 0xFF;//Initialize ports
        P6OUT = 0x00;
        P7DIR = 0xFF;//Initialize ports
        P7OUT = 0x00;
        P8DIR = 0xFF;//Initialize ports
        P8OUT = 0x00;
        PAOUT = 0;
        PADIR = 0xFFFF;
    
    
    
    
        while (1)
        {
            
            ADC12CTL0 &= ~ENC;
            ADC12CTL0 &= ~ADC12ON; //ADC OFF
            P6DIR = 0xFF;//Initialize ports
            P6OUT = 0x00;
            ADC12IE = 0x00;
            __bis_SR_register(LPM3_bits + GIE);       // Enter LPM3 w/ interrupt
    
        }
    }
    
    
    // Timer A0 interrupt service routine
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=TIMERA0_VECTOR
    __interrupt void Timer_A (void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(TIMERA0_VECTOR))) Timer_A (void)
    #else
    #error Compiler not supported!
    #endif
    {
    
        P6SEL |= 0x01; // P6.0-ADC option select
        P6SEL |= BIT0; //Connect pin to A0 input
        ADC12CTL0 |= ADC12ON; //ADC ON
        ADC12CTL0 |= ENC;
        ADC12IE = 0x01; //ADC12 interrupt enabled
        ADC12CTL0 |= ADC12SC; //Software controlled start sample and hold
        __bic_SR_register(LPM3_bits + GIE ); ///Exit LPM3, go back to main
    
    }
    
    
    
    
    
    //////////////////////ADC Interrupt///////////////////////
    ///////Interrupt happens when sample and hold conversion is done/////////////////
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=ADC12_VECTOR
    __interrupt void ADC12ISR (void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(ADC12_VECTOR))) ADC12ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
    
        in_value1= ADC12MEM0; //P6.0
        in_value2= ADC12MEM1; //On board temperature sensor
    
       __bic_SR_register_on_exit(LPM3_bits + GIE); // Exit active CPU ///Exit LPM3, go back to main
    
    
    }
    

  • Actually I was able to resolve the issue. Along with your advice I also needed to clear the REFON bit after taking a measurement (it was staying on and consuming the bulk of the current). I am now seeing ~1 uA current draw while in LPM3. Thank you for your help.

    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2012, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *******************************************************************************
     *
     *                       MSP430 CODE EXAMPLE DISCLAIMER
     *
     * MSP430 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
     * for an API functional library-approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    //*****************************************************************************
    //  MSP430x26x Demo - ADC12, Sample A10 Temp, Set P1.0 if Temp ++ ~2C
    //
    //  Description: Use ADC12 and the integrated temperature sensor to detect
    //  temperature gradients. The temperature sensor output voltage is sampled
    //  ~ every 60ms and compared with the defined delta values using an ISR.
    //  (ADC12OSC/256)/ determines sample time which needs to be greater than
    //  30us for temperature sensor.
    //  ADC12 is operated in repeat-single channel mode with the sample and
    //  convert trigger sourced from Timer_A CCR1. The ADC12MEM0_IFG at the end
    //  of each converstion will trigger an ISR.
    //  ACLK = n/a, MCLK = SMCLK = default DCO ~ 1.045M, ADC12CLK = ADC12OSC
    //
    //           MSP430F261x/241x
    //            -----------------
    //        /|\|              XIN|-
    //         | |                 |
    //         --|RST          XOUT|-
    //           |                 |
    //           |A10          P1.0|-->LED
    //
    //  B. Nisarga
    //  Texas Instruments Inc.
    //  September 2007
    //  Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.42A
    //******************************************************************************
    
    #include <msp430.h>
    
    #define ADCDeltaOn   12                     // ~2 Deg C delta
    
    int in_value1=0, in_value2=0;
    int main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog
    
      /////////TIMER//////////////////////////////////
        TACCTL1 = OUTMOD_4;  // Toggle on EQU1 (TAR = 0)
        TACTL = TASSEL_1 + MC_1 + ID_0; // ACLK, divider of 1, up mode
        TACCR0 = 65000;
        TACCTL0 = CCIE; // Enable interrupt on Timer A2
    ///////////TURN ON CRYSTAL/////////////////////////
          BCSCTL1 &=  ~XTS;
          BCSCTL3 |= XT2S_0 + LFXT1S_0 + XCAP_3;
    
    
              do
    
              {
                  IFG1 &= ~OFIFG;
                  __delay_cycles(100);
              }
              while(IFG1 & OFIFG);
    
              BCSCTL2 |= SELM_3;
              BCSCTL2 |= DIVM_0;
    
    
      ///////ADC/////////////////////////////////
      ADC12CTL1 = SHS_0 + SHP + CONSEQ_1;       // TA trig., rpt conv.
      ADC12MCTL0 = SREF_1 + INCH_0;
      ADC12MCTL1 = SREF_1 + INCH_10 + EOS;// Channel A10, Vref+
      ADC12IE = 0x01;                           // Enable ADC12IFG.0
    
      ADC12CTL0 = SHT0_8 + REF2_5V + REFON + ADC12ON + ENC + MSC; // Config ADC12
    
      //HANDLE PINS/////////////////////////
    
        P1DIR = 0xFF;//Initialize ports
        P1OUT = 0x00;
        P2DIR = 0xFF;//Initialize ports
        P2OUT = 0x00;
        P3DIR = 0xFF;//Initialize ports
        P3OUT = 0x00;
        P4DIR = 0xFF;//Initialize ports
        P4OUT = 0x00;
        P5DIR = 0xFF;//Initialize ports
        P5OUT = 0x00;
        P6DIR = 0xFF;//Initialize ports
        P6OUT = 0x00;
        P7DIR = 0xFF;//Initialize ports
        P7OUT = 0x00;
        P8DIR = 0xFF;//Initialize ports
        P8OUT = 0x00;
        PAOUT = 0;
        PADIR = 0xFFFF;
    
    
    
        while (1)
        {
    
            ADC12CTL0 &= ~ENC;      //  ADC12CTL0 &= ~MSC;
            ADC12CTL0 &= ~REFON;
            ADC12CTL0 &= ~ADC12SC; //Software controlled start sample and hold
            ADC12CTL0 &= ~ADC12ON; //ADC OFF
            P6DIR = 0xFF;//Initialize ports
            P6OUT = 0x00;
            ADC12IE = 0x00;
            __bis_SR_register(LPM3_bits + GIE);       // Enter LPM3 w/ interrupt
    
        }
    }
    
    
    // Timer A0 interrupt service routine
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=TIMERA0_VECTOR
    __interrupt void Timer_A (void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(TIMERA0_VECTOR))) Timer_A (void)
    #else
    #error Compiler not supported!
    #endif
    {
    
        P6SEL |= 0x01; // P6.0-ADC option select
        P6SEL |= BIT0; //Connect pin to A0 input
        ADC12CTL0 |= REFON; //Turn reference on 
        ADC12CTL0 |= ENC;
        ADC12CTL0 |= ADC12ON; //ADC ON
        ADC12IE = 0x01; //ADC12 interrupt enabled
        ADC12CTL0 |= ADC12SC; //Software controlled start sample and hold
        __bic_SR_register(LPM3_bits + GIE ); ///Exit LPM3, go back to main
    
    }
    
    
    
    
    
    //////////////////////ADC Interrupt///////////////////////
    ///////Interrupt happens when sample and hold conversion is done/////////////////
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=ADC12_VECTOR
    __interrupt void ADC12ISR (void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(ADC12_VECTOR))) ADC12ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
    
        in_value1= ADC12MEM0; //P6.0
        in_value2= ADC12MEM1; //On board temperature sensor
        ADC12CTL0 &= ~ADC12SC; //Software controlled start sample and hold
    
       __bic_SR_register_on_exit(LPM3_bits + GIE); // Exit active CPU ///Exit LPM3, go back to main
    
    
    }
    

**Attention** This is a public forum