This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] MSP430FR2522:MSP430FR2422移植到 MSP430FR2522、ADC 问题

Guru**** 1587215 points
Other Parts Discussed in Thread: MSP430FR2522, MSP430FR2422
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1023423/msp430fr2522-msp430fr2422-porting-to-msp430fr2522-adc-issue

器件型号:MSP430FR2522
主题中讨论的其他器件: MSP430FR2422

您好!

我要将应用从 MSP430FR2422移植到 MSP430FR2522。 除 ADC 外、一切似乎都正常工作。

我使用的是两个 ADC 通道、A0和 A4。 通过调用 StartADCConversion 函数来配置通道并启动转换、我可以在通道之间切换。  

然后、我在 ADC 中断上获取 ADC 读数、并将其存储在我在 StartADCConversion 函数上传递的结构中。

我遇到的问题是、当我使用其他通道启动转换时、ADC 会获取随机读数。 请注意、我在两次读数之间至少等待5毫秒。

代码在 MSP430FR2422上工作正常、因此我想知道什么与 MSP430FR2522不同。

void StartADCConversion(adc_input_vrbls_t * channel)
{
    //Configure Memory Buffer
    /*
     * Base Address for the ADC Module
     * Input A6 as first multiple sample channel
     * Use positive reference of AVcc
     * Use negative reference of AVss
     */
    ADC_configureMemory(ADC_BASE,
            channel->AdcChannel,
            ADC_VREFPOS_AVCC,
            ADC_VREFNEG_AVSS);

    adcReading = channel;

    //Enable and Start the conversion
    //in Multiple-Channels, Single Conversion Mode
    ADC_startConversion(ADC_BASE,
                        ADC_SINGLECHANNEL);

    _BIS_SR(GIE);
}

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Stanley、

    您能告诉我有关您如何配置器件的更多信息吗? 如果您提供了代码的其余部分、也会有所帮助。

    谢谢、

    王国新

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Urica、

    这就是我配置 ADC 的方法。 在下面、您还可以找到中断例程。

    然后、在主循环中、每当我需要从特定通道读取数据时、我都会调用 StartADCConversion。 我允许读数之间的间隔时间大约为5-30ms。

    void StartADCConversion(adc_input_vrbls_t * channel)
    {
        //Configure Memory Buffer
        /*
         * Base Address for the ADC Module
         * Input A6 as first multiple sample channel
         * Use positive reference of AVcc
         * Use negative reference of AVss
         */
        ADC_configureMemory(ADC_BASE,
                channel->AdcChannel,
                ADC_VREFPOS_AVCC,
                ADC_VREFNEG_AVSS);
    
        adcReading = channel;
    
        //Enable and Start the conversion
        //in Multiple-Channels, Single Conversion Mode
        ADC_startConversion(ADC_BASE,
                            ADC_SINGLECHANNEL);
    
        _BIS_SR(GIE);
    }
    
    void configADC(void)
    {
        //Initialize the ADC Module
        /*
         * Base Address for the ADC Module
         * Use internal ADC bit as sample/hold signal to start conversion
         * USE MODOSC 5MHZ Digital Oscillator as clock source
         * Use default clock divider of 1
         */
        ADC_init(ADC_BASE,
            ADC_SAMPLEHOLDSOURCE_SC,
            ADC_CLOCKSOURCE_ADCOSC,
            ADC_CLOCKDIVIDER_1);
    
        ADC_enable(ADC_BASE);
    
        /*
         * Base Address for the ADC Module
         * Sample/hold for 16 clock cycles
         * Enable Multiple Sampling
         */
        ADC_setupSamplingTimer(ADC_BASE,
                ADC_CYCLEHOLD_16_CYCLES,
                ADC_MULTIPLESAMPLESENABLE);
    
        ADC_clearInterrupt(ADC_BASE,
                ADC_COMPLETED_INTERRUPT);
    
        //Enable Memory Buffer interrupt
        ADC_enableInterrupt(ADC_BASE,
                ADC_COMPLETED_INTERRUPT);
    
    }
    
    
    //ADC10 interrupt service routine
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=ADC_VECTOR
    __interrupt
    #elif defined(__GNUC__)
    __attribute__((interrupt(ADC_VECTOR)))
    #endif
    void ADC_ISR (void)
    {
        switch (__even_in_range(ADCIV,12)){
            case  0: break; //No interrupt
            case  2: break; //conversion result overflow
            case  4: break; //conversion time overflow
            case  6: break; //ADC10HI
            case  8: break; //ADC10LO
            case 10: break; //ADC10IN
            case 12:        //ADC10IFG0
                adcReading->Voltage = ADC_getResults(ADC_BASE);
                adcReading->ReadingReady = true;
              break;
            default: break;
        }
    }

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Stanley、

    感谢您的澄清。  根据 driverlib API 文档,在切换通道时,您可能需要调用 adc_disableConversion()来重新初始化 adc/重新配置内存缓冲区控制。 我还看到您使用的是单通道单次转换模式、该模式采样一次、但您启用了多个采样。

    此致、

    王国新