极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 11252|回复: 3

求助attachInterrupt 中断 运行闪退

[复制链接]
发表于 2015-2-28 13:20:51 | 显示全部楼层 |阅读模式
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()
{

}
回复

使用道具 举报

发表于 2015-2-28 13:27:31 | 显示全部楼层

void bnt1press()
{
        cnt1++;
        printf("cnt1 %d times\n",cnt1);
}
中的printf("cnt1 %d times\n",cnt1);删除试试?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2015-2-28 14:07:34 | 显示全部楼层
song549 发表于 2015-2-28 13:27

void bnt1press()
{

还是一样,直接闪退
回复 支持 反对

使用道具 举报

发表于 2015-3-2 00:40:26 | 显示全部楼层
不好意思, 請問 "闪退了" 是什麼意思.
程式中只有 printf 作輸出, 如果都刪了, 你怎知程式是否在執行?

如樓上所說, printf 放在 interrupt 中不太好, 刪去比較好.
可以在 loop 中補回, 例如Serial.println(cnt1);
看看是否有問題.

沒用過 pcduino, 想多了解一下.  pcduino 的 pritnf 是否會送到 serial monitor 的?
有 printf 可用, 真方便.
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-17 13:03 , Processed in 0.036652 second(s), 20 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表