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.

MSP432P401R: MSP432P401R

Part Number: MSP432P401R

I had my code working perfectly fine. It still works and runs fine, except now my ADC values are garbage and mean absolutely nothing. I have been testing with P4.7, but wanted to test my idle state so I connected P4.1-4.6 to 5[V] that way their reading would be high and not cause the interrupt so i could isolate it to P4.7. Once i did this all of my values just do random things. I disconnected all pins and connected only P4.7 and now all ADC results are just random super large numbers or small or just anything. I move hand far and close to my sonar sensors and the ADC readings give no form of pattern or logical reading. I know the code works perfectly fine because I was running it for hours testing things and it was all perfect. I would just like to know if anyone can help me figure out what i did when I connected all those pins to the 5[V] and how I can reverse it. To run my code open: Resource Explorer > MSP432P401R LaunchPad - Red 2.x (Red) > SimpleLink MSP432P4 SDK - v:2.30.00.14 > Examples > Development Tools > MSP432P401R LaunchPad - Red 2.x (Red) > DriverLib > adc14_single_conversion_repeat_timera_source > No RTOS > CCS Compiler > Import project to IDE

and copy paste my code it will run fine.

/*      DLUG = MSP432_DriverLib_Users_Guide-MSP432P4xx-2_20_00_08        */
/*   hold command and click any API to see information about it          */

/* DriverLib Includes */
#include <ti/devices/msp432p4xx/driverlib/driverlib.h>

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

 /* For usleep() */
//#include <unistd.h>
//#include <stddef.h>

/* TI-RTOS Header files */
#include <ti/drivers/GPIO.h>
//#include <ti/display/Display.h>

/* Board Header file */
//#include "Board.h"

/* Statics */
uint16_t resultsBuffer[7];//Buffer to hold ADC readings of each Sonar Sensor

/* DLUG section: 2.6.2.25 | Registers an interrupt handler for the ADC interrupt.  */
void ADC14_registerInterrupt(void (*ADC14_IRQHandler)(void));

void PWMConfigure(void);//set up PWM
void ADCConfigure(void);//set up ADC
void InitDCO(void);//Change operation frequency of DCO
void SonarOne(void);
void SonarTwo(void);
void SonarThree(void);
void SonarFour(void);
void SonarFive(void);
void SonarSix(void);
void SonarSeven(void);
void EmergencyStop(void);

/**********************Timer_A PWM Configuration Parameter for Right motor*********************
    *hold command and click Timer_A_PWMConfig to see that pwmConfigR is a typedef struct _Timer_A_PWMConfig
    *S1 is for right motor */
    Timer_A_PWMConfig pwmConfigR =
    {
    TIMER_A_CLOCKSOURCE_SMCLK,//clock source for PWM operation
    TIMER_A_CLOCKSOURCE_DIVIDER_1,//divider of clocksource SMCLK
    4800,//period
    TIMER_A_CAPTURECOMPARE_REGISTER_3,
    TIMER_A_OUTPUTMODE_RESET_SET,
    2400//start at 50% duty cycle of 5[V] (2.5[V]) so motors not moving.
    };

/**********************Timer_A PWM Configuration Parameter for Left motor*********************
    *S2 is for left motor*/
    Timer_A_PWMConfig pwmConfigL =
    {
    TIMER_A_CLOCKSOURCE_SMCLK,
    TIMER_A_CLOCKSOURCE_DIVIDER_1,
    4800,
    TIMER_A_CAPTURECOMPARE_REGISTER_4,//makes P2.7 work because TA0.4
    TIMER_A_OUTPUTMODE_RESET_SET,
    2400
    };

/*********************************END TIMER_A_PWMConfig FOR BOTH MOTORS *********************************
 * The motors work with direction and speed as one input. 51-100% duty cycle is forward speed (5[V] max,
 * higher duty cycle is faster forward speed), 0-49% duty cycle is backward speed (0[V] max, lower duty
 * cycle is faster backward speed) and 50% is no movement(2.5[V]).
 *
 * We want to use about half of each directions duty cycle since we do not want to go fast. Each direction
 * has 2,400 levels of speed. Half of each is 1,200 levels of speed. Forward can have a duty cycle of
 * 2,401-4,800 and backwards can have a duty cycle of 0 - 2,399. We will be using Forward: 2,401-3,600 &
 * Backward: 1,200 - 2,399   */



/*********************************START MAIN**********************************/
int main(void)
{
    /* Halting WDT  */
    MAP_WDT_A_holdTimer();

    PWMConfigure();//set up PWM
    ADCConfigure();//set up ADC
    MAP_Interrupt_enableSleepOnIsrExit();

    /* Going to sleep */
    while (1)
    {
        MAP_PCM_gotoLPM0();//sleep while no interrupts are happening.
    }
}//END MAIN
/*********************************END MAIN**********************************/

void SonarOne(void){//P4.1 & resultsBuffer[6]
    MAP_GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);//LED1 (left)
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P2, GPIO_PIN1);
}
void SonarTwo(void){//P4.2 & resultsBuffer[5]
    MAP_GPIO_setOutputHighOnPin(GPIO_PORT_P2, GPIO_PIN1);//LED2 (right)
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
}
void SonarThree(void){//P4.3 & resultsBuffer[4]

}
void SonarFour(void){//P4.4 & resultsBuffer[3]

}
void SonarFive(void){//P4.5 & resultsBuffer[2]

}
void SonarSix(void){//P4.6 & resultsBuffer[1]

}
void SonarSeven(void){//P4.7 & resultsBuffer[0]

}

/*********************************START ADC HANDLER**********************************/
/* This interrupt is fired whenever a Sonar Reading is whatever the comparator says and the MAP_ADC14_enableInterrupt(X) says. */
void ADC14_IRQHandler(void)
{
    uint64_t status;

    status = MAP_ADC14_getEnabledInterruptStatus();//gets interrupt status for comparison
    MAP_ADC14_clearInterruptFlag(status);//clears interrupt flag for next interrupt check

    if(status & ADC_LO_INT)
    {
//    MAP_ADC14_getMultiSequenceResult(resultsBuffer);
    resultsBuffer[0] = MAP_ADC14_getResult(ADC_MEM0);//P4.7
    resultsBuffer[1] = MAP_ADC14_getResult(ADC_MEM1);//P4.6
    resultsBuffer[2] = MAP_ADC14_getResult(ADC_MEM2);//P4.5
    resultsBuffer[3] = MAP_ADC14_getResult(ADC_MEM3);//P4.4
    resultsBuffer[4] = MAP_ADC14_getResult(ADC_MEM4);//P4.3
    resultsBuffer[5] = MAP_ADC14_getResult(ADC_MEM5);//P4.2
    resultsBuffer[6] = MAP_ADC14_getResult(ADC_MEM6);//P4.1
    }

    if ((resultsBuffer[0] < 550) || (resultsBuffer[1] < 550) || (resultsBuffer[2] < 550) || (resultsBuffer[3] < 550) || (resultsBuffer[4] < 550) || (resultsBuffer[6] < 550) ){//LED 1 ON WHEN OBJECTS ARE CLOSE (RED)
        SonarOne();
    }
    else{//LED 2 ON WHEN OBJECTS ARE FAR (GREEN)
        SonarTwo();
    }
}//END ADC14 INTERRUPT HANDLER
/*********************************END ADC HANDLER**********************************/

/*********************************START PORT 1 HANDLER**********************************/
    /* Port1 ISR - This ISR will progressively step up the duty cycle of the PWM
     * on a button press */
void PORT1_IRQHandler(void)
{
    uint32_t status = MAP_GPIO_getEnabledInterruptStatus(GPIO_PORT_P1);//P2.7 brown wire
    MAP_GPIO_clearInterruptFlag(GPIO_PORT_P1, status);

    if (status & GPIO_PIN1)
    {
        if(pwmConfigL.dutyCycle == 4800 && pwmConfigR.dutyCycle == 4800){
            pwmConfigL.dutyCycle = 480;
            pwmConfigR.dutyCycle = 480;}
        else{
            pwmConfigL.dutyCycle += 480;
            pwmConfigR.dutyCycle += 480;}

        MAP_Timer_A_generatePWM(TIMER_A0_BASE, &pwmConfigL);
    }
}//END PORT 1 INTERRUPT HANDLER
/*********************************END PORT 1 HANDLER**********************************/

/*********************************START PWM CONFIGURE**********************************/
void PWMConfigure(){

    InitDCO();//Change clock frequency to 48[MHz]

    /* DLUG section: 6.6.2.18 | Initialize SMCLK to DCOCLK frequency divided by 1*/
    MAP_CS_initClockSignal(CS_SMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1);

    /* Configuring GPIO2.7 as peripheral output for PWM for right motor and
    * Configuring GPIO2.6 as peripheral output for PWM for left motor and P1.1 for button interrupt */
    MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P2, GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION);//P2.7 (right motor)
    MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P2, GPIO_PIN6, GPIO_PRIMARY_MODULE_FUNCTION);//P2.6 (left motor)
    MAP_GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P1, GPIO_PIN1);//set Pin 1 on Port 1
    MAP_GPIO_clearInterruptFlag(GPIO_PORT_P1, GPIO_PIN1);
    MAP_GPIO_enableInterrupt(GPIO_PORT_P1, GPIO_PIN1);

