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

Blue Mountain

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

Arduino101学习笔记(十二)—— 101定时器中断

一、API

1、开定时器中断

复制代码
//*********************************************************************************************
//函数名称:CurieTimerOne.start(int timerPeriodUsec, userCallBack)
//输入参数:timerPeriodUsec:: 多少微妙产生中断
//                  userCallBack      : 中断函数
//函数返回:无
//函数功能:开定时器中断
//*********************************************************************************************
CurieTimerOne.start(int timerPeriodUsec, userCallBack);
复制代码

 

2、重定义定时器时间

复制代码
//*********************************************************************************************
//函数名称:CurieTimerOne.restart(int timerPeriodUsec)
//输入参数:timerPeriodUsec:: 多少微妙产生中断
//函数返回:无
//函数功能:重开定时器中断时间
//*********************************************************************************************
CurieTimerOne.restart(int timerPeriodUsec);
复制代码

 

3、关中断,恢复为上电状态

复制代码
//*********************************************************************************************
//函数名称:CurieTimerOne.kill()
//输入参数:无
//函数返回:无
//函数功能:关中断
//*********************************************************************************************
CurieTimerOne.kill();
复制代码

 

4、重配置定时器中断函数

复制代码
//*********************************************************************************************
//函数名称:CurieTimerOne.attachInterrupt(userCallBack)
//输入参数:userCallBack:中断函数
//函数返回:无
//函数功能:配置中断函数
//*********************************************************************************************
CurieTimerOne.attachInterrupt(userCallBack);
复制代码

 

5、取消配置此中断函数,但定时器不停止

复制代码
//*********************************************************************************************
//函数名称:CurieTimerOne.detachInterrupt()
//输入参数:无
//函数返回:无
//函数功能:取消配置中断函数
//*********************************************************************************************
CurieTimerOne.detachInterrupt();
复制代码

 

6、返回触发的中断次数

复制代码
//*********************************************************************************************
//函数名称:CurieTimerOne.readTickCount()
//输入参数:无
//函数返回:中断次数
//函数功能:返回触发的中断次数
//*********************************************************************************************
CurieTimerOne.readTickCount();
复制代码

 

7、重置中断次数

复制代码
//*********************************************************************************************
//函数名称:rdRstTickCount()
//输入参数:无
//函数返回:中断次数
//函数功能:返回触发的中断次数并重置
//*********************************************************************************************
rdRstTickCount();
复制代码

 

8、暂停定时器中断

复制代码
//*********************************************************************************************
//函数名称:CurieTimerOne.pause()
//输入参数:无
//函数返回:无
//函数功能:暂停定时器中断
//*********************************************************************************************
CurieTimerOne.pause();
复制代码

 

9、PWM生成

复制代码
//*********************************************************************************************
//函数名称:CurieTimerOne.pwmStart(int outputPin, int dutyRange, unsigned int periodUsec) 
//输入参数:outputPin 输出管脚
//                 dutyRange  范围是0到1023,对应0到100占空比
//                 periodUsec : Hz=(periodUsec/1000000) 
//函数返回:无
//函数功能:PWM
//*********************************************************************************************
CurieTimerOne.pwmStart(int outputPin, int dutyRange, unsigned int periodUsec) ;



//*********************************************************************************************
//函数名称:CurieTimerOne.pwmStart(int outputPin, double dutyPercentage, unsigned int periodUsec)
//输入参数:outputPin 输出管脚
//                 dutyPercentage, 占空比
//                 periodUsec : Hz=(periodUsec/1000000) 
//函数返回:无
//函数功能:PWM
//*********************************************************************************************
CurieTimerOne.pwmStart(int outputPin, double dutyPercentage, unsigned int periodUsec) ;
复制代码

 

10、关PWM,设置管脚状态为LOW

复制代码
//*********************************************************************************************
//函数名称:CurieTimerOne.pwmStop()
//输入参数:无
//函数返回:无
//函数功能:关PWM
//*********************************************************************************************
CurieTimerOne.pwmStop() ;
复制代码

本文作者:Blue Mountain

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

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

posted @   Blue Mountain  阅读(4908)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起
  1. 1 404 not found REOL
404 not found - REOL
00:00 / 00:00
An audio error has occurred.