TI中文支持网
TI专业的中文技术问题搜集分享网站

关于CC2540的TICK_TIME设置,系统时钟初始化的问题?

大家好!

我在SimpleBLECentral例子的OnBoard.h中看到如下宏定义

#define TICK_TIME 1000 /* Timer per tick – in micro-sec */
#define TICK_COUNT 1
#define OSAL_TIMER  HAL_TIMER_3

我知道这定义系统的节拍为1微妙,定时器为定时器4.但是我在程序其他地方没有看到哪里使用了这些宏定义.

我想知道系统时钟在哪里初始化的,初始化时做了哪些事?

Yue TANG:

不是Timer3,4,而是Timer2.可以看看osalTimeUpdate()的处理。

edgar liu:

回复 Yue TANG:

/********************************************************************* * @fn osalTimeUpdate * * @brief Uses the free running rollover count of the MAC backoff timer; * this timer runs freely with a constant 320 usec interval. The * count of 320-usec ticks is converted to msecs and used to update * the OSAL clock and Timers by invoking osalClockUpdate() and * osalTimerUpdate(). This function is intended to be invoked * from the background, not interrupt level.

*

* @param None. * * @return None. */void osalTimeUpdate( void ){ uint16 tmp; uint16 ticks625us; uint16 elapsedMSec = 0;

// Get the free-running count of 625us timer ticks tmp = ll_McuPrecisionCount();

if ( tmp != previousLLTimerTick ) { // Calculate the elapsed ticks of the free-running timer. ticks625us = tmp – previousLLTimerTick;

// Store the LL Timer tick count for the next time through this function. previousLLTimerTick = tmp;

/* It is necessary to loop to convert the usecs to msecs in increments so as * not to overflow the 16-bit variables. */ while ( ticks625us > MAXCALCTICKS ) { ticks625us -= MAXCALCTICKS; elapsedMSec += MAXCALCTICKS * 5 / 8; remUsTicks += MAXCALCTICKS * 5 % 8; }

// update converted number with remaining ticks from loop and the // accumulated remainder from loop tmp = (ticks625us * 5) + remUsTicks;

// Convert the 625 us ticks into milliseconds and a remainder elapsedMSec += tmp / 8; remUsTicks = tmp % 8;

// Update OSAL Clock and Timers if ( elapsedMSec ) { osalClockUpdate( elapsedMSec ); osalTimerUpdate( elapsedMSec ); } }}

不知道ll_McuPrecisionCount这个函数的做了什么?

节拍是320us吗?还是625us?

Yue TANG:

回复 edgar liu:

625us

edgar liu:

回复 Yue TANG:

TY

625us

赞(0)
未经允许不得转载:TI中文支持网 » 关于CC2540的TICK_TIME设置,系统时钟初始化的问题?
分享到: 更多 (0)