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() ;
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值