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.

msp430f5529 adc problem

Other Parts Discussed in Thread: MSP430F5529

Hi,

     I am using msp430f5529  microcontroller , i am using adc12 , I want to read voltage across pin 5 of PORT6 ,i am able to read values across register ADC12MEM5  but the values are not constant , values are changing. below is my code.


P6SEL |= BIT5 ;
P5SEL |= BIT0 ;

ADC12CTL0 |= ADC12ON | ADC12SHT0_2| ADC12SHT1_15 ;
ADC12CTL1 |= ADC12SHS_0 | ADC12CSTARTADD_5 | ADC12SHP | ADC12CONSEQ_0 | ADC12SSEL_0 | ADC12DIV_1 ; 
ADC12CTL2 |= ADC12TCOFF | ADC12RES_2 ;
ADC12MCTL5 |= ADC12SREF_2 | ADC12INCH_5 ; 

ADC12CTL0 |= ADC12ENC ; 


while (1)
{


ADC12CTL0 |= ADC12SC; 

while (!(ADC12IFG & BIT5));

ADC12IFG &= ~BIT5;

__no_operation(); // SET BREAKPOINT HERE


}

  • Why did you start a second thread for the same problem?

  • Hi Jens-Michael,

    I am able to read ADC value but values are not correct. my code as follows. Please tell us where the flow going wrong.


    P6SEL |= BIT5;                                    // TEMPERATURE AS peripheral
    REFCTL0 &= ~REFMSTR;               // reference master control set to zero
    ADC12CTL0 |= ADC12SHT0_10 | ADC12ON | ADC12REFON | ADC12REF2_5V ; // ADC sample hold bit select,ADC enable, ADC reference voltage enable,ADC refernce voltage is 2.5v
    ADC12CTL1 |= ADC12CSTARTADD_5 | ADC12SHP | ADC12DIV_1 | ADC12CONSEQ_0 | ADC12SSEL_0 | ADC12SHS_0; ADC conversion start address,sample hold pulse mode,clock divided by 1,conversion sequence, clock source select,sample and hold select
    ADC12CTL2 |= ADC12REFOUT ;                                   // ADC reference output
    ADC12MCTL5 |= ADC12SREF_1 | ADC12INCH_5 ; //ADC reference, channel input 5
    ADC12CTL0 |= ADC12ENC ;                                          // ADC enable conversion

    while (1)

    {

    ADC12CTL0 &= ~ADC12ENC ;
    ADC12CTL1 |= ADC12CSTARTADD_5;
    ADC12MCTL5 |= ADC12SREF_1 | ADC12INCH_5 ;
    ADC12CTL0 |= ADC12ENC;
    ADC12CTL0 |= ADC12SC;                                    // enable start conversion
    while (!(ADC12IFG & BIT5));
    gAdc_value_capture_temp = ADC12MEM5;      // store data in variable
    ADC12IFG &= ~BIT5;

    }

    Regards

    Arun j

  • ADC12MCTLx and ADC12INCH_x are independent. AS long as you set ADC12INCH_5, you can as well use it on ADC12MCTL0. It's a common misunderstanding.
    You don't tell the MSP you're using. On some, it is not necessary to use ADC12REFOUT, on some it is required for using the default MODOSC clock, on some it is always required. But if you do, you need to apply an external 10µF tantalum/100nF ceramic combo. (will increase performance even if not required for your MSP/clock speed)
    You don't need to re-configure STARTADD and channel settings in your while loop. Therefor it isn't required to clear ADC12ENC. In your loop, just set ADC12SC and wait for the IFG bit. Then read ADC12MEM5 (which will clear ADC12IFG.5 implicitly). ADC12SC will auto-clear in single-channel single-conversion mode.
    But before entering your while loop, wait the required settling delay for the reference.

    BTW: it is not necessary to set P6SEL.5, the analog pin functions are independent of the digital I/O (see the pin schematics in the datasheet). What do you mean with "TEMPERATURE AS peripheral"?

**Attention** This is a public forum