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/MSP432P401R: Multiple ADC Channels

Part Number: MSP432P401R

Tool/software: Code Composer Studio

Hello, 

I'm using the examples/demos from Resource explorer:

boostxl_edumkii_microphonefft_msp432p401r and msp-exp432p401r_grlib_example


I'm integrating a touchscreen LCD and creating a menu to go to different display pages. One of the pages being an FFT of an audio signal playing with my project. On the FFT screen I would like to have an "X" in the top right to touch and get out of the FFT display screen to go back to the main menu. The problem I'm running into is that the touchscreen and FFT have two separate ADC configurations. Shown below are the two snippets of the ADC configurations:

FFT:

MAP_ADC14_enableModule(); // Enables ADC Block

MAP_ADC14_initModule(ADC_CLOCKSOURCE_MCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_1, 0);
                                                       // MCLK - Clock Source for CPU
                                                       // Predivider_1 - Divides the given clock source before feeding it into the main clock divider. (Default)
                                                       // Divider_1 - Divides the pre-divided clock source (Default)
                                                       // 0 - ADC_NOROUTE, no InternalChannelMask

MAP_ADC14_setResolution(ADC_14BIT);

MAP_ADC14_setSampleHoldTrigger(ADC_TRIGGER_SOURCE1, false);
                                                       // Trigger Source 1 - Sets the source for the trigger of the ADC module.
                                                       // False - Trigger signal on rising edge

MAP_ADC14_setSampleHoldTime(ADC_PULSE_WIDTH_4, ADC_PULSE_WIDTH_4);

MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P4, GPIO_PIN3, // ADC Port 4 Pin 3 ---- A10
GPIO_TERTIARY_MODULE_FUNCTION);

// Configuring ADC Memory
MAP_ADC14_configureSingleSampleMode(ADC_MEM9, true); // ADC_MEM0 - Configures the ADC module to use a single ADC memory location for sampling/conversion.
                                                                                                      // True - cause the ADC module to resume sampling once the initial sample/conversion set is executed.

// ****************************************************************************** //
MAP_ADC14_configureConversionMemory(ADC_MEM9, ADC_VREFPOS_AVCC_VREFNEG_VSS,
ADC_INPUT_A10, false);
                                            // ADC_MEM0 - individual ADC memory location to configure
                                            // Vref = 3.3 to GND
                                            // A10 - channel to be used for ADC sampling
                                            // False - Differential mode off
// ****************************************************************************** //
// Set ADC result format to signed binary
MAP_ADC14_setResultFormat(ADC_SIGNED_BINARY);
MAP_ADC14_enableConversion();

 

touch_P401R.c :


MAP_ADC14_initModule(ADC_CLOCKSOURCE_MCLK, ADC_PREDIVIDER_1, // ADCOSC

ADC_DIVIDER_1, 0);
MAP_ADC14_setResolution(ADC_14BIT);

MAP_ADC14_enableSampleTimer(ADC_MANUAL_ITERATION);
MAP_ADC14_setSampleHoldTime(ADC_PULSE_WIDTH_96, ADC_PULSE_WIDTH_96);
MAP_ADC14_setSampleHoldTrigger(ADC_TRIGGER_ADCSC, false);

MAP_ADC14_enableModule();

/* Configure Y+ input to memory buffer 0. */
MAP_ADC14_configureConversionMemory(TOUCH_Y_PLUS_MEMORY,
ADC_VREFPOS_AVCC_VREFNEG_VSS,
TOUCH_Y_PLUS_INPUT,
false);

/* Configure X+ input to memory buffer 1. */
MAP_ADC14_configureConversionMemory(TOUCH_X_PLUS_MEMORY,
ADC_VREFPOS_AVCC_VREFNEG_VSS,
TOUCH_X_PLUS_INPUT,
false);

for(i = 0; i < TOUCH_OVERSAMPLE; i++)
{
MAP_ADC14_toggleConversionTrigger();
status = MAP_ADC14_getInterruptStatus();
while(status != TOUCH_X_PLUS_IFG)
{
status = MAP_ADC14_getInterruptStatus();
}
aDCtemp += ADC14->MEM[1];
}

aDCtemp = (aDCtemp >> TOUCH_AVERAGE_DIVISOR);

The main difference I've noticed in the ADC registers is that the FFT uses

Single Channel - Repeat Conversion (ADC14CONSEQ = 10)

SAMPCON signal is sourced from the sample-input signal (ADC14SHP = 0).

Touchscreen ADC uses

Single Channel - Single Conversion(ADC14CONSEQ = 00)

SAMPCON signal is sourced from the sampling timer (ADC14SHP = 1) with a pulse width of 96. 

I know there is an analog input mux that selects the channel for conversion, so is there a way to use both of these ADC configurations and select between the channels to run both at the same time or sequentially? Would multi-sequence mode be a possible solution?

Thank you!

  • Hello Jacob,

    The functional parameters for sampling the channels are different and they cannot be set in a multi sequence mode of operation. Since the touch screen needs to be sampled intermittently, you must change the configuration between two set of FFT acquisition.

    In other words when on the FFT page, the sequence of operation would be

    FFT data capture -> check for touch -> FFT data capture.

    Another way of doing this all the time would be to use the DMA's scatter gather mechanism to reconfigure the DMA and this is shown in the SDK example

    C:\ti\simplelink_msp432p4_sdk_2_10_00_14\examples\nortos\MSP_EXP432P401R\demos\cmsis_dsplib_vibration_msp432p401r
    C:\ti\simplelink_msp432p4_sdk_2_10_00_14\examples\nortos\MSP_EXP432P401R\demos\cmsis_dsplib_ulp
  • Amit,

    So I changed configurations as you mentioned. Run FFT then I configured ADC for touch, check to see if touch is detected, else re-initialize FFT ADC and continue on that sequence.

    I was worried about the performance of the FFT being affected with the clock cycles it takes to basically stop the FFT, initialize the ADC for touch, check touch and then re-initialize the FFT but it honestly isn't noticeable especially running 16-bit parallel. The touch is a little buggy, basically because it checks it so quickly, but I'm able to touch the "X" button and get out of the screen. I may run a small FOR loop when detecting touch to give a longer period of detecting touch.

    Thanks for the suggestion!

    Jacob
  • Hello Jacob,

    The FFT performance will not be affected as long the sample data for FFT is acquired one-shot and at fixed interval of the sampling frequence. The FFT is discrete and only relies on set of samples and not on a rolling window.

    As for the touch, yes you could change the sampling period for the Touch to be such that you could do 2 continous FFT windows and then touch check, and in the touch period make the loop longer.
  • Amit,

    That makes sense then, thank you!

    As for the touch, can I modify the ADC14SHT0 and ADC14SHT1 registers to increase the sampling interval? Right now it's set to 96
  • Hello Jacob,

    Yes you can change the value as long as it is not more than the maximum allowed by the TRM.

**Attention** This is a public forum