微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI Zigbee设计交流 > z-stack系统时钟问题

z-stack系统时钟问题

时间:10-02 整理:3721RD 点击:

在z-stack-2.5.1a中系统时钟所用的定时器四在哪个地方启的

用的是Timer2

void osalTimeUpdate( void )
{
halIntState_t intState;
uint32 tmp;
uint32 ticks320us;
uint16 elapsedMSec = 0;

HAL_ENTER_CRITICAL_SECTION(intState);
// Get the free-running count of 320us timer ticks
tmp = macMcuPrecisionCount();
HAL_EXIT_CRITICAL_SECTION(intState);

if ( tmp != previousMacTimerTick )
{
// Calculate the elapsed ticks of the free-running timer.
ticks320us = (tmp - previousMacTimerTick) & 0xffffffffu;

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

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

// Convert the 320 us ticks into milliseconds and a remainder
CONVERT_320US_TO_MS_ELAPSED_REMAINDER( tmp, elapsedMSec, remUsTicks );

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

/*********************************************************************
* @fn osalClockUpdate
*
* @brief Updates the OSAL Clock time with elapsed milliseconds.
*
* @param elapsedMSec - elapsed milliseconds
*
* @return none
*/
static void osalClockUpdate( uint16 elapsedMSec )
{
// Add elapsed milliseconds to the saved millisecond portion of time
timeMSec += elapsedMSec;

// Roll up milliseconds to the number of seconds
if ( timeMSec >= 1000 )
{
OSAL_timeSeconds += timeMSec / 1000;
timeMSec = timeMSec % 1000;
}
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top