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.

[参考译文] TM4C129ENCPDT:ADC 值影响温度传感器读数的问题

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

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1573320/tm4c129encpdt-problem-where-adc-values-affect-the-temperature-sensor-readings

器件型号:TM4C129ENCPDT


工具/软件:

我尝试按单个序列接收五个值、即 ADC 通道 CH0 至 CH3 和温度传感器。  
我已经使用以下代码对其进行了配置、并可以使用接收数据:  
ADCSequenceDataGet (ADC0_BASE、0、GS_pui32ADCBuffer);但是、当我向 AIN3 (ADC CH3) 施加 1V 电压时、温度传感器值也会略有变化 (ADCSequenceDataGet 函数写入的值增加约 100)。您是否知道温度传感器值可能会发生变化?在其他函数中启用计时器中断。

     //
    // Enable the peripherals used by this application.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);

    //
    // Enable the GPIO pin for ADC0 Channel 0-4 (PE3 PE2 PE1 PE0) which configures it for
    // analog functionality.
    //
    GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_0);
    GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_1);
    GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_2);
    GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3);
    
 ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PIOSC | ADC_CLOCK_RATE_HALF, 1);

    //
    // Wait for the clock configuration to set.
    //
    SysCtlDelay(10);

    //
    // Disable the ADC0 sequence 0 interrupt on the processor (NVIC).
    //
    IntDisable(INT_ADC0SS0);

    //
    // Disable interrupts for ADC0 sample sequence 0 to configure it.
    //
    ADCIntDisable(ADC0_BASE, 0);

    //
    // Disable ADC0 sample sequence 0.  With the sequence disabled, it is now
    // safe to load the new configuration parameters.
    //
    ADCSequenceDisable(ADC0_BASE, 0);

    //
    // Enable sample sequence 0 with a processor signal trigger.  Sequence 0
    // will do a single sample when the processor sends a signal to start the
    // conversion.
    //
    ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_TIMER, 0);

    ADCReferenceSet(ADC0_BASE,ADC_REF_EXT_3V);

    //アナログ入力0-4Ch,温度センサの値を取得する設定

    ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH0);
    ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ADC_CTL_CH1);
    ADCSequenceStepConfigure(ADC0_BASE, 0, 2, ADC_CTL_CH2);
    ADCSequenceStepConfigure(ADC0_BASE, 0, 3, ADC_CTL_CH3);

    ADCSequenceStepConfigure(ADC0_BASE, 0, 4,
                             ADC_CTL_TS | ADC_CTL_END | ADC_CTL_IE);

    //
    // Since sample sequence 0 is now configured, it must be enabled.
    //
    ADCSequenceEnable(ADC0_BASE, 0);

    //
    // Clear the interrupt status
    ADCIntClear(ADC0_BASE, 0);

    //
    // Enables the DMA channel for the ADC0 sample sequence 0.
    //
    //ADCSequenceDMAEnable(ADC0_BASE, 0);

    //
    // Enable the ADC 0 sample sequence 0 interrupt.
    //
    ADCIntEnable(ADC0_BASE, 0);

    //
    // Enable the interrupt for ADC0 sequence 0 on the processor (NVIC).
    //
    IntEnable(INT_ADC0SS0);

    //
    // Enable the ADC trigger output for Timer A.
    //
    TimerControlTrigger(TIMER0_BASE, TIMER_A, true);

    //
    // Enable processor interrupts.
    //
    IntMasterEnable();

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

    您能找到有关此问题的任何解决方案吗? 我期待您的答复。

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

    > ADCSequenceStepConfigure (ADC0_BASE、0、4、 ADC_CTL_TS | ADC_CTL_END | ADC_CTL_IE);

    这(隐式)将采样/保持 (ADCSSH) 时间设置为 4 个时钟 (ADC_CTL_shold_4 [=0])。  

    温度传感器需要至少 16 个时钟的采样/保持[参考数据表 (SPMS441B) 第 18.3.6 节]。 过短的采样/保持可能会伪装成信道之间的串扰。

    请尝试:

    > ADCSequenceStepConfigure (ADC0_BASE、0、4、 ADC_CTL_TS | ADC_CTL_END | ADC_CTL_IE | ADC_CTL_shold_16);