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.

MSP432 ADC high current & REV C ADC issues

Other Parts Discussed in Thread: ENERGIA, MSP432WARE

Good afternoon,


We have been testing some custom built MSP432 prototype boards (ultra-low power sensor development) along with the both REV B / REV C launchpads and have encountered 2 issues with the ADCs. 

1.

Regarding current consumed by the ADCs, in the MSP432 datasheet (page 64) (at 3.3V, 24MHz, 1Msps, single ended mode_) we should be consuming on the order of 640uA MAX. We ran the code attached below (code is slightly modified version of "adc14_single_conversion_repeat" from the most recent MSP432 driver library v3_21_00_05 and most recent system files loaded) on a brand new REV C launchpad.  We turned the ADC module on/off using an interrupt and found that we are consuming ~1.8mA = (18mW-12mW)/3.3V (energia screenshot attached and confirmed with multimeter)  However bumping up the clock to 48Mhz, this same code consumes a whopping ~3.6mA = (26mW-14mW)/3.3V (energia screenshot attached).  On our custom board, we are seeing even a larger current consumption, around 4.85mA, with the ADC configured identically.
Is this how the ADC should be functioning?

In another TI document posted on the MSP432 main site "Bringing High Performance to low-power Applications" (page 4), it states that at full speed the ADC draws 375uA..

2.


Our other issue deals with the ADC example code.  We currently have the most recent MSP432 driver library (v3_21_00_05) running on the most recent CCS Version: 6.1.3.00034 , but the ADC example code does not function correctly.  Judging by the current consumed, the ADC module itself is turning on and off, but we are not registering any values being read by the ADCs on the launchpad (did a memory check to confirm values were not changing)  Strangely enough the REV B micros work perfectly but as soon as we switch over to REV C micros, we encounter a significant amount of issues with the ADCs using the same exact code.  Any suggestions?  There may be some files linked incorrectly that are causing this issue or something wasn't updated accordingly.. Note: I loaded the MSP432 example file from the TI Resource Explorer and then created a new project which has the newest "startup_msp432p401r_ccs.c" and "system_msp432p401r.c" and copied the example into this new project.


Your help is much appreciated.


Best,

Rob

/*******************************************************************************
 * MSP432 ADC14 - Single Channel Sample Repeat
 *
 * Description: This code example will demonstrate the basic functionality of
 * of the DriverLib ADC APIs with sampling a single channel repeatedly. Each
 * time the ADC conversion occurs, the result is stored into a local variable.
 * The sample timer is used to continuously grab a new value from the ADC
 * module using a manual iteration that is performed in the ADC ISR. A
 * normalized ADC value with respect to the 3.3v Avcc is also calculated using
 * the FPU.
 *
 *                MSP432P401
 *             ------------------
 *         /|\|                  |
 *          | |                  |
 *          --|RST         P5.5  |<--- A0 (Analog Input)
 *            |                  |
 *            |                  |
 *            |                  |
 *            |                  |
 *            |                  |
 *
 * Author: Timothy Logan
 ******************************************************************************/
/* DriverLib Includes */
#include "driverlib.h"

/* Standard Includes */
#include <stdint.h>

#include <stdbool.h>

/* Statics */
volatile uint16_t curADCResult;
volatile float normalizedADCRes;
volatile uint16_t *previous_position = &curADCResult;
int i = 0;

int main(void)
{
    /* Halting the Watchdog  */
    MAP_WDT_A_holdTimer();

    /* Initializing Variables */
    curADCResult = 0;

    /* Setting Flash wait state */
    PCM_setCoreVoltageLevel(PCM_VCORE1);
    MAP_FlashCtl_setWaitState(FLASH_BANK0, 2);
    MAP_FlashCtl_setWaitState(FLASH_BANK1, 2);

    /* Initialize MCLK to run from DCO with divider = 1*/
    CS_initClockSignal(CS_MCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1);

    /* 48MHz is a standard centered frequency */
    MAP_CS_enableDCOExternalResistor();
	MAP_CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_24);

