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.

adc14_single_conversion_repeat - MSP432 Launcpad

Hello all,

Has anyone else had trouble getting this example to run?  I've had success with the other examples in the Resource Explorer for the MSP432 but I cannot get this example to return a result.  The memory locations for the output remain zeroed out.

Thanks,

Patrick Henderson

  • Hello Patrick,

    I am able to run the example with success. Make sure that A0 (P5.5) is not connected to GND as this will return a result of zero. You can also try connecting P5.5 to Vcc to try and force a non-zero result.

    Regards,
    Ryan
  • Hmm,
    I tried with A0 connected to a Function Generator @ 1.5V high, .25V low, 5Khz, and High Z impedance. When that didn't work I tried it at the 1V DC using a simple resistor voltage divider circuit. I even altered the GPIO setting to different pins to see if it was only A0 that wasn't working. A no point did the curADCResult variable populate. The MEM0 register also remained empty. I ran it on my laptop and the workstation computer with the same results.

    This example is the only one in the ADC14 driverlib folder that I can't get working and unfortunately it is the exact function I need the ADC to do for a project I'm working on.

    Anyone have a suggestion as to what I should try next to get this going?
  • So you can get every other ADC14 driverlib example to work?  This tells me that something is wrong with your adc14_single_conversion_repeat file, specifically the ADC initialization since MEM0 remains at zero.  I would try re-downloading the example.  Also attached is my c file for reference.

    /*
     * -------------------------------------------
     *    MSP432 DriverLib - v2_20_00_08 
     * -------------------------------------------
     *
     * --COPYRIGHT--,BSD,BSD
     * 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.
     * --/COPYRIGHT--*/
    /*******************************************************************************
     * 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 */
    static volatile uint16_t curADCResult;
    static volatile float normalizedADCRes;
    
    int main(void)
    {
        /* Halting the Watchdog  */
        MAP_WDT_A_holdTimer();
    
        /* Initializing Variables */
        curADCResult = 0;
    
        /* Setting DCO to 48MHz  */
        MAP_PCM_setPowerState(PCM_AM_LDO_VCORE1);
        MAP_CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_48);
    
        /* Enabling the FPU for floating point operation */
        MAP_FPU_enableModule();
        MAP_FPU_enableLazyStacking();
    
        /* Initializing ADC (MCLK/1/4) */
        MAP_ADC14_enableModule();
        MAP_ADC14_initModule(ADC_CLOCKSOURCE_MCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_4,
                0);
                
        /* Configuring GPIOs (5.5 A0) */
        MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P5, GPIO_PIN5,
        GPIO_TERTIARY_MODULE_FUNCTION);
    
        /* Configuring ADC Memory */
        MAP_ADC14_configureSingleSampleMode(ADC_MEM0, true);
        MAP_ADC14_configureConversionMemory(ADC_MEM0, ADC_VREFPOS_AVCC_VREFNEG_VSS,
        ADC_INPUT_A0, false);
    
        /* Configuring Sample Timer */
        MAP_ADC14_enableSampleTimer(ADC_MANUAL_ITERATION);
    
        /* Enabling/Toggling Conversion */
        MAP_ADC14_enableConversion();
        MAP_ADC14_toggleConversionTrigger();
    
        /* Enabling interrupts */
        MAP_ADC14_enableInterrupt(ADC_INT0);
        MAP_Interrupt_enableInterrupt(INT_ADC14);
        MAP_Interrupt_enableMaster();
    
        while (1)
        {
            MAP_PCM_gotoLPM0();
        }
        
    }
    
    /* ADC Interrupt Handler. This handler is called whenever there is a conversion
     * that is finished for ADC_MEM0.
     */
    void adc_isr(void)
    {
        uint64_t status = MAP_ADC14_getEnabledInterruptStatus();
        MAP_ADC14_clearInterruptFlag(status);
    
        if (ADC_INT0 & status)
        {
            curADCResult = MAP_ADC14_getResult(ADC_MEM0);
            normalizedADCRes = (curADCResult * 3.3) / 16384;
    
            MAP_ADC14_toggleConversionTrigger();
        }
    }
    
    

    Hope this helps, Ryan

  • Uninstall - Reinstall of CCS and now I 'm getting results!

    Thank you for your help on this Ryan.

**Attention** This is a public forum