求助attachInterrupt 中断 运行闪退
pcduino v3 的板子,在anduino环境中编译没错,下载成功,但是运行到attachInterrupt的时候程序就闪退了望各位能指导一下,谢谢
代码如下:
//test_interrupt
#include <core.h>
#define INT_MODE RISING //中断模式:上升沿
int cnt1=0,cnt2=0;
void bnt1press()
{
cnt1++;
printf("cnt1 %d times\n",cnt1);
}
void setup()
{
//GPIO2=INT0
//GPIO3=INT1
printf("Attaching interrupt pins.\n");
attachInterrupt(0,bnt1press,INT_MODE);
}
void loop()
{
}
把
void bnt1press()
{
cnt1++;
printf("cnt1 %d times\n",cnt1);
}
中的printf("cnt1 %d times\n",cnt1);删除试试? song549 发表于 2015-2-28 13:27 static/image/common/back.gif
把
void bnt1press()
{
还是一样,直接闪退 不好意思, 請問 "闪退了" 是什麼意思.
程式中只有 printf 作輸出, 如果都刪了, 你怎知程式是否在執行?
如樓上所說, printf 放在 interrupt 中不太好, 刪去比較好.
可以在 loop 中補回, 例如Serial.println(cnt1);
看看是否有問題.
沒用過 pcduino, 想多了解一下.pcduino 的 pritnf 是否會送到 serial monitor 的?
有 printf 可用, 真方便.
页:
[1]