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() ;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM