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.

MSP430FR6820: inner ADC module problem

Expert 6280 points
Part Number: MSP430FR6820

Hi,

we use the ADC module in MSP430FR6820 for two different measurements, having two configurations and 'deconfiguration' (common for both configurations).

We are doing the measurements in a cycle: first configuration, getting sample, deconfiguring ADC; second configuration, getting sample, deconfiguring ADC, and so on. We have a problem that the ADC doesn´t end the conversion, reaching  "frozen ADC module" state (attached first picture below). Registers after deconfiguration are attached below in the second picture. 

If I test only first configuration, (never-ending cycle: first configuration, getting sample, deconfig), or only second configuration (never-ending cycle: first configuration, getting sample, deconfig), everything works fine.

Can you help with some advice?

In which case can ADC stop working?

Thanks

  • Hi,

    I think you meet the problem that ADC will do conversion for another one time. It because when you read the ADCMEMX, the next conversion is started. It will finish the conversion after all.

    Add ADCCTL0 &= ~ ADCENC after the last conversion. If if doesn't solve your question. Please post your code.

    Eason

  • Hi Eason,

    thanks for your feedback. So far after adding that part it looks good, will check again after a few days.

    1. One question on this: If we use reference of 1,2V (ADC12MCTL0 = ADC12INCH_31 | ADC12VRSEL_1 | ADC12WINC), is it posible to connect higher voltage than the reference to input? Max input voltage will be 1,8V.Understood that from 1.2V to 1.8V we will have ADCMEM0 value of 0x0FFF. Will it break the converter?

    Also, we need to check the minimal battery voltage (higher than 1,8V). In our aplication we use 868MHz transciever (Tx current 30mA, voltage goes down gradually) and we need to be able to turn it off in time. Do we have any example of measurement of the baterry(Vcc) with comparator / msp430fr6820?

    Thanks!

  • Hi,

    It will not break the converter. See from the spec, if analog input voltage range below AVCC, it will be OK.

    Here is the reference code you can find:

    msp430fr6x7x_compe_01.c
    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2014, 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--*/
    //******************************************************************************
    // MSP430FR6x7x Demo - COMPE output Toggle in LPM4; input channel C1;
    //                     Vcompare is compared against internal 2.0V reference
    //
    // Description: Use CompE and internal reference to determine if input'Vcompare'
    // is high or low.  When Vcompare exceeds 2.0V COUT goes high and when Vcompare
    // is less than 2.0V then CEOUT goes low.
    //
    //                MSP430FR6972
    //             ------------------
    //         /|\|                  |
    //          | |                  |
    //          --|RST        P1.1/C1|<--Vcompare
    //            |                  |
    //            |         P1.2/COUT|----> 'high'(Vcompare>2.0V); 'low'(Vcompare<2.0V)
    //            |                  |
    //
    //   Andreas Dannenberg
    //   Texas Instruments Inc.
    //   September 2014
    //   Built with IAR Embedded Workbench V5.60 & Code Composer Studio V6.0
    //******************************************************************************
    #include <msp430.h>
    
    int main(void)
    {
      WDTCTL = WDTPW | WDTHOLD;                 // Stop WDT
    
      // Configure P1.1 as C1 and P1.2 as COUT
      P1SEL1 |= BIT1 | BIT2;
      P1SEL0 &= ~(BIT1 | BIT2);
      P1DIR |= BIT2;
    
      // Disable the GPIO power-on default high-impedance mode to activate
      // previously configured port settings
      PM5CTL0 &= ~LOCKLPM5;
    
      // Setup Comparator_E
      CECTL0 = CEIPEN | CEIPSEL_1;              // Enable V+, input channel CE1
      CECTL1 = CEPWRMD_1;                       // normal power mode
      CECTL2 = CEREFL_2 | CERS_3 | CERSEL;      // VREF is applied to -terminal
                                                // R-ladder off; bandgap ref voltage
                                                // supplied to ref amplifier to get Vcref=2.0V
      CECTL3 = BIT1;                            // Input Buffer Disable @P1.1/CE1
      CECTL1 |= CEON;                           // Turn On Comparator_E
    
      __delay_cycles(75);                       // delay for the reference to settle
    
      __bis_SR_register(LPM4_bits);             // Enter LPM4
      __no_operation();                         // For debug
    }
    

    msp430fr6x7x_compe_02.c
    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2014, 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--*/
    //******************************************************************************
    // MSP430FR6x7x Demo - COMPE output Toggle in LPM4; input channel C12;
    //                     Vcompare is compared against internal 2.0V reference
    //
    // Description: Use CompE and internal reference to determine if input'Vcompare'
    // is high or low.  When Vcompare exceeds 2.0V COUT goes high and when Vcompare
    // is less than 2.0V then COUT goes low.
    //
    //                MSP430FR6972
    //             ------------------
    //         /|\|                  |
    //          | |                  |
    //          --|RST       P9.4/C12|<--Vcompare
    //            |                  |
    //            |         P1.2/COUT|----> 'high'(Vcompare>2.0V); 'low'(Vcompare<2.0V)
    //            |                  |
    //
    //   Andreas Dannenberg
    //   Texas Instruments Inc.
    //   September 2014
    //   Built with IAR Embedded Workbench V5.60 & Code Composer Studio V6.0
    //******************************************************************************
    #include <msp430.h>
    
    int main(void)
    {
      WDTCTL = WDTPW | WDTHOLD;                 // Stop WDT
    
      // Configure Comp_E C12
      P9SEL1 |= BIT5;
      P9SEL0 |= BIT5;                           // Select C12 function on P9.5
    
      // Configure Comp_E COUT
      P1SEL1 |= BIT2;
      P1SEL0 &= ~(BIT2);
      P1DIR |= BIT2;                            // Select COUT function on P1.2
    
      // Disable the GPIO power-on default high-impedance mode to activate
      // previously configured port settings
      PM5CTL0 &= ~LOCKLPM5;
    
      // Setup Comparator_E
      CECTL0 = CEIPEN | CEIPSEL_12;             // Enable V+, input channel CE12
      CECTL1 = CEPWRMD_1;                       // normal power mode
      CECTL2 = CEREFL_2 | CERS_3 | CERSEL;      // VREF is applied to -terminal
                                                // R-ladder off; bandgap ref voltage
                                                // supplied to ref amplifier to get Vcref=2.0V
      CECTL3 = BITC;                            // Input Buffer Disable @P9.5/CE12
      CECTL1 |= CEON;                           // Turn On Comparator_E
    
      __delay_cycles(75);                       // delay for the reference to settle
    
      __bis_SR_register(LPM4_bits);             // Enter LPM4
      __no_operation();                         // For debug
    }
    

    msp430fr6x7x_compe_04.c
    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2014, 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--*/
    //******************************************************************************
    // MSP430FR6x7x Demo - COMPE Toggle from LPM4; CompE in ultra low power mode
    //                     Vcompare is compared against the Vcc*1/2
    //
    // Description: Use CompE and shared reference to determine if input 'Vcompare'
    //    is high or low.  When Vcompare exceeds Vcc*1/2 COUT goes high and when
    //    Vcompare is less than Vcc*1/2 then COUT goes low.
    //
    //                MSP430FR6972
    //             ------------------
    //         /|\|                  |
    //          | |                  |
    //          --|RST        P1.1/C1|<--Vcompare
    //            |                  |
    //            |         P1.2/COUT|----> 'high'(Vcompare>Vcc*1/2); 'low'(Vcompare<Vcc*1/2)
    //            |                  |
    //
    //   Andreas Dannenberg
    //   Texas Instruments Inc.
    //   September 2014
    //   Built with IAR Embedded Workbench V5.60 & Code Composer Studio V6.0
    //******************************************************************************
    #include <msp430.h>
    
    int main(void)
    {
      WDTCTL = WDTPW | WDTHOLD;                 // Stop WDT
    
      // Configure all un-used GPIO to lowest power state
      PADIR = 0xFFFF;
      PAOUT = 0;
    
      PBDIR = 0xFFFF;
      PBOUT = 0;
    
      PCDIR = 0xFFFF;
      PCOUT = 0;
    
      PDDIR = 0xFFFF;
      PDOUT = 0;
    
      PEDIR = 0xFFFF;
      PEOUT = 0;
    
      PJDIR = 0xFF;
      PJOUT = 0;
    
      // Configure P1.1 as C1 and P1.2 as COUT
      P1SEL1 |= BIT1 | BIT2;
      P1SEL0 &= ~(BIT1 | BIT2);
      P1DIR |= BIT2;
    
      // Disable the GPIO power-on default high-impedance mode to activate
      // previously configured port settings
      PM5CTL0 &= ~LOCKLPM5;
    
      // Setup Comparator_E
      CECTL0 = CEIPEN | CEIPSEL_1;              // Enable V+, input channel CE01
      CECTL1 = CEMRVS | CEPWRMD_2;              // CMRVL selects the refV - VREF0
                                                // Ultra-low power comparator mode
      CECTL2 = CERS_1 | CERSEL | CEREF04;       // VREF is applied to -terminal
                                                // VCC applied to R-ladder; VREF0 is Vcc*1/2
      CECTL3 = BIT1;                            // Input Buffer Disable @P1.1/CE1
      CECTL1 |= CEON;                           // Turn On Comparator_E
    
      __delay_cycles(75);                       // delay for the reference to settle
    
      __bis_SR_register(LPM4_bits);             // Enter LPM4
      __no_operation();                         // For debug
    }
    

    msp430fr6x7x_compe_05.c
    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2014, 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--*/
    //******************************************************************************
    //  MSP430FR6x7x Demo - COMPE Hysteresis, COUT Toggle in LPM4; High speed mode
    //
    //  Description: Use CompE and shared reference to determine if input 'Vcompare'
    //  is high or low.  Shared reference is configured to generate hysteresis.
    //  When Vcompare exceeds Vcc*3/4 COUT goes high and when Vcompare is less
    //  than Vcc*1/4 then COUT goes low.
    //
    //                MSP430FR6972
    //             ------------------
    //         /|\|                  |
    //          | |                  |
    //          --|RST        P1.1/C1|<-- Vcompare
    //            |                  |
    //            |         P1.2/COUT|--> 'high'(Vcompare>Vcc*3/4); 'low'(Vcompare<Vcc*1/4)
    //            |                  |
    //
    //   Andreas Dannenberg
    //   Texas Instruments Inc.
    //   September 2014
    //   Built with IAR Embedded Workbench V5.60 & Code Composer Studio V6.0
    //******************************************************************************
    #include <msp430.h>
    
    int main(void)
    {
      WDTCTL = WDTPW | WDTHOLD;                 // Stop WDT
    
      // Configure GPIO
      P1SEL1 |= BIT1;                           // P1.1 C1 for Vcompare
      P1SEL0 |= BIT1;
      P1DIR |= BIT2;                            // P1.2COUT output direction
      P1SEL1 |= BIT2;                           // Select COUT function on P1.2/COUT
    
      // Disable the GPIO power-on default high-impedance mode to activate
      // previously configured port settings
      PM5CTL0 &= ~LOCKLPM5;
    
      // Setup Comparator_E
      CECTL0 = CEIPEN | CEIPSEL_1;              // Enable V+, input channel CE1
      CECTL1 = CEPWRMD_0;                       // CEMRVS=0 => select VREF1 as ref when CEOUT
                                                // is high and VREF0 when CEOUT is low
                                                // High-Speed Power mode
      CECTL2 = CEREF13 | CERS_1 | CERSEL | CEREF04 | CEREF03;  // VRef is applied to -terminal
                                                // VREF1 is Vcc*1/4
                                                // VREF0 is Vcc*3/4
    
      CECTL3 = BIT1;                            // Input Buffer Disable @P1.1/C1
      CECTL1 |= CEON;                           // Turn On ComparatorE
    
      __delay_cycles(75);                       // delay for the reference to settle
    
      __bis_SR_register(LPM4_bits);             // Go to LPM4
      __no_operation();                         // For debug
    }
    

    Eason

  • Thanks Eason,

    This helps.

    Regarding the last question about battery voltage measurement, do you happen to have some feedback on that (comparator based measurement with msp)?

  • HI Bart,

    Sorry to make you confused and reply late. The code I attached is for comparator. It can be used in your situation.

    Eason

**Attention** This is a public forum