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.

problem with MSP430f5328 ADC12

Other Parts Discussed in Thread: MSP430F5328

Hi, i have been working with MSP430f5328, and am trying to use ADC12,when running the program the registers have their correct values but when connecting the analog signal (P6.1) nothing happen

any one have any idea !!!

here is the code

#include <msp430.h>

int main(void) {
    WDTCTL = WDTPW | WDTHOLD;    // Stop watchdog timer
    P1DIR |= BIT0;
    P6SEL |= BIT1;
    REFCTL0 &= ~REFMSTR;
    ADC12CTL0 &= ~ADC12ENC;
    ADC12CTL0 |= ADC12ON+ADC12SHT0_11+ADC12REFON+ADC12REF2_5V;
    ADC12CTL1 |=  ADC12CSTARTADD_1+ADC12SSEL_3;
    ADC12MCTL0 |= ADC12INCH_1+ADC12SREF0;
    __delay_cycles(30);
    ADC12CTL0 |= ADC12ENC;

    while (1)
      {
        ADC12CTL0 |= ADC12SC;
        __delay_cycles(30);
      }
    return 0;
}

  • Hi Alaa!

    Your way of handling the ADC12 is a bit unusual. This here

    while( 1 )
    {
      ADC12CTL0 |= ADC12SC;
      __delay_cycles( 30 );
    }

    is not the best way to do it. Did you look at the code examples for this processor that show how to use the ADC12? It would be a better idea to work with the BUSY flag of the ADC or to use the interrupts for a done conversion instead of starting the conversion and add some random delay. Additionally you never grab the ADC result from the register - I guess you pause the program and look at the register itself?

    Better start with the examples - this is tested code that works. There are various programs that can be changed according to your requirements:

    • MSP430F532x_adc_01.c              ADC12, Sample A0, Set P1.0 if A0 > 0.5*AVcc
    • MSP430F532x_adc_02.c              ADC12, Using the Internal Reference
    • MSP430F532x_adc_05.c              ADC12, Using an External Reference
    • MSP430F532x_adc_06.c              ADC12, Repeated Sequence of Conversions
    • MSP430F532x_adc_07.c              ADC12, Repeated Single Channel Conversions
    • MSP430F532x_adc_08.c              ADC12, Using A8 and A9 Ext Channels for Conversion
    • MSP430F532x_adc_09.c              ADC12, Sequence of Conversions (non-repeated)
    • MSP430F532x_adc_10.c              ADC12, Sample A10 Temp and Convert to oC and oF

    Dennis

**Attention** This is a public forum