//    Interrupt_setPriority(INT_PORT1,0);

    /* DLUG section: 12.4.2.4 | Enabling interrupts on port 1 for button */
    MAP_Interrupt_enableInterrupt(INT_PORT1);

    /* DLUG section: 24.4.2.11 | Generate a PWM with timer running in up mode. Clock is set at 48[MHz],
     * which is 0.0208333[us] [Microseconds] (2.08s*10^-8). Each Timer is set up with a period of 4,800
     * ticks so period is 0.0001[s] which is a frequency of 1/.0001 = 10[kHz] */
    MAP_Timer_A_generatePWM(TIMER_A0_BASE, &pwmConfigR);
    MAP_Timer_A_generatePWM(TIMER_A0_BASE, &pwmConfigL);
}//END PWM CONFIGURATION
/*********************************END PWM CONFIGURE**********************************/

/*********************************START ADC CONFIGURE**********************************/
void ADCConfigure(){

    /* DLUG section: 2.6.2.14 | This will enable operation of the ADC block. */
    MAP_ADC14_enableModule();
//    MAP_ADC14_initModule(ADC_CLOCKSOURCE_ADCOSC, ADC_PREDIVIDER_1, ADC_DIVIDER_1,
//    0);

    /* Configuring GPIOs for Tertiary Function and inputs on Port 4 Pins 1-7 inclusive */
    MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P4, GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3 |
                      GPIO_PIN4 | GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7 , GPIO_TERTIARY_MODULE_FUNCTION);

    /* Setting LED1 and LED2 on board as outputs and initializing them as low */
    MAP_GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);//LED1(left and red)
    MAP_GPIO_setAsOutputPin(GPIO_PORT_P2, GPIO_PIN1);
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P2, GPIO_PIN1);//LED2(right and green)
//    MAP_GPIO_setAsOutputPin(GPIO_PORT_P2, GPIO_PIN2);

    /* DLUG section: 2.6.2.3 | Configuring ADC Memory (ADC_MEM0 - ADC_MEM6 (A6 - A12)  with no repeat)
     * with internal 3.3[V] reference */
    MAP_ADC14_configureMultiSequenceMode(ADC_MEM0,ADC_MEM6, true);

    /* DLUG section: 2.6.2.2 | Configures individual memory locations for each ADC module.
     *  (memory locations, type of voltage reference, which channel is being used for
     *  ADC sampling, false for non-differential inputs) */
    //ADC_VREFPOS_INTBUF_VREFNEG_VSS (does 2.5[V] reference voltage)
    MAP_ADC14_configureConversionMemory(ADC_MEM0,
        ADC_VREFPOS_AVCC_VREFNEG_VSS, ADC_INPUT_A6, false);//ADC6 = P4.7 = MEM0
    MAP_ADC14_configureConversionMemory(ADC_MEM1,
        ADC_VREFPOS_AVCC_VREFNEG_VSS, ADC_INPUT_A7, false);//ADC7 = P4.6 = MEM1
    MAP_ADC14_configureConversionMemory(ADC_MEM2,
        ADC_VREFPOS_AVCC_VREFNEG_VSS, ADC_INPUT_A8, false);//ADC8 = P4.5 = MEM2
    MAP_ADC14_configureConversionMemory(ADC_MEM3,
        ADC_VREFPOS_AVCC_VREFNEG_VSS, ADC_INPUT_A9, false);//ADC9 = P4.4 = MEM3
    MAP_ADC14_configureConversionMemory(ADC_MEM4,
        ADC_VREFPOS_AVCC_VREFNEG_VSS, ADC_INPUT_A10, false);//ADC10 = P4.3 = MEM4
    MAP_ADC14_configureConversionMemory(ADC_MEM5,
        ADC_VREFPOS_AVCC_VREFNEG_VSS, ADC_INPUT_A11, false);//ADC11 = P4.2 = MEM5
    MAP_ADC14_configureConversionMemory(ADC_MEM6,
        ADC_VREFPOS_AVCC_VREFNEG_VSS, ADC_INPUT_A12, false);//ADC12 = P4.1 = MEM6

    /* DLUG section: 2.6.2.16 | Setting up the sample timer to automatically step through the sequence convert
     * After one sample/convert is finished, the ADC module will automatically continue on to the next sample.*/
    MAP_ADC14_enableSampleTimer(ADC_AUTOMATIC_ITERATION);

    /*DLUG section: 2.6.2.11 | Enables the specified mask of memory channels to use the specified comparator window. The
    ADCC module has two different comparator windows that can be set with this function.*/
    ADC14_enableComparatorWindow(ADC_MEM0 | ADC_MEM1 | ADC_MEM2 | ADC_MEM3 | ADC_MEM4 | ADC_MEM5 | ADC_MEM6,
        ADC_COMP_WINDOW0);
