...
Description
Application-defined function to get current CPU timestamp timer count. Anchor |
---|
1054117 | 1054117Files
...
cpu_core.h /
Application’s cpu_bsp.c
Anchor |
---|
1054122 | 1054122Prototype
...
...
HTML Table |
---|
summary |
---|
class | Code_Listing |
---|
Table Row (tr) |
---|
Table Cell (td) |
---|
Anchor |
---|
1054121 | 1054121 | |
...
|
CPU_TS_TMR CPU_TS_TmrRd (void); |
...
Arguments
...
1053507 | None.
Anchor |
10535081053508 | Returned Value
...
CPU timestamp timer count value. Anchor |
---|
1053510 | 1053510Required Configuration
...
CPU_TS_TmrRd()
is an application/BSP function that must be defined by the developer if either of the following CPU features is enabled in cpu_cfg.h
: Anchor |
---|
1056770 | 1056770- CPU timestamps when either
CPU_CFG_TS_32_EN
or CPU_CFG_TS_64_EN
is DEF_ENABLED
...
- . See Timestamps Configuration.
- CPU interrupts disabled time measurements when
CPU_CFG_INT_DIS_MEAS_EN
is #define'd
...
Notes / Warnings
...
- CPU timestamp timer count values must be returned via word-size-configurable
CPU_TS_TMR
data type. If timer has more bits, truncate timer values’ higher-order bits greater than the configured CPU_TS_TMR
timestamp timer data type word size. However, since the timer must not have less bits than the configured CPU_TS_TMR
timestamp timer data type word size; CPU_CFG_TS_TMR_SIZE
must be configured so that all bits in CPU_TS_TMR
data type are significant. In other words, if timer size 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.
...
- CPU timestamp timer should be an ‘up’ counter whose values increase with each time count. If timer is a ‘down’ counter whose values decrease with each time count, then the returned timer value must be ones-complemented.
...
- When applicable, CPU timestamp timer period should be less than the typical measured time but must be less than the maximum measured time; otherwise, timer resolution inadequate to measure desired times.
...
Implementation Template
...
...
Listing - CPU_TS_TmrRd() implementation template | | Listing - CPU_TS_TmrRd() implementation template |
---|
|
Code Block |
---|
language | cpp |
---|
title | Listing - CPU_TS_TmrRd() implementation template |
---|
linenumbers | true |
---|
|
CPU_TS_TMR CPU_TS_TmrRd (void) Anchor |
---|
| 1053769 | 1053769 | { Anchor |
---|
1053770 | 1053770 |
{
CPU_TS_TMR ts_tmr_cnts;
Anchor |
---|
1053771 | 1053771 | Anchor |
---|
1053772 | 1053772 | ... Anchor |
---|
1053773 | 1053773 |
...
ts_tmr_cnts = /* Insert code to get/return CPU timestamp timer counts. */
; Anchor |
---|
1053774 | 1053774 | ... Anchor |
---|
1053775 | 1053775 | Anchor |
---|
1053776 | 1053776 | return ;
...
return (ts_tmr_cnts);
Anchor |
---|
1053777 | 1053777 | }
...
16-bit Up Timer Example
...
...
Listing - 16-bit Up timer example | | Listing - 16-bit Up timer example |
---|
|
Code Block |
---|
language | cpp |
---|
title | Listing - 16-bit Up timer example |
---|
linenumbers | true |
---|
|
CPU_TS_TMR CPU_TS_TmrRd (void) Anchor |
---|
| 1053868 | 1053868 | { Anchor |
---|
1053869 | 1053869 |
{
CPU_TS_TMR ts_tmr_cnts; /* sizeof(CPU_TS_TMR) = 16 bits
*/ Anchor |
---|
1053870 | 1053870 | Anchor |
---|
1053871 | 1053871 | Anchor |
---|
1053872 | 1053872 | */
ts_tmr_cnts = /* Insert code to read 16-bit up timer value. */
; Anchor |
---|
1053873 | 1053873 | Anchor |
---|
1053874 | 1053874 | return ;
return (ts_tmr_cnts);
Anchor |
---|
1053875 | 1053875 | }
...
16-bit Down Timer Example
...
...
Listing - 16-bit Down timer example | | Listing - 16-bit Down timer example |
---|
|
Code Block |
---|
language | cpp |
---|
title | Listing - 16-bit Down timer example |
---|
linenumbers | true |
---|
|
CPU_TS_TMR CPU_TS_TmrRd (void) Anchor |
---|
| 1053891 | 1053891 | { Anchor |
---|
1053892 | 1053892 | CPU_INT16U tmr_val; Anchor |
---|
1053893 | 1053893 |
{
CPU_INT16U tmr_val;
CPU_TS_TMR ts_tmr_cnts; /* sizeof(CPU_TS_TMR) = 16 bits
*/ Anchor |
---|
1053894 | 1053894 | Anchor |
---|
1053895 | 1053895 | Anchor |
---|
1053896 | 1053896 | tmr_val = /* Insert code to read 16-bit down timer value. */ ; Anchor |
---|
1053897 | 1053897 | */
tmr_val = /* Insert code to read 16-bit down timer value. */ ;
ts_tmr_cnts = ~tmr_val; /* Ones-complement 16-bit down timer value.
*/ Anchor |
---|
1053898 | 1053898 | Anchor |
---|
1053899 | 1053899 | return */
return (ts_tmr_cnts);
Anchor |
---|
1053900 | 1053900 | }
...
32-bit Up Timer Example
...
...
Listing - 32-bit Up timer example | | Listing - 32-bit Up timer example |
---|
|
Code Block |
---|
language | cpp |
---|
title | Listing - 32-bit Up timer example |
---|
linenumbers | true |
---|
|
CPU_TS_TMR CPU_TS_TmrRd (void) Anchor |
---|
| 1053916 | 1053916 | { Anchor |
---|
1053917 | 1053917 |
{
CPU_TS_TMR ts_tmr_cnts; /* sizeof(CPU_TS_TMR) = 32 bits
*/ Anchor |
---|
1053918 | 1053918 | Anchor |
---|
1053919 | 1053919 | Anchor |
---|
1053920 | 1053920 | */
ts_tmr_cnts = /* Insert code to read 32-bit up timer value. */
; Anchor |
---|
1053921 | 1053921 | Anchor |
---|
1053922 | 1053922 | return ;
return (ts_tmr_cnts);
Anchor |
---|
1053923 | 1053923 | }
...
48-bit Down Timer Example
...
...
Listing - 48-bit Down timer example | | Listing - 48-bit Down timer example |
---|
|
Code Block |
---|
language | cpp |
---|
title | Listing - 48-bit Down timer example |
---|
linenumbers | true |
---|
|
CPU_TS_TMR CPU_TS_TmrRd (void) Anchor |
---|
| 1053937 | 1053937 | { Anchor |
---|
1053938 | 1053938 | CPU_INT64U tmr_val; Anchor |
---|
1053939 | 1053939 |
{
CPU_INT64U tmr_val;
CPU_TS_TMR ts_tmr_cnts; /* sizeof(CPU_TS_TMR) = 32 bits
*/ Anchor |
---|
1053940 | 1053940 | Anchor |
---|
1053941 | 1053941 | Anchor |
---|
1053942 | 1053942 | tmr_val = /* Insert code to read 48-bit down timer value. */ ; Anchor |
---|
1053943 | 1053943 | */
tmr_val = /* Insert code to read 48-bit down timer value. */ ;
ts_tmr_cnts = (CPU_TS_TMR)tmr_val; /* Truncate 48-bit timer value to 32-bit timestamp ...
*/ Anchor |
---|
1053944 | 1053944 | /* ... timer data type. */ Anchor |
---|
1053945 | 1053945 | */
/* ... timer data type. */
ts_tmr_cnts = ~ts_tmr_cnts; /* Ones-complement truncated down timer value.
*/ Anchor |
---|
1053947 | 1053947 | Anchor |
---|
1053968 | 1053968 | return */
return (ts_tmr_cnts);
Anchor |
---|
1053948 | 1053948 |
}