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.

Using ADC of EXP430F5438 board.

Other Parts Discussed in Thread: MSP430F5438

Hello Everyone

I want to evaluate the ADC of MSP430F5438. I have the EXP430F5438 experimenter board with me.

I tried the sample code examples  of MSP430F5438 , the problem I am facing is i am giving an analog input at Port 7.6  but it is never going inside the interrupt.

Here is the code

 

#include "msp430x54x.h"

void main(void)
{
  unsigned char adcval;
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
 
  ADC12CTL0 = ADC12SHT02 + ADC12ON;         // Sampling time, ADC12 on
  ADC12CTL1 = ADC12SHP;                     // Use sampling timer
  ADC12IE = 0x4000;                           // Enable interrupt
  ADC12CTL0 |= ADC12ENC;
 
 
  P7SEL |= 0x40;                            // P7.6 ADC option select
  P1DIR |= 0x01;                            // P1.0 output
  P1OUT &= ~BIT0;
  ///__bis_SR_register(LPM0_bits + GIE);     // LPM0, ADC12_ISR will force exit
    _BIS_SR(GIE);

  while (1)
  {
     ADC12CTL0 |= ADC12SC;                   // Start sampling/conversion
  

                    
      if (ADC12MEM14 >= 0x7FFF)
                P1OUT ^= 0x01;         
    
   //  __no_operation();                       // For debugger
  }
}

#pragma vector = ADC12_VECTOR
__interrupt void ADC12_ISR(void)
{
 
 
  switch(__even_in_range(ADC12IV,34))
  {
  case  0: break;                           // Vector  0:  No interrupt
  case  2: break;                           // Vector  2:  ADC overflow
  case  4: break;                           // Vector  4:  ADC timing overflow
  case  6: break;                                 // Vector  6:  ADC12IFG0
  
  case  8: break;                           // Vector  8:  ADC12IFG1
  case 10: break;                           // Vector 10:  ADC12IFG2
  case 12: break;                           // Vector 12:  ADC12IFG3
 
  P1OUT |= BIT0;
 
 
  case 14: break;                           // Vector 14:  ADC12IFG4
  case 16: break;                           // Vector 16:  ADC12IFG5
  case 18: break;                           // Vector 18:  ADC12IFG6
  case 20: break;                           // Vector 20:  ADC12IFG7
  case 22: break;                           // Vector 22:  ADC12IFG8
  case 24: break;                           // Vector 24:  ADC12IFG9
  case 26: break;                           // Vector 26:  ADC12IFG10
  case 28: break;                           // Vector 28:  ADC12IFG11
  case 30: break;                           // Vector 30:  ADC12IFG12
  case 32: break;                           // Vector 32:  ADC12IFG13
  case 34:  if (ADC12MEM14 >= 0x7FFF)                 //.5Vcc//
                              // P1.0 = 0
      P1OUT &= ~BIT0;
    else
         P1OUT |= BIT0;// P1.0 = 1
       //  P2OUT |= BIT1;

   __bic_SR_register_on_exit(LPM0_bits);   // Exit active CPU   // Vector 34:  ADC12IFG14
  default: break;
  }
}

  • Hi ajay,

    ajay pawar said:
    while (1)
      {
         ADC12CTL0 |= ADC12SC;                   // Start sampling/conversion
      

                        
          if (ADC12MEM14 >= 0x7FFF)
                    P1OUT ^= 0x01;         
        
       //  __no_operation();                       // For debugger
      }

    You're starting the ADC again and again! So, how should it ever generate an interrupt?

    Rgds
    aBUGSworstnightmare

  • Hello Abugsworstnighmare

    I am using this code from the code examples of TI.

    However I am also putting     this code inside the while loop at the end    __bis_SR_register(LPM0_bits + GIE);     // LPM0, ADC12_ISR will force exit.

    It is going inside the interrupt vector but it is firing case 6 , i am selecting channel A14 but it is still driving A0. I dont know y.

    Thank you for the help.

    Regards

    Ajay

  • Ajay,

    I think the problem is you need to setup the input channel to the ADC12.

    You need to add ' ADC12MCTL0 |= ADC12INCH14; ' before you set the ENC bit to use channel 14 on P7.6.

    So before line 11 if you call the #include... line 1.

    Let me know what you think.

    Best regards,

    Austin Miller

**Attention** This is a public forum