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.

MSP430FR2355: ADC configurations

Part Number: MSP430FR2355

Tool/software:

Hi 

I am using MSP430FR2355 controller for my project,

I want to ADC for one of my project, i am initailaize all the ADC registers, ADC interrupt also working.

But while read from ADCMEM0 register always it's shows 101 or 102 value, i am applied voltage on the port pin 1.0 as 1.55VDC.

Help to resolve this issue.

I am starting the ADC conversion every 100ms once by using below commands.

ADCCTL0 |= (ADCENC | ADCSC);   

My code is below:

void adc_config()
{
    P1SEL0  |=BIT0;
    P1SEL1  |=BIT0;

    // Disable the GPIO power-on default high-impedance mode to activate
    // previously configured port settings
    PM5CTL0 &= ~LOCKLPM5;

    // Configure ADC12
    ADCCTL0 |= ADCSHT_2 | ADCON;                             // ADCON, S&H=16 ADC clks
    ADCCTL1 |= ADCSHP;                                       // ADCCLK = MODOSC; sampling timer
    ADCCTL2 &= ~ADCRES;                                      // clear ADCRES in ADCCTL
    ADCCTL2 |= ADCRES_2;                                     // 12-bit conversion results
    ADCMCTL0 |= ADCINCH0;                                   // A1 ADC input select; Vref=AVCC
    ADCIE |= ADCIE0;

}


// ADC interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=ADC_VECTOR
__interrupt void ADC_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(ADC_VECTOR))) ADC_ISR (void)
#else
#error Compiler not supported!
#endif
{
    switch(__even_in_range(ADCIV,ADCIV_ADCIFG))
    {
        case ADCIV_NONE:
            break;
        case ADCIV_ADCOVIFG:
            break;
        case ADCIV_ADCTOVIFG:
            break;
        case ADCIV_ADCHIIFG:
            break;
        case ADCIV_ADCLOIFG:
            break;
        case ADCIV_ADCINIFG:
            break;
        case ADCIV_ADCIFG:
            ADC_data[0] = ADCMEM0;

            __bic_SR_register_on_exit(LPM0_bits);            // Clear CPUOFF bit from LPM0

            break;
        default:
            break;
    }
}

Thanks,

Yuvaraj

  • > P1SEL0 |=BIT0;
    > P1SEL1 |=BIT0;

    ADC channel A1 is P1.1, not P1.0 [Ref datasheet (SLASEC4D) Table 6-63]. Try instead:

    > P1SEL0 |=BIT1;  // P1.1 as A1 per DS Table 6-63
    > P1SEL1 |=BIT1;

  • Hello Yuvaraj,

    I noticed that you setting the ADC channel to be A0, which is on P1.0. You mentioned you are applying the reference voltage to the same pin? What pin are you using to input to the ADC? Your code has the input channel select as ADCINCH0, but your comment mentions A1. How exactly are you trying to configure this?

    Best,

    Owen

  • Hi,

    Actually i want to measure voltage presence at Pin#1, P1.0. I am selected input channel select as ADCINCH0.(My comment was wrong).

    ADCMCTL0 |= ADCINCH0;                                   // A0 ADC input select; Vref=AVCC

    The voltage presence on the 1.55VDC, but i am getting ADC count as 100. If i vary the voltage to 2VDC, i am getting same result  as100.

    I need help for this.

    Regards,

    Yuvaraj

  • Hi,

            My ADC channel want to measure the voltage is P1.0.

    BR,

    Yuvaraj  

  • > ADCMCTL0 |= ADCINCH0;                                   // A0 ADC input select; Vref=AVCC

    This sets A1 (ADCINCH_1). Try instead:

    > ADCMCTL0 |= ADCINCH_0;                                   // A0 ADC input select; Vref=AVCC

    [Edit: If you're using the Launchpad, don't forget to remove the jumper on J10 (LED1).]

  • Hi Yuvaraj,

    Your code seems almost correct, but I believe you have a typo in your code.
    Modify it such that: ADCMCTL0 |= ADCINCH_0; // A0 ADC input select; Vref=AVCC

    If the above does not work, try these suggestions to see if they function as expected (note the ADC channel configured in the example).

    1. Can you try running this SDK example: msp430fr235x_adc12_01.c
    2. Another thing you can try is changing the reference voltage. You can set it to 1.5V and see how this affects your ADC readings. You can do this by modifying this line of code: ADCMCTL0 |= ADCINCH_1 | ADCSREF_1;

    Best,

    Owen

**Attention** This is a public forum