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.

MSP430FR5969: MSP low-power microcontroller forum

Part Number: MSP430FR5969


Hello,

I am trying to read 4 ADC channels from A0 to A3 out of 32 ADC channels. I want it to work in Sequence-of-channels (Autoscan) mode.

For the configuration, I followed the below steps:

ADC12CTL0 |= ADC12SHT0_0 | ADC12SHT1_0;      // Set sampling time
ADC12CTL1 |= ADC12CONSEQ_1;                           // Sequence of channels, single conversion mode
ADC12CTL1 |= ADC12SSEL_3;                                 // Select SMCLK clock
ADC12CTL1 |= ADC12SHP;                                       // Use sampling timer
ADC12CTL2 &= ~(3 << 4);                                         // Reset ADC resolution settings
ADC12CTL2 |= ADC12RES_2;                                  // Selecting 12-bit resolution
ADC12MCTL0 |= ADC12INCH_0;                              // Select ADC input channel A0
ADC12MCTL1 |= ADC12INCH_1;                              // Select ADC input channel A1
ADC12MCTL2 |= ADC12INCH_2;                              // Select ADC input channel A2
ADC12MCTL3 |= ADC12INCH_3;                              // Select ADC input channel A3

For the logic, I followed the below steps:

ADC12CTL0 |= ADC12ON;                                         // Turn ON ADC
ADC12CTL0 |= ADC12ENC;                                      // Enable ADC
ADC12CTL0 |= ADC12SC;                                        // Start conversion-software trigger
while(ADC12CTL1 & ADC12BUSY);                         // Poll for ADC Busy status
for(index = 0 ; index < 4 ; index++){
     ADCvar[index] = ADC12MEM++;                         // Store the converted value to an array
}

Q1- When the code was checked in debug mode, it was found that, the ADC12BUSY always remains high. And as a result, it is stuck in the while loop.
       Is there anything wrong with the ADC configuration?
       Please note: the ADC12ENC and ADC12SC bits are set with separate instructions, with internal trigger.

Q2- The values are all stored in ADC12MEM0 only. Should the user increment the register ADC12CSTARTADDx in ADC12CTL3?
        I expected it to increment automatically by the processor once the conversion starts. Is that not the function?

Thank you,
Padmini

  • I think you also need:

    > ADC12CTL0 |= ADC12MSC;   // Do the whole batch at once

    and

    ADC12MCTL3 |= ADC12INCH_3|ADC12EOS;  // Select ADC input channel A3, and that's the last one

    Without the first, the ADC needs a separate trigger (ADC12SC) for each conversion [Ref User Guide (SLAU367P) Fig 34-9].

    Without the second, the ADC will keep cycling through (all 32 of) the channels forever [Also Fig 34-9].

    [Edit: I just noticed:

    >      ADCvar[index] = ADC12MEM++;                         // Store the converted value to an array

    I suspect you wanted

    >      ADCvar[index] = ADC12MEM[index];                   // Store the converted value to an array

    ]

  • I added the two statements and it indeed worked.

    Thank you!

**Attention** This is a public forum