为了能到远方,脚下的每一步都不能少.|

Blue Mountain

园龄:10年7个月粉丝:572关注:0

Arduino101学习笔记(九)—— 中断函数

1、设置中断函数

复制代码
//*********************************************************************************************
//函数名称:void attachInterrupt (uint8_t interruptNum, void(*)(void)userFunc, int mode);
//输入参数:interruptNum:终端类型0和1两种
//                 userFunc:         设置中断函数指针
//                 mode:               设置中断类型
//                                                LOW 低电平触发中断  //                                                CHANGE 变化时触发中断  //                                                
RISING 低电平变为高电平触发中断  //                                                FALLING 高电平变为低电平触发中断
//函数返回:
//函数功能:指定中断函数. 外部中断有0和1两种, 一般对应2号和3号数字引脚
//*********************************************************************************************
void attachInterrupt (uint8_t interruptNum, void(*)(void)userFunc, int mode);
复制代码

   在中断函数中 delay 函数不能使用, millis 始终返回进入中断前的值. 读串口数据的话, 可能会丢失. 中断函数中使用的变量需要定义为 volatile 类型

 

2、取消中断

复制代码
//*********************************************************************************************
//函数名称:void detachInterrupt (uint8_t interruptNum);
//输入参数:interruptNum:终端类型0和1两种
//函数返回:无
//函数功能:关中断
//*********************************************************************************************
void detachInterrupt (uint8_t interruptNum);
复制代码

本文作者:Blue Mountain

本文链接:https://www.cnblogs.com/BlueMountain-HaggenDazs/p/6056660.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   Blue Mountain  阅读(3494)  评论(1编辑  收藏  举报
历史上的今天:
2015-11-12 通信原理实践(五)——2PSK 与2DPSK 通信系统
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起
  1. 1 404 not found REOL
404 not found - REOL
00:00 / 00:00
An audio error has occurred.