//    ADC14_enableComparatorWindow(ADC_MEM0 | ADC_MEM1 | ADC_MEM2 | ADC_MEM3 | ADC_MEM4 | ADC_MEM5 | ADC_MEM6,
//            ADC_COMP_WINDOW1);

    /* DLUG section: 2.6.2.26 | Sets the lower and upper limits of the specified window comparator.
     * (window 0 or 1, lower limit, upper limit) */
    ADC14_setComparatorWindowValue(ADC_COMP_WINDOW0,550, 2000);
//    ADC14_setComparatorWindowValue(ADC_COMP_WINDOW1,550, 2000);

    /* DLUG section: 2.6.2.13 | Enabling the interrupt when a channel drops below threshold of comparator,
     * if use ADC_HI_INT enables interrupt when channel goes above threshold of comparator or
     * ADC_IN_INT enables interrupt channel when channel is whithin threshold */
    MAP_ADC14_enableInterrupt(ADC_LO_INT);
//    MAP_ADC14_enableInterrupt(ADC_HI_INT);
//    MAP_ADC14_enableInterrupt(ADC_IN_INT);

    /* DLUG section: 12.4.2.4 - 12.4.2.5 | Enabling Interrupts */
    MAP_Interrupt_enableInterrupt(INT_ADC14);
//    Interrupt_setPriority(INT_ADC14,0);
    MAP_Interrupt_enableMaster();

    /* DLUG section: 2.6.2.12 & 2.6.2.32 | Enables conversion of ADC data. Triggering the start of the sample.
     * Toggles the trigger for conversion of the ADC module by toggling the trigger software bit.*/
    MAP_ADC14_enableConversion();
    MAP_ADC14_toggleConversionTrigger();
}//END ADC CONFIGURATION
/*********************************END ADC CONFIGURE**********************************/

/*********************************START DCO INIT**********************************/
void InitDCO() {
    /* DLUG section: 9.3.2.4 | Enables the floating-point unit. */
    FPU_enableModule();

    /* DLUG section: 14.7.2.16 | Sets the core voltage level (Vcore). The function will
     * take care of all power state transitions needed to shift between core voltage levels.
     * Before we start we have to change VCORE to 1 to support the 48MHz frequency */
    PCM_setCoreVoltageLevel(PCM_AM_LDO_VCORE1);

    /* DLUG section: 8.4.2.22 | Changes the number of wait states that are used by the flash
     * controller for read operations. When changing frequency ranges of the clock, this
     * functions must be used in order to allow for readable flash memory.*/
    FlashCtl_setWaitState(FLASH_BANK0, 1);
    FlashCtl_setWaitState(FLASH_BANK1, 1);

    /* DLUG section: 6.6.2.21 | Sets the centered frequency of DCO operation to [32MHz to 64MHz]. */
    MAP_CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_48);

    /* DLUG section: 9.3.2.1 | Disables the floating-point unit. */
    FPU_disableModule();
}//END DCO INITIALIZATION
/*********************************END DCO INIT**********************************/


/*********************************START EMERGENCY STOP**********************************/
void EmergencyStop(){
        pwmConfigL.dutyCycle = 2400;
        pwmConfigR.dutyCycle = 2400;
}
/*********************************END EMERGENCY STOP**********************************/

  • The Absolute Maximum ratings [DS sec. 5.1] say don't apply more than 4.17V to any pin. It doesn't always damage something but it can.

    Do you have another Launchpad? Can you use the ADC inputs on P5/P6?
  • I switched to P5.0-2, P4.7, P4.0 and P6.0-1 for my ADCs and they work. I have another one I can test on tomorrow. I very well might have fried the other pins. My fault for not thinking twice before i plugged them in. I will post tomorrow when I check the other one so you can close this!
  • I'm glad you got it working. Being a klutz, I try to buy my Launchpads in pairs. (My specialty is plugging things in backwards.)
  • I hooked up my code to our other MSP432 and it looks like those pins also do not respond to the sensor readings at all. I hook up a sonar to P4.7 and it works fine, but when i switch and hook up 4.1-4.6 all the readings are trash. I never connected these directly to any voltage either.

  • I don't know the answer.

    > I hook up a sonar to P4.7 and it works fine, but when i switch and hook up 4.1-4.6 all the readings are trash
    These words seem to say that hooking up P4.1-6 affects the function of P4.7. If so, that may be a clue.

    Do the P5/P6 pins (from yesterday) also malfunction?

    Can you quantify (or at least classify) "trash"? Stuck high/low/other? Floats over the 14-bit range? Floats over a smaller range? What if you connect one to 3.3V or GND?

    When you say "sonar" I think of an SR-04ish ultrasonic thing. Is that about right? And you're using a Launchpad?

    Set a breakpoint on the second line of main(), to make sure you're not getting a surprise Reset.
  • Brandon,
    There is only one sample and hold circuit which is muxed to the different channels. The circuit is not discharged or 'erased' between channels, so any voltage on the sample and hold capacitor will be the initial voltage for the next channel. You may want to increase the sample-and-hold time from the default minimum to see if that helps.

    In the working example with just one channel, was that also using the window comparator? - I do not remember if the window comparator preserves the result contents.

    Regards,
    Chris
  • Brandon,
    Did increasing the sample-hold window have any impact? Can you verify that the window comparator is being used for the one channel case (which works)?

    Thanks,
    Chris
  • Hey Chris,

    I am sorry for the delay, the holidays had me busy. I came back and restarted back with the initial code from the example program and have discovered some things that are both extremely confusing, but might allow y'all to help me figure out what is going on. Using the code provided, if I hook up P4.1-6 to the sonar sensors and change the program to those pins they have a random reading and do not change, if I connect them directly to ground they change to a low number (not always 0) and if i connect them to 3.3[V] they give a high number around 16,300. If i connect the ADC and change the code for P4.0, P4.7 ,P6.0-1, P5.0-2 and P 5.4-5 they all work now. Seems as if wiring them through the breadboard to the MSP432 was for some reason causing errors in the readings. Although, if i go back to my original code and hook up 2 sonar sensors they kinda work, if I leave them steady they will read the correct value, then after a little start giving random readings until the start giving the correct reading again? I did notice that these datasheet for my sensors say "Readings can occur up to every 50mS, (20-Hz rate) ", though in with my code I am not giving a reading rate, I am simply using "MAP_ADC14_enableModule();" , maybe this could be causing the random jumps in my readings? If I can get the readings to be steady I am not really worried about the other pins. I am using the LV-MaxSonar MB1000 sonar sensors. www.maxbotix.com/.../LV-MaxSonar-EZ_Datasheet.pdf

     

     

    ///* --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;
    uint64_t currentresult;
    
    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_P6, GPIO_PIN1,
        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_A14, 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);
        currentresult = MAP_ADC14_getResult(ADC_MEM0);
    
    
        if (status & ADC_INT0)
        {
            if(resPos == UINT8_MAX)
            {
               resPos = 0;
            }
    
            resultsBuffer[resPos++] = MAP_ADC14_getResult(ADC_MEM0);
        }
    
    }
    

     

  • Brandon,
    In the example the sample and hold time appears to be one ACLK cycle (32Khz) or 30us. You can make this time longer by decreasing the value in the compareConfig structure. Currently since it is equal to upModeConfig you only get 1 cycle which is the rollover to 0 (see timerA description in the TRM). In your original code the sample and hold time is only 160nS and is determined by the ADC internal sample timer which is enabled but not configured so the default is 4 clocks, and it appears that you are not initializing the ADC clock source (it is commented out) so the default clock source is the MODCLK which is 25Mhz. I would double check, but I think this also means you are sampling somewhere in the range of 100Ksps where as the example is 2Sps.

    Regards,
    Chris

    www.ti.com/.../slau356h.pdf
  • As an alternative to what Chris suggests, just add this line:

    > MAP_ADC14_enableSampleTimer(ADC_AUTOMATIC_ITERATION); // Set SHP

    (I suspect you just forgot it, but Chris explained why it was important.)
  • So I have been looking at the example code to try to figure this out. I messed with the period in upModeConfig and the compare value in compareConfig to see the changes. If you could explain the math to me maybe it will make more sense. I am thinking of it in reference to how the PWM works: Use a clock source of example 48[MHz], which is 20.82[ns] and use a period of 4,800 making it .1[ms], which is 10k[Hz] and from there I can select a duty cycle based on a .1[ms] tick. Does the upModeConfig and compareConfig work similarly? I was thinking if the clock source is ACLK = 32[kHz] and period is 16,000 that gives .5[s], but what exactly does the compare value have to do with anything? Which of these numbers exactly makes the Samples per Second. Instead of using 16,000 I used 160 for my period and 160 for my compare value and received much faster sample rate. I would just like to understand how exactly It works. While using the example code I was able to get 1 sonar sensor working fine, but once I plugged in another sensor (even though there was no code or anything for it) it would start to mess up my current sensor readings. I think this has something to do with you mentioned December 28th. I then looked into my sensors and they have a chaining ability where 1 sensor will read then once its reading is complete it will trigger the next sensor to read and so on in a loop. This seemed to work fine once I wired them accordingly. Going back to my original code I already had the MAP_ADC14_enableSampleTimer(ADC_AUTOMATIC_ITERATION); in my code that Mr. Bruce mentioned, with the new wiring this works fine for both my sensors, so I think my problem was with the single sample and hold circuit. Now my concern is do i need to worry about setting up a Timer_A to specify my sample rate or should I stick with the ADC_AUTOMATIC_ITERATION even if I plan on having 7 sensors in total (since I am doing the chaining their will be a relatively big delay since 1 complete reading of all sensors will take the time of 1 sensor reading x7)? If so how do I set that up on my original code, I copied all necessary code that the example uses and my sensors do not read with that code added, I am not sure If i need to do anything extra since I am doing ADC14_configureMultiSequenceMode or because I am not doing an automatic iteration.
  • Brandon,

        The ADC trigger can be sourced from a timer, from software, or it can be automatic.   If you choose the automatic mode, then the sample rate will be a function of the sample-hold time plus the time it takes to makes a conversion (16 clocks for a 14-bit result).  You can refer to the TRM to see how this time, and effectively the sample rate, can be calculated.

        The timer trigger sources are defined in the datasheet.  For example if you select trigger 1, that is the Capture Compare register 1 of timer A0. While the period is set by the upMode configuration, it is the compare configuration which actually generates the capture compare 1 signal which generates the ADC trigger.  Now the importance of the compare configuration is dependent upon the mode selected.  If using the extended sample mode (this means that the built in sample hold timer of the ADC is not used), then the upMode configuration, which sets the timer period, determines the sample rate.  The compare configuration is used to determine the sample and hold time.  Please bear in mind that the TRM states that the maximum sample and hold time should not exceed 420us.  If you are using the pulse sample mode (meaning you are using the sample timer within the ADC), then you can simply set the sample and hold time as a function of the ADC clock (multiples of 4).  Again is you set if to the automatic mode, then the timer is irrelevant and the sample frequency is a function of the ADC sample and conversion timing.

    At this link you will find a description of the different modes.  If you are trying to measure all 7 channels at a 10Khz rate, then I would recommend the extended sample mode with the timer trigger.  Either the burst mode, repeated auto-scan with manual trigger, or repeated auto-scan with automatic trigger would work.  

    For the timer, a couple of comments.  24Mhz is the maximum you should source to any peripheral.  The timer period is always '+1'.  There is an extra clock for going from CCR0 to 1.  So if you use 160 for CCR0 and 160 for CCR1 then the period is actually 161 and for one clock cycle CCR1 will be active (from 160 to 0).

    Regards,

    Chris

  • Brandon,

       Please find the attached example.  Technically, it is measuring the same channel multiple times but you can change the definition to multiple channels.  Please see the description in the PWM configuration for timing as well as in the ADC configuration to use the internal sample timer and the time is set to 8 ADC clocks which is also sourced from the 24Mhz SMCLK.

    /*
     * adc14_multiple_channel_repeat_timera_source_forum.c
     *
     * The PWM is started once the GPIO interrupt for P1.1 is serviced.
     *
     *                MSP432P401
     *             ------------------
     *         /|\|                  |
     *          | |                  |
     *          --|RST         P4.7  |<--- A6, Ain
     *            |                  |
     *            |            P1.1  |<--- GPIO trigger to Start conversions
     *            |                  |
     *            |            P1.0  |---> Debug port to show ADC ISR
     *            |            P2.4  |---> Debug TA0.1, ADC trigger
     *            |                  |
     *
     */
    
    #include <ti/devices/msp432p4xx/driverlib/driverlib.h>
    
    /* Standard Includes */
    #include <stdint.h>
    #include <string.h>
    
    #define HFXTAL
    
    #define NUMBER_OF_SAMPLES   128
    
    uint32_t prim_buffer0[NUMBER_OF_SAMPLES];
    
    /*
     * Timer_A Compare Configuration Parameter
     * CCR1 is used to trigger the ADC14, conversion time
     * SMCLK = 24Mhz,
     *
     * ADC::
     * Sample-Hold = 8 clocks
     * Conversion = 16 clocks
     * Memory = 1 clock
     * Sync = 6 pulses
     */
    const Timer_A_PWMConfig timerA_PWM =
    {
        .clockSource = TIMER_A_CLOCKSOURCE_SMCLK,
        .clockSourceDivider = TIMER_A_CLOCKSOURCE_DIVIDER_1,
        .timerPeriod = 31,
        .compareRegister = TIMER_A_CAPTURECOMPARE_REGISTER_1,
        .compareOutputMode TIMER_A_OUTPUTMODE_SET_RESET,
        .dutyCycle = 16
    };
    
    uint16_t measureIndex,debugStatusCounter;
    
    uint64_t debugStatus[20];
    
    int main(void)
    {
        /* Halting WDT  */
        MAP_WDT_A_holdTimer();
        MAP_Interrupt_enableSleepOnIsrExit();
    
        measureIndex = 0;
    
        /*
         * Starting HFXT in non-bypass mode without a timeout. Before we start
         * we have to change VCORE to 1 to support the 48MHz frequency
         */
        MAP_PCM_setCoreVoltageLevel(PCM_VCORE1);
    
        /*
         * Revision C silicon supports wait states of 1 at 48Mhz
         */
        MAP_FlashCtl_setWaitState(FLASH_BANK0, 1);
        MAP_FlashCtl_setWaitState(FLASH_BANK1, 1);
    
        /*
         * Setting up clocks
         * MCLK = MCLK = 48MHz
         * SMCLK = MCLK/2 = 24Mhz
         * ACLK = REFO = 32Khz
         */
    
    #ifdef HFXTAL
        /* Configuring pins for peripheral/crystal usage and LED for output */
        MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_PJ,
                GPIO_PIN3 | GPIO_PIN2, GPIO_PRIMARY_MODULE_FUNCTION);
        MAP_GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);
    //    MAP_CS_startHFXT(false);
        CS->KEY = CS_KEY_VAL ;                  // Unlock CS module for register access
        CS->CTL2 |= CS_CTL2_HFXT_EN | CS_CTL2_HFXTFREQ_6 | CS_CTL2_HFXTDRIVE;
        while(CS->IFG & CS_IFG_HFXTIFG)
            CS->CLRIFG |= CS_CLRIFG_CLR_HFXTIFG;
    
        CS->KEY = 0;                            // Lock CS module from unintended accesses
    
    
        /* Initializing MCLK to HFXT (effectively 48MHz) */
        MAP_CS_initClockSignal(CS_MCLK, CS_HFXTCLK_SELECT, CS_CLOCK_DIVIDER_1);
        MAP_CS_initClockSignal(CS_SMCLK, CS_HFXTCLK_SELECT, CS_CLOCK_DIVIDER_2);
    
    #else
        MAP_CS_setDCOFrequency(48000000);
        MAP_CS_initClockSignal(CS_SMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_2);
        MAP_CS_initClockSignal(CS_MCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1);
    
    #endif
    
    
        MAP_CS_initClockSignal(CS_ACLK, CS_REFOCLK_SELECT, CS_CLOCK_DIVIDER_1);
    
        /* Initializing ADC (SMCLK/1/1) */
        MAP_ADC14_enableModule();
    
        MAP_ADC14_initModule(ADC_CLOCKSOURCE_SMCLK, ADC_DIVIDER_1, ADC_DIVIDER_1,0);
    
        /*
         * Debug
         * Configuring P1.0 as output
         */
        MAP_GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);
        P1OUT &= ~BIT0;
        MAP_GPIO_setAsOutputPin(GPIO_PORT_P2, GPIO_PIN0+GPIO_PIN1);
        P2OUT &= ~(BIT0+BIT1);
    
        /*
         * Configuring GPIOs (4.6, A7)
         */
        MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P4, (GPIO_PIN6),
        GPIO_TERTIARY_MODULE_FUNCTION);
    
        /*
         * Debug: set TA0.1 as output to see ADC trigger signal
         */
        MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P2, GPIO_PIN4,
        GPIO_PRIMARY_MODULE_FUNCTION);
    
        /*
         * Configuring P1.1 as an input and enabling interrupt, the timer is started from
         * GPIO ISR.
         */
        MAP_GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P1, GPIO_PIN1);
        MAP_GPIO_interruptEdgeSelect(GPIO_PORT_P1,GPIO_PIN1,GPIO_HIGH_TO_LOW_TRANSITION);
        MAP_GPIO_clearInterruptFlag(GPIO_PORT_P1, GPIO_PIN1);
        MAP_GPIO_enableInterrupt(GPIO_PORT_P1, GPIO_PIN1);
    
        MAP_REF_A_setReferenceVoltage(REF_A_VREF2_5V);
        MAP_REF_A_enableReferenceVoltage();
    
        /*
         * Configuring the sample trigger to be sourced from Timer_A0 CCR1 and on the
         * rising edge, default samplemode is extended (SHP=0)
         */
        MAP_ADC14_setSampleHoldTrigger(ADC_TRIGGER_SOURCE1, false);
        MAP_ADC14_setSampleHoldTime(ADC_PULSE_WIDTH_8,ADC_PULSE_WIDTH_8);
        MAP_ADC14_setResultFormat(ADC_SIGNED_BINARY);
    
        /* Configuring ADC Memory (ADC_MEM0 - ADC_MEM31 with repeat)
         * with internal 2.5v reference */
        MAP_ADC14_configureMultiSequenceMode(ADC_MEM0, ADC_MEM31, true);
    
        /*
         * Configuring ADC Memory, reference, and differential conversion
         * A0 goes to mem0, AVcc is the reference, and the conversion is
         * single-ended
         */
        MAP_ADC14_configureConversionMemory(ADC_MEM0,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM1,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM2,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM3,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM4,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM5,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM6,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM7,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM8,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM9,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM10,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM11,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM12,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM13,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM14,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM15,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
    
        MAP_ADC14_configureConversionMemory(ADC_MEM16,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM17,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM18,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM19,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM20,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM21,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM22,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM23,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM24,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM25,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM26,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM27,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM28,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM29,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM30,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
        MAP_ADC14_configureConversionMemory(ADC_MEM31,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
    
    	/*
    	 * Configuring the sample trigger to be sourced from Timer_A0 CCR1
    	 * and setting it to automatic iteration after it is triggered
    	 */
    	MAP_ADC14_setSampleHoldTrigger(ADC_TRIGGER_SOURCE1, false);
    
        /*
         * Setting up the sample timer to manually step through the sequence
         * convert.
         */
        MAP_ADC14_enableSampleTimer(ADC_MANUAL_ITERATION);
    
        /*
         * Enabling the interrupt when a conversion on channel 8
         * and enabling conversions
         */
        MAP_ADC14_enableInterrupt(ADC_INT31);
        /*
         * If this is not enabled the interrupt still occurs, it is just not registered in
         * ADC14->IFGR1.
         */
        MAP_ADC14_enableInterrupt(ADC_OV_INT);
        MAP_ADC14_enableConversion();
        /*
         * Clear IFGs before enabling interrupt
         */
        MAP_ADC14_clearInterruptFlag(0xFFFFFFFFFFFFFFFF);
        MAP_Interrupt_enableInterrupt(INT_ADC14);
        MAP_Interrupt_enableInterrupt(INT_PORT1);
    
        MAP_Interrupt_enableMaster();
    
    	MAP_PCM_gotoLPM0();
    	__no_operation();
    	while(1);
    	/*
    	 * Process three arrays
    	 */
    }
    
    /*
     * This interrupt is fired whenever the sequence is completed
     *
     */
    /* Completion interrupt for ADC14 MEM0 */
    __attribute__((ramfunc))  // Requires compiler TI v15.12.1.LTS
    void ADC14_IRQHandler(void)
    {
        volatile uint8_t ii;
        uint64_t status;
        // Turn on LED
    
        MAP_GPIO_toggleOutputOnPin(GPIO_PORT_P2, GPIO_PIN0);
        status = MAP_ADC14_getEnabledInterruptStatus();
        MAP_ADC14_clearInterruptFlag(status);
        if(status & ADC_INT31)
        {
            MAP_GPIO_toggleOutputOnPin(GPIO_PORT_P2, GPIO_PIN1);
            for(ii=0;ii<32;ii++)
            {
        	    prim_buffer0[measureIndex] = MAP_ADC14_getResult(ADC_MEM0 << ii);       // Move A0 results, IFG is cleared
                measureIndex++;
            }
            __no_operation();
        	if(measureIndex == NUMBER_OF_SAMPLES)
        	{
        		/*
        		 * Stop Timer
        		 */
        		MAP_Timer_A_stopTimer(TIMER_A0_BASE);
        		measureIndex = 0;
        		MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
        	}
        }
        /*
         * Debug find other interrupts
         */
        else
        {
            debugStatus[debugStatusCounter++] = status;
        }
    }
    
    void PORT1_IRQHandler(void)
    {
        debugStatusCounter = 0;
        P1->OUT |= BIT0;
        P1IFG &= ~BIT1;
        MAP_Timer_A_generatePWM(TIMER_A0_BASE, &timerA_PWM);
    }
    

    Regards,

    Chris

**Attention** This is a public forum