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.

MSP430F5438A: Multi-channel sampling of the ADC

Part Number: MSP430F5438A

Hi team,

Here's an issue from the customer may need your help:

Referring to here, repeat the sequence sampling A0 - A3. However, the voltage signal from the sensor is continuous, which always triggers an interrupt on the ADC sampling and does not allow for normal procedure.

They want to sample every 10 seconds, other times normally using the board for other operations. A sensor connected to the UART serial port is also required, so a UART interrupt is also required to read the sensor's data. How to avoid the conflict?

May we know is there anyway to sample adc without an interrupt? Or the interrupt can be jumped out after sampling is complete, and the interrupt can be done after other programs. 

Could you help look into this case? Thanks.

Best Regards,

Cherry

  • 1) Change this line:

    >   ADC12CTL1 = ADC12SHP+ADC12CONSEQ_3;

    to this:

    >   ADC12CTL1 = ADC12SHP+ADC12CONSEQ_1;  // Sample a batch each time ADC12SC is set

    2) When you want to capture 1 batch (sequence) use:

    >   ADC12CTL0 &= ~ADC12SC;   // Reset  ADC

    >   ADC12CTL0 |= ADC12SC;   // Start ADC

    The samples should be complete in (4 channels * (64 SHT + 12 + 1) ) = 308 ADC clock ticks or 308/5 = ~62 microseconds.

    3) If you don't want to use LPM to wait, you can spin for completion using:

    >  while (ADC12CTL1 & ADC12BUSY) /*EMPTY*/;   // Spin until ADC finishes

    [Ref User Guide (SLAU208Q) Table 28-14 and Sec 28.2.7.2 ]

  • Hi Bruce,

    Thanks for your help!

    Since it is a simple sampling, is there a way to not use ADC interrupts? Just take the reading directly, and execute

    A0results = ADC12MEM0; // Move A0 results, IFG is cleared
    A1results = ADC12MEM1; // Move A1 results, IFG is cleared

    Thanks and regards,

    Cherry

  • Hi Cherry,

    It need ADC interrupt flag ensure the conversion completed. You can add  

    while(!ADC12IFG3);  to wait for adc conversion complete

    or you can simply do with delay 10s, with the long time it can also complete the conversion.

    Thanks and Best regards

    Joe

  • If you use item (3) above, you can remove this line:

    >  ADC12IE = 0x08; // Enable ADC12IFG.3

    since when the spin-loop completes (ADC12BUSY=0) the samples are done. (After you remove the ADC12IE setting, you can remove the ISR.)

**Attention** This is a public forum