//    /* Enabling the FPU for floating point operation */
    MAP_FPU_enableModule();
    MAP_FPU_enableLazyStacking();

    /* Initializing ADC (MCLK/1/4) */
    ADC14_enableModule();
    ADC14_initModule(ADC_CLOCKSOURCE_MCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_4,
            0);

    /* Configuring GPIOs (5.5 A0) */
    GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P5, GPIO_PIN5,
    GPIO_TERTIARY_MODULE_FUNCTION);

    /* Configuring ADC Memory */
    ADC14_configureSingleSampleMode(ADC_MEM0, false);
    ADC14_configureConversionMemory(ADC_MEM0, ADC_VREFPOS_AVCC_VREFNEG_VSS,ADC_INPUT_A0, false);

    ADC14_setPowerMode(ADC_UNRESTRICTED_POWER_MODE);

    /* Enabling interrupts */
    ADC14_enableInterrupt(ADC_INT0);

    /* Configuring SysTick to trigger at 24000000 (MCLK is 48MHz so this will
     * make it toggle every 0.5s) */
    MAP_SysTick_enableModule();
    MAP_SysTick_setPeriod(12000000);
    MAP_SysTick_enableInterrupt();

     /* Enabling MASTER interrupts */
    MAP_Interrupt_enableInterrupt(INT_ADC14);
    MAP_Interrupt_enableInterrupt(FAULT_SYSTICK);
    MAP_Interrupt_enableMaster();

    /* Configuring Sample Timer */
    ADC14_enableSampleTimer(ADC_MANUAL_ITERATION);

    /* Enabling/Toggling Conversion */
    ADC14_enableConversion();
    ADC14_toggleConversionTrigger();

    while (1)
    {
        MAP_PCM_gotoLPM0();
    }

}

/* ADC Interrupt Handler. This handler is called whenever there is a conversion
 * that is finished for ADC_MEM0.
 */
void ADC14_IRQHandler(void)
{
    uint64_t status = ADC14_getEnabledInterruptStatus();
    ADC14_clearInterruptFlag(status);

    if (ADC_INT0 & status)
    {
    	*previous_position = ADC14_getResult(ADC_MEM0);
        normalizedADCRes = (curADCResult * 3.3) / 16384;

        ADC14_toggleConversionTrigger();
    }
}

void SysTick_Handler(void)
{
	if (i<8){
		ADC14_enableModule();
		ADC14_enableInterrupt(ADC_INT0);
		MAP_Interrupt_enableInterrupt(INT_ADC14);
		i++;
	}
	else if (i>=8 && i<16){
		MAP_Interrupt_disableInterrupt(INT_ADC14);
		ADC14_disableInterrupt(ADC_INT0);
		ADC14_disableModule();
		i++;
	}
	else {
		i=0;
	}

}

24 MHz clock running above

