Part Number: MSP-EXP430FR2355
Hello Team,
I'm working on ADC, i want to read data from 3 channels A1,A2,A3 and initially ADC is by default to MODOSC getting data for 3 channels fine.
But when I configured ADC to 24Mhz with the ref(slau445i) UG, Only one channel(A1) data is repeating every time. why it is not getting updated ?
like if A1 = 768 , A2 and A3 also getting 768. ADC_channelno is increasing but A2 and A3 not updating, why? below is the code i've tried. Any help would be greatly thankful.
while (ADC_channelno <= 3)
{
// ADC conversion enable
while ((ADCCTL1 & ADCBUSY)); //Wait for conversion to end
ADCCTL0 &= ~ADCENC; // Disable
ADCMCTL0 = (ADCMCTL0 & ~ADCINCH) | ADC_channelno; // We "know" INCH is the LSb-s
ADCCTL0 |= ADCENC | ADCSC; // // Sampling and conversion start(Every Channel)
while ((ADCCTL1 & ADCBUSY)); //Wait for conversion to end
__bis_SR_register(GIE); // LPM0, ADC_ISR will force exit
sprintf(str, "%d", ADC_Result1);
for(i=0; str[i] != '\0'; i++)
{
temp = str[i];
str1[j] += temp;
j++;
}
}
if (ADC_channelno > 3)
{
ADC_channelno = 1;
}
void adc_init()
{
// Configure ADC A1,A2,A3 pin
P1SEL0 |= BIT1;
P1SEL1 |= BIT1;
P1SEL0 |= BIT2;
P1SEL1 |= BIT2;
P1SEL0 |= BIT3;
P1SEL1 |= BIT3;
// Configure ADC12
ADCCTL0 |= ADCSHT_2 | ADCON; // ADCON, S&H=16 ADC clks
ADCCTL1 |= ADCSSEL_3 | ADCSHP | ADCSHS_0; // ADCCLK = SMCLK; sampling timer
ADCCTL2 &= ~ADCRES; // clear ADCRES in ADCCTL
ADCCTL2 |= ADCRES_2; // 12-bit conversion results
ADCIE |= ADCIE0; // Enable ADC conv complete interrupt
}
// 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:
ADCIFG &= ~ADCIFG; // clear interrupt flag
ADC_Result1 = ADCMEM0; // Save away result
ADC_channelno++;
break;
default:
break;
}
}