0

标题几乎是不言自明的。当我写入输出比较寄存器(OC8RS 或 OC8R)时,会触发外部中断 INT4 引脚上的中断。我正在使用 Timer3 和 OC8 模块进行 PWM。INT4 引脚连接到一个物理开关,按下时会触发中断。但是,当我为我的 PWM 功能更新 OC8RS 寄存器时,从 INT4 触发了一个中断......这是没有意义的(再次,因为这个引脚连接到一个物理开关 - 与 PWM 无关)。

我猜我没有正确初始化、设置或清除某些东西,但我没有想法。其他人有吗?谢谢!

我使用的是 PIC24HJ256GP610A 处理器,以及最新的 MPLAB v8 和 C30 以及 ICD3。

4

1 回答 1

0

I found a solution. Instead of setting the tristate bit of INT4 to be an input (i.e., bit 15 of TRISA = 1), I set it to be an output (TRISAbit15=0). Now, this doesn't make sense because as I've already stated, I'm using a mechanical switch to send a pulse to the INT4 pin when pressed... i.e., an input signal to the MCU. I have the INT4 pin connected to a 10K pullup resistor for the switch to work.

So, setting the pin/tristate bit as an output no longer causes the INT4 interrupt to trigger. The signal looks noisier than it should, as if it's "fighting" with another signal, but it works fine now. Still confused as to how this could work with the pin set as an output when it's receiving an input...

于 2012-10-18T14:27:15.230 回答