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.

Does it really make sense to use interrupt for reading ADC12?

Hi...

My question is...  does it really make sense to sleep in LPM0 when reading the ADC, or not?   Especially when you have a low impedance input and can use the shortest sample and hold period.

I'm using the ADC12 on the MSP430F5535.  I am using an external low-power 2.5V reference, with high precision, and it is always on.   There is no issue of waiting to power up the reference.

I was using the interrupt to wake up the core after the conversion, but I find I get just fine results with this code: 

 

  ADC12CTL0 = ADC12ON;  // turn on ADC

  ADC12MCTL0 =

      BOOST_OUTPUT_SENSE// input channel

    + ADC12SREF_2       // voltage reference VeREF+ for high, GND for low

    + ADC12EOS;         // end of sequence

  ADC12CTL0 =

      ADC12ON 

    + ADC12ENC          // enable conversion

    + ADC12SC;          // start conversion

  __delay_cycles(5);    // wait for 5 microseconds

  BoostVoltage = ADC12MEM0;   // save result

  ADC12CTL0 = 0;        // turn off ADC

You can see that I do not enter LPM0, and I do not enable interrupts.  Instead, I just start conversion, then wait for 5+ microseconds, then read result.  I don't need super-accurate results, but this is working.   And, if the off-time will be < 5 microseconds anyway, then does it make sense for any reason to enter LPM, which will cause the overhead of the interrupt service routine and then re-entering the main program execution?

Please... your comments and thoughts.

  • For what you are doing it probably doesn't make sense to use an interrupt. If you were sampling a sequence of channels it would make more sense to use an interrupt. If you were sampling at regular intervals you'd probably be crazy not to use interrupts.  One size does not fit all.

  • Thank you Steve, and to Adrian for verifying this.

    It's common sense, but I wanted to bring it up, because I almost *always* see people using the interrupt method, even for a single ADC read...  it's become the norm, I suppose.

     

    One more question, Adrian or anyone else, please...

    I haven't seen this addressed in the documentation anywhere.

    When setting registers like ADC12MCTL0, is it necessary to have the ADC switch ON at that point, or can it be set before the ADC is turned on?

    I assume so, but I always see code turning it ON first, then setting up the registers.

    It's a fine point, but I want to learn the fine points of the MSP430.   I think it could make a bit of difference in power consumption.  I could do experiments, but I want to get a more official answer.

     

    thanks!

    Sage

     

     

     

     

**Attention** This is a public forum