刚进入工作,学习msp430一周,对公司一产品的程序理解中遇到一些问题,向各位大牛求教
首先是一个adc10的模块程序如下,不懂之处已标红,望有人给我解释解释,尤其是那个控制器1左移12是有什么意义,非常不解,谢谢了!/*
* ADC10Conversion(unsigned char):
* 功能: adc10启动并根据传入采样通道完成一次采样
* 输入: 要采样的adc10的通道
* 输出: 一次完成的采样值
**/
unsigned int ADC10Conversion(unsigned char inch)
{
//if(inch > 7) /* ADC10 channel #0~7*/
//return 0;
if(inch > 7 && inch < 15)
return 0;
ADC10CTL0 &= ~ADC10SC;
ADC10CTL0 &= ~ENC;
ADC10CTL1 = ((unsigned int)inch << 12) + ADC10SSEL_3; //input channel + clock source select SMCLK
ADC10AE0 = BIT0 << inch; //Analog input enabled
ADC10CTL0 |= ENC + ADC10SC; //adc10 enabled + start sample and conversion
ADC10CTL0 |= ADC10SC;
while(ADC10CTL1 & ADC10BUSY);
return ADC10MEM;
}