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 ADC14 Multiple Channel No Repeat only actually returns one converted value. The others don't change when I change the applied voltage.

Other Parts Discussed in Thread: MSPWARE

Hi,

I'm having problems getting all the results when I modify the example in driverlib to use four random ADC14 channels.  My code is below.  The problem that I notice in the debugger is that only ADC_MEM0 is being returned in the resultsBuffer.  The others get numbers, but they don't change when I change the applied voltage to their respective pins.  Any tips on what I'm doing wrong?

I should mention that the call to ADC14_getResultArray(ADC_MEM0, ADC_MEM3, resultsBuffer); causes the processor to go picking daises.  There was already a previous post where someone else pointed out that bug and it was duplicated by someone at TI. 

Thanks,

Rob

/* DriverLib Includes */
#include "driverlib.h"

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

#include <string.h>

static uint16_t resultsBuffer[4];

int main(void)
{
	/* Halting WDT */
	WDT_A_holdTimer();
	Interrupt_enableSleepOnIsrExit();

	/* Zero-filling buffer */
	memset(resultsBuffer, 0x00, 4);

	/* Setting reference voltage to 2.5 and enabling reference */
	//REF_A_setReferenceVoltage(REF_A_VREF2_5V);
	//REF_A_enableReferenceVoltage();

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

	/* Configuring GPIOs for Analog In */
	GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P5,
			GPIO_PIN2 | GPIO_PIN0, GPIO_TERTIARY_MODULE_FUNCTION);
	GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P4,
			GPIO_PIN1 | GPIO_PIN3, GPIO_TERTIARY_MODULE_FUNCTION);

	/* Configuring GPIOs for Analog In

	 * Pin 5.0 is S11_I, A5 resultsBuffer[0]
	 * Pin 5.2 is S11_Q, A3 resultsBuffer[1]
	 * Pin 4.3 is S21_I, A10 resultsBuffer[2]
	 * Pin 4.1 is S21_Q, A12 resultsBuffer[3] */


	/* Configuring ADC Memory (ADC_MEM0 - ADC_MEM3 (A5,A3,A10,A12) with no repeat)
	 * with internal 2.5v reference */
	ADC14_configureMultiSequenceMode(ADC_MEM0, ADC_MEM3, false);
	ADC14_configureConversionMemory(ADC_MEM0,
			ADC_VREFPOS_INTBUF_VREFNEG_VSS,
			ADC_INPUT_A5, ADC_NONDIFFERENTIAL_INPUTS);
	ADC14_configureConversionMemory(ADC_MEM1,
			ADC_VREFPOS_INTBUF_VREFNEG_VSS,
			ADC_INPUT_A3, ADC_NONDIFFERENTIAL_INPUTS);
	ADC14_configureConversionMemory(ADC_MEM2,
			ADC_VREFPOS_INTBUF_VREFNEG_VSS,
			ADC_INPUT_A10, ADC_NONDIFFERENTIAL_INPUTS);
	ADC14_configureConversionMemory(ADC_MEM3,
			ADC_VREFPOS_INTBUF_VREFNEG_VSS,
			ADC_INPUT_A12, ADC_NONDIFFERENTIAL_INPUTS);

	ADC14_setSampleHoldTime(ADC_PULSE_WIDTH_192,ADC_PULSE_WIDTH_192);
	/* Enabling the interrupt when a conversion on channel 3 (end of sequence)
	 * is complete and enabling conversions */
	ADC14_enableInterrupt(ADC_INT3);

	/* Enabling Interrupts */
	Interrupt_enableInterrupt(INT_ADC14);
	Interrupt_enableMaster();

	/* Setting up the sample timer to automatically step through the sequence
	 * convert.
	 */
	ADC14_enableSampleTimer(ADC_AUTOMATIC_ITERATION);

	/* Going to sleep */
	while (1)
	{
		/* Triggering the start of the sample */
		ADC14_enableConversion();
		ADC14_toggleConversionTrigger();
		// PCM_gotoLPM0();
	}
}

/* This interrupt is fired whenever a conversion is completed and placed in
 * ADC_MEM7. This signals the end of conversion and the results array is
 * grabbed and placed in resultsBuffer */
