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.

ADC not coming out of BUSY loop

Hi,

Below is my code to read INCH_3 channel but for some reason the code is getting hanged at BUSY loop, any pointers to resolve this issue?, thanks

        P1OUT &= ~0x01;
        P1DIR |=   0x01;

         ADC10CTL0 = SREF_0 + ADC10SHT_3 + REF2_5V + REFON + ADC10ON;
         ADC10CTL1 = SHS_0 + ADC10SSEL_0 + ADC10DIV_2 + CONSEQ_2 + INCH_3;
         ADC10AE0 |=  0x09;

            ADC10CTL0 |=  ENC + ADC10SC;                
            while (ADC10CTL1 & ADC10BUSY);                // Wait for ADC10BUSY
            ADCval = ADC10MEM;
      
            ADC10CTL0 &= ~ENC;                          // ADC10 disable
            ADC10CTL1 |= ~ (INCH_3)| REFON;            // End conversion and turn off ADC

  • I reversed ADC10CTL0 and ADC10CTL1 definitions and it worked !!!!  

    Is this thumb rule we need follow for configuring ADC? At same time I am seeing same value in ADC10MEM i.e., 0x1B4 always irrespective of channel . I certainly see some issue with ADC configuration . Can any please suggest me what is going wrong here?

                ADC10CTL1 = SHS_0 + ADC10SSEL_0 + ADC10DIV_2 + CONSEQ_2 + INCH_11;
                ADC10CTL0 = SREF_0 + ADC10SHT_3 + REF2_5V + REFON + ADC10ON;
                ADC10AE0 |=  0x09;
                while (ADC10CTL1 & ADC10BUSY);                // Wait for ADC10BUSY
                ADCVal= ADC10MEM;
                __no_operation();
                ADC10CTL0 &= ~ENC;                          // ADC10 disable
                ADC10CTL1 |= ~ (INCH_11)| REFON;            // End conversion and turn off ADC

  • Raj P said:
    Is this thumb rule we need follow for configuring ADC?

    Normally not. I rather guess it 'fixed' a bug by ignoring (part of) the ADC10CTL1 settings because ADC10ON is not set when you make them. It also explains why the channel selection makes no difference :)

    In the original code, you enabled CONSEQ_2, which is a repeated mode. So after being started once, the ADC will be eternally busy until you clear ENC.
    In the second code, you never set ENC and SC, so of course the ADC isn't busy - it never was.

    To check whether an individual conversion is done in a sequence or repeated mode, check the IFG bit, not the busy bit.

**Attention** This is a public forum