donot use timer converter
// ========================== define ==========================================
-#define RFTIMER_MAX_COUNT 0x3ffffff // use a value less than 0xffffffff/61 and also equal to 2^n-1
+#define RFTIMER_MAX_COUNT 0xffffffff
#define TIMERLOOP_THRESHOLD 0xfffff // 0xffff is 2 seconds @ 32768Hz clock
#define MINIMUM_COMPAREVALE_ADVANCE 5
@@ -58,7 +58,7 @@ void sctimer_setCompare(PORT_TIMER_WIDTH val){
PORT_TIMER_WIDTH currentTime;
- currentTime = TIMER_COUNTER_CONVERT_RFTIMER_CLK_TO_32K(RFTIMER_REG__COUNTER);
+ currentTime = RFTIMER_REG__COUNTER;
sctimer_enable();
if (currentTime - val < TIMERLOOP_THRESHOLD){
@@ -75,9 +75,7 @@ void sctimer_setCompare(PORT_TIMER_WIDTH val){
} else {
// mark clear the flag here
// schedule the timer at val
- RFTIMER_REG__COMPARE0 = (PORT_TIMER_WIDTH)(TIMER_COUNTER_CONVERT_32K_TO_RFTIMER_CLK(val) & RFTIMER_MAX_COUNT);
- RFTIMER_REG__COMPARE0_CONTROL = RFTIMER_COMPARE_ENABLE | \
- RFTIMER_COMPARE_INTERRUPT_ENABLE;
+ RFTIMER_REG__COMPARE0 = (PORT_TIMER_WIDTH)(val) & RFTIMER_MAX_COUNT;
}
}
}
@@ -88,7 +86,7 @@ void sctimer_setCompare(PORT_TIMER_WIDTH val){
\returns The current value of the timer's counter.
*/
PORT_TIMER_WIDTH sctimer_readCounter(void){
- return TIMER_COUNTER_CONVERT_RFTIMER_CLK_TO_32K(RFTIMER_REG__COUNTER);
+ return RFTIMER_REG__COUNTER;
}
void sctimer_enable(void){
