dsPic33E:如何在数字输入引脚上实现输入变化通知?

dsPic33E : How to Implement Input Change Notification on Digital Input Pin?

正如问题所说,我想为数字输入引脚实现 ICN(输入更改通知)。

我用的是dsPic33EP512GM604。

我已将 Pin<22> RB1​​ 配置为输入 Pin。

红外传感器连接到同一个引脚。我正在寻找一种方法(轮询除外)在传感器检测到对象(发送高信号)时获得中断。

在检查设备 Datasheet 时,我发现了一个可用的输入更改通知 (ICN) 功能。

它说:

"The Input Change Notification function of the I/O ports allows devices to generate interrupt requests to the processor in response to a Change-of-State (COS) on selected input pins. This feature can detect input Change-of-States (COS), even in Sleep mode when the clocks are disabled. Every I/O port pin can be selected (enabled) for generating an interrupt request on a Change-of-State."

我试图搜索有关其实现的更多信息,但找不到任何信息。

任何人都可以指导我实现它的方法或与我分享 link 解释其实现或相关信息吗???

您需要通用的 dspic33e 手册(在每个外设的单独文件中有一章)。

试试

 CNENBbits.CNIEB1 = 1; // Enable RB1 pin for interrupt detection
 _CNIP=7;       // priority (7 = highest)
 _CNIE = 1; // Enable CN interrupts
 _CNIF = 0; // clear interrupt flag

并大致如下定义您的 _CN 中断例程:

void __attribute__((__interrupt__, no_auto_psv)) _CNInterrupt(void)
{
     _CNIF = 0; 
}  

如果为多个引脚启用 CN,则必须轮询中断中的引脚以确定激活它的引脚。