MSP430FR2476 中的 12 位 ADC 似乎只能在 10 位模式下工作

发布于 2025-01-12 15:42:03 字数 1639 浏览 0 评论 0原文

问题是:我试图初始化 MSP430FR2476 上的 12 位内置 ADC,但无论我做什么,它似乎都以 10 位工作。我更改了控制寄存器中的分辨率位,可惜没有效果。无论我尝试什么都没有帮助,总是 10 位。最高有效字节永远不会高于 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;
    }
}

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. 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. The most significant byte never gets higher than 3. Please help, here is a snippet of the code:

 //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;
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乞讨 2025-01-19 15:42:03

错误恰好在这里:

ADCCTL2 |= (ADCRES_2); 

想法是默认值是1,所以当我对寄存器执行|=操作时,最终值变成3,而不是2。我需要首先将该位字段清零!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文