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.

MSP430f5529LP ADC ADC example code results

Other Parts Discussed in Thread: MSP-EXP430F5529LP, MSP430FR5739

Hi ,

I have  a MSP-EXP430f5529lp. I use your example code from CCS example projects: MSP430F55xx_adc_02 

I  am inputting a 1 Volt DC to P6.0  and I expect to see the right sample after running your code. 

I do the following conversion:

float sample = ADC12MEM0 * 2.5 /4095

If I do the right thing, I expect to see 1V, but what I actually see is that value at ADC12MEM0 after conversion  is about 1.5V . ( even if I input 0.5 V I still get value around 1.1 V)

Do I lack anything in this example code?

Could you please give the right adc code for this MSP430 ?

Thanks,

Ekaterina

  • What's ADC12MEM0 contents when you sample 1V and 1.1V input with 2.5V reference?

  • Inputting 1 V or 1.1V, do not has much difference. Contents at ADC12MEM0 differes every loop, though signal is a  DC...

    What I've recently got : 2088 and 2053

  • Ekaterina Shyshchenko said:
    Inputting 1 V or 1.1V, do not has much difference. Contents at ADC12MEM0 differes every loop

    First you have to ensure that voltage source is ok. What's signal source impedance? Describe voltage source circuit.

    Then you have to ensure that you set-up ADC correcty.

    Only then you have to think about math conversion which is simplest part of all this.

  • Ekaterina Shyshchenko said:
    I have  a MSP-EXP430f5529lp. I use your example code from CCS example projects: MSP430F55xx_adc_02 

    Driverlib 1.40.0.24 shows this as the source you refer to:

    #include <msp430.h>
    
    int main(void)
    {
      volatile unsigned int i;
      WDTCTL = WDTPW+WDTHOLD;                   // Stop watchdog timer
      P6SEL |= 0x01;                            // Enable A/D channel A0
      REFCTL0 &= ~REFMSTR;                      // Reset REFMSTR to hand over control to 
                                                // ADC12_A ref control registers
      ADC12CTL0 = ADC12ON+ADC12SHT02+ADC12REFON+ADC12REF2_5V;
                                                // Turn on ADC12, Sampling time
                                                // On Reference Generator and set to
                                                // 2.5V
      ADC12CTL1 = ADC12SHP;                     // Use sampling timer
      ADC12MCTL0 = ADC12SREF_1;                 // Vr+=Vref+ and Vr-=AVss
    
      for ( i=0; i<0x30; i++);                  // Delay for reference start-up
    
      ADC12CTL0 |= ADC12ENC;                    // Enable conversions
    
      while (1)
      {
        ADC12CTL0 |= ADC12SC;                   // Start conversion
        while (!(ADC12IFG & BIT0));
        __no_operation();                       // SET BREAKPOINT HERE
    
      }
    }
    
    

    Ekaterina Shyshchenko said:
    Do I lack anything in this example code?

    I don't see that the required delay for the reference to stabilize is coded properly. The for() loop could be optimized away... better to use __delay_cycles() instrinsic. Take a look at the REF section (Chapter 26) of SLAU208M.PDF as well as the datasheet for the 5529 to see what the settling time is.

  • Voltage sourse is generated with agilent waveform generator. Inputeing in  oscilloscope shows the right result and DC stable signal.

    More over, I have tried similar example with MSP430FR5739, where reference 1.5V

    The results are close to reality, though it 10 bit adc

  • I  use this datasheet, but could you please be more spesific how to stabilize the reference?

  • Brian is right, the for loop isn't suitable for the reference settling delay. It likely gets optimized away (because it does not change the system state and is therefore bvoid form the compiler's view). So the first few readings are perhaps not reliable.

    However, the code doesn't ever clear ADC12IFG.0 after the first conversion. So for each subsequent loop througt the while(1), thewhile (!(ADC12IFG & BIT0)); is a NOP and you're reading the same result over and over (of course, if you single-step through the code, you are slow enough to have a new conversion ready each time).

    So the cited driverlib code apparently isn't the best :)

    But there's more. When using the ADC12, it runs on default MODOSC. On some 5x family MSPs, there is an erratum ADC27, which states unreliable results when the ADC12 is run with >2MHz and the reference is not externally buffered (10µ tantalum/100n ceramic combo on Vref)

    Also, this MSP has a separate AVCC supply, which should be decoupled from DVCC with a R/C low-pass filter to stabilize analog functions and filter digital switching noise/ripple form the analog supply.
    Having an unstabilized supply voltage on the  analog parts is as bad as having an unstable reference, no matter how stable the input voltage is.

**Attention** This is a public forum