Arduino PinChangeInt.h产生编译器错误

Arduino PinChangeInt.h yields compiler errors

本文关键字:编译器 错误 PinChangeInt Arduino      更新时间:2023-10-16

我尝试重新编译使用PinChangeInt的旧arduino草图。编译器报告以下错误:

Arduino: 1.6.9 (Windows 7), TD: 1.29, Board: "Arduino/Genuino Micro"
In file included from D:homearnolddevelopmentarduinodroneserial_commRxRx.ino:50:0:
C:packagesarduinolibrariesPinChangeInt/PinChangeInt.h:328:32: error: 'PCMSK1' was not declared in this scope
 PCintPort portC=PCintPort(3, 1,PCMSK1); // port PC==3  (also in pins_arduino.c, Arduino version 022)
C:packagesarduinolibrariesPinChangeInt/PinChangeInt.h:331:32: error: 'PCMSK2' was not declared in this scope
 PCintPort portD=PCintPort(4, 2,PCMSK2); // port PD==4
exit status 1
Error compiling for board Arduino/Genuino Micro.

有谁知道这里有什么问题,我该如何修复这些错误?使用Arduino 1.6.9版本,PinChangeInt版本为2402。

Arduino Micro中使用ATMega32U4,在PORTB上只支持PCMSK0。其他端口不具备此功能。参见:ATMega32U4 datasheet。

您也可以使用attachInterrupt来处理外部中断。因此,您在引脚0, 1, 2, 37 (HW引脚:PD0 - PD3, PE6)上有八个PCINT0源(所有这些源都有一个ISR处理程序)和五个外部中断源(每个都有自己的ISR处理程序)。