void SCA60C_init(void)
{
ADC12CTL0 = ADC12SHT02 + ADC12ON; // 打开ADC12设置采样间隔
ADC12CTL1 = ADC12SHP+ADC12CONSEQ_1; // 采样保持出发信号选择采样定时器序列通道单次转换
ADC12MCTL0 = ADC12INCH_6; // 模拟输入通道选择通道A6
ADC12MCTL1 = ADC12INCH_7+ADC12EOS; // 模拟输入通道选择通道A7
ADC12CTL0 |= ADC12ENC; // 使能转换
ADC_PORT_SEL |= 0xff; //ADC选择 P6.6 P6.7作为输入(A6)(A7)
ADC12IE = 0x08;
}
uint16_t *SCA60C_getValue(void)
{
ADC12CTL0 |= ADC12SC; // Start sampling/conversion开始采样转换
__bis_SR_register(LPM4_bits+GIE); // ADC12_ISR will force exit进入LPM4并全局中断调试到这里就发现下一步没有进入中断而是直接继续执行
///////省略若干代码}
////中断服务程序
#pragma vector = ADC12_VECTOR
__interrupt void ADC12_ISR(void)
{
switch (__even_in_range(ADC12IV, ADC12IV_ADC12IFG15))
{
………………
case ADC12IV_ADC12IFG3:
positionData[0] = ADC12MEM0; // 读取转换结果
positionData[1] = ADC12MEM1; // 读取转换结果
__bic_SR_register_on_exit(LPM4_bits); // Exit active CPU退出低功耗 唤醒CPU
break;
…………
default:
break;
}
} |