[英]12-bit ADC in MSP430FR2476 seems to only work in 10-bit mode
Here is the problem: I am trying to initialize the 12-bit built-in ADC on MSP430FR2476, but no matter what I do it seems to work at 10 bits.问题是:我正在尝试初始化 MSP430FR2476 上的 12 位内置 ADC,但无论我做什么,它似乎都以 10 位工作。 I change the resolution bits in a control register and alas, to no avail.我更改了控制寄存器中的分辨率位,唉,没有用。 No matter what I have tried nothing helps, always 10 bits.无论我尝试了什么,都没有任何帮助,总是 10 位。 The most significant byte never gets higher than 3. Please help, here is a snippet of the code:最高有效字节永远不会高于 3。请帮助,这是代码片段:
//Configuring ADC
PMMCTL2 |= (INTREFEN); //Internal reference, default 1.5V
ADCCTL0=ADCCTL1 = 0; //Ensuring that the ADC is off
ADCCTL0 |= (ADCSHT_7 + ADCMSC); //sample and hold = 64clk, multiple conversion
ADCCTL1 |= (ADCSHP + ADCSSEL_2 + ADCCONSEQ_1 + ADCDIV_7); //Conversion is triggered
//manually, ADC clock source - SMCLK/8 ~ 2Mhz, sequence of
//channels single conversion,
ADCCTL2 |= (ADCRES_2); //12 bit resolution, no matter what setting I have, no change
ADCMCTL0 |= (ADCSREF_1 + ADCINCH_1); //Employing the internal reference and starting
//conversion from A1 (P1.1)
ADCIE |= ADCIE0; //Activate interrupt
ADCCTL0 |= (ADCON); //Switching ADC on
SYSCFG2 |= (BIT1); //Activate ADC module on the pins (this line
//doesn't do anything for some reason
void adc_convert_begin(){
ADCCTL0 |= ADCENC;
ADCCTL0 |= ADCSC; //Start conversion
//The interrupt simpy send the most significant byte over UART
__attribute__((interrupt(ADC_VECTOR)))
void ADC_ISR(void){
switch(__even_in_range (ADCIV, 0x0C)){
case 0x0C:
adc_data[adc_index] = ADCMEM0;
UCA1TXBUF = (unsigned char)(ADCMEM0>>8);
break;
}
}
The error happens to be here:错误恰好在这里:
ADCCTL2 |= (ADCRES_2);
The idea is the default value is 1, so when I perform an |=
operation on the register, the final value turns out to be 3, instead of 2. I need to zero that bit field first!我的想法是默认值为 1,所以当我对寄存器执行|=
操作时,最终值变成 3,而不是 2。我需要先将该位域清零!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.