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.

setting analog input pins (ADC10 sample codes)

I am struggling with figuring out what the sample code means.

Code seems inconsistent with what I think.

- ADC10CTL1 = CONSEQ_2 + INCH_1;            // Repeat single channel, A1

- ADC10CTL1 = INCH_1 + CONSEQ_3;            // A1/A0, repeat multi channel

- ADC10CTL1 = INCH_3 + CONSEQ_1;            // A3/A2/A1, single sequence

Can somebody explain what the code lines above mean?

I think I got the first line, but for the 2nd line, it just selected pin 1.1 as input channel, but why is pin 1.0 (A0) also defined as an input channel?

Same for 3rd line, why are pin 1.1 and pin 1.2 selected as input channel when only pin 1.3 should be selected (that is what INCH_3 means)

Thanks.

  • I didnt look up your controller or anything else, but I am using the ADC of other MSP430 so I guess this will help you understanding it:

    Look into the FamilyUsefGuide of your MSP430 family, look up the ADC function and the registers and their usage.

    Probably you will find exactly what INCH_3 and so on is supposed to mean. Sometimes the answers to your ADC Channel usage refers to the Datasheet fo your exact controller, so look up in the datasheet what is meant for Pins and usages witht eh ADC.

    It is a bit hard at first and seems complicated to use the FamilyUserGuide, but once you start it becomes clearer every day :)

    Hope you will find what You looking for.

  • Which device are you using?  What is the name of the sample code file(s) you are referring to?

  • I am using G2231 Launchpad.

    Sample code is msp430g2x31_adc10_11.c and msp430g2x31_adc10_14.c

    Thanks.

  • From the user guide slau144i:

    22.2.6 Conversion Modes
    The ADC10 has four operating modes selected by the CONSEQx bits as discussed in Table 22-1.
    Table 22-1. Conversion Mode Summary
    CONSEQx Mode Operation
    00 Single channel single-conversion A single channel is converted once.
    01 Sequence-of-channels A sequence of channels is converted once.
    10 Repeat single channel A single channel is converted repeatedly.
    11 Repeat sequence-of-channels A sequence of channels is converted repeatedly.

    For the sequence modes (CONSEQ_1 and _3) it starts at the INCH_x and moves down to INCH_0.  Have a read through the diagrams in the UM for a more detailed explanation.

    Regards,

    Chris.

**Attention** This is a public forum