48MHz clock running above

  • Hi Rob,

    We are actually in the process of updating all of our code examples to support Rev C silicon - thanks for your patience here.

    Please keep in mind that the purpose of this code example is to highlight the ADC functionality, and it's not purpose-built for low-power. I noticed that this code example uses Flash Wait State 2 for RevB, but now RevC can operate at 48 MHz using Flash Wait State 1 instead. This may not decrease power consumption, but it should increase performance.

    For your reference, take a look at the Designing an Ultra-Low-Power (ULP) Application With MSP432™ Microcontrollers app note. It features several power optimization strategies and should be helpful for your application, including when to use the DC-DC converter instead of the LDO for better efficiency.

    Also, refer to Section 2.3.5 of the LaunchPad's User's Guide for the most accurate current measurement method, which includes making sure there are no floating I/O pins (this is done in the 'msp432p401_pcm_02.c' code example below) and accounting for the back-channel UART and any circuitry connected to the MSP432 that may be drawing additional current (which would explain why your custom board consumes slightly more current).

    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2013, 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.
     *
     *******************************************************************************
     *
     *                       MSP432 CODE EXAMPLE DISCLAIMER
     *
     * MSP432 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/.../mspdriverlib for an API functional
     * library & https://dev.ti.com/pinmux/ for a GUI approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    //******************************************************************************
    //   MSP432P401 Demo - Enter LPM3 with ACLK = REFO
    //
    //  Description: MSP432 device is configured to enter LPM3 mode with GPIOs properly 
    //  terminated. P1.1 is configured as an input. Pressing the button connect to P1.1
    //  results in device waking up and servicing the Port1 ISR. LPM3 current can be 
    //  measured when P1.0 is output low (e.g. LED off). 
    // 
    //  ACLK = 32kHz, MCLK = SMCLK = default DCO
    //
    //
    //               MSP432p401rpz
    //            -----------------
    //        /|\|                 |
    //         | |                 |
    //         --|RST              |
    //     /|\   |                 |
    //      --o--|P1.1         P1.0|-->LED
    //     \|/
    //
    //   Dung Dang
    //   Texas Instruments Inc.
    //   October 2015 (updated) | November 2013 (created)
    //   Built with Code Composer Studio V6.0
    //******************************************************************************
    
    #include "msp.h"
    int main(void)
    {   
        /* Hold the watchdog */
        WDTCTL = WDTPW | WDTHOLD;
        /* Configuring P1.0 as output and P1.1 (switch) as input with pull-up resistor*/
        /* Rest of pins are configured as output low */
        /* Notice intentional '=' assignment since all P1 pins are being deliberately configured */
        P1DIR = ~(BIT1);
        P1OUT = BIT1;
        P1REN = BIT1;                           // Enable pull-up resistor (P1.1 output high)
        P1SEL0 = 0;
        P1SEL1 = 0;
        P1IFG = 0;                              // Clear all P1 interrupt flags
        P1IE = BIT1;                            // Enable interrupt for P1.1
        P1IES = BIT1;                               // Interrupt on high-to-low transition
    
        // Enable Port 1 interrupt on the NVIC
        NVIC->ISER[1] = 1 << ((PORT1_IRQn) & 31);
    
        // Terminate all remaining pins on the device
        P2DIR |= 0xFF; P2OUT = 0;
        P3DIR |= 0xFF; P3OUT = 0;
        P4DIR |= 0xFF; P4OUT = 0;
        P5DIR |= 0xFF; P5OUT = 0;
        P6DIR |= 0xFF; P6OUT = 0;
        P7DIR |= 0xFF; P7OUT = 0;
        P8DIR |= 0xFF; P8OUT = 0;
        P9DIR |= 0xFF; P9OUT = 0;
        P10DIR |= 0xFF; P10OUT = 0;
    
        /* Configure Port J */
        PJDIR |= (BIT2 | BIT3); PJOUT &= ~(BIT2 | BIT3);
    
        /* PJ.0 & PJ.1 configured for XT1 */
        PJSEL0 |= BIT0 | BIT1;
        PJSEL1 &= ~(BIT0 | BIT1);
    
        /* Starting LFXT in non-bypass mode without a timeout. */
        CS->KEY = CS_KEY_VAL ;
        CS->CTL1 &= ~(CS_CTL1_SELA_MASK | CS_CTL1_SELB);
        CS->CTL1 |= CS_CTL1_SELA__LFXTCLK;                // Source LFXTCLK to ACLK & BCLK
        CS->CTL2 &= ~(CS_CTL2_LFXTDRIVE_MASK);               // Configure to lowest drive-strength    
        CS->CTL2 |= CS_CTL2_LFXT_EN;
        while (CS->IFG & CS_IFG_LFXTIFG)
            CS->CLRIFG |= CS_CLRIFG_CLR_LFXTIFG;
        CS->KEY = 0;
        /* Turn off PSS high-side supervisors */
        PSS->KEY = PSS_KEY_KEY_VAL;
        PSS->CTL0 |= PSS_CTL0_SVSMHOFF;
        PSS->KEY = 0;
    
        /* Enable PCM rude mode, which allows to device to enter LPM3 without waiting for peripherals */
        PCM->CTL1 = PCM_CTL0_KEY_VAL | PCM_CTL1_FORCE_LPM_ENTRY;
    
    
        /* Enable all SRAM bank retentions prior to going to LPM3  */
        SYSCTL->SRAM_BANKRET |= SYSCTL_SRAM_BANKRET_BNK7_RET;
        __enable_interrupt();
        SCB->SCR |= SCB_SCR_SLEEPONEXIT_Msk;           // Do not wake up on exit from ISR
    
    
        /* Setting the sleep deep bit */
        SCB->SCR |= (SCB_SCR_SLEEPDEEP_Msk);
        /* Go to LPM3 */
        __sleep();
    
    }
    
    /* Port1 ISR */
    void PORT1_IRQHandler(void)
    {
        volatile uint32_t i, status;
        /* Toggling the output on the LED */
        if(P1IFG & BIT1)
            P1OUT ^= BIT0;
    
        /* Delay for switch debounce */
        for(i = 0; i < 10000; i++)
    
        P1IFG &= ~BIT1;
    
    }
    

    Hope this helps.

    Regards,

    James

    MSP Customer Applications

  • Thank you for your prompt response James. Regarding your comments I have a few questions:

    We are actually in the process of updating all of our code examples to support Rev C silicon - thanks for your patience here.

    Is there an expected release date? For now the base port manipulation code should do and seems to function.

    Please keep in mind that the purpose of this code example is to highlight the ADC functionality, and it's not purpose-built for low-power. I noticed that this code example uses Flash Wait State 2 for RevB, but now RevC can operate at 48 MHz using Flash Wait State 1 instead. This may not decrease power consumption, but it should increase performance.

    Good observation, thanks!

    For your reference, take a look at the Designing an Ultra-Low-Power (ULP) Application With MSP432™ Microcontrollers app note. It features several power optimization strategies and should be helpful for your application, including when to use the DC-DC converter instead of the LDO for better efficiency.
    
    Also, refer to Section 2.3.5 of the LaunchPad's User's Guide for the most accurate current measurement method, which includes making sure there are no floating I/O pins (this is done in the 'msp432p401_pcm_02.c' code example below) and accounting for the back-channel UART and any circuitry connected to the MSP432 that may be drawing additional current (which would explain why your custom board consumes slightly more current).

    We will go ahead and review this documentation in more detail but our initial tests initialized floating I/O pins and external circuity was accounted for.  However I went ahead and switched the DCO clock frequency from 48MHz to 24MHz and our protoboard's current consumption decreased by a whopping 10mA! (23mA original 48MHz -> 12.5mA at 24MHz)  Seems like this may be our fix, since we should be able to get away with a slower operating frequency.

    If we wanted to operate at say 32-36MHz, the CS library function CS_tuneDCOFrequency() should do the trick to get us that extra performance but the function's comments states that this will not be available on pre-release MSP432 devices.  Would this include both REV C and REV B? Comment from CS library posted below.

    //! Tunes the DCO to a specific frequency. Tuning of the DCO is based off of the
    //! following equation in the user's guide:
    //!
    //! See the user's guide for more detailed information about DCO tuning.
    //!
    //! \note This function is not currently available on pre-release MSP432 devices.
    //!  On early release versions of MSP432, the DCO calibration information has not been
    //!  populated making the DCO only able to operate at the pre-calibrated centered 
    //!  frequencies accessible by the \link CS_setDCOCenteredFrequency \endlink
    //!  function. While this function will be added on the final devices being released,
    //!  for early silicon please default to the pre-calibrated DCO center frequencies.
    //!
    //! \param tuneParameter Tuning parameter in 2's Compliment representation.
    //!  Can be negative or positive.
    //!
    //! \return NONE

    I also noticed that we can retrieve code examples from two locations: MSPWare driver library and MSP432P4xx Device Code Examples (example msp432p401_pcm_02.c which you posted above).  Are these Device Code examples (one click projects) routinely updated and have they already been updated for the REV C micros?

    EDIT: seems like the rudimentary low level code seems to work fine on REV C micros, we will go ahead and omit using the library until it is released.

    Once again your help is very much appreciated.

    Best,

    Robert

  • Hi Robert,

    Sorry for the delayed response. I'm happy to hear that you were able to lower your power consumption!

    Regarding the release date, I can't give you a specific release date for all our code examples. However, MSP432Ware will be the best place to find the latest updates for MSP432 RevC devices, as discussed here. You should get notifications in CCS whenever there are new updates to install.

    For setting the DCO to a non-centered frequency, take a look at our latest "cs_dco_frequency_tune.c" code example from MSP432Ware v3.50.00.02. The MAP_CS_setDCOFrequency() function should allow you to enter a frequency, and it automatically takes care of the tuning. I found this example in the TI Resource Explorer under Libraries -> Driver Library -> MSP432P4xx -> Example Projects -> CS.

    /*
     * -------------------------------------------
     *    MSP432 DriverLib - v3_21_00_05 
     * -------------------------------------------
     *
     * --COPYRIGHT--,BSD,BSD
     * Copyright (c) 2016, 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.
     * --/COPYRIGHT--*/
    /*******************************************************************************
     * MSP432 Clock System - Tune DCO Frequency to Non-Standard Frequency
     *
     * Description: In this example, we show how easy it is to set the DCO frequency
     * to non-standard frequencies. Since MSP432 has the ability to granularly tune
     * the DCO frequency to non standard frequencies, this can be done easily using
     * the  CS_setDCOFrequency frequency. This application will set the DCO
     * frequency to 8.33MHz, and then use the SysTick module to blink and LED
     * on P1.0.
     *
     *              MSP432P401
     *             ------------------
     *         /|\|                  |
     *          | |                  |
     *          --|RST         P1.0  |---> P1.0 LED
     *            |                  |
     *            |                  |
     *            |                  |
     *            |                  |
     *            |                  |
     *
     * Author: Timothy Logan
     ******************************************************************************/
    /* DriverLib Includes */
    #include "driverlib.h"
    
    /* Standard Includes */
    #include <stdint.h>
    
    #include <stdbool.h>
    
    int main(void)
    {
        /* Halting the Watchdog */
        MAP_WDT_A_holdTimer();
    
        /* Configuring GPIO as an output */
        MAP_GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);
        
        /* Enabling FPU for DCO Frequency calculation */
        MAP_FPU_enableModule();
        
        /* Setting the DCO Frequency to a non-standard 8.33MHz */
        MAP_CS_setDCOFrequency(8330000);
        
        /* Configuring SysTick to trigger at 4165000 (MCLK is 8.33MHz so this will
         * make it toggle every ~0.5s) */
        MAP_SysTick_enableModule();
        MAP_SysTick_setPeriod(4165000);
        MAP_Interrupt_enableSleepOnIsrExit();
        MAP_SysTick_enableInterrupt();
        
        /* Enabling MASTER interrupts */
        MAP_Interrupt_enableMaster();
    
        while (1)
        {
            MAP_PCM_gotoLPM0();
        }
    }
    
    void SysTick_Handler(void)
    {
        MAP_GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0);
    }
    
    

    Hope this helps!

    Regards,

    James

    MSP Customer Applications

**Attention** This is a public forum