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.

MSP430FR5972: ADC 2 channel

Part Number: MSP430FR5972


Hi All,

I want to use analog input for ADC that should be on  P9.4 and P9.6 with the interrupt. I have worked for the single channel.

So I need to know GPIO setting for this two channel as well as adc register configuration for this two channels.  

  • Hi PK U,

    This is provided on Table 6-30 of the Datasheet, A12/A14 functionality is selected by setting BIT4 & BIT6 of the P9SEL0 & P9SEL1 registers. You can follow the code examples in order to initialize the ADC registers properly.

    Regards,
    Ryan
  • Hi Ryan Brown,

    Thank you for reply.
    As per my understand, please varify is it correct or not for A12 and A14

    P9SEL0 |= BIT4 + BIT6; // Configure P9.4 and P9.6 for ADC
    P9SEL1 &= ~(BIT4 + BIT6); // Configure P9.4 and P9.6 for ADC

    REFCTL0 |= REFVSEL_0 | REFON; // Select internal ref = 1.2V

    ADC12CTL0 = ADC12SHT0_2 | ADC12ON;
    ADC12CTL1 = ADC12SHP; // ADCCLK = MODOSC; sampling timer
    ADC12CTL2 |= ADC12RES_2; // 12-bit conversion results
    ADC12IER0 |= ADC12IE12; // Enable ADC conv complete interrupt
    ADC12MCTL0 |= ADC12INCH_12 | ADC12VRSEL_1; // A1 ADC input select; Vref=1.2V

    while(!(REFCTL0 & REFGENRDY)); // Wait for reference generator to settle
  • Hello PK U,

    You should be setting the P9SEL1 bits, not clearing them. If you plan to use ADC12MCTL0 then the interrupt you should use is ADC12IE0. Please refer to the ADC code examples provided by TI.

    Regards,
    Ryan
  • Ya you are right.
    Now I want to access two different ADC channel. I want to see both the output at a time It should be convert all the time.
  • Now you are going to want to use repeat-sequence-of-channels mode, once again referring to the TI code examples along with the User's Guide to understand how this is accomplished.

    Regards,
    Ryan
  • Hi Ryan,

    Now I am facing one more issue, I am giving the different supply (from 1.5 V to 3.6 V) to ADC channel P9.4 (A12) but it give the MAX value (4095) and when I provide GND then it gives 0 (zero) value.

    conclution it gives only two value either 4095 or 0.

    I am using code like:-

    void adc_ch_A12()
    {
    ADC12MCTL0 |= ADC12INCH_12 | ADC12VRSEL_1; // A12 ADC input select; Vref=1.2V
    P9SEL1 |= BIT4; // Configure P9.4 for ADC
    }

    void adc_init()
    {
    // Configure ADC12
    ADC12CTL0 = ADC12SHT0_2 | ADC12ON;
    ADC12CTL1 = ADC12SHP; // ADCCLK = MODOSC; sampling timer
    ADC12CTL2 |= ADC12RES_2; // 12-bit conversion results
    ADC12IER0 |= ADC12IE0; // Enable ADC conv complete interrupt
    }
  • This is due to the fact that you are using ADC12VRSEL_1 and REFVSEL_0 for an internal reference voltage of 1.2 V. Use ADC12VRSEL_0 to reference AVCC or increase your internal reference voltage to 2.0 or 2.5 V (controlled with REFVSEL).

    Regards,
    Ryan
  • Thank you Ryan for quick reply my problem is solved.

**Attention** This is a public forum