Timestamps
µC/CPU timestamps emulate a real-time 32- or 64-bit timer using any size hardware (or software) timer. If the hardware (or software) timer used has the same (or greater) number of bits as the 32- or 64-bit CPU timestamps, then calls to CPU_TS_Get()
functions return the timer value directly with no additional calculation overhead. But if the timer has less bits than the 32- or 64-bit CPU timestamps, CPU_TS_Update()
must be called periodically by an application-/developer-defined function (see CPU_TS_Update) to accumulate timer counts into the 32- or 64-bit CPU timestamps. An application can then use CPU timestamps either as raw timer counts or converted to microseconds (see CPU_TS32_to_uSec and CPU_TS64_to_uSec).
Note that if either the CPU timestamp feature or the interrupts disable time measurement feature is enabled, then the application/developer must provide CPU timestamp timer functions (see CPU_TS_TmrInit and CPU_TS_TmrRd). In addition, the CPU timestamp timer word size must be appropriately configured via CPU_CFG_TS_TMR_SIZE
in cpu_cfg.h
:
CPU_WORD_SIZE_08
8-bit word size
CPU_WORD_SIZE_16
16-bit word size
CPU_WORD_SIZE_32
32-bit word size
CPU_WORD_SIZE_64
64-bit word size
This configures the size of the CPU_TS_TMR
data type (see CPU_TS_TmrRd). Since the CPU timestamp timer must not have less bits than the CPU_TS_TMR
data type; CPU_CFG_TS_TMR_SIZE
must be configured so that all bits in CPU_TS_TMR
data type are significant. In other words, if the size of the CPU timestamp timer is not a binary-multiple of 8-bit octets (e.g. 20-bits or even 24-bits), then the next lower, binary-multiple octet word size should be configured (e.g. to 16-bits). However, the minimum supported word size for CPU timestamp timers is 8-bits.
Timestamps Configuration
The following µC/CPU timestamps configurations must be configured in cpu_cfg.h
:
CPU_CFG_TS_32_EN
Includes 32-bit CPU timestamp functionality. This feature may be configured to either DEF_DISABLED
or DEF_ENABLED
.
CPU_CFG_TS_64_EN
Includes 64-bit CPU timestamp functionality. This feature may be configured to either DEF_DISABLED
or DEF_ENABLED
.
CPU_CFG_TS_TMR_SIZE
Configures the CPU timestamp’s hardware or software timer word size.