void ADC14_IRQHandler(void)
{
	uint64_t status;

	status = ADC14_getEnabledInterruptStatus();
	ADC14_clearInterruptFlag(status);

	if(status & ADC_INT3)
	{
		ADC14_getMultiSequenceResult(resultsBuffer);
		//ADC14_getResultArray(ADC_MEM0, ADC_MEM3, resultsBuffer);
	}

}

  • Hi,

    I'm having problems getting all the results when I modify the example in driverlib to use four random ADC14 channels.  My code is below.  The problem that I notice in the debugger is that only ADC_MEM0 is being returned in the resultsBuffer.  The others get numbers, but they don't change when I change the applied voltage to their respective pins.  Any tips on what I'm doing wrong?

    Thanks,

    Rob

    /* DriverLib Includes */
    #include "driverlib.h"
    
    /* Standard Includes */
    #include <stdint.h>
    
    #include <string.h>
    
    static uint16_t resultsBuffer[4];
    
    int main(void)
    {
    	/* Halting WDT */
    	WDT_A_holdTimer();
    	Interrupt_enableSleepOnIsrExit();
    
    	/* Zero-filling buffer */
    	memset(resultsBuffer, 0x00, 4);
    
    	/* Setting reference voltage to 2.5 and enabling reference */
    	//REF_A_setReferenceVoltage(REF_A_VREF2_5V);
    	//REF_A_enableReferenceVoltage();
    
    	/* Initializing ADC (MCLK/1/1) */
    	ADC14_enableModule();
    	ADC14_initModule(ADC_CLOCKSOURCE_MCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_1,
    			0);
    
    	/* Configuring GPIOs for Analog In */
    	GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P5,
    			GPIO_PIN2 | GPIO_PIN0, GPIO_TERTIARY_MODULE_FUNCTION);
    	GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P4,
    			GPIO_PIN1 | GPIO_PIN3, GPIO_TERTIARY_MODULE_FUNCTION);
    
    	/* Configuring GPIOs for Analog In
    
    	 * Pin 5.0 is S11_I, A5 resultsBuffer[0]
    	 * Pin 5.2 is S11_Q, A3 resultsBuffer[1]
    	 * Pin 4.3 is S21_I, A10 resultsBuffer[2]
    	 * Pin 4.1 is S21_Q, A12 resultsBuffer[3] */
    
    
    	/* Configuring ADC Memory (ADC_MEM0 - ADC_MEM3 (A5,A3,A10,A12) with no repeat)
    	 * with internal 2.5v reference */
    	ADC14_configureMultiSequenceMode(ADC_MEM0, ADC_MEM3, false);
    	ADC14_configureConversionMemory(ADC_MEM0,
    			ADC_VREFPOS_INTBUF_VREFNEG_VSS,
    			ADC_INPUT_A5, ADC_NONDIFFERENTIAL_INPUTS);
    	ADC14_configureConversionMemory(ADC_MEM1,
    			ADC_VREFPOS_INTBUF_VREFNEG_VSS,
    			ADC_INPUT_A3, ADC_NONDIFFERENTIAL_INPUTS);
    	ADC14_configureConversionMemory(ADC_MEM2,
    			ADC_VREFPOS_INTBUF_VREFNEG_VSS,
    			ADC_INPUT_A10, ADC_NONDIFFERENTIAL_INPUTS);
    	ADC14_configureConversionMemory(ADC_MEM3,
    			ADC_VREFPOS_INTBUF_VREFNEG_VSS,
    			ADC_INPUT_A12, ADC_NONDIFFERENTIAL_INPUTS);
    
    	ADC14_setSampleHoldTime(ADC_PULSE_WIDTH_192,ADC_PULSE_WIDTH_192);
    	/* Enabling the interrupt when a conversion on channel 3 (end of sequence)
    	 * is complete and enabling conversions */
    	ADC14_enableInterrupt(ADC_INT3);
    
    	/* Enabling Interrupts */
    	Interrupt_enableInterrupt(INT_ADC14);
    	Interrupt_enableMaster();
    
    	/* Setting up the sample timer to automatically step through the sequence
    	 * convert.
    	 */
    	ADC14_enableSampleTimer(ADC_AUTOMATIC_ITERATION);
    
    	/* Going to sleep */
    	while (1)
    	{
    		/* Triggering the start of the sample */
    		ADC14_enableConversion();
    		ADC14_toggleConversionTrigger();
    		// PCM_gotoLPM0();
    	}
    }
    
    /* This interrupt is fired whenever a conversion is completed and placed in
     * ADC_MEM7. This signals the end of conversion and the results array is
     * grabbed and placed in resultsBuffer */
    void ADC14_IRQHandler(void)
    {
    	uint64_t status;
    
    	status = ADC14_getEnabledInterruptStatus();
    	ADC14_clearInterruptFlag(status);
    
    	if(status & ADC_INT3)
    	{
    		//ADC14_getMultiSequenceResult(resultsBuffer);
    		ADC14_getResultArray(ADC_MEM0, ADC_MEM3,
    				resultsBuffer);
    	}
    
    }

  • Hi Rob,

    I merged your two threads into one. Also, in the future, please use the SyntaxHighlighter when pasting code, I changed your posts to reflect that.

    Your code is having trouble reaching the ISR. Try to set a breakpoint in there to see if it ever reaches.

    I took the example code that we have and modified it to use the same 4 pins that you are trying to use and it seems to be working fine.

    /* DriverLib Includes */
    #include "driverlib.h"
    
    /* Standard Includes */
    #include <stdint.h>
    
    #include <string.h>
    
    static uint16_t resultsBuffer[4];
    
    int main(void)
    {
        /* Halting WDT  */
        MAP_WDT_A_holdTimer();
        MAP_Interrupt_enableSleepOnIsrExit();
    
        /* Zero-filling buffer */
        memset(resultsBuffer, 0x00, 4);
    
        /* Setting reference voltage to 2.5  and enabling reference */
        MAP_REF_A_setReferenceVoltage(REF_A_VREF2_5V);
        MAP_REF_A_enableReferenceVoltage();
    
        /* Initializing ADC (MCLK/1/1) */
        MAP_ADC14_enableModule();
        MAP_ADC14_initModule(ADC_CLOCKSOURCE_MCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_1,
                0);
    
        /* Configuring GPIOs for Analog In */
        MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P5,
                GPIO_PIN2 | GPIO_PIN0, GPIO_TERTIARY_MODULE_FUNCTION);
        MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P4,
                GPIO_PIN3 | GPIO_PIN1, GPIO_TERTIARY_MODULE_FUNCTION);
    
    
        /* Configuring ADC Memory (ADC_MEM0 - ADC_MEM3 (A3,5,10,12)  with no repeat)
         * with internal 2.5v reference */
        MAP_ADC14_configureMultiSequenceMode(ADC_MEM0, ADC_MEM3, false);
        MAP_ADC14_configureConversionMemory(ADC_MEM0,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A3, false);
        MAP_ADC14_configureConversionMemory(ADC_MEM1,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A5, false);
        MAP_ADC14_configureConversionMemory(ADC_MEM2,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A10, false);
        MAP_ADC14_configureConversionMemory(ADC_MEM3,
                ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A12, false);
    
        /* Enabling the interrupt when a conversion on channel 3 (end of sequence)
         *  is complete and enabling conversions */
        MAP_ADC14_enableInterrupt(ADC_INT3);
    
        /* Enabling Interrupts */
        MAP_Interrupt_enableInterrupt(INT_ADC14);
        MAP_Interrupt_enableMaster();
    
        /* Setting up the sample timer to automatically step through the sequence
         * convert.
         */
        MAP_ADC14_enableSampleTimer(ADC_AUTOMATIC_ITERATION);
    
        /* Triggering the start of the sample */
        MAP_ADC14_enableConversion();
        MAP_ADC14_toggleConversionTrigger();
    
        /* Going to sleep */
        while (1)
        {
            MAP_PCM_gotoLPM0();
        }
    }
    
    /* This interrupt is fired whenever a conversion is completed and placed in
     * ADC_MEM3. This signals the end of conversion and the results array is
     * grabbed and placed in resultsBuffer */
    void ADC14_IRQHandler(void)
    {
        uint64_t status;
    
        status = MAP_ADC14_getEnabledInterruptStatus();
        MAP_ADC14_clearInterruptFlag(status);
    
        if(status & ADC_INT3)
        {
            MAP_ADC14_getMultiSequenceResult(resultsBuffer);
        }
    
    }

    Regards,

    Akash Patel

  • Thanks Akash! To fix my problem, I had to add MAP_ to each of the routines, or at least one of them, but I didn't figure out what one that was. The MSPWare I'm using is 3_20_00_37. This seems like a bug TI should fix in driverlib, at least the way I understand it. MAP_ is supposed to use the ROM if it hasn't been modified with the latest driverlib, and if it has, then it uses the latest driverlib. I guess there is a bug in the latest driverlib that isn't there in the ROM. If you want me to chase this down further, I will, but you guys can too. :-)

    Thanks for the help. My students are trying to get their projects ready for delivery to the TI Innovation Challenge tomorrow, and your note was very timely for them!

    Rob
  • Thanks Rob for reporting the issue. Best of luck to your students with the TI Innovation Challenge!

    Regards,
    Akash Patel
  • Hi,

    I am running into the same issue, I have made the same changes (except for the ADC ports) that you have made and I am seeing only ADC_MEM0 able to get the correct value. I am checking the issue by setting up ADC_MEM0 , ADC_MEM1 and ADC_MEM2 to the same analog input to see if i get the same results. the analog input has a 3.3V input connected to it and I am using the 14 bit conversion for the ADC. I send the results to a terminal over serial and I see the following:

    ADC_MEM0 = 16383 
    ADC_MEM1 =  3488
    ADC_MEM2 =  5576

    However, they should be the same. Also, if I change the voltage, ADC_MEM1 and ADC_MEM2 do not change its value.  My code is below. I use a main loop to call the MAP_ADC14_toggleConversionTrigger function. Do you have any suggestions?

    void init_ADC_no_temp(void)
    {
       
          /* Setting reference voltage to 2.5 and enabling temperature sensor */
    
            MAP_REF_A_setReferenceVoltage(REF_A_VREF2_5V);
            MAP_REF_A_enableReferenceVoltage();
    
          /* Initializing ADC (MCLK/1/1) with temperature sensor routed */
          MAP_ADC14_enableModule();
          MAP_ADC14_initModule(ADC_CLOCKSOURCE_MCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_1, 0);
    
          /* Setting up GPIO pins as analog inputs (and references) */
           MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P4,
           GPIO_PIN7 | GPIO_PIN5, GPIO_TERTIARY_MODULE_FUNCTION);
    
          /* Configuring ADC Memory   */
          MAP_ADC14_configureMultiSequenceMode(ADC_MEM0, ADC_MEM2, false);
    
          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); 
    
          /* Configuring the sample/hold time for 192 */
          MAP_ADC14_setSampleHoldTime(ADC_PULSE_WIDTH_192,ADC_PULSE_WIDTH_192);
    
          MAP_ADC14_enableInterrupt(ADC_INT2);
    
          /* Enabling Interrupts */
            MAP_Interrupt_enableInterrupt(INT_ADC14);
            MAP_Interrupt_enableMaster();
    
          MAP_ADC14_enableSampleTimer(ADC_AUTOMATIC_ITERATION);
    
          /* Triggering the start of the sample */
              MAP_ADC14_enableConversion();
              MAP_ADC14_toggleConversionTrigger();
    }
    
    void ADC14_IRQHandler(void)
    {
        uint64_t status;
        char strToSendLocal[200]= "";
    	uint16_t resultsBuffer[3];
        status = MAP_ADC14_getEnabledInterruptStatus();
        MAP_ADC14_clearInterruptFlag(status);
        
        if(status & ADC_INT2)
        {      
            MAP_ADC14_getMultiSequenceResult(resultsBuffer);
           //MAP_ADC14_getResultArray(ADC_MEM0, ADC_MEM2, resultsBuffer);
            sprintf(strToSendLocal, "All raw values: %i, %i, %i",resultsBuffer[0],resultsBuffer[1], resultsBuffer[2]);
            sendStringToUART_A2(strToSendLocal, sizeof(strToSendLocal)); //Send message to UART2
    
        }
    }
    

**Attention** This is a public forum