主题中讨论的其他器件:TM4C123、 MSP430F2370
你(们)好。
我正在尝试使用 tm41294NCPDT 内部模拟比较器
我正在尝试实现低功耗 NFC/RFID 卡检测算法
我对 RC 电路进行充电、RC 电路随后放电、通过 NFC 天线、我在电压降至阈值以下时立即读取电压、在我的情况下、我使用1.65V (测试用例)比较器应生成中断
我想使用 C0+引脚从比较器0生成以下输出
1:-但问题是它在上升沿和下降沿触发中断、此外、有时它会在配置中断后立即生成中断一次
2:-我在 IAR 中调试期间观察了寄存器、我注意到比较器0寄存器比较器1寄存器也在更新(COMPACSTAT1)、但我还没有配置比较器1
3:-但我的主要优先级是生成如图所示的输出、然后在比较器输出返回1时触发中断、这意味着中断在上升沿
下面随附了代码:
谢谢
#include #include #include "inc/hw_memmap.h" #include "driverlib/gpio.h" #include "driverlib/pin_map.h" #include "driverlib/pwm.h" #include "driverlib/sysctl.h" #include "inc/hw_types.h" #include "driverlib/debug.h" #include "driverlib/interrupt.包含"driverlib"#include "driverlib"#include "driverlib.h"#include "driverlib.comp.h #include "driverlib/uart.h" #include "utils/uartstdio.h" #include "driverlib/rom.h" #include "inc/hw_ints.h" #include "driverlib/rom_map.h" uint32_t g_ui32SysClock=120000000; #ifdef 文件名/hw_ints.h; #include "out_int_status_t = nateg_int0;void in 0_int_int_int_int_int_int_int_status_int0;void = u32_int_int_int_int_int_integ_int_int_int_int_int_int_int_int_integ_int_int_int_int_int_int_int_int_int_int_int_ int Comp_OUT; Comp_OUT = ComparatorValueGet (COMP_BASE、0); // ComparatorIntClear (COMP_BASE、0); // // bool ulStatus; // ulStatus =ComparatorIntStatus (COMP_BASE、0、TRUE); ComparatorIntClear (COMP_BASE、 0); // ComparatorIntDisable (COMP_BASE、0); X++; // if (status=0) // { // GPIOPinWrite (GPIO_PORTN_BASE、GPIO_PIN_0、0x1); // STATUS=1; //} // // // if (status=1) // { // GPIOPinWrite (GPIO_PORTN_BASE、GPIO_PIN_0、0x0); // STATUS=0; //} } int main (void) { g_ui32SysClock= SysCtlClockFreqSet ((SYSCTL_XTAL_25MHz | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480)、120000000); int 计数器=20; SysCtlPeripheralEnable (SYSCTL_Periph_GPIOF); while ((!SysCtlPeripheralReady (SYSCTL_Periph_GPIOF))&&(counter=0) ){ 计数器--; } GPIOPinTypeGPIOOutput (GPIO_PORTF_BASE、GPIO_PIN_4); IntMasterDisable (); SysCtlPeripheralEnable (SYSCTL_Periph_GPIOC); //为负输入启用端口 C int counter1=20; while (!SysCtlPeripheralReady (SYSCTL_Periph_GPIOC))&&(counter1=0) { 计数1--; } SysCtlPeripheralEnable (SYSCTL_Periph_GPIOD); //为输出启用端口 D int counter2=20; while ((!SysCtlPeripheralReady (SYSCTL_Periph_GPIOD))&(counter2=0) ){ 柜台2--; } GPIOPinTypeGPIOInput (GPIO_PORTC_BASE、GPIO_PIN_6); GPIOPinTypeGPIOOutput (GPIO_PORTD_BASE、GPIO_PIN_0); // GPIOPinWrite (GPIO_PORTD_BASE、 GPIO_PIN_0、1); // SysCtlDelay (100); // GPIOPinWrite (GPIO_PORTD_BASE、GPIO_PIN_0); SysCtlPeripheralEnable (SYSCTL_Periph_COMP0); //启用比较器1 int counter3=20; while (!SysCtlPeripheralReady (SYSCTL_Periph_COMP0))&&(counter3=0) { 反3 -; } //分配引脚类型 // GPIOPinTypeComparator (GPIO_PORTC_BASE、GPIO_PIN_7); //模拟比较器1负输入。 GPIOPinTypeComparator (GPIO_PORTC_BASE、GPIO_PIN_6); //模拟比较器1正输入。 //GPIOPinTypeComparator (GPIO_PORTD_base、GPIO_PIN_0); //模拟比较器1输出。 //GPIOPinConfigure (GPIO_PIN_4); //引脚配置 //GPIOPinConfigure (GPIO_PIN_5); //不需要,因为缺省功能是模拟输入 GPIOPinConfigure (GPIO_PD0_C0O); 比较器配置(COMP_BASE、0、COMP_TRIG_NONE | COMP_ASRCP_REF |COMP_INT_FALL | COMP_OUTPUT 正常); //比较器配置 SysCtlDelay (100); //设置内部基准电压 ComparatorRefSet (COMP_BASE,COMP_REF_1_65V); //IntDisable (COMP_BASE); ComparatorIntRegister (COMP_BASE、0、COMP_BASE_Interrupt); ComparatorIntEnable (COMP_BASE、0); //ComparatorIntRegister (COMP_BASE、0); INT_COMP0); //IntEnable (INT_COMP0); IntMasterEnable(); //SysCtlDelay (g_ui32SysClock / 96); //延迟 ; while (1) { COMP_OUT =比较器 ValueGet (COMP_BASE、0); //读取比较器输出 // // int_status=ComparatorIntStatus (COMP_BASE、0、TRUE); // 如果(Comp_OUT=0) // { // GPIOPinWrite (GPIO_PORTF_BASE、GPIO_PIN_0、0x0); // STATUS=1; // SysCtlDelay (1000000); //} // // // 如果(Comp_out=1) // { // GPIOPinWrite (GPIO_PORTF_BASE、GPIO_PIN_0、0x1); // STATUS=0; // SysCtlDelay (1000000); //} GPIOPinWrite (GPIO_PORTF_BASE、GPIO_PIN_0、0x1); SysCtlDelay (1000); GPIOPinWrite (GPIO_PORTF_BASE、GPIO_PIN_0、0x0); SysCtlDelay (1000); } }
