Because of the Thanksgiving holiday in the U.S., TI E2E™ design support forum responses may be delayed from November 25 through December 2. Thank you for your patience.

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/MSP432E401Y: How to capture the ADC values at specified PWM cycle???

Part Number: MSP432E401Y

Tool/software: Code Composer Studio

I am new to the msp432e401y , can u please suggest how to capture the ADC values only at on time / off time of the pwm...

if I consider the pwm with 50% duty cycle of 2khz , then on cycle will be for 1khz ….

since the msp432e401y adc has maximum of 2MSPS , can u pls guide me how to capture the adc (minimum /least msps) in 1khz cycle of pwm...

  • Hi,

    you can use the ADC trigger signals described in datasheet in table 6-51

    The source is selected via the ADC14SHSx bits located in register ADC14CTL0.

    Easiest thing is to review code example from SDK see below

  • Thank you!!

    I have the updated version of sdk wch is sdk v:2, so don't have that example

    but I am not getting the concept of , how to trigger the adc read at timer pwm

    how to get the interrupt at timer pwm?

    Table 6-

  • Hi

    I attached you the code file of my SDK example which might help you to check how to setup Timer and ADC. Even with newer SDK the example should be in.

    adc14_single_conversion_repeat_timera_source.c
    /* --COPYRIGHT--,BSD
     * Copyright (c) 2017, 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 Continuous Sample w/ Timer_A Trigger
     *
     * Description: In this ADC14 code example, a single input channel is sampled
     * using the standard 3.3v reference. The source of the sample trigger for this
     * example is Timer_A CCR1. The ADC is setup to continuously sample/convert
     * from A0 when the trigger starts and store the results in resultsBuffer (it
     * is setup to be a circular buffer where resPos overflows to 0). Timer_A is
     * setup in Up mode and a Compare value of 16384  is set as the compare trigger
     *  and reset trigger. Once the Timer_A is started, after 0.5s it will trigger
     * the ADC14 to start conversions. Essentially this example will use
     * the Timer_A module to trigger an ADC conversion every 0.5 seconds.
     *
     *                MSP432P401
     *             ------------------
     *         /|\|                  |
     *          | |                  |
     *          --|RST         P5.5  |<--- A0 (Analog Input)
     *            |                  |
     *            |                  |
     *            |                  |
     *            |                  |
     *            |                  |
     *
     ******************************************************************************/
    /* DriverLib Includes */
    #include <ti/devices/msp432p4xx/driverlib/driverlib.h>
    
    /* Standard Includes */
    #include <stdint.h>
    #include <stdbool.h>
    
    /* Timer_A Continuous Mode Configuration Parameter */
    const Timer_A_UpModeConfig upModeConfig =
    {
            TIMER_A_CLOCKSOURCE_ACLK,            // ACLK Clock Source
            TIMER_A_CLOCKSOURCE_DIVIDER_1,       // ACLK/1 = 32Khz
            16384,
            TIMER_A_TAIE_INTERRUPT_DISABLE,      // Disable Timer ISR
            TIMER_A_CCIE_CCR0_INTERRUPT_DISABLE, // Disable CCR0
            TIMER_A_DO_CLEAR                     // Clear Counter
    };
    
    /* Timer_A Compare Configuration Parameter */
    const Timer_A_CompareModeConfig compareConfig =
    {
            TIMER_A_CAPTURECOMPARE_REGISTER_1,          // Use CCR1
            TIMER_A_CAPTURECOMPARE_INTERRUPT_DISABLE,   // Disable CCR interrupt
            TIMER_A_OUTPUTMODE_SET_RESET,               // Toggle output but
            16384                                       // 16000 Period
    };
    
    /* Statics */
    static volatile uint_fast16_t resultsBuffer[UINT8_MAX];
    static volatile uint8_t resPos;
    
    int main(void)
    {
        /* Halting WDT  */
        MAP_WDT_A_holdTimer();
        MAP_Interrupt_enableSleepOnIsrExit();
        resPos = 0;
    
        /* Setting up clocks
         * MCLK = MCLK = 3MHz
         * ACLK = REFO = 32Khz */
        MAP_CS_initClockSignal(CS_ACLK, CS_REFOCLK_SELECT, CS_CLOCK_DIVIDER_1);
    
        /* Initializing ADC (MCLK/1/1) */
        MAP_ADC14_enableModule();
        MAP_ADC14_initModule(ADC_CLOCKSOURCE_MCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_1,
                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 Timer_A in continuous mode and sourced from ACLK */
        MAP_Timer_A_configureUpMode(TIMER_A0_BASE, &upModeConfig);
    
        /* Configuring Timer_A0 in CCR1 to trigger at 16000 (0.5s) */
        MAP_Timer_A_initCompare(TIMER_A0_BASE, &compareConfig);
    
        /* Configuring the sample trigger to be sourced from Timer_A0  and setting it
         * to automatic iteration after it is triggered*/
        MAP_ADC14_setSampleHoldTrigger(ADC_TRIGGER_SOURCE1, false);
    
        /* Enabling the interrupt when a conversion on channel 1 is complete and
         * enabling conversions */
        MAP_ADC14_enableInterrupt(ADC_INT0);
        MAP_ADC14_enableConversion();
    
        /* Enabling Interrupts */
        MAP_Interrupt_enableInterrupt(INT_ADC14);
        MAP_Interrupt_enableMaster();
    
        /* Starting the Timer */
        MAP_Timer_A_startCounter(TIMER_A0_BASE, TIMER_A_UP_MODE);
    
        /* Going to sleep */
        while (1)
        {
            MAP_PCM_gotoLPM0();
        }
    }
    
    /* This interrupt is fired whenever a conversion is completed and placed in
     * ADC_MEM0 */
    void ADC14_IRQHandler(void)
    {
        uint64_t status;
    
        status = MAP_ADC14_getEnabledInterruptStatus();
        MAP_ADC14_clearInterruptFlag(status);
    
    
        if (status & ADC_INT0)
        {
            if(resPos == UINT8_MAX)
            {
               resPos = 0; 
            }
            
            resultsBuffer[resPos++] = MAP_ADC14_getResult(ADC_MEM0);
        }
    
    }
    

  • Thank you sooo much!!!

**Attention** This is a public forum