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.

MSPM0G3106-Q1: ADC configuration issue

Part Number: MSPM0G3106-Q1
Other Parts Discussed in Thread: SYSCONFIG

Hi Team,

I have tried to configure ADC to read voltage at the PIN A1_0, A1_1 and A1_2.

I Have connected the pins to oscilloscope where i can see they are having stable 2V but the ADC values is not constant and oscillating between 0.2 to 1.9V.

The following is my configuration and it is not working as expected and even i tried sample ADC code from SDK which uses interrupts and timers where i face the same issue.

 

static const DL_TimerA_ClockConfig gTIMER_SampleClockConfig = {
    .clockSel    = DL_TIMER_CLOCK_BUSCLK,
    .divideRatio = DL_TIMER_CLOCK_DIVIDE_1,
    .prescale    = 0U,
};

/*
 * Timer load value (where the counter starts from) is calculated as (timerPeriod * timerClockFreq) - 1
 * TIMER_Sample_INST_LOAD_VALUE = (0.0625 ms * 80000000 Hz) - 1
 */
static const DL_TimerA_TimerConfig gTIMER_SampleTimerConfig = {
    .period     = TIMER_Sample_INST_LOAD_VALUE,
    .timerMode  = DL_TIMER_TIMER_MODE_PERIODIC_UP,
    .startTimer = DL_TIMER_STOP,
};

SYSCONFIG_WEAK void SYSCFG_DL_TIMER_Sample_init(void) {

    DL_TimerA_setClockConfig(TIMER_Sample_INST,
        (DL_TimerA_ClockConfig *) &gTIMER_SampleClockConfig);

    DL_TimerA_initTimerMode(TIMER_Sample_INST,
        (DL_TimerA_TimerConfig *) &gTIMER_SampleTimerConfig);
    DL_TimerA_enableShadowFeatures(TIMER_Sample_INST);
    DL_TimerA_enableClock(TIMER_Sample_INST);

    DL_TimerA_enableEvent(TIMER_Sample_INST, DL_TIMERA_EVENT_ROUTE_1, (DL_TIMERA_EVENT_CC0_UP_EVENT |
        DL_TIMERA_EVENT_CC1_UP_EVENT));

    DL_TimerA_setPublisherChanID(TIMER_Sample_INST, DL_TIMERA_PUBLISHER_INDEX_0, TIMER_Sample_INST_PUB_0_CH);

 

}

 

/* ADC0 Initialization */
static const DL_ADC12_ClockConfig gADC1ClockConfig = {
    .clockSel       = DL_ADC12_CLOCK_SYSOSC,
    .divideRatio    = DL_ADC12_CLOCK_DIVIDE_1,
    .freqRange      = DL_ADC12_CLOCK_FREQ_RANGE_24_TO_32,
};
SYSCONFIG_WEAK void SYSCFG_DL_ADC1_init(void)
{
    DL_ADC12_setClockConfig(ADC1_INST, (DL_ADC12_ClockConfig *) &gADC1ClockConfig);

    DL_ADC12_initSeqSample(ADC1_INST,
        DL_ADC12_REPEAT_MODE_ENABLED, DL_ADC12_SAMPLING_SOURCE_AUTO, DL_ADC12_TRIG_SRC_EVENT,
        DL_ADC12_SEQ_START_ADDR_00, DL_ADC12_SEQ_END_ADDR_02, DL_ADC12_SAMP_CONV_RES_12_BIT,
        DL_ADC12_SAMP_CONV_DATA_FORMAT_UNSIGNED);
    DL_ADC12_configConversionMem(ADC1_INST, ADC1_ADCMEM_0,
        DL_ADC12_INPUT_CHAN_0, DL_ADC12_REFERENCE_VOLTAGE_VDDA, DL_ADC12_SAMPLE_TIMER_SOURCE_SCOMP1, DL_ADC12_AVERAGING_MODE_DISABLED,
        DL_ADC12_BURN_OUT_SOURCE_DISABLED, DL_ADC12_TRIGGER_MODE_AUTO_NEXT, DL_ADC12_WINDOWS_COMP_MODE_DISABLED);
    DL_ADC12_configConversionMem(ADC1_INST, ADC1_ADCMEM_1,
        DL_ADC12_INPUT_CHAN_1, DL_ADC12_REFERENCE_VOLTAGE_VDDA, DL_ADC12_SAMPLE_TIMER_SOURCE_SCOMP0, DL_ADC12_AVERAGING_MODE_DISABLED,
        DL_ADC12_BURN_OUT_SOURCE_DISABLED, DL_ADC12_TRIGGER_MODE_AUTO_NEXT, DL_ADC12_WINDOWS_COMP_MODE_DISABLED);
    DL_ADC12_configConversionMem(ADC1_INST, ADC1_ADCMEM_2,
        DL_ADC12_INPUT_CHAN_2, DL_ADC12_REFERENCE_VOLTAGE_VDDA, DL_ADC12_SAMPLE_TIMER_SOURCE_SCOMP0, DL_ADC12_AVERAGING_MODE_DISABLED,
        DL_ADC12_BURN_OUT_SOURCE_DISABLED, DL_ADC12_TRIGGER_MODE_AUTO_NEXT, DL_ADC12_WINDOWS_COMP_MODE_DISABLED);
    DL_ADC12_configHwAverage(ADC1_INST,DL_ADC12_HW_AVG_NUM_ACC_128,DL_ADC12_HW_AVG_DEN_DIV_BY_128);
    DL_ADC12_setSampleTime0(ADC1_INST,80);
    DL_ADC12_setSampleTime1(ADC1_INST,80);
    DL_ADC12_setSubscriberChanID(ADC1_INST,ADC1_INST_SUB_CH);
    DL_ADC12_enableConversions(ADC1_INST);
}

/* Defines for TIMER_Sample */
#define TIMER_Sample_INST                                                (TIMA1)
#define TIMER_Sample_INST_IRQHandler                            TIMA1_IRQHandler
#define TIMER_Sample_INST_INT_IRQN                              (TIMA1_INT_IRQn)
#define TIMER_Sample_INST_LOAD_VALUE                                     (1599U)
#define TIMER_Sample_INST_PUB_0_CH                                           (2)

/* Defines for ADC1 */
#define ADC1_INST                                                           ADC1
#define ADC1_INST_IRQHandler                                     ADC1_IRQHandler
#define ADC1_INST_INT_IRQN                                       (ADC1_INT_IRQn)
#define ADC1_ADCMEM_0                                         DL_ADC12_MEM_IDX_0
#define ADC1_ADCMEM_0_REF                        DL_ADC12_REFERENCE_VOLTAGE_VDDA
#define ADC1_ADCMEM_0_REF_VOLTAGE_V                                          3.3
#define ADC1_ADCMEM_1                                         DL_ADC12_MEM_IDX_1
#define ADC1_ADCMEM_1_REF                        DL_ADC12_REFERENCE_VOLTAGE_VDDA
#define ADC1_ADCMEM_1_REF_VOLTAGE_V                                          3.3
#define ADC1_ADCMEM_2                                         DL_ADC12_MEM_IDX_2
#define ADC1_ADCMEM_2_REF                        DL_ADC12_REFERENCE_VOLTAGE_VDDA
#define ADC1_ADCMEM_2_REF_VOLTAGE_V                                          3.3
#define ADC1_INST_SUB_CH                                                     (2)
#define GPIO_ADC1_C7_PORT                                                  GPIOA
#define GPIO_ADC1_C7_PIN                                          DL_GPIO_PIN_15
#define GPIO_ADC1_C3_PORT                                                  GPIOA
#define GPIO_ADC1_C3_PIN                                          DL_GPIO_PIN_16
#define GPIO_ADC1_C2_PORT                                                  GPIOA
#define GPIO_ADC1_C2_PIN                                          DL_GPIO_PIN_17 

 

 

What is the issue here every 2ms i read the ADC out as follows which is not accurate

chA = DL_ADC12_getMemResult(ADC1, DL_ADC12_MEM_IDX_0);
                chB = DL_ADC12_getMemResult(ADC1, DL_ADC12_MEM_IDX_1);
                chC = DL_ADC12_getMemResult(ADC1, DL_ADC12_MEM_IDX_2);

 

help me to find the solution