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.

MSP430F248 & ADC12

Other Parts Discussed in Thread: MSP430F248, MSP430F249

Hi Everyone,

I am using MSP430F248 controller & i am trying to read analog data via port P6.6/A6 for Single-channel, single-conversion without ISR enable.
 
The reference is AVcc & AVss, The clock is ADC12OSC.
 
I try to use the example code from TI site but no success to get 12 bit accuracy.

Please HELP!

Doron

 

 

 

  • Hi,

    which example did you use? The one below is from the MSP430X24X code examples (http://www.ti.com/litv/zip/slac149e).

    Kind regards
    aBUGSworstnightmare

    //******************************************************************************
    //  MSP430x24x Demo - ADC12, Using the Internal Reference
    //
    //  Description: This example shows how to use the internal reference of ADC12.
    //  It uses the internal 2.5V reference and performs a single conversion
    //  on channel A0. The conversion results are stored in ADC12MEM0. Test by
    //  applying a voltage to channel A0, then setting and running to a break point
    //  at the "_NOP()" instruction. To view the conversion results, open an ADC12
    //  register window in debugger and view the contents of ADC12MEM0.
    //
    //                MSP430F249
    //             ---------------
    //            |               |
    //     Vin -->|P6.0/A0        |
    //            |               |
    //
    //
    //  B. Nisarga
    //  Texas Instruments Inc.
    //  September 2007
    //  Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.42A
    //******************************************************************************

    #include  <msp430x24x.h>

    void main(void)
    {
      volatile unsigned int i;
      WDTCTL = WDTPW+WDTHOLD;                   // Stop watchdog timer

    // modify the line below for A6
      P6SEL |= 0x01;                            // Enable A/D channel A0

    // P6SEL |= BIT6;                          // Enable A/D channel A6


      ADC12CTL0 = ADC12ON+SHT0_2+REFON+REF2_5V; // Turn on and set up ADC12
      ADC12CTL1 = SHP;                          // Use sampling timer
      ADC12MCTL0 = SREF_1;                      // Vr+=Vref+

      for ( i=0; i<0x3600; i++);                // Delay for reference start-up
     
      ADC12CTL0 |= ENC;                         // Enable conversions

      while (1)
      {
        ADC12CTL0 |= ADC12SC;                   // Start conversion
        while ((ADC12IFG & BIT0)==0);
        _NOP();                                 // SET BREAKPOINT HERE
      }
    }

  • Thanks for quick reply!

    I use also this example with the following updated:

    #include  <msp430x24x.h>

    void main(void)
    {

          volatile unsigned int i;
          WDTCTL = WDTPW+WDTHOLD;                      // Stop watchdog timer
         
          // Enable A/D channel A6
          P6SEL |= BIT6;                         
          ADC12CTL0 = ADC12ON+SHT0_15+REFON+REF2_5V; // Turn on and set up ADC12
          ADC12CTL1 = SHP + CSTARTADD_6;            // Use sampling timer
          ADC12MCTL6 = INCH_6 + SREF_1;                // Vr+=Vref+
         
          for ( i=0; i<0x3600; i++);                                        // Delay for reference start-up
         
          ADC12CTL0 |= ENC;                                            // Enable conversions
         
          while (1)
          {
              ADC12CTL0 |= ADC12SC;                               // Start conversion
              while ((ADC12IFG & BIT6)==0);
              _NOP();                                                                // SET BREAKPOINT HERE
          }
    }

  • Hi,

    and what is the result? Does it work or not?

    Rgds
    aBUGSworstnightmare

  • doron bs said:
    The reference is AVcc & AVss, The clock is ADC12OSC.

     
    I try to use the example code from TI site but no success to get 12 bit accuracy.

     

    Clarification: Does the code take sane readings (just not 12 bit accurate) or does it not work entirely?

  • Hi,

    The code is working but with no 12 bit accuracy, I use external AVCC=3.3V & I want to see accuracy of 3300/4096=0.8mV, The accuracy that i get is about 40mV

    I also try to use the internal reference & the same problem.

    Doron

     

     

  • Hi,

    The code is working but without 12 bit accuracy, 40mv accuracy instead 0.8mv accuracy.

    Doron

     

  • Hi Doron,

    the sample code configures the ADC12 to use internal reference. You should also ensure you've followed the AVREF decoupling guidance figured out in the usres manual.

    Rgds
    aBUGSworstnightmare

  • Hi,

    Yes i have allready the ADC12 Grounding and Noise Considerations the same as in user manual.

    Doron

     

  • doron bs said:

    Hi,

    The code is working but without 12 bit accuracy, 40mv accuracy instead 0.8mv accuracy.

    Doron

     

    *I'm assuming by accuracy you mean precision, or "noise".  If this is an incorrect assumption then I'm an idiot and my post is useless*

     

    Hmm.  Well you'll never get 0.8mV precision with a single sample (the bottom two LSBs are generally quite noisy, I'm used to seeing around 10bits of usable resolution with the ADC12), but you should be able to get much better than 40mV.  

    I would try simplifying your system until the measurement improves.  One way to simplify is to measure yourself!  By using a derivation of your reference signal as your input, you can mostly cancel noise that may be on your reference.  For testing sake I'd try to use the internal supply monitoring channel (reads as Vcc/2, I think it's channel 11?).  Although I'd never advocate using Vcc as your reference, for this test please do.  If this measurement works, you can do the same test using the internal (or an external) reference using two external resistors to create your divided Vref to sample.  Make sure you don't violate the reference's current output, the msp430's is rather weak!

    Once you know you're taking clean measurements using a reasonable reference (even the internal one is OK for 10-12bit stuff as long as you don't care about temperature changes), you can confidently move from measuring yourself to measuring an external signal :)  Also, at this point you can usually attribute any additional noise to either your reference or your external signal, not the ADC itself.

     

    After your measurements are as noise free as you can get them, we can talk accuracy!

     

    -memoryleak

     

    edit:  the decoupling techniques BUGs mentioned actually end up being really important.  I didn't mention them as you said you've already done them but I want to make sure I convey that they are a prerequisite to any of the junk I mentioned above.

  • Hi,

    Thanks for your quick reply!

    1. The external reference is a regulator type: TPS780330220 with fixed 3.3v

    2. I have checked the external reference with the ADC12MEM11 = (AVCC-AVSS)/2 with  referenct to internal reference 2.5v.

    3. I recieved an error about 9.4mV maximum.

    Doron

     

     

     

**Attention** This is a public forum