Hello All,
I am working on the MSP430f67641 and set the clock frequency 16 MHz.
I am working on the ADC and get the problem with not come out from the BUSY flag.
my code is:
void ADC_init(void)
{
P9SEL |= BIT1 | BIT2 | BIT3; // Enable A3,A4,A5
// ADC initialization
ADC10CTL0 &= ~ADC10ENC;
ADC10CTL0 = ADC10SHT_3 + ADC10ON + REFON;
ADC10MCTL0 = ADC10SREF_1;
}
uint8_t ADC_read(int channel)
{
if(channel==3)
ADC10CTL1 = ADC10INCH_3 + ADC10DIV_3;
else if(channel==4)
ADC10CTL1 = ADC10INCH_4 + ADC10DIV_3;
else if(channel==5)
ADC10CTL1 = ADC10INCH_5 + ADC10DIV_3;
__delay_cycles(30);
ADC10CTL0 |= ADC10ENC + ADC10SC; // Sampling and conversion start
//__delay_cycles(160000);
while (ADC10CTL1 & ADC10BUSY); // check for ADC conversion is completed
ADCDATA = ADC10MEM0; // Read ADC value
tempInDeg = ((ADCDATA - 673) * 423) / 1024;
ADC10CTL0 |= ~ADC10ENC; // disable the conversion for oter channel
return tempInDeg;
}
i am stuck here need help...