Debug Timer
Features
Dual clock sources:
XTAL40M: 1μs resolution (1MHz from 40MHz crystal)
SDM32K: ~30.5μs per period (32768 Hz); since the counter has no fractional part, each tick increments the count by 31μs (an inherent hardware rounding error)
Sleep mode persistence
A lock-free counter: atomic counter access for multi-core systems
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.
- Returns:
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.
- Returns:
Atom counter value after auto-increment.
-
void DTimer_AtomSet(u32 NewValue)
Set the Debug Timer atom counter value.
- Parameters:
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.
- Parameters:
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.
- Returns:
Current scratch register value.
-
void DTimer_ScratchSet(u32 NewValue)
Set the Debug Timer scratch register value.
- Parameters:
NewValue – New scratch register value.
-
u32 DTimestamp_Get(void)
Get the Debug Timer u32 current counter.
- Returns:
Current u32 counter value.
-
void DTimestamp_Set(u32 NewValue)
Set the Debug Timer current counter.
- Parameters:
NewValue – New counter value.
-
void DTimer_CLK(u8 DTim_speed)
Select clock for timestamp, which works at 1MHz by default.
- Parameters:
DTim_speed –
Speed of debugtimer counter.
0: OSC32KHz.
1: 1MHz, which is divided from XTAL40MHz.
FUNCTION_REF=DTimestamp_Set
FUNCTION_REF=DTimer_CLK
FUNCTION_REF=DTimestamp_Set
FUNCTION_REF=DTimer_CLK
FUNCTION_REF=DTimestamp_Set
FUNCTION_REF=DTimer_CLK
FUNCTION_REF=DTimestamp_Set
FUNCTION_REF=DTimer_CLK
FUNCTION_REF=DTimestamp_Set
FUNCTION_REF=DTimer_CLK
-
void DTimestamp_Set(u64 NewValue)
Set the Debug Timer u64 current counter.
- Parameters:
NewValue – New u64 counter value.
-
u32 DTimesPassedtime32_Get(u32 OldTime)
Get the u32 elapsed time.
- Parameters:
OldTime – Old timestamp value for comparison.
- Returns:
Elapsed timer ticks since OldTime.
-
u64 DTimesPassedtime64_Get(u64 OldTime)
Get the u64 elapsed time.
- Parameters:
OldTime – Old timestamp value for comparison.
- Returns:
Elapsed timer ticks since OldTime.
-
u64 DTimestamp64_Get(void)
Get the Debug Timer u64 current counter.
- Returns:
Current u64 counter value.
FUNCTION_REF=DTimestamp_Set_RTL8721F
FUNCTION_REF=DTimesPassedtime32_Get
FUNCTION_REF=DTimesPassedtime64_Get
FUNCTION_REF=DTimestamp64_Get