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.

[参考译文] TM4C1294NCPDT:多个 ADC 通道问题

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

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/993089/tm4c1294ncpdt-multiple-adc-channels-issue

器件型号:TM4C1294NCPDT

你(们)好

我使用 中断读取8个 ADC0通道, 但我还需要9个通道,我尝试使用不同的采样序列发生器、单独的 ISR 以及轮询所有 这些方法都不会为我提供第9个通道 ADC 数据。 这位于端口 E CH_8上,是否存在配置问题或缺少任何内容。

我的代码基于 Tiva 系列 SDK 版本:- TivaWare_C_Series-2.2.0.295

编译器是:- TI v 18.12.2.LTS

请帮助。

此致

霍迪达斯

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
//#include "inc/tm4c1294ncpdt.h"
#include "driverlib/comp.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_adc.h"
#include "inc/hw_types.h"
#include "inc/hw_udma.h"
#include "inc/hw_emac.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "driverlib/adc.h"
#include "driverlib/udma.h"
#include "driverlib/emac.h"
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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

    你(们)好  

    [引用 userid="289369" URL"~/support/microcontrollers/other/f/other-microcontrollers-forum/993089/tm4c1294ncpdt-multiple-adc-channels-issue ]I 尝试使用不同的采样序列发生器、单独的 ISR 以及轮询所有 这些方法都不会为我提供第9个通道 ADC 数据。 这位于端口 E CH_8上、[/报价]

    请注意、每个序列发生器都有自己的中断矢量。 见下表。 我注意到您只注册 了 INT_ADC0SS0的 ADC0IntHandler。 您会想念 ADC0SS1。  

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

    您好!

    这种方式是否与代码中的方式一样? 在这里、这也不起作用、我是寄存的独立 ISR 处理程序。  

    此致

    霍迪达斯

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    void ADC0IntHandler(void)
    {
    // Clear interrupt Flag
    ADCIntClear(ADC0_BASE, 0);
    ADCSequenceDataGet(ADC0_BASE, 0, adcBuffer2);
    }
    void ADC1IntHandler(void)
    {
    // Clear interrupt Flag
    ADCIntClear(ADC0_BASE, 1);
    ADCSequenceDataGet(ADC0_BASE, 1, &adcBuffer2[9]);
    }
    void adc2_init(void)
    {
    uint32_t adcClock=0, adcDiv=0;
    // Enable the ADC0 peripheral
    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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

    您好!

     我尝试修改现有的 TivaWare ADC 示例。 我在序列发生器1上使用 PE5 (AIN8)、但看不到任何问题。 您能否尝试以下示例并确认电路板上的 PE5 (AIN8)是否正常工作? 如果我连接到 VDD、则 AIN8上的值为4095。  

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #include <stdbool.h>
    #include <stdint.h>
    #include "inc/hw_memmap.h"
    #include "driverlib/adc.h"
    #include "driverlib/gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/uart.h"
    #include "utils/uartstdio.h"
    //*****************************************************************************
    //
    //! \addtogroup adc_examples_list
    //! <h1>Single Ended ADC (single_ended)</h1>
    //!
    //! This example shows how to setup ADC0 as a single ended input and take a
    //! single sample on AIN8/PE3.
    //!
    //! This example uses the following peripherals and I/O signals. You must
    //! review these and change as needed for your own board:
    //! - ADC0 peripheral
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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

    您好!

    不管怎样、我的问题 是9 个 ADC 通道。 当采用第9 个 ADC 通道时(任何通道为 第9个通道) 不起作用、并且所有其他 8个通道都起作用。 那么  、我应该 对 超过8 个 ADC 通道执行什么操作

    此致

    霍迪达斯

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

    您好!

     我修改了最后一个程序的位、以便在序列0中对 AIN0进行8次采样、而第9个通道 AIN8位于序列发生器1中。 我将 AIN8连接到3.3V、将 AIN0连接到 GND。 我能够看到正确测量了 AIN8。  

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #include <stdbool.h>
    #include <stdint.h>
    #include "inc/hw_memmap.h"
    #include "driverlib/adc.h"
    #include "driverlib/gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/uart.h"
    #include "utils/uartstdio.h"
    //*****************************************************************************
    //
    //! \addtogroup adc_examples_list
    //! <h1>Single Ended ADC (single_ended)</h1>
    //!
    //! This example shows how to setup ADC0 as a single ended input and take a
    //! single sample on AIN8/PE3.
    //!
    //! This example uses the following peripherals and I/O signals. You must
    //! review these and change as needed for your own board:
    //! - ADC0 peripheral
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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

    您还会遇到编程错误。  

    语句 ADCSequenceDataGet (ADC0_BASE、1、&adcBuffer2[9])错误。 将 AIN8值放入数组的第10个元素中。 您应该已经被写为  ADCSequenceDataGet (ADC0_BASE、1、&adcBuffer2[8]);

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

    您好!

    我知道并 已纠正该错误、但仍然存在问题。  此外 、我总共需要 9个 ADC 通道数据。 因为我有9 个不同的模拟输入。

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

     我按原样运行代码并修改两个方面。 我 将 adcBuffer2[8]以及下面一行中序列发生器1的优先级固定在一起、当我连接到3.3V 时、我可以看到第9个通道(AIN8)转换为4095。 当您使用 ADC_TRIGGER_Always 时、不能将序列发生器1置于较低的优先级。 序列发生器0完成后、它将再次尝试重新启动、序列发生器1将永远不会获得采样的机会。 您必须使用相同的优先级、这样两个序列发生器就可以旋转。  

    ADCSequenceConfigure (ADC0_BASE、1、ADC_TRIGGER_ALE一直、0);

      

    这是修改后的代码。

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #include <stdint.h>
    #include <stdbool.h>
    #include <stdio.h>
    //#include "inc/tm4c1294ncpdt.h"
    #include "driverlib/comp.h"
    #include "inc/hw_ints.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_adc.h"
    #include "inc/hw_types.h"
    #include "inc/hw_udma.h"
    #include "inc/hw_emac.h"
    #include "driverlib/debug.h"
    #include "driverlib/gpio.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/uart.h"
    #include "driverlib/adc.h"
    #include "driverlib/udma.h"
    #include "driverlib/emac.h"
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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

    您好!

    我已经尝试调试,发现第9个 ADC 通道正在工作,但它停止了其它8个通道。 我希望所有9个通道都能持续工作。  

    此致

    霍迪达斯

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

    当您有多个序列发生器时、始终使用触发器似乎并不理想。 在本例中、序列发生器1现在占用所有带宽。 我建议您使用处理器触发器。 使用修改后的代码、我可以看到所有9个通道都在工作。  

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #include <stdint.h>
    #include <stdbool.h>
    #include <stdio.h>
    //#include "inc/tm4c1294ncpdt.h"
    #include "driverlib/comp.h"
    #include "inc/hw_ints.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_adc.h"
    #include "inc/hw_types.h"
    #include "inc/hw_udma.h"
    #include "inc/hw_emac.h"
    #include "driverlib/debug.h"
    #include "driverlib/gpio.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/uart.h"
    #include "driverlib/adc.h"
    #include "driverlib/udma.h"
    #include "driverlib/emac.h"
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     

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

    您好!

    感谢您的深入支持。 我 对它进行了测试、工作正常。 此外、我 还使用  触发始终和中断的8个通道以及 使用处理器触发的第9个通道进行了测试。 这符合我 的应用标准。

    此致

    霍迪达斯