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.

MSP430FR2311: Reading multiple ADC inputs.

Part Number: MSP430FR2311


Hey, I have an example code from Resource Explorer where it reads the ADC value on 2 pins. Pins 1.0,1.1 and stores the ADC values in ADC_Result Array. If i plug all 2 ports into 3.3V i get 255 which is the 8 bit conversion result for 3.3 V but I want the 10 bit result. How do I change it?

#include <msp430.h>

unsigned char ADC_Result[2];                                    // 8-bit ADC conversion result array
unsigned char i;

int main(void)
{
    WDTCTL = WDTPW | WDTHOLD;                                   // Stop WDT
    
    // Configure ADC A0~2 pins
    P1SEL0 |= BIT0 + BIT1;
    P1SEL1 |= BIT0 + BIT1;

    // Disable the GPIO power-on default high-impedance mode to activate
    // previously configured port settings
    PM5CTL0 &= ~LOCKLPM5;

    // Configure ADC 
    ADCCTL0 |= ADCSHT_2 | ADCMSC | ADCON;                       // 16ADCclks, MSC, ADC ON
    ADCCTL1 |= ADCSHP | ADCCONSEQ_1 | ADCSSEL_1;                // ADC clock ACLK, sampling timer, s/w trig.,single sequence
    ADCCTL2 |= ADCRES_1;                                        //10-bit conversion results
    ADCMCTL0 |= ADCINCH_1 | ADCSREF_1;                          // A0~2(EoS); Vref=1.5V
    ADCIE |= ADCIE0;                                            // Enable ADC conv complete interrupt
    
    // Configure reference
    PMMCTL0_H = PMMPW_H;                                        // Unlock the PMM registers
    PMMCTL2 |= INTREFEN;                                        // Enable internal reference
    __delay_cycles(400);                                        // Delay for reference settling
    __no_operation();

    while(1)                                
    {
        i = 1;
        while(ADCCTL1 & ADCBUSY);                                // Wait if ADC core is active
        ADCCTL0 |= ADCENC | ADCSC;                               // Sampling and conversion start
        __bis_SR_register(LPM0_bits | GIE);                      // Enter LPM0 w/ interrupts
        __no_operation();                                        // Only for debug
        __delay_cycles(5000);
        __no_operation();
    }
}

// ADC interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=ADC_VECTOR
__interrupt void ADC_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(ADC_VECTOR))) ADC_ISR (void)
#else
#error Compiler not supported!
#endif
{
    switch(__even_in_range(ADCIV,ADCIV_ADCIFG))
    {
        case ADCIV_NONE: 
            break;                              
        case ADCIV_ADCOVIFG: 
            break;             
        case ADCIV_ADCTOVIFG: 
            break;            
        case ADCIV_ADCHIIFG: 
            break;             
        case ADCIV_ADCLOIFG: 
            break;             
        case ADCIV_ADCINIFG: 
            break;             
        case ADCIV_ADCIFG:
            ADC_Result[i] = ADCMEM0;
            if(i == 0)
            {
                __bic_SR_register_on_exit(LPM0_bits);              // Exist LPM0
            }
            else
            {
                i--;
            }
            break;                                             
        default: 
            break; 
    }  
}

**Attention** This is a public forum