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