调试定时器

功能特性

  • 两种时钟源可选:

    • XTAL40M:通过分频器得到 1M 的时钟源,每一拍计数时间是 1us

    • SDM32K:时钟频率为 32768 Hz,每一拍周期约为 30.5us;由于计数器不保存小数,每一拍计数值增加 31us(硬件固有的舍入误差)

  • 可以在睡眠状态下继续计数

  • 无锁计数器:支持多核环境下安全并发读写

API

Raw API

DEBUGTIMER Exported Constants

Debug Timer Clock Source
/* Select XTAL as clock source */
#define DTIM_CLK_XTAL 0

/* Select 32K as clock source */
#define DTIM_CLK_32K 1

DEBUGTIMER Exported Functions

u32 DTimer_AtomGet(void)

Get the Debug Timer atom counter value. Reading this register does not increment the atom counter.

返回:

Current atom counter value.

u32 DTimer_AtomIncGet(void)

Get the Debug Timer atom counter value and trigger auto-increment. Reading this register auto-increments the atom counter by 1.

返回:

Atom counter value after auto-increment.

void DTimer_AtomSet(u32 NewValue)

Set the Debug Timer atom counter value.

参数:
  • NewValue -- New atom counter value.

void DTimer_Cmd(bool Newstatus)

Enable or disable the Debug Timer peripheral The debug timer is a free-running timer that works at 1 MHz.

参数:
  • Newstatus -- New state of the Debug Timer peripheral. This parameter can be: ENABLE or DISABLE.

u32 DTimer_ScratchGet(void)

Get the Debug Timer scratch register value.

返回:

Current scratch register value.

void DTimer_ScratchSet(u32 NewValue)

Set the Debug Timer scratch register value.

参数:
  • NewValue -- New scratch register value.

u32 DTimestamp_Get(void)

Get the Debug Timer u32 current counter.

返回:

Current u32 counter value.

RTL8721Dx:
void DTimestamp_Set(u32 NewValue)

Set the Debug Timer current counter.

参数:
  • NewValue -- New counter value.

void DTimer_CLK(u8 DTim_speed)

Select clock for timestamp, which works at 1MHz by default.

参数:
  • DTim_speed --

    Speed of debugtimer counter.

    • 0: OSC32KHz.

    • 1: 1MHz, which is divided from XTAL40MHz.