This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] MMWCAS-DSP-EVM:关于计时 API

Guru**** 2451970 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/sensors-group/sensors/f/sensors-forum/1515587/mmwcas-dsp-evm-about-timing-apis

部件号:MMWCAS-DSP-EVM

工具/软件:

VPS 驱动程序中使用的时序函数:

BspOsal_getCurTimeInUsec

通过读取 CPU 的内部时钟周期计数器寄存器来检索当前时间(以微秒为单位)。

UInt64 BspOsal_getCurTimeInUsec(void)
{
    static UInt64 cpuMhz = 500U;        /* default */
    static Bool   isInit = FALSE;
    UInt64        cpuHz;
    UInt64        curTs, curTimeUsec;

    if (FALSE == isInit)
    {
        /* do this only once */
        isInit = (Bool) TRUE;
        /* convert to Mhz */
        cpuHz  = BspOsal_getTimestampFreq();
        cpuMhz = (cpuHz / (1000U * 1000U));
    }
    curTs       = BspOsal_getTimestamp64();
    curTimeUsec = (curTs / cpuMhz);

    return (curTimeUsec);
} 

在 RTOS 中、该函数 Utils_getCurGlobalTimeInUsec直接从寄存器中读取值、将其除以32,786Hz (从20 MHz 源获取的时钟除以610、这不是标准的32,768Hz)、从而获得以微秒为单位的时间。

#define COUNTER_32K_CR_REG_PHYS_ADDR        (0x4AE04030)
#define COUNTER_32K_CR_REF_CLK   (32786U) /* Actual value used on 20M/610
                                            610 is post div in clock tree*/
UInt64 Utils_getCurGlobalTimeInUsec(void)
{
    UInt64 curGblTime;
    UInt32 oldIntState;
    UInt64 clk32KhzValue;
    UInt64 clk32KhzValue64;
    uint64_t temp; /* Using uint64_t datatype as UInt64 datatype causes
                      MisraC issue while performing shift operation*/

    oldIntState = Hwi_disable();

    clk32KhzValue = COUNTER_32K_CR;

    if(clk32KhzValue < gUtils_GlobalTimerObj.oldClk32KhzValue)
    {
        gUtils_GlobalTimerObj.clk32KhzOverflow++;
    }

    temp = (uint64_t)gUtils_GlobalTimerObj.clk32KhzOverflow &
        0xFFFFFFFFU;
    temp  = temp << 32U;
    clk32KhzValue64  = (UInt64)clk32KhzValue | temp;

    curGblTime = (1000000U*clk32KhzValue64)/COUNTER_32K_CR_REF_CLK;

    gUtils_GlobalTimerObj.oldClk32KhzValue = clk32KhzValue;

    Hwi_restore(oldIntState);

    return (curGblTime);
}

通过调试输出、我发现两个时间戳不同。 我想知道:这两个函数是否访问同一个寄存器? 哪一个提供更准确的计时? 我的时间戳间隔并非恰好是100ms 这一事实是否 与 MMWCAS-DSP-EVM 内的时钟源相关?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    你(们)好

    遗憾的是、开发 MMWCAS-DSP-EVM 电路板的团队不再提供支持。  

    我们的支持团队无法支持此请求

    谢谢你

    Cesar