最近在使用MSP430FR2422的ADC, 参考了TI提供的例子程序。发现如下代码:
“
// Configure ADC10
ADCCTL0 &= ~ADCENC; // Disable ADC
ADCCTL0 = ADCSHT_2 | ADCON; // ADCON, S&H=16 ADC clks
ADCCTL1 = ADCSHP; // ADCCLK = MODOSC; sampling timer
ADCCTL2 = ADCRES; // 10-bit conversion results
ADCIE = ADCIE0; // Enable ADC conv complete interrupt
ADCMCTL0 = ADCINCH_13 | ADCSREF_0; // A13 ADC input select = 1.5V Ref
// Vref = DVCC
// Configure reference module located in the PMM
PMMCTL0_H = PMMPW_H; // Unlock the PMM registers
PMMCTL2 |= INTREFEN; // Enable internal reference
while(!(PMMCTL2 & REFGENRDY)); // Poll till internal reference settles
”
发现有时候寄存器使用了标准的|= ,而有时候却直接用了=。 开始以为是例子程序写的时候忘记加| ,因此就都给补上了|, 但程序运行中发现ADC没有工作起来,采样值为0x000. 研究了很长时间发现,将程序复原为上述例子程序中的那样则ADC能正常工作。很是费解。请帮忙解释一下。非常感谢。
Brian