?? settimer34period.c
字號:
/******************************************************************************
Filename: setTimer34Period.c
Target: cc2430
Revised: 16/12-2005
Revision: 1.0
******************************************************************************/
#include "hal.h"
//------------------------------------------------------------------------------------------------------
// See hal.h for a description of this function.
//------------------------------------------------------------------------------------------------------
BYTE halSetTimer34Period(BYTE timer, DWORD period){
BYTE div = 0;
if(TICKSPD > 5) { // Checking that the period is not too short.
if( (period < 2*(TICKSPD-5)) && (period != 0) ){
return 0;
}
}
if(period == 0){ // If period is 0, max period length and max prescaler
div = 7; // division is used.
period = 255;
} else {
period = ((period*32) >> TICKSPD);// Determining how many timer ticks the period consist of
while(period > 255){ // If the period is too long, the prescaler division is
period = (period >> 1); // increased.
div++;
if(div > 7){ // If the period is too long when using max prescaler division,
return 0; // 0 is returned.
}
}
}
if(timer == 4){
// Timer 4 selected
T4CTL |= (div << 5); // Setting prescaler value
T4CC0 = (BYTE) period; // Setting timer value.
} else if(timer == 3){
// Timer 3 selected
T3CTL |= (div << 5); // Setting prescaler value
T3CC0 = (BYTE) period; // Setting timer value.
} else {return 0;}
return period;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -