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.

[参考译文] CCS/TM4C1230H6PM:模拟比较器0

Guru**** 2595805 points
Other Parts Discussed in Thread: EK-TM4C123GXL

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

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/736840/ccs-tm4c1230h6pm-analog-comparator-0

器件型号:TM4C1230H6PM
Thread 中讨论的其他器件:EK-TM4C123GXL

工具/软件:Code Composer Studio

大家好、

您能否简要了解一下我的模拟比较器0配置?

不管用。

短整型:

-输入+(内部)上的 int ref

-负输入(PC7)上的模拟值介于0...3V 之间

- PF0上的 COMP 输出

这是我的代码片段:

#include
#include
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/timer.h"
#include "driverlib/comp.h"

空初始化()

uint32_t g_ui32SysClock;//系统时钟速率、单位为 Hz。

SysCtlClockSet (SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHz | SYSCTL_OSC_MAIN);

G_ui32SysClock = SysCtlClockGet ();

SysCtlPeripheralEnable (SYSCTL_Periph_GPIOG);//启用 GPIO 端口
GPIOPinTypeGPIOOutput (GPIO_PORTG_base、GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);//为 LED 启用 GPIO 引脚(PN0和 PN1)


IntMasterEnable();//启用处理器中断

SysCtlPeripheralEnable (SYSCTL_Periph_COMP0);//启用比较器0

while (!SysCtlPeripheralReady (SYSCTL_Periph_COMP0))//等待 COMP 模块准备就绪


ComparatorRefSet (COMP_BASE、COMP_REF_0_275V);//配置内部电压基准

SysCtlPeripheralEnable (SYSCTL_Periph_GPIOC);//启用端口 C
SysCtlPeripheralEnable (SYSCTL_Periph_GPIOF);//启用端口 F

GPIOPinConfigure (GPIO_PF0_C0O);
//GPIOPinConfigure (GPIO_PC7_C0-);

GPIOPinTypeComparator (GPIO_PORTC_BASE、GPIO_PIN_7);//比较器输入
GPIOPinTypeComparatorOutput (GPIO_PORTF_BASE、GPIO_PIN_0);//比较器输出
比较器配置(COMP_BASE、0、(COMP_TRIG_NONE | COMP_INT_Both | COMP_ASRCP_REF | COMP_OUTPUT_NORMAL));//配置比较器0

ComparatorValueGet (COMP_BASE、0);

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    我可以在周一回到办公室时查看它。 我有一个适用于 TM4C129的示例、但引脚当然不同。 它可能会有所帮助。 
    (笑声) // //启用 COMP 模块。 // SysCtlPeripheralEnable (SYSCTL_Periph_COMP0); // //等待 COMP 模块准备就绪。 // while (!SysCtlPeripheralReady (SYSCTL_Periph_COMP0)) { } // //配置内部电压基准。 // ComparatorRefSet (COMP_BASE、COMP_REF_1_65V); // //配置比较器2。 // 比较器配置(COMP_BASE、2、 (COMP_TRIG_NONE | COMP_ASRCP_REF | COMP_OUTPUT_NORMAL); // //启用并等待端口准备好访问 // SysCtlPeripheralEnable (SYSCTL_Periph_GPIOD);//针对 C2o SysCtlPeripheralEnable (SYSCTL_Periph_GPIOP);//针对 C2- SysCtlPeripheralEnable (SYSCTL_Periph_GPION); while (!SysCtlPeripheralReady (SYSCTL_Periph_GPION)) { } //为 LED 操作配置 GPIO 端口。 GPIOPinTypeGPIOOutput (GPIO_PORTN_BASE、(USER_LED1|USER_LED2)); //为比较器2输出配置 GPIO 端口 GPIOPinTypeComparatorOutput (GPIO_PORTD_base、GPIO_PIN_2);// PD2为 C2o GPIOPinConfigure (GPIO_PD2_C2O); GPIOPinTypeComparator (GPIO_PORTP_BASE、GPIO_PIN_1);// PP1为 C2- // //永久循环 // while (1) { //读取比较器输出值。 // if (ComparatorValueGet (COMP_BASE、2)= true) { LED = USER_LED1|USER_LED2;//如果输入为低电平则同时闪烁 } 其他 { LED = USER_LED1;//如果输入为高电平,则闪烁1 } // //打开 LED // GPIOPinWrite (GPIO_PORTN_BASE、(USER_LED1|USER_LED2)、LED); // //延迟一位 // SysCtlDelay (ui32SysClock/6); // //关闭 LED // GPIOPinWrite (GPIO_PORTN_BASE、(USER_LED1|USER_LED2)、0); // //延迟一位 // SysCtlDelay (ui32SysClock/6); } }

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

    下面是在 EK-TM4C123GXL Launchpad 上工作的一些代码。

    #include 
    #include 
    #include "inc/hw_ints.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "driverlib/debug.h"
    #include "driverlib/gpio.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/pin_map.h"
    #define "driverlib_gpio"#define #define #define #define "driverlib_gpio_gpio.h"#define #define #include "#define #define #define #define #define #define "driverlib_gpio_gpins/blue_pio.h"#define #define #define #include
    
    
    
    
    
    
    
    
    
    uint32_t g_ui32SysClock;//系统时钟速率、单位为 Hz。
    
    SysCtlClockSet (SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHz | SYSCTL_OSC_MAIN);
    
    G_ui32SysClock = SysCtlClockGet ();
    
    
    
    IntMasterEnable();//启用处理器中断
    
    SysCtlPeripheralEnable (SYSCTL_Periph_GPIOC);//启用端口 C
    SysCtlPeripheralEnable (SYSCTL_Periph_GPIOF);//启用端口 F
    SysCtlPeripheralEnable (SYSCTL_Periph_COMP0);//启用比较器0
    while (!SysCtlPeripheralReady (SYSCTL_Periph_COMP0))//等待 COMP 模块准备就绪
    {
    }
    
    GPIOPinTypeGPIOOutput (GPIO_PORTF_BASE、红色|蓝色|绿色);//为 LED 启用 GPIO 引脚(PF1红色、PF2蓝色、PF3绿色)
    
    ComparatorRefSet (COMP_BASE、COMP_REF_0_275V);//配置内部电压基准
    GPIOPinConfigure (GPIO_PF0_C0O);
    GPIOPinTypeComparator (GPIO_PORTC_BASE、GPIO_PIN_7);//比较器输入
    GPIOPinTypeComparatorOutput (GPIO_PORTF_BASE、GPIO_PIN_0);//比较器输出
    
    比较器配置(COMP_BASE、0、(COMP_TRIG_NONE | COMP_INT_Both | COMP_ASRCP_REF | COMP_OUTPUT_NORMAL));//配置比较器0
    
    while (1)
    {
    if (ComparatorValueGet (COMP_BASE、0)= true)
    {
    GPIOPinWrite (GPIO_PORTF_BASE、红色|蓝色|绿色、绿色);//< 0.275V
    }
    其他
    {
    GPIOPinWrite (GPIO_PORTF_BASE、红色|蓝色|绿色、红色);//> 0.275V
    }
    
    }
    
    

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

    尊敬的 Bob:

    感谢您的回复。

    我出差的时候去的-马上就会去的。

    此致